coerce_tool_arguments
Repair malformed tool arguments by casting stringified values, wrapping scalars into arrays, resolving fuzzy enums, stripping extra keys, and backfilling missing required fields to match JSON Schema.
Instructions
[Cost: $0.0005 USDC on Base & Solana] Automatically heals, coerces, and repairs malformed tool call arguments emitted by smaller open-weight models (Llama-3, Mistral, Qwen).
Casts stringified numbers/booleans, wraps scalar strings into arrays, resolves fuzzy enums, strips extra hallucinated keys, and backfills missing required properties in < 1ms.
Eliminates expensive 2-second LLM re-prompting cycles with 100% deterministic schema conformance.
Args:
raw_arguments: The raw parameter dictionary (or JSON string) produced by the model.
target_schema: The JSON Schema dictionary (or JSON string) declaring expected property types.
strict_keys: If True, strips extra hallucinated keys not in the schema (default: True).
backfill_defaults: If True, backfills missing required fields with schema or type defaults (default: True).
payment_signature: Optional x402 Base USDC transaction hash or developer mock key.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"raw_arguments": "<raw_arguments>",
"target_schema": "<target_schema>"
},
"name": "coerce_tool_arguments"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| strict_keys | No | ||
| raw_arguments | Yes | ||
| target_schema | Yes | ||
| backfill_defaults | No | ||
| payment_signature | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |