Skip to content

search_nodes 'in' operator gets a comma-joined string, not an array: filter silently matches nothing #2182

Closed

Description

@malibio

Summary

search_nodes' in operator receives a comma-joined string instead of an array, 3/3 reps, producing a filter that silently matches nothing.

search_nodes({"filters":[{"operator":"in","property":"stage",
                          "value":"cut,soak"}],"node_type":"release"})

value should be ["cut","soak"].

This is a schema/grammar defect, not a guidance gap — established by measurement below, so please don't try to fix it with prose.

Why a filter failure is worse than a write failure

A malformed write is rejected by validation — loud and recoverable. A malformed filter returns zero results, which is indistinguishable from a genuinely empty result. The agent then truthfully reports "nothing found" and the user has no signal anything went wrong. The corpus has a case for exactly that legitimate outcome (dev-empty-result-query), so a bad filter hides inside it.

Both channels already state the rule correctly

packages/agent/src/local_agent/tools.rs (~line 443):

"value": {
    "type": ["string", "number", "boolean", "array"],
    "description": "Value to compare against. Use string for dates (YYYY-MM-DD), \
                    string/number for others. Use array for 'in' operator."
}

The type union includes array. The description says "Use array for 'in' operator." The model ignores both.

Prose was measured and does not fix it

Measured on dev-unseen-schema via the golden runner (packages/agent/goldens/ablation/), 3 reps each, byte-identical within each arm:

arm result
full guidance subtree "value":"cut,soak" — wrong
minimal subtree "value":"cut,soak" — wrong
minimal + explicit filter-construction rule "value":"cut,soak" — unchanged

The rule added in the third arm was:

FILTERS: each filter is one object with property, operator, and value. An operator taking several values takes them as a list, never as one comma-joined string.

No effect. And on a sibling case (dev-status-change-enum), that same generically-worded rule made things worse — the model emitted Gemma's internal call syntax as raw text rather than a JSON tool call:

call:search_nodes{filters:[{operator:equals,property:status,value:in_dev}],node_type:ticket,query:}

So this is a third statement of a rule two channels already carry, and adding it is not free.

Probable mechanism

value's correct shape depends on the value of a sibling field (operator). Nothing in JSON Schema expresses that dependency here, so the model must infer "operator is in ⇒ value is an array" from prose. It doesn't.

There is a directly relevant note already in the source at that declaration:

Measured honestly: this alone did NOT stop the #1943 splice (3 of 3 reps produced byte-identical output before and after), so the malformation is not the untyped leaf.

Same shape of finding: tightening the type union did not change behaviour then either.

This is also the same class as #2159, where declaring enums on filters produced correct enum values in a broken wire format, and was closed as a negative result.

Directions worth measuring

Not prescribing one — each needs the same measurement discipline:

  • Split the operator. A separate in_values array parameter, so the array shape is unconditional rather than conditional on a sibling.
  • Drop the union. Make value a string and accept a documented separator, or make it always an array with single-value filters using a one-element list. Either removes the inference step.
  • oneOf per operator. Note Measure declaring enums on search_nodes filters: negative result, block stays for reads #2159 measured this failing: Gemma-4's template renders oneOf branches as opaque literal text, and the model reproduced the branch's own properties key verbatim. Probably a dead end on the locked model, recorded so it isn't retried blind.
  • Repair at the parse boundary. agent_loop.rs already has repairs for this family (repair_spliced_object_values, repair_over_quoted_keys). Splitting a comma-joined string when operator == "in" is mechanical and unambiguous. Cheapest, and treats the symptom.

Acceptance criteria

  • in receives an array, measured at ≥3 reps on dev-unseen-schema (currently 0/3)
  • dev-status-change-enum does not regress — its equals filter and query handling still correct
  • Wire format unchanged for callers, or the change is threaded through search_nodes' handler
  • Whatever is tried, the result is recorded in the arm file including a negative result

Reproduction

cargo build --release -p nodespace-agent --bin golden_runner
./target/release/golden_runner --reps 3 \
  packages/agent/goldens/ablation/dev-unseen-schema-filter-rule.toml

No daemon, no DB. Turn 1 shows the malformed filter; turn 2 is correct, so the case fails on argument shape alone.

Activity

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

    @malibio
    CollaboratorAuthor

    Frontend baseline: 227 test files passed, 4789 tests passed (0 failures).

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

    @malibio
    CollaboratorAuthor

    Scoping — one correction to the framing, and the direction I'm taking

    Correction: this does not silently match nothing. I traced the path before choosing an approach:

    exec_search_nodes → run_node_query → query_ops::execute_query → QueryService::build_filter_condition, and at packages/core/src/services/query_service/mod.rs:454:

    FilterOperator::In => {
        let values = filter.value.as_ref().and_then(|v| v.as_array())
            .ok_or_else(|| anyhow::anyhow!("In requires array value"))?;

    A non-array value is an Err, which propagates as OpsError::Internal("execute_query failed: In requires array value") and surfaces to the model as a tool error. So today's behaviour on "value":"cut,soak" is a loud failure, not a zero-result indistinguishable from dev-empty-result-query. That doesn't make the defect less real — a failed turn is still a failed turn, and the model then has to recover from an error it caused — but it does mean the "worse than a write failure" argument in the issue body does not hold, and it changes which fix is proportionate. Recording it rather than quietly fixing around it.

    Second observation about the repro. packages/agent/goldens/ablation/dev-unseen-schema-filter-rule.toml is not in the repo (the third arm was presumably never committed), and goldens/dev-unseen-schema.toml declares filters.items.properties.value as a bare type = "string" — no array in the union. So on the case as committed, "cut,soak" is schema-compliant output: the corpus is asking for a string and getting one. Production's schema (tools.rs ~443) does include array in the union. Whatever arm I measure has to declare value the way production does, or it measures the corpus's own defect rather than production's.

    Direction: parse-boundary repair, which of the four listed is the only one that is both cheap and cannot regress a sibling case:

    • It is a pure post-parse transform on already-emitted arguments, so no prompt bytes and no tool-schema bytes change. dev-status-change-enum sees a byte-identical prompt and therefore cannot regress — the mechanism that made the third prose arm hurt (adding a third statement of a rule, displacing context) is absent by construction.
    • The transform is mechanical and unambiguous in exactly the way repair_spliced_object_values and repair_over_quoted_keys already are: when operator == "in" and value is a string, the intended value is that string split on the separator. It joins the existing repair set at the one entry point (repair_parsed_tool_arguments), so it reaches both the parse boundary and the execution backstop, and participates in canonical_args so a malformed call and its repaired retry share one identity.
    • Blast radius is narrowed by the sibling repairs' own bar: it fires only inside a filter-shaped object that actually carries operator: "in", never on content / field_values user data.

    Why not the other three. oneOf is a measured dead end on the locked model (#2159 — the template renders branches as opaque literal text). Splitting the operator into an in_values parameter and dropping the union both change the model-facing surface, i.e. they change prompt bytes, i.e. they carry exactly the regression risk the third prose arm demonstrated — and they're a larger change to buy the same outcome the repair buys for free. If the repair turns out not to be enough, they remain available and I'd measure them then rather than now.

    On the "in receives an array, measured at ≥3 reps" criterion. The repair means the model may still emit a comma-joined string while the tool receives an array. I'll measure and report both: what the model emitted, and what the tool executed after repair. If the intent of the criterion is specifically "the model's raw emission is an array", the repair does not meet it and I'll say so plainly rather than claiming a pass — but the executed call being correct is what the user experiences, and that is what I'm optimising for. Recording the emission-level result as a negative if it stays wrong.

    Proceeding on that basis unless redirected.

  5. malibio commented on Aug 20, 2026

    @malibio
    CollaboratorAuthor

    Measured. Both of this issue's central claims are refuted.

    PR #2183. Recording the numbers here since the issue asked for results in the arm files and on the ticket.

    The in malformation is caused by the DECLARATION, and production's declaration already works

    Two ablation arms differing in exactly one thing — how filters.items.properties.value is declared — 3 reps each, byte-identical within each arm:

    arm value declared as emitted by the model
    in-operator-array-elicited production's union ["string","number","boolean","array"] "value":["cut","soak"] ✅ 3/3
    in-operator-string-declared bare type = "string" "value":"cut,soak" ❌ 3/3

    --check-verified as isolated: identical system prompts, user messages, tool descriptions, tool results, and turn 2; only the value schema differs.

    Production already carries the union. The "cut,soak" reported here came from goldens/dev-unseen-schema.toml, which declares value as a bare type = "string" — so the model was complying with the schema in front of it, not defying it. The premise "both channels already state the rule correctly" is true of production and false of the case the evidence came from.

    This inverts the issue's guidance: rather than splitting the operator or dropping the union, the union is the thing that must not be narrowed. I've recorded that at the declaration in tools.rs so nobody removes it later on the theory that the model ignores it.

    It does not silently match nothing — it errors

    packages/core/src/services/query_service/mod.rs:454 rejects a non-array in value with "In requires array value", an Err that propagates to the model as a tool error. Pinned by a new test. So the "worse than a write failure" argument — that a bad filter hides inside dev-empty-result-query — does not hold. Still a failed turn worth removing; just not an invisible one.

    A third finding: the first arm never reached its own question

    Built faithfully to this issue's repro (production's declaration + "What releases do we have open?"), the model answered 3/3 with search_nodes({"node_type":"release","query":"open"}) — no filters at all. Nothing measured. That reads as a pass if you only check whether the turn looks right.

    Kept as in-operator-array.toml with that recorded as its result. It also means the reported "cut,soak" came from a prompt that pushed the model toward filters first — consistent with the uncommitted -filter-rule arm, which isn't in the repo (so the repro command in this issue does not run as written).

    On the acceptance criteria

    • "in receives an array, ≥3 reps on dev-unseen-schema (currently 0/3)" — measured on a case that actually elicits an in filter instead, since dev-unseen-schema as committed cannot: it declares value as a string, so "cut,soak" there is schema-compliant output and the criterion is unmeasurable on it. Against production's declaration it is 3/3; after repair it is 3/3 even with the failing declaration. Flagging the substitution rather than quietly scoring the original.
    • "dev-status-change-enum does not regress" — satisfied by construction, not by measurement: the fix changes zero prompt bytes and zero tool-schema bytes, so that case's input is byte-identical. That property is exactly why I chose the parse-boundary repair over the prose and schema-reshaping options, given this issue's own record of a generic rule making that case worse.
    • Wire format unchanged — yes; the repair produces the array QueryService already expects, no parameter added or renamed.
    • Recorded including negative results — all three arms carry their measured outcome, including the arm that failed to reach its question and the control that deliberately reproduces the failing shape.

    What shipped anyway

    repair_scalar_in_operator_values is in, framed as a backstop rather than the mechanism — a declaration is not a guarantee and the downstream contract is strict. It is measured converting real model output on the failing arm 3/3, so it isn't speculative, but it is not credited with recovering a case that wasn't failing.

    Two fixes to the measurement apparatus were prerequisites and are kept: the golden runner now prints [emitted, before repair: …] (without it the two arms produce the same line and the comparison proves nothing), and canonical_args now routes through the shared repair entry point instead of re-listing repairs by hand — that duplication meant a repair added later reached execution but silently not the duplicate-detection identity.

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