Closed
Conversation
Implements a validation + repair pipeline for tool calls from models
with known tool-calling quirks (MiniMax M2.5, GLM-5, Grok 4).
## Files
- src/agents/tool-call-validator.ts — validates tool calls, reports
typed issues, determines repairability via fuzzy matching
- src/agents/tool-call-repair.ts — applies 7 ordered repair strategies
to produce a best-effort corrected call
- src/agents/tool-call-validator.test.ts — 50 unit tests
- src/agents/tool-call-repair.test.ts — 98 unit tests
## Validator
Reports typed issues:
- unknown_tool (fuzzy-aware repairability check)
- invalid_id
- empty_args
- malformed_json
- missing_required
- wrong_type (notes coercibility)
- extra_params
## Repair strategies (in order)
1. JSON fix-up: trailing commas, single quotes, unquoted keys,
missing braces/brackets, BOM removal
2. Type coercion: string->boolean, string->number, scalar->array
3. Tool name fuzzy matching: Levenshtein <= 3 or case-insensitive
4. Parameter name normalisation: camelCase <-> snake_case
5. Missing required params relocation from extra fields
6. Tool call ID generation/sanitisation
7. Provider-specific fixes:
- MiniMax: unwrap object/string wrappers, double-encoded JSON,
malformed strings via fixJson
- GLM-5/ZhipuAI: unwrap parameters/function_arguments wrappers
- Grok 4: same patterns as MiniMax
- Generic (unknown provider): heuristic single-key wrapper detection
## Test results
148/148 passing, 0 skipped
TypeScript: clean (tsc --noEmit exit 0)
ESLint: 0 errors, 0 warnings
Levenshtein distance implemented from scratch, no external deps.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Owner
Author
|
Closing — all commits already present in dgarson/fork. |
dgarson
added a commit
that referenced
this pull request
Feb 22, 2026
Built by Reed: - Two-column: version sidebar + release notes content - 5 releases: v2.4.1 (patch), v2.4.0 (minor/major Horizon launch), v2.3.0 (node/browser), v2.2.0 (sessions), v2.0.0 (major rewrite) - Section types: ✨ New / 🛠️ Improvements / 🐛 Fixes /⚠️ Breaking / 📦 Dependencies - Latest badge, version type badges (major/minor/patch/beta) - Prev/Next navigation, Subscribe CTA - Full a11y: role=listbox/option, aria-selected Build: ✓ 0 TS errors, 1.39s, 9.55 kB / gzip 3.28 kB
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
Describe the problem and fix in 2–5 bullets:
Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
List user-visible changes (including defaults/config).
If none, write
None.Security Impact (required)
Yes/No)Yes/No)Yes/No)Yes/No)Yes/No)Yes, explain risk + mitigation:Repro + Verification
Environment
Steps
Expected
Actual
Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
Compatibility / Migration
Yes/No)Yes/No)Yes/No)Failure Recovery (if this breaks)
Risks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None.