fix(core): preserve text tool argument boundaries - #6750
Merged
Merged
Conversation
Use one byte-indexed balanced-object scan for the live legacy text-tool fallback. Preserve nested JSON and quoted braces, use JSON escape rules only for JSON, and keep literal CLI backslashes and apostrophes accepted. Reject malformed present arguments and an unclosed outer wrapper instead of panicking, inventing empty arguments, or trying a looser tool-name match. Recognize compact and whitespace-separated argument arrows consistently. Validation on this exact single-file tree, executed by the coordinating agent and independently checked from its saved logs: - codewhale-core tool_parser::tests: 12 passed, 0 failed, 0 ignored. - npm test: 636 passed, 0 failed (68 + 16 + 50 + 502). - npm run check:web: passed through the production Next build, exit 0. - rustfmt --edition 2024 --check and git diff --check: passed. Source review was independently completed by two peer agents. This local checkpoint does not claim hosted CI, provider execution, or release proof. Signed-off-by: Hunter B <hmbown@gmail.com>
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.
No-Issue: verified bug-hunt findings
Legacy text tool calls containing Unicode or braces inside argument values could panic, truncate their JSON, or become empty-argument calls when an object was malformed. The engine still uses this fallback when a response has tool markers but no structured calls.
The parser now uses one byte-indexed, quote-aware balanced-object scan. JSON keeps its escape rules; supported CLI arguments keep literal backslashes and apostrophes, including Windows directory endings and names such as
O'Brien.txt. Nested objects and quoted braces are preserved. Malformed present arguments and unclosed outer wrappers are rejected, and compact or whitespace-separated argument arrows follow the same validation path. The module documentation now describes the active caller.Validation on the final local tree:
npm test: 636 passed, 0 failed (68 + 16 + 50 + 502).npm run check:web: passed through the production Next build.Hosted CI remains required before merge. No provider call, deployment, or release validation is claimed.