Skip to content

fix(core): reject malformed tool arguments and settle unfinished calls - #53685

Merged
rekram1-node merged 2 commits into
v2from
tool-call-gate
Oct 8, 2026
Merged

rekram1-node merged 2 commits into
v2from
tool-call-gate

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Reject broken arguments without delaying valid calls

flowchart TD
    A[Tool arguments stream] --> B[Partial preview stays available]
    A --> C{Final arguments decode as complete JSON?}
    C -->|Yes| D[Execute immediately on tool-call]
    C -->|No| E[AI emits tool-input-error]
    E --> F[Core records failure: not executed]
    G[Stream ends with an uncalled local tool] --> F
    F --> H[Existing tool-error continuation allows a corrected call]
Loading
 Final tool arguments
- Repair incomplete JSON, or fall back to {}
+ Reject malformed JSON; never execute repaired arguments

 Unfinished local call at step closeout
- Remain streaming indefinitely
+ Record an unexecuted tool failure

Ownership: packages/ai decodes arguments and emits call/error events. packages/core persists terminal tool state and owns continuation; its closeout sweep catches calls that parsers never finalized.

Unchanged: streaming previews, eager execution, empty input for zero-argument tools, and hosted-tool/refusal/transport handling. A completed valid call may already have executed before a later refusal or output limit. Text-only truncation continuation is out of scope.

Verification

  • Local: full AI suite 1,777 passed, 28 skipped; focused Core suite 252 passed; both affected-package typechecks pass.
  • CI: Linux unit tests, Linux E2E, and workspace typechecking pass.
  • Windows unit failure: unrelated Npm.add Git-subdirectory installation test exceeded its 5-second timeout.
  • Updates existing tests for strict final JSON parsing and terminal tool state; adds one regression for unfinished calls after an output limit. Existing suites continue to cover previews, valid calls, zero-argument tools, and error recovery.

Related issues

Fixes #52553

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