Parse whole-response tool call arrays - #2689
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
Adds safe recovery of whole-response JSON tool-call arrays while preserving parser security boundaries and browser parity.
Changes:
- Parses valid standalone JSON arrays atomically.
- Rejects mixed, disallowed, and narrated batches.
- Adds Chrome/Firefox parity and regression coverage.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/chrome/src/agent/tool-call-parser.js |
Adds atomic array parsing and shared conversion. |
src/firefox/src/agent/tool-call-parser.js |
Mirrors the Chrome parser changes. |
test/run.js |
Covers valid, narrated, mixed, and disallowed arrays. |
馃挕 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
call:name{}fallbacks so call-like strings inside rejected arrays cannot be minedWhy
PR #2682 deliberately narrowed bare JSON recovery to objects that stand alone on their line. That safer rule also drops legitimate compact batches such as:
[{"name":"read_page","arguments":{}},{"name":"click","arguments":{"text":"Go"}}]Parsing only when the complete response is a JSON array recovers that format without reopening arbitrary inline-object scanning. Atomic validation prevents an allowed-looking subset from executing when another element is disallowed, metadata, narration, or a call-like string.
Validation
node test/run.js: 1,483 passed; the sole failure is the pre-existingpackage.json26.1.2 vsCHANGELOG.md26.1.0 assertionnode test/security/injection-corpus.mjs: 60/60node --checkon both parser modulesgit diff --check