Skip to main content

Crate argmend

Crate argmend 

Source
Expand description

Argmend repairs broken tool-call arguments into JSON.

Callers pass the raw argument string and, when they have it, the tool’s JSON schema.

Match RepairOutcome, RewriteKind, and RepairError with a wildcard arm. A later release can add a variant. Build RepairRequest with RepairRequest::new so a new field is not required. RepairRequest::with_options turns off path backslashes, alias renames, or truncation closing. The default keeps those repairs on. embedded_json stays off. Set it to parse one JSON string when the schema type is an object or an array. leading_prose stays off. Set it and pass the options to repair_json_with to take one object or array after a prefix. wrap_scalar stays off. normalize uses those defaults. normalize_with is the same call with explicit switches.

repair_args and normalize produce JSON. A successful result is not a promise that the schema accepts it. The host still validates before it runs a tool.

Structs§

ArgumentPreview
A look at a tool-call argument that may still be streaming.
RepairOptions
Which repairs repair_args may apply.
RepairRequest
Arguments plus an optional JSON schema.
Repaired
A value the host can execute, with every rewrite that produced it.
Rewrite
One recorded rewrite. Valid JSON that needs no schema change has none.

Enums§

RepairError
Repair refused. RepairError::Ambiguous is not a guess.
RepairOutcome
Result of repair_json.
RewriteKind
Why a rewrite was applied.

Functions§

normalize
Apply a tool schema to an already-parsed value.
normalize_with
normalize with explicit repair switches.
preview_args
Preview a tool-call argument while tokens are still arriving.
repair_args
Parse raw, then apply normalize when a schema is present.
repair_json
Syntax repair only. Empty input and garbage stay RepairOutcome::Unfixable.
repair_json_with
repair_json with RepairOptions.
tool_schema
JSON Schema stored on an OpenAI, Anthropic, or MCP tool definition.