mirror of
https://github.com/jwadow/kiro-gateway.git
synced 2026-04-25 01:15:57 +03:00
[GH-ISSUE #56] Kiro API truncates large tool call payloads mid-stream #37
Labels
No labels
bug
bug
enhancement
enhancement
fixed
fixed
invalid
needs-info
needs-testing
pull-request
question
upstream
wontfix
workaround
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/kiro-gateway-jwadow#37
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @bhaskoro-muthohar on GitHub (Jan 25, 2026).
Original GitHub issue: https://github.com/jwadow/kiro-gateway/issues/56
Summary
When Claude generates tool calls with large payloads (e.g., Write tool with 200+ lines of code), the Kiro API truncates the response stream before the tool call completes. This results in incomplete JSON that cannot be parsed, causing tool calls to fail silently with empty parameters.
This is an upstream Kiro API limitation, not a gateway bug. The gateway correctly logs and handles the truncated data, but cannot recover the missing payload.
Environment
Symptoms
Write: {}in client transcripttool_blocks=0in gateway logscontextUsagePercentage"stop":trueeventEvidence
Truncated vs Working Session Comparison
"stop":trueeventsRaw Stream Analysis
The truncated stream shows the tool call starting correctly but being cut off mid-payload:
Key Finding: No
max_tokensSupportThe Kiro API does not accept
max_tokensorinferenceConfigparameters. The gateway payload only contains:conversationState(messages, history, tools)profileArnThis means there is no client-side control over output limits - truncation is entirely server-side.
Reproduction Steps
DEBUG_MODE=allto capture raw streamdebug_logs/response_stream_raw.txtWhy This Is NOT a Gateway Bug
STREAMING_READ_TIMEOUT=300sis generous; stream ends cleanly at packet boundary_diagnose_json_truncation()detects and logs the issueWorkarounds
Users can mitigate this by:
Questions for Maintainer
Suggested Documentation
Consider adding a note to the README about this limitation so users are aware and can use the workarounds proactively.
Investigated with DEBUG_MODE=all. Raw stream evidence available if needed.
@jwadow commented on GitHub (Jan 30, 2026):
Hi, bro, gateway now detects when Kiro API truncates tool calls mid-stream and injects a notice in the next request so the model knows what happened and can adapt. Works for both tool calls and regular content truncation.
Implementation:
[API Limitation]noticeTRUNCATION_RECOVERY=falseThe ~5KB limit is still there (upstream issue), but at least now the model understands why the tool call failed instead of thinking it forgot a parameter.