Skip to content

feat(agent): add guarded tool argument JSON repair#1685

Merged
wsp1911 merged 1 commit into
GCWing:mainfrom
wsp1911:json-fix
Jul 22, 2026
Merged

feat(agent): add guarded tool argument JSON repair#1685
wsp1911 merged 1 commit into
GCWing:mainfrom
wsp1911:json-fix

Conversation

@wsp1911

@wsp1911 wsp1911 commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Normalize provider terminal states into a typed tool-call completion signal.
  • Keep Write on conservative tail-closure recovery, and gate broad JSON repair on a confirmed normal tool-use completion.
  • Add repair provenance and tool-result guidance that distinguishes repaired malformed JSON from truncated writes.
  • Add the local bitfun-tool-call-jsonrepair fork, including upstream non-CLI regression coverage and a tool-call profile that preserves Markdown-like content.
  • Add the model setting, localized UI copy, configuration propagation, and crate-boundary registration.

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-jsonrepair
  • cargo test -p bitfun-tool-call-jsonrepair --features serde
  • cargo test -p bitfun-agent-stream -p bitfun-ai-adapters
  • cargo test -p bitfun-core tool_pipeline --lib
  • cargo test -p bitfun-core persistence_omits_default_memories_config --lib
  • pnpm run type-check:web
  • pnpm run i18n:audit
  • node scripts/check-core-boundaries.mjs
  • git diff --check

Reviewer Notes

The local repair crate is based on jsonrepair-rs 0.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

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above.
  • User-facing strings and locales are updated.

- 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
wsp1911 marked this pull request as ready for review July 22, 2026 14:21
@wsp1911
wsp1911 merged commit 9ce9012 into GCWing:main Jul 22, 2026
5 checks passed
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