You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Kiro API 400 error after compaction due to mismatched toolUses/toolResults #14367
After compaction/pruning, the Kiro API returns a 400 Improperly formed request error.
Root Cause
When filterCompacted trims history to only include messages after the summary, assistant messages with toolUses can remain while their corresponding toolResults in the next user message get cut. The existing validation only checked the last history item, missing mismatches in intermediate history.
Expected Behavior
The converter should validate toolUses/toolResults pairs across the entire history, not just the last item.
Additional investigation from #17065 (closing as duplicate):
Proxy is not the cause. I reproduced this error using hai-proxy as a local passthrough and confirmed it forwards Anthropic's 400 verbatim — it does not mangle or truncate message history itself. The errorCode: PROXY_LLM_ERROR wrapper is just hai-proxy's envelope around the raw Anthropic error.
Isolation method: wrote a repro script testing four scenarios directly against the proxy:
Well-formed tool_use → tool_result pair → 200 OK
Orphaned tool_use with no tool_result → 400 (proxy passes through verbatim)
Long history with orphaned tool_use at end (compaction-style) → 400
Multiple tool_use, only one tool_result → 400
All 400s originated from Anthropic. The proxy is a transparent passthrough, confirming the bug is entirely in OpenCode's filterCompacted history reconstruction as identified here.
Environment: OpenCode 1.2.22, claude-sonnet-4-6, macOS 26.2, triggered at ~300 messages.
Activity
ke7in-zz commentedon Mar 11, 2026
Additional investigation from #17065 (closing as duplicate):
Proxy is not the cause. I reproduced this error using hai-proxy as a local passthrough and confirmed it forwards Anthropic's
400verbatim — it does not mangle or truncate message history itself. TheerrorCode: PROXY_LLM_ERRORwrapper is just hai-proxy's envelope around the raw Anthropic error.Isolation method: wrote a repro script testing four scenarios directly against the proxy:
tool_use→tool_resultpair →200 OKtool_usewith notool_result→400(proxy passes through verbatim)tool_useat end (compaction-style) →400tool_use, only onetool_result→400All 400s originated from Anthropic. The proxy is a transparent passthrough, confirming the bug is entirely in OpenCode's
filterCompactedhistory reconstruction as identified here.Environment: OpenCode 1.2.22,
claude-sonnet-4-6, macOS 26.2, triggered at ~300 messages.feat: add session depth warning and compaction event tracking (P4k-b/c)
github-actions commentedon Jul 4, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.