Skip to content

fix(kiro): validate completed nested tool_call payloads - #2681

Open
SemonCat wants to merge 3 commits into
decolua:masterfrom
SemonCat:fix/kiro-nested-tool-call-validation
Open

SemonCat wants to merge 3 commits into
decolua:masterfrom
SemonCat:fix/kiro-nested-tool-call-validation

Conversation

@SemonCat

@SemonCat SemonCat commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • validate Kiro's nested tool_call wrapper only after its streamed input is complete
  • accumulate phased toolUseEvent input by toolUseId instead of rejecting the init frame when it has no input yet
  • preserve emitted OpenAI tool-call index ordering when wrapper and direct tools are interleaved
  • emit a clean invalid_kiro_tool_call stream error without producing a fake legal function call, then cancel the upstream reader

Why

Kiro may stream a wrapper tool call in phases:

  1. an init event containing name: "tool_call" and toolUseId
  2. one or more input fragments
  3. a terminal event

Validating the init frame immediately creates false failures because the nested { name, arguments } payload is not present yet. Conversely, forwarding a truly malformed final wrapper as a normal function call hides the provider error and leaves downstream agents with an unusable tool name.

This change buffers only wrapper metadata/input until a terminal boundary, validates the completed payload, and keeps normal non-wrapper tools streaming as before.

Tests

  • focused Kiro wrapper validation tests, including phased input, mixed wrapper/direct ordering, duplicate IDs, malformed terminal payloads, clean SSE failure, and upstream cancellation
  • related Kiro translator and OpenAI Responses tests
  • changed-file ESLint
  • git diff --check
  • npm run build

Claude Code reviewed the final branch and approved it for push.

@SemonCat SemonCat changed the title fix(kiro): validate nested tool_call payloads fix(kiro): validate completed nested tool_call payloads Jul 18, 2026
tkgo11 pushed a commit to tkgo11/OmniRoute that referenced this pull request Sep 23, 2026
Validate Kiro's nested tool_call wrappers only after their payloads are complete,
and forward malformed upstream envelopes as sanitized stream errors.

Co-authored-by: Edison42 <gn00742754@gmail.com>
Inspired-by: decolua/9router#2681
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