feat(agent): add guarded tool argument JSON repair#1685
Merged
Conversation
- Normalize provider terminal states into typed tool-call completion signals. - Repair malformed tool arguments only after a confirmed normal tool-use completion. - Preserve conservative Write tail-closure recovery and record repair provenance. - Add the local bitfun-tool-call-jsonrepair fork with upstream non-CLI regressions. - Preserve Markdown-like tool payloads when missing opening quotes would otherwise parse as comments. - Add the allow_tool_json_repair setting, enabled by default and omitted from persisted config at its default value. - Add localized settings UI and keep explicit false values persisted. - Update stream, adapter, tool-contract, configuration, and boundary coverage.
wsp1911
marked this pull request as ready for review
July 22, 2026 14:21
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
bitfun-tool-call-jsonrepairfork, including upstream non-CLI regression coverage and a tool-call profile that preserves Markdown-like content.Fixes #
Type and Areas
Type:
Feature / regression fix / test
Areas:
Rust core, AI adapters, agent stream, tool contracts, web UI, configuration
Motivation / Impact
Malformed JSON from a provider-confirmed tool call can now be repaired before normal schema validation. Output-limit, interruption, filtering, and unknown endings remain fail-closed for broad repair. Write keeps its separate conservative recovery behavior.
Verification
cargo test -p bitfun-tool-call-jsonrepaircargo test -p bitfun-tool-call-jsonrepair --features serdecargo test -p bitfun-agent-stream -p bitfun-ai-adapterscargo test -p bitfun-core tool_pipeline --libcargo test -p bitfun-core persistence_omits_default_memories_config --libpnpm run type-check:webpnpm run i18n:auditnode scripts/check-core-boundaries.mjsgit diff --checkReviewer Notes
The local repair crate is based on
jsonrepair-rs0.2.1 under MIT. Its non-CLI upstream regression suite is vendored; the CLI is intentionally excluded because the internal crate does not ship a binary.Checklist