Files
oh-my-pi/packages/coding-agent/src/session
DarkPhilosophy ad444f652c fix(coding-agent): retry orphaned toolUse stops to prevent history corruption
When Anthropic Claude returns stopReason: "toolUse" but the assistant
message contains no actual toolCall, the session would append a spurious
toolResult entry. This creates tool_result blocks without matching
tool_use blocks — structurally invalid for Anthropic's API validator.

The symptom is overloaded_error on every subsequent request (in: 0 out: 0),
even though servers aren't overloaded. Other providers handle the same
corrupted history more leniently, making the problem appear Anthropic-specific.

The #isEmptyAssistantStop guard now checks for stopReason === "toolUse"
with no text and no toolCall. When the retry cap is hit, tool-use orphans
are still removed from active context (unlike regular empty stops) because
they corrupt message history. A regression test covers both the retry and
cap scenarios.

For affected sessions: run /compact to drop the corrupted history tail.

Fixes review feedback from chatgpt-codex-connector.
2026-06-05 21:15:42 +03:00
..