Skip to content

fix(parsers): merge dict tool_input fragments instead of concatenating#225

Open
LazarusX wants to merge 1 commit into
jwadow:mainfrom
LazarusX:fix/tool-call-dict-fragment-parsing
Open

fix(parsers): merge dict tool_input fragments instead of concatenating#225
LazarusX wants to merge 1 commit into
jwadow:mainfrom
LazarusX:fix/tool-call-dict-fragment-parsing

Conversation

@LazarusX

Copy link
Copy Markdown

Summary

  • Fix false "Tool call truncated by Kiro API" errors on Write tool calls with large content
  • Root cause: when Kiro API sends tool arguments split across multiple tool_input events as dicts, the parser serialized each dict independently and concatenated the JSON strings — producing invalid JSON like {"file_path":"..."}{"content":"..."}
  • The brace-counting diagnostic then misidentified this ~130-150 byte invalid JSON as upstream truncation
  • Fix accumulates dict fragments via .update() and serializes once at finalize time

Test plan

  • All 73 existing parser unit tests pass
  • Verified dict fragment scenario (empty start + multiple dict inputs with brace-containing content)
  • Verified single dict with stop (immediate finalization)
  • Verified string fragment path unchanged
  • Live test: large Write tool call with JSON-like patterns in content succeeds without truncation error

Fixes #153

🤖 Generated with Claude Code

When the Kiro API sends tool arguments split across multiple tool_input
events as dicts, the parser was serializing each dict independently and
concatenating the JSON strings — producing invalid JSON like
`{"file_path":"..."}{"content":"..."}`. The brace-counting diagnostic
then misidentified this as upstream truncation.

Fix: accumulate dict fragments via .update() and serialize once at
finalize time. String fragment path remains unchanged.

Fixes jwadow#153

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@cla-bot

cla-bot Bot commented Jun 17, 2026

Copy link
Copy Markdown

Thanks for the PR! 🎉

Before merge, we need a one-time CLA confirmation.
It confirms that you have the right to contribute this code and allow the project to use it.

Full CLA text:
https://github.com/jwadow/kiro-gateway/blob/main/CLA.md

Please reply once with:

I have read the CLA and I accept its terms

You need to write once, all further messages from me can be ignored.

@LazarusX

Copy link
Copy Markdown
Author

I have read the CLA and I accept its terms

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.

BUG: Claude Code not writing files

1 participant