GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Kiro API 400 error after compaction due to mismatched toolUses/toolResults · Issue #14367 · anomalyco/opencode

Kiro API 400 error after compaction due to mismatched toolUses/toolResults #14367

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Kiro API 400 error after compaction due to mismatched toolUses/toolResults#14367
Copy link
Assignees
rekram1-node

Description

@ricoshin
ricoshin
opened on Feb 20, 2026
Issue body actions

Problem

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.

Affected Code

packages/opencode/src/provider/kiro/converters.ts

Activity

  1. github-actions
    assigned
    rekram1-node
    on Feb 20, 2026
  2. github-actions
    added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Feb 20, 2026
  3. ke7in-zz commented on Mar 11, 2026

    @ke7in-zz
    ke7in-zz
    on Mar 11, 2026
    More actions

    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:

    1. Well-formed tool_use → tool_result pair → 200 OK
    2. Orphaned tool_use with no tool_result → 400 (proxy passes through verbatim)
    3. Long history with orphaned tool_use at end (compaction-style) → 400
    4. 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.

  4. thdxr
    removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  5. kylecui
    added a commit that references this issue on May 11, 2026

    feat: add session depth warning and compaction event tracking (P4k-b/c)

    e197c79
  6. github-actions commented on Jul 4, 2026

    @github-actions
    github-actionsBot
    on Jul 4, 2026 – with GitHub Actions
    Contributor
    More actions

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

  7. github-actions
    closed this as not plannedon Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @rekram1-node
    rekram1-node

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.