fix(kiro): dedup toolResults + reframe caveman injection#18
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
How
Checklist
make testpassesmake vetpassesnpm run lintandnpm run typecheckpass (if frontend changed)