fix(agent-core-v2): coerce string-typed tool arguments at the parse boundary #2175
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.40) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 295 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.340
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2175"
general
weight: 0.35
HelloWorldU
Related Issue
Resolve #2118
Problem
Some third-party models emit tool-call arguments as JSON strings (
"3") instead of the declared JSON types (3) — reported in the linked issue on 0.29.0 with Qwen. The arguments are decoded faithfully and validated strictly, so the call is rejected withInvalid args for tool ...and the turn stalls, even though the model's intent is unambiguous.What changed
The fix sits at the tool-call parse boundary — the earliest point the harness controls — and keeps validation itself strict. Two moves, as discussed in the issue:
1. A normalization layer before validation. It is generic and bounded by design, so it stays a single schema-driven rule rather than growing into a catalog of model-specific hacks: only lossless
string → integer / number / booleancoercions, only when the schema does not already accept strings at that position;$refnodes and ambiguous schemas are left untouched.2. A warning that keeps the provider's violation visible. Coerced calls succeed, but the tool result carries a model-visible note (rendered to the model at projection time, never shown in UIs) describing exactly what was coerced — the non-conforming output is absorbed without being silently hidden.
When coercion cannot fix the arguments, the rejection now says what actually arrived (e.g.
/line_offset must be integer (received string "3")) so the model can self-correct, and duplicate type errors from union branches are deduplicated.Scope: the v2 engine only, which is what the current CLI runs on. The v1 engine has an isomorphic parse/validate path; happy to mirror the change there if the team wants both covered.
Tests: unit coverage for the normalization rules and the new error wording, plus executor integration tests covering coercion with the warning note, note merging with the tool's own note, honest rejection, and clean passthrough. Roughly half of the +571/−11 diff is tests.
Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.