Skip to content

fix(core): preserve text tool argument boundaries - #6750

Merged
Hmbown merged 1 commit into
mainfrom
fix/tool-parser-boundaries
Sep 29, 2026
Merged

Hmbown merged 1 commit into
mainfrom
fix/tool-parser-boundaries

Conversation

@Hmbown

@Hmbown Hmbown commented Sep 29, 2026

Copy link
Copy Markdown
Owner

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:

  • Focused core parser tests: 12 passed, 0 failed, 0 ignored. Cases cover Unicode, nested and escaped JSON, CLI quote compatibility, malformed objects, missing arguments, and existing non-executable wrapper handling.
  • npm test: 636 passed, 0 failed (68 + 16 + 50 + 502).
  • npm run check:web: passed through the production Next build.
  • Formatting and whitespace checks passed; two independent source reviews completed.

Hosted CI remains required before merge. No provider call, deployment, or release validation is claimed.

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>
Copilot AI balanced review requested due to automatic review settings September 29, 2026 11:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Hmbown
Hmbown merged commit e29d5a2 into main Sep 29, 2026
35 checks passed
@Hmbown
Hmbown deleted the fix/tool-parser-boundaries branch September 29, 2026 13:20
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.

2 participants