Skip to content

fix(providers): stream "{}" for Kiro tool calls with no input - #18780

Merged
diegosouzapw merged 4 commits into
cheaper-inference:release/v3.8.53from
gaurav0107:fix/18718-fix-providers-kiro-tool-calls-with-no-in
Nov 4, 2026
Merged

diegosouzapw merged 4 commits into
cheaper-inference:release/v3.8.53from
gaurav0107:fix/18718-fix-providers-kiro-tool-calls-with-no-in

Conversation

@gaurav0107

@gaurav0107 gaurav0107 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • When Kiro streams a tool call that has no input (a tool with no parameters, or one whose parameters are all optional and the model passed none), the executor sends the tool-call start chunk with function.arguments: "" and nothing after it. Clients reassemble "" and strict OpenAI clients reject the call. OpenAI sends "{}" in this case.
  • flush() now calls a new flushEmptyToolCallArgs helper after the buffered-args flush and before the finish chunk. It sends "{}" for every started tool call that has streamed no arguments (missing, "", or whitespace only).
  • The fill runs only at the terminal flush, not at messageStopEvent, so a late argument fragment can never be appended after an injected {}.
  • flushPendingWrapperToolCalls now records the arguments it emits in toolArgsEmitted. Without that, the fill would append {} to a valid tool_call wrapper payload.

Related Issues

Target Branch

  • Base is the active release/v3.8.x branch (release/v3.8.53), not main
  • New feature? Not applicable: this is a bug fix

Validation

  • Change type: provider
  • Focused tests: every test file that imports the Kiro executor
  • eslint + prettier --check on the changed files, and npm run check:open-sse-typecheck
  • Reconciled with the current release/v3.8.53 tip
  • Production-code change includes new automated tests

Without the fix, the new end-to-end test fails (the reassembled arguments are ""):

✖ Kiro streams {} arguments for a tool call that carries no input (#18718)
ℹ tests 24
ℹ pass 23
ℹ fail 1

With the fix, across the 15 test files that import open-sse/executors/kiro.ts:

$ node --import tsx/esm --import ./open-sse/utils/setupPolyfill.ts --import ./tests/_setup/isolateDataDir.ts --test --test-force-exit <15 kiro test files>
ℹ tests 137
ℹ pass 137
ℹ fail 0

$ npm run check:open-sse-typecheck
openSseTypecheckErrors=0
[open-sse-typecheck] OK — 0 pre-existing error(s), all within frozen baseline.

Tests Added Or Updated

  • tests/unit/executor-kiro.test.ts: a stream with three tool calls: no input, input: "", and an object input. The first two reassemble to {}, the third is unchanged, and the fill lands before the tool_calls finish chunk. A second case checks that a valid tool_call wrapper does not get {} appended.
  • tests/unit/kiro-tool-args-streaming.test.ts: unit tests for flushEmptyToolCallArgs covering missing, empty, and whitespace-only arguments, a call that already streamed arguments, idempotence, and the no-tool-call case.

Coverage Notes

  • The open-sse/executors/kiro.ts change is covered by the two test files above. The new helper is exercised directly and through transformEventStreamToSSE, and every branch is covered.

Reviewer Notes

  • The fill only applies to calls whose emitted argument string is empty after trimming. Calls that streamed string fragments or a buffered object are untouched.
  • Changelog fragment: changelog.d/fixes/18780-kiro-empty-tool-arguments.md.

🤖 Opened with Superhuman, an open-source contribution agent.

A Kiro tool call starts with `arguments: ""`. When Kiro sends no input for
it (a no-parameter tool, or optional parameters the model left out),
nothing replaces the empty string, so OpenAI clients reassemble `""` and
strict ones reject the call. At the terminal flush, send `"{}"` for every
started tool call that streamed no arguments, matching OpenAI.

The tool_call wrapper path now records the arguments it emits, so the
fill never appends to a wrapper call's JSON.

Closes cheaper-inference#18718
@gaurav0107
gaurav0107 marked this pull request as ready for review November 2, 2026 18:21
@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@diegosouzapw
diegosouzapw merged commit 2b5a61f into cheaper-inference:release/v3.8.53 Nov 4, 2026
3 of 37 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.

fix(providers): kiro tool calls with no input stream function.arguments: "" instead of "{}", so strict OpenAI clients reject the call

2 participants