Commit Graph

3 Commits

Author SHA1 Message Date
rshks b504fb1deb fix(tool-pair-validator): emit schema-compatible synthetic tool results 2026-05-15 21:04:03 +09:00
PeterPonyu 17030b9a0d Prevent subagent repair from corrupting background sessions
Guard the tool-pair validator when transformed assistant messages belong to a tracked subagent session, while keeping normal main-session orphaned tool_use repair intact.

Constraint: code-yeongyu/oh-my-openagent#3996 reports background Oracle sessions hanging after synthetic placeholder tool_result insertion.
Rejected: disable tool-pair-validator globally | would regress main-session compaction/orphaned tool_use repair.
Confidence: high
Scope-risk: narrow
Directive: Keep subagent skip coverage and normal repair coverage together when changing tool-pair validation.
Tested: bun test src/hooks/tool-pair-validator/hook.test.ts src/plugin/messages-transform.test.ts
Tested: bun run typecheck
Not-tested: live Oracle background task e2e; no remote push or PR comment performed.
2026-05-14 21:32:48 -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