Skip to content

fix(kiro): dedup toolResults + reframe caveman injection#18

Merged
mydisha merged 2 commits into
mainfrom
fix/performance-degrataion
Jun 19, 2026
Merged

fix(kiro): dedup toolResults + reframe caveman injection#18
mydisha merged 2 commits into
mainfrom
fix/performance-degrataion

Conversation

@mydisha

@mydisha mydisha commented Jun 19, 2026

Copy link
Copy Markdown
Owner

What

Two fixes for the kiro connector path: dedup tool results before sending to CodeWhisperer/Bedrock, and reframe the caveman style injection so agentic coding tools accept it.

Why

  • kiro: CodeWhisperer/Bedrock rejects a userInputMessage whose toolResults list the same toolUseId more than once with TOOL_DUPLICATE (HTTP 400). Duplicates arise from merging consecutive user turns, clients resending tool_result on resume/retry, or the same id appearing as both a RoleTool message and a user-embedded tool_result.
  • caveman: the self-identifying sentinel + "caveman mode" framing caused agentic coding tools to treat the guideline as injected content and reject it.

How

  • Add dedupKiroUIMToolResults to keep the first occurrence of each toolUseId per userInputMessage; apply to every history user turn and the current message during history construction.
  • Remove the sentinel marker and "caveman mode" framing so the guideline reads as part of the operator system prompt; detect idempotency from the directive text via a stable probe substring.
  • Regression tests added for the merged-consecutive-turns duplicate case and caveman directive detection.

Checklist

  • make test passes
  • make vet passes
  • npm run lint and npm run typecheck pass (if frontend changed)
  • Documentation updated (if applicable)
  • Config example updated (if applicable)

mydisha added 2 commits June 19, 2026 23:29
Remove the self-identifying sentinel marker and "caveman mode" framing so
agentic coding tools treat the guideline as part of the operator's own
system prompt instead of rejecting it as injected content. Detect
idempotency from the directive text itself via a stable probe substring.
CodeWhisperer/Bedrock rejects a userInputMessage whose toolResults list
the same toolUseId more than once with TOOL_DUPLICATE (HTTP 400).
Duplicates can arise from merging consecutive user turns, a client
resending the same tool_result on resume/retry, or the same id appearing
as both a RoleTool message and a user-embedded tool_result.

Add dedupKiroUIMToolResults to keep the first occurrence of each
toolUseId per userInputMessage, and apply it to every history user turn
and the current message during history construction. Includes a
regression test covering the merged-consecutive-turns duplicate case.
@mydisha mydisha merged commit bdf9eb2 into main Jun 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant