Skip to main content
Glama

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.
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
strict_keysNo
raw_argumentsYes
target_schemaYes
backfill_defaultsNo
payment_signatureNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.3.0

TDQS

A4.4/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden and does so well: it discloses cost, sub-millisecond latency, deterministic schema conformance, and specific transformations such as casting, array wrapping, enum resolution, key stripping, and backfilling. It omits failure modes and auth details, but the core behavior is clear.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is front-loaded with cost and core purpose, then uses a structured Args block. It is somewhat long, but the length is justified by the low schema coverage and the need to document parameters and payment behavior.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, low schema coverage, and the existence of an output schema, the description covers the operational essentials: inputs, controls, cost, latency, and determinism. It does not explain failure behavior or output format, but those are partially covered by the output schema and the core invocation requirements are clear.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate, and it does: the Args section documents all five parameters, including accepted JSON-string forms for raw_arguments and target_schema, defaults for strict_keys and backfill_defaults, and the payment_signature format. This adds substantial meaning beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific action ('heals, coerces, and repairs') on a precise resource ('malformed tool call arguments') and emphasizes deterministic schema conformance. This makes its purpose clear and distinguishes it from generic repair utilities like repair_malformed_json.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description gives clear use context: use for malformed arguments from smaller open-weight models and to avoid expensive LLM re-prompting cycles. It does not explicitly name sibling tools or state when not to use it, so it stops short of a 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.