Skip to content

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

@ricoshin

Description

@ricoshin

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions