Commit Graph

8 Commits

Author SHA1 Message Date
YeonGyu-Kim 45d670a7dc fix(plugin): constrain Anthropic prefill guard
Tighten the assistant-tail repair after review so only the Anthropic provider is treated as prefill-rejecting, and so assistant-tail model metadata is evaluated independently from the last user model.

Add regression coverage for an allowed user model followed by a rejecting Anthropic assistant tail, plus a non-Anthropic provider carrying a Claude-looking model id.

Plan: plans/fix-anthropic-assistant-prefill-tail.md
2026-05-19 12:24:37 +09:00
YeonGyu-Kim 3509bf47ae fix(plugin): guard Anthropic assistant prefill tails
Claude Opus 4.7 rejects requests whose final message is an assistant turn, because Anthropic treats that as unsupported assistant prefill. Add a transform guard that appends the existing synthetic user recovery turn only for Anthropic prefill-rejecting model IDs, while preserving assistant-prefill behavior for supported and unknown models.

Tests cover Opus 4.7, Opus 4.6 assistant metadata fallback, direct Sonnet 4.6 model fields, allowed OpenAI/Sonnet 4.5 tails, missing metadata, and compaction continuation compatibility.

Plan: plans/fix-anthropic-assistant-prefill-tail.md
2026-05-19 12:17:32 +09:00
YeonGyu-Kim ca3ea0bbe2 fix(messages-transform): narrow assistant-tail recovery trigger
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
2026-05-18 15:50:23 +09:00
YeonGyu-Kim 41629b5262 fix(plugin): guard assistant prefill message tails 2026-05-10 15:54:29 +09:00
YeonGyu-Kim d67e57ef3e feat(plugin): include team-mode in message transform and skill context 2026-05-06 14:19:39 +09:00
mrosnerr 69a4b2f49c fix(messages-transform): isolate hook failures so tool-pair-validator always runs
Previously each transform hook was awaited sequentially without per-hook
error handling. If contextInjectorMessagesTransform or thinkingBlockValidator
threw, toolPairValidator was silently skipped, leaving orphaned tool_use
blocks in the post-compaction API payload and producing
"messages.N: tool_use ids were found without tool_result blocks immediately
after" 400s from Anthropic.

Wraps each hook in runHookSafely so an upstream throw is logged but the
chain continues. Adds regression tests covering the isolation contract and
the consecutive-assistants compaction tail case (ses_22bd806).
2026-04-28 17:38:28 -04:00
YeonGyu-Kim 2440ed9a6f fix(hook): add tool_use/tool_result pair validator to prevent API errors
Adds a defensive tool-pair-validator hook that runs as the final step in
the messages transform pipeline. When compaction or context-window recovery
removes user messages containing tool_result blocks without removing the
preceding assistant message with tool_use blocks, this validator detects
the mismatch and either:

1. Injects missing tool_result parts into the next user message, or
2. Creates a synthetic user message with placeholder tool_results

This prevents Anthropic API errors like 'tool_use ids found without
tool_result blocks immediately after'.

Fixes #3014
2026-04-02 13:31:48 +09:00
YeonGyu-Kim 598a4389d1 refactor(core): split index.ts and config-handler.ts into focused modules
Main entry point:
- create-hooks.ts, create-tools.ts, create-managers.ts
- plugin-interface.ts: plugin interface types
- plugin/ directory: plugin lifecycle modules

Config handler:
- agent-config-handler.ts, command-config-handler.ts
- tool-config-handler.ts, mcp-config-handler.ts
- provider-config-handler.ts, category-config-resolver.ts
- agent-priority-order.ts, prometheus-agent-config-builder.ts
- plugin-components-loader.ts
2026-02-08 16:25:25 +09:00