tool-call-repair
Skill0 starsChanged 50 days agoMITView on GitHub
Validate-then-repair for malformed LLM tool-call inputs, so a recoverable mistake is fixed at the failing path instead of failing the call. Use when an open or cheaper model (DeepSeek, Qwen, GLM, Kimi, local) keeps bouncing off a strict tool schema: null for an optional field, a stringified array, a bare string for an array, an empty {} placeholder, a markdown-autolinked path.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- yinqd3/workbuddy-skillstheir own version, first seen Jun 3, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- yinqd3/workbuddy-skills★ 10same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository17 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/humanizer/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- cherrypickerSkill
- copyable-markdownSkill
- deltamaxxSkill
- docs-mirrorSkill
- ffmpegSkill
- humanizerSkill
- prompt-packSkill
- socials-mirrorSkill
- spamcheckSkill
- writing-beatsSkill
- writing-for-agentsSkill
- writing-fragmentsSkill
- writing-shapeSkill
- yt-ccSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Do not fail a tool call on recoverable noise.
- Distinctive: line 70
No Command Code proprietary source is used or included.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
tool-call-repair
Do not fail a tool call on recoverable noise. Validate first; repair only where the schema actually disagreed.
python3 scripts/tool_call_repair.py '<schema-json>' '<data-json>'Or import it:
from tool_call_repair import repair_tool_input, fill_relational_defaults
out = repair_tool_input(tool_schema, model_supplied_args, tool_name="readFile", model="deepseek-v4-flash")
if out["status"] == "invalid":
return out["message"] # model-readable, no "Error:" prefix
run_tool(out["data"]) # valid or repaired inputWhy
A strict schema filters out noise, but it also filters out recoverable noise from any model that did not memorize your exact JSON contract. Big commercial models absorb that cost invisibly; open and cheap models pay it loudly and get called "bad at tool calls." It's usually a harness problem, not a model problem. Ahmad Awais showed DeepSeek V4 Pro beat a frontier model 6/10 on internal evals once a repair layer handled its quirks.
The catalog (finite, compositional, ordered)
| Repair | Model sent | Schema wanted |
| null-for-optional | {"timeoutMs": null} | key omitted |
| json-array-parse | "[\"a\",\"b\"]" | ["a","b"] |
| empty-placeholder | {} (array field) | [] |
| bare-string-wrap | "foo" | ["foo"] |
| path-autolink | "/p/[notes.md](http://notes.md)" | "/p/notes.md" |
Order matters: json-array-parse runs before bare-string-wrap, or
'["a","b"]' becomes ['["a","b"]'] — schema-valid, meaning lost.
Rules
- Valid inputs are never touched. Parse as-is; only on failure walk the issue list and repair at the failing paths. Preprocessing-before-validation corrupts valid data that merely looks broken (e.g. file content that is itself JSON-shaped).
- Mark path fields with
"format": "path"in the schema (thepathString()equivalent) so the degenerate markdown-auto-link leak is caught. Real links like[click](https://x.com)pass through untouched. - Relational invariants are not input repair. For a mutually-dependent pair
like read_file's offset/limit, use
fill_relational_defaults: fill the intended default and surface the choice with NOError:prefix, so the model self-corrects next turn. - Telemetry is free. The
logfield (tool_input_repaired:<tool>/tool_input_invalid:<tool>) lets you watch repair rates per (model, tool) and catch a regression before users do.
Attribution
Technique and catalog by Ahmad Awais (@MrAhmadAwais), published in the Command Code "Tool Call Repairs" write-up: https://commandcode.ai/docs/harness-engineering/tool-call-repairs This skill is an independent Python reimplementation of the documented method. No Command Code proprietary source is used or included.
Requirements
python3, standard library only. scripts/test_tool_call_repair.py runs
offline in under a second.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

