pub fn repair_tool_args(tool_name: &str, args: &str) -> StringExpand description
JSON repair utilities for malformed LLM tool-call output.
LLMs frequently produce JSON with issues such as trailing commas, single quotes, unquoted keys, invalid backslash escapes, and markdown code fences. These functions attempt to repair such output before falling back to last-resort key-value extraction. Normalize tool-call arguments into valid JSON before execution.
Runs the repair chain: direct parse → repair_json → tool-specific extractor → generic key-value extraction. Returns the original string unchanged if all strategies fail (caller can then surface a parse error to the model).
tool_name selects a specialized extractor when available (e.g. edit_file
which may contain unescaped source code in old_string/new_string).