Skip to content

Model emits malformed JSON args for search_nodes filters, so the filter never runs #1943

Closed

Description

@malibio

Summary

The locked native model (gemma-4-E4B-it-Q4_K_M) emits malformed JSON arguments for search_nodes filters: object keys arrive with embedded quote characters, and a value is spliced into a neighbouring field. The call is rejected by argument parsing before it ever runs, so a search the model correctly intended never executes.

This blocks "How many tasks are open?" from returning a count, even though — after #1939 / #1941 — the model now forms the right intent and targets the right field.

Observed

Reproduced 3/3 at temperature 0.1 while verifying #1939 (packages/agent/tests/live_unset_schema_field.rs, live_model_recovers_from_a_bad_enum_value_without_asking):

LIVE[rep 0] retried: {"filters":[{"\"operator\"":"equals","\"property\"":"status","\"type\"":"task\",\"value\":"}],"\"node_type\"":"task","query":null}
LIVE[rep 0] retry rejected: invalid arguments for tool search_nodes:
             unknown field `"node_type"`, expected one of `query`, `node_type`, `filters`, `sorting`, `limit`

Two distinct corruptions in one payload:

  1. Keys carry literal quotes — "\"property\"" instead of "property", at both the top level ("\"node_type\"") and inside the filter object.
  2. A value is spliced across fields — "\"type\"":"task\",\"value\":" has swallowed what should have been the value key and its content, so the filter loses its comparison value entirely.

Identical output across all 3 reps, so this is deterministic at this temperature, not sampling noise.

Not new

#1939 recorded the same class of defect from production and explicitly scoped it out as "a model slip that self-corrected on retry":

args_preview={"filters":[{"operator":"equals","property":"status","type":"task","value":"open"}],"node_type":"task"}
result_preview={"error":"...Unknown filter type 'task'. Supported: property, content, relationship, metadata"}

packages/agent/tests/live_update_node_noop_gate.rs:188 also carries an unparseable args branch for the same reason. So the behaviour is known and tolerated in several places, but has not been characterised or fixed.

Note the production instance and the one above are not identical: production emitted well-formed JSON with a wrong type value, whereas the reproduction emits structurally corrupt JSON. They may be one defect or two — worth establishing which before designing a fix.

Why this matters now

Before #1941 the read path failed earlier, at the model asking the user to name the field, so this defect was masked. With the field list delivered, the model reaches the point of emitting a filter — and this is what it hits. Measured A/B, 3 reps each, identical but for the payload:

empty result carries outcome
{count, nodes} only 0/3 retried — "I do not have enough information to continue…"
+ filterable_properties 3/3 retried against status, 3/3 rejected on malformed args

So this is now the last thing between the user and a working "how many tasks are open?".

Acceptance criteria

  • Determine where the corruption originates — grammar-constrained decoding, the tool-call parser, or the model itself. Grammar triggered on regex: '<|tool_call>' appears in the logs immediately before each affected generation, which makes the grammar/parser seam the first place to look
  • Establish whether the production case (valid JSON, wrong type value) and the reproduction (structurally invalid JSON) are one defect or two
  • Confirm whether this is specific to search_nodes' nested filters array, or affects any tool with a nested-object parameter — update_node's flat properties object does NOT exhibit it (3/3 clean in the same test run), which suggests nesting depth is the trigger
  • Fix, or add a repair path if the corruption is unfixable at the source
  • Regression test at the same 3-rep granularity
  • live_model_recovers_from_a_bad_enum_value_without_asking upgraded to assert the retry executes, replacing the deliberately-scoped assertion left in place by Surface a node type's schema fields so unset fields can be set and filtered (closes #1939) #1941
  • Verified on the locked native model

Environment

Activity

  1. added
    bug
    on Aug 3, 2026
  2. malibio commented on Aug 3, 2026

    @malibio
    CollaboratorAuthor

    Baseline (worktree issue-1943-malformed-tool-args): Frontend: 171 test files passed, 4108 tests passed.

  3. self-assigned this
    on Aug 3, 2026
  4. malibio commented on Aug 3, 2026

    @malibio
    CollaboratorAuthor

    Acceptance criterion deviated-with-rationale, not met as written.

    The criterion live_model_recovers_from_a_bad_enum_value_without_asking upgraded to assert the retry **executes** is NOT satisfied as stated, deliberately. Recording it here so the delta stays visible rather than resting in a merged PR body.

    The model writes the delimiters that should have introduced value as string content ("type": "task\",\"value\":"), so the comparison value is never generated at all. Nothing downstream can recover it — synthesizing "open" would fabricate the user's query. Asserting execution would encode a capability this model does not have and leave a permanently red test.

    The test instead asserts every retry reaches exactly the missing-value failure:

    assert_eq!(executed + missing_value_only, recovered, ...)

    This still gates the fix. missing_value_only increments only on "Missing value", so a repair regression (fails as unknown field), a category-inference regression (fails as Unknown filter type 'task'), or a new malformation all land in neither bucket and trip the assertion.

    Verified on the locked native model, 3/3: recovered=3 executed=0 missing_value_only=3 asked_the_user=0.

    Making the retry actually execute needs the model to emit the value — a prompting/model-capability question, not a repair one. Worth a separate issue if the count matters for "how many tasks are open?"; the read path now gets everything except that value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

backendbug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions