Skip to content

Model retries a rejected tool call with identical malformed JSON, never self-corrects #1876

Closed

Description

@malibio

Split out of #1872's verification.

Symptom

The model sometimes emits a tool call (observed on create_schema and update_schema) whose JSON arguments have double-quoted keys — e.g. {"fields":[{"\"name\"":"capacity","\"type\"":"number"}]}, where the key is literally "name" (quotes included) instead of name. The tool correctly rejects this:

error: invalid params: fields[0] is missing "name"; fields[0] is missing "type".
Every entry in "fields" needs both "name" and "type", e.g. {"name":"amount","type":"number"}.
Re-send the call with only the listed entries corrected — leave every other field exactly as it was.

The model does retry (as instructed by both the tool's own error message and #1872's new SCHEMA_VALIDATION_ERROR_RETRY guidance), but retries with the identical malformed payload, sometimes alternating tools (create_schema → update_schema → create_schema) while never actually changing the JSON shape. After exhausting the turn's tool-call budget, the turn ends with empty final text and nothing persisted — no schema, no error surfaced to the user, no create_node.

Why this is worth tracking separately

This produces the same end-state as #1865/#1872's original symptom (a turn that accomplishes nothing) but via a different mechanism: those were about the model choosing not to act (asking a clarifying question) or having nothing valid to act on (a genuinely absent schema). This is the model attempting to act, repeatedly, but with a self-generated syntax error it does not seem to recognize as the cause — telling it "the error names the specific problem, fix that and retry" (as #1872's guidance does) doesn't help when the problem is in the model's own JSON encoding, not in the schema's semantic content.

Observed on both create_schema's fields array and update_schema's add_fields array, so it isn't specific to one tool's argument shape — likely a broader tool-call-formatting issue (possibly in how nested-object array arguments get encoded at this model size/quantization) rather than something a skill_rules.rs guidance addition can fix.

Measurement

3 of 8 live trials of the agent-matrix chat-8 sequence (8a→8b turns) against gemma-4-e4b-q4km, isolated daemon, purged DB. Not yet characterized against other tools with nested-array arguments (create_relationship, create_nodes_from_markdown) — worth checking whether this is unique to fields/add_fields or general to any array-of-objects tool parameter.

Suggested starting points

  • Check packages/agent/src/local_agent/chat (tool-call parsing / chat-template application) for whether nested-object-array arguments have a known encoding quirk at this model's chat template.
  • Check whether the first malformed call and the retry are byte-identical, or whether the model is generating a fresh (still-broken) attempt each time — different root causes (a stuck/copied generation vs. a systematic encoding habit) suggest different fixes.
  • Consider whether the tool-result error message could be more actionable for a self-generated JSON bug specifically — e.g. detecting the double-quote pattern server-side and naming it explicitly ("your JSON key is \"name\" including the quote marks — remove the extra quotes") rather than the current message, which is accurate but assumes the model can already tell its own JSON is malformed.

Acceptance criteria

  • Determine whether this is specific to fields/add_fields-shaped arguments or general to any nested-object-array tool parameter
  • Determine whether retries are byte-identical or independently regenerated (still-broken) attempts
  • A rejected tool call with this malformation either self-corrects on retry, or the turn produces an honest "I couldn't complete this" response rather than ending empty with nothing persisted and nothing said

Activity

  1. malibio commented on Aug 1, 2026

    @malibio
    CollaboratorAuthor

    Frontend baseline: 171 test files passed, 4108 tests passed (Duration 49.46s). Starting investigation.

  2. self-assigned this
    on Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions