Skip to content

resolve_query is offered but not called for indirect-target updates (model-guidance gap) #1894

Closed

Description

@malibio

Overview

resolve_query now reaches the model's offered tool surface when its owning skill routes and clears the mutating-skill score bar (fixed in #1893). But even when correctly offered, the model does not reliably call it for an indirect-target update — it instead fabricates a plausible-looking node id and reports success without ever resolving or mutating anything.

Problem Statement

Reproduced live against a purged, isolated daemon running gemma-4-e4b-q4km, with resolve_query confirmed present in toolsOffered for the turn:

  • Prompt: "The 2400 one came back — set it to returned" (an update keyed on a bare value — replacement cost — rather than a directly-named field, exactly the case resolve_query's own tool description and the Graph Editing skill's INDIRECT TARGET guidance call out).
  • toolsOffered included resolve_query, update_node, and the rest of the Graph Editing whitelist.
  • The model made zero tool calls. Its raw output: "I've updated the laser cutter checkout record (nodespace://6d515ce1-f61c-4558-9a30-3de6a81d20d8) to show that it has been returned." — a fabricated node id, no resolve_query call, no update_node call, false claim of success.

This is a distinct failure mode from the tool-availability bug fixed in #1893: the tool is present in the schema the model is given, and the Graph Editing skill's guidance already explicitly instructs "If the request identifies the target indirectly... call resolve_query(...) FIRST" — the model has both the tool and the instruction, and still doesn't follow either.

Proposed Solution

Not yet diagnosed — needs its own investigation before a fix is chosen. Candidate angles, none confirmed:

  • Whether the guidance text reaches the model with enough salience once combined with the rest of the resident system prompt and the turn's actual candidate block (cf. prior findings that a large resident prompt can score worse than a minimal one on cases targeting its own rules).
  • Whether the specific phrasing "the 2400 one" is being (mis)matched against search_nodes-style direct lookup patterns the model has seen more examples of, rather than being recognized as the "bare value, no field named" case resolve_query's description defines.
  • Whether this is a general have-tool-will-still-hallucinate failure mode independent of resolve_query specifically, worth checking against other multi-step tool sequences.

Acceptance Criteria

  • Reproduce the failure with a raw-output trace captured (RUST_LOG=debug) across multiple runs to establish it is not a one-off
  • Determine whether the model ever considers resolve_query at all (check raw generation text for any mention/near-miss, not just the final tool call) or skips straight to fabrication
  • Identify what, if anything, changes the model's behavior (prompt-only test, no code changes, iterating on guidance wording/placement)
  • Land a guidance or prompting change, backed by a measurement showing improvement over the baseline established above
  • Agent-matrix scenario 6 ("The 2400 one came back — set it to returned") passes across repeated runs, at an n large enough to clear the demonstrated run-to-run noise band for this fixture

Technical Specifications

Reference Files

  • Graph Editing skill guidance: packages/agent/src/skill_pipeline.rs — graph_editing_guidance(), the INDIRECT TARGET paragraph
  • resolve_query tool definition: packages/agent/src/local_agent/tools.rs — def_resolve_query()
  • Agent-matrix scenario: scripts/eval/fixtures/agent-matrix.ts — scenario id "6"
  • Live-eval setup: nodespace-docs/development/agent-eval.md

Related Issues

Activity

  1. malibio commented on Aug 1, 2026

    @malibio
    CollaboratorAuthor

    Baseline (worktree issue-1894-resolve-query-guidance): Frontend: 171 test files passed, 4108 tests passed, 0 failed (49.8s).

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

    @malibio
    CollaboratorAuthor

    Investigation findings: the premise doesn't hold, and the real blocker is structural

    Investigated on a purged, isolated daemon (NODESPACE_HOME, served_db_path verified) at current main (09a54074), E4B, n_ctx=32768.

    1. The reproduction in this issue measured a pre-#1893 daemon

    The three runs the issue is built on (/tmp/nodespaced-test/results-run{1,2,3}.json) record evalCommit: 4b66ec4f — dated 10:31, while the #1893 fix (69a4f902) landed at 19:36. The runs executed at 17:04–17:11, i.e. before the fix existed.

    Their scenario-6 toolsOffered was:

    search_nodes, search_semantic, get_node, create_node, update_node, create_schema,
    update_schema, update_task_status, create_relationship, get_related_nodes,
    delete_node, create_nodes_from_markdown
    

    That is Tool::ALL minus search_skills minus resolve_query — the fail-open surface, not a scoped one, and tools_count=12 on every turn of that log. So the issue's stated premise ("resolve_query confirmed present in toolsOffered", "the tool is present in the schema the model is given") is not what those runs actually measured. resolve_query was never offered, and RELEVANT ENTITY TYPES rendered 0 times in the entire log.

    This is not a model-guidance failure. The model never had the tool.

    2. At current main, #1893's fix works — the surface is now genuinely scoped

    Fresh run at 09a54074 shows per-turn scoping varying by routed skill (5/6/7/8 tools rather than a constant 12):

    5: search_nodes, search_semantic, get_node, create_node, create_relationship
    8: search_nodes, search_semantic, get_node, create_node, update_node, create_schema, update_schema, update_task_status
    

    Graph Editing routes correctly (routing_decision=query, candidates injected, top_score well above bar) and its other whitelisted tools appear. resolve_query still does not — for a different and legitimate reason.

    3. The actual blocker: resolve_query is gated on a block that needs a custom schema to exist

    agent_loop.rs:739 retains resolve_query only if tools_with_available_guidance contains it, which requires an eligible candidate whose own schema_metadata renders a non-empty RELEVANT ENTITY TYPES block (routing.rs:311-341). This gate is deliberate and well-documented: resolve_query's node_type is required and its description says to copy the id from that block, so offering it without the block strands the model.

    The seeded Graph Editing skill (verified in the live DB, correctly hoisted under properties.skill) declares no node_types:

    "skill": { "tool_whitelist": [..., "resolve_query"], "max_iterations": 3 }

    With no node_types, skill_ops.rs:203 falls back to "all non-core schemas". So:

    no custom schema in the workspace → empty schema_metadata → no entity-types block → resolve_query withheld.

    In my run, scenario 3 failed to create any schema (it called create_node; create_schema wasn't even offered that turn — routing sent it to Node Creation). Semantic schema retrieval logged count=0 on all 12 turns. Scenario 6 was therefore unwinnable by construction — exactly the hazard the fixture's own comment at agent-matrix.ts:277-287 warns about, arriving via a path that comment doesn't cover.

    4. What the raw traces show about the model

    Worth recording, since AC #2 asks. Across the pre-#1893 runs the model never mentions resolve_query — it fabricates an id and claims success, or asks for one:

    "I need a specific node ID to mark the laser cutter as returned. Could you provide me with that?"

    At current main, same shape:

    "I need to know which specific equipment item you are referring to... Could you provide the ID or a more detailed description of that "2400 one"?"

    The model correctly identifies that it needs a resolved id — the exact gap resolve_query fills — and asks the user instead, because the tool isn't on its surface. That's reasonable behavior given its inputs, not a guidance-adherence failure. Guidance wording cannot be evaluated until the tool is actually offered.

    Proposed re-scope

    The remaining acceptance criteria (iterate on guidance wording, measure improvement) are not yet testable — they presuppose an offered tool. I'd restructure as:

    1. Decide the gating question (the real fix): scenario 6 keys on replacement_cost, a field of a custom type, so a correct run should have a schema by then. But a bare-value update against core types (task, text) can never satisfy this gate, so resolve_query is structurally unreachable for them. Options: give Graph Editing an explicit node_types; render the block from workspace schemas rather than per-candidate; or accept core types are out of scope for resolve_query and say so in its description.
    2. Fix the fixture's unwinnability so scenario 6 fails loudly when its upstream schema is missing, instead of scoring as a resolve_query failure. Scenarios 3/8a/8b regressing to create_node is a separate defect worth its own issue.
    3. Only then measure guidance wording.

    Recommendation: proceed with (1), taking the explicit node_types route on Graph Editing as the smallest change that makes the tool reachable, plus a regression test asserting resolve_query is offered when a custom schema exists. Proceeding unless redirected.

    Note on measurement conditions

    A second full run was aborted as invalid: every turn failed with Decode Error -3 (routing_decision="failed" ×6) — two E4B instances contending on a 16 GB machine, as another eval session was running concurrently. Single-run matrix numbers are not decision-grade here; the tool-surface finding above is drawn from toolsOffered/log evidence, which is deterministic and unaffected by that noise.

  4. malibio commented on Aug 2, 2026

    @malibio
    CollaboratorAuthor

    Same pattern as #1899, twice in a row now: caught the issue's own premise didn't hold before building on it, this time via commit-timestamp vs. run-timestamp comparison (the reproduction predates #1893 by two hours) rather than taking the log's self-description at face value. Good discipline, worth keeping up as standard practice on every issue in this cluster from here — check the evidence a filing rests on before treating it as ground truth.

    The structural finding at current main is the real content here, and the chain is concrete and checkable end to end (agent_loop.rs:739 → routing.rs:311-341 → Graph Editing's empty node_types → fallback to all-non-core-schemas → zero custom schemas → empty block → tool withheld). Agreed this makes the remaining acceptance criteria untestable as written — no point iterating on guidance wording for a tool that isn't on the model's surface, and the model's actual behavior (asking for an id instead of fabricating one) confirms it's behaving reasonably given what it was offered, not failing to follow instructions.

    One pushback on the proposed fix before you build it: of the three gating options, I'd want more reasoning for picking explicit node_types on Graph Editing over rendering the block from workspace schemas broadly. A hardcoded (or even seeded-but-fixed) node_types list on a skill whose whole purpose is mutating arbitrary existing nodes/relationships risks becoming the same "doesn't scale with the registry" anti-pattern #1802 flags for resident prose — just as a maintained list instead of a maintained sentence, and one more thing to keep in sync as schemas are added. Rendering from workspace schemas generally (option 2) seems more consistent with ADR-038's "retrieval, not enumeration" position, even if it's a larger change. If there's a reason option 1 is actually the structurally correct answer and not just the smallest diff — e.g. a real cost/scoping concern with option 2 — lay that out, but "smallest change" alone isn't sufficient justification given what #1802 is about to spend a full pass scrutinizing exactly this kind of layering decision.

    Agreed on deferring measurement until the gate is fixed, and on filing the fixture's unwinnability (scenario 6 scoring as a resolve_query failure when the real fault is further upstream) as its own separate concern.

  5. malibio commented on Aug 2, 2026

    @malibio
    CollaboratorAuthor

    Re: gating options — you're right, and option 1 is worse than I represented

    I went looking for the cost/scoping justification for option 1 and found the opposite: option 2 is not the larger change, and option 1 is a clearer instance of the anti-pattern #1802 targets than I gave it credit for. Withdrawing the recommendation.

    The machinery option 2 needs already exists and is already retrieval-based

    build_workspace_context (context_ops.rs:280) already renders a RELEVANT ENTITY TYPES block from schemas retrieved semantically against the turn's query — semantic_search_nodes_of_type(q, "schema", MAX_SEMANTIC_SCHEMAS=5, SCHEMA_SIMILARITY_THRESHOLD=0.2), blending the last BLENDED_HISTORY_TURNS=2 messages. It's resident, it's per-turn, and it scales with the registry by construction — no maintained list.

    Both sites already share one renderer (entity_types_block) and one heading constant (RELEVANT_ENTITY_TYPES_HEADER), and the doc comment at context_ops.rs:100-108 says why: the heading is rendered at exactly these two call sites, and a previous fix that touched only one left the other reinforcing the contamination the first was changed to prevent.

    So the layering today is: two independent injection sites for the same block, from two different retrieval paths, and resolve_query's gate consults only one of them — the per-candidate schema_metadata path, not the workspace-context path. That asymmetry is the actual defect. tools_with_available_guidance asks "did this candidate carry entity types?" when the question the tool's required node_type parameter actually needs answered is "will the assembled prompt contain an entity-types block?"

    Why that reframes option 1 as the anti-pattern

    Your read is right, and it's sharper than "a list to keep in sync". Graph Editing's purpose is mutating arbitrary existing nodes; any fixed node_types on it is a claim about which types the user might edit, which is unknowable at seed time and wrong the moment someone adds a schema. It would also narrow today's behavior: scoped_type_ids non-empty switches skill_ops.rs:203 from "all non-core schemas" to "exactly these", so I'd be trading an empty block for a wrong-but-non-empty one — passing the gate while handing the model a type list that may not contain the type it needs. That's worse than the current failure, which at least fails visibly.

    It also wouldn't fix the core-type case at all (task/text are is_core, filtered out at skill_ops.rs:206 regardless), so option 1 buys a green scenario 6 and leaves the structural hole.

    Revised recommendation

    Make the gate depend on what the assembled prompt will actually contain, rather than on one of the two paths that can fill it. Concretely: resolve_query is offered when an entity-types block will render for the turn from either source — the candidate's schema_metadata or workspace context's semantically-retrieved schemas.

    That keeps the gate's original purpose intact (never offer a tool whose required parameter points at a block the model can't see — the reason it exists per tools.rs:1115-1124), removes the per-candidate coupling, and inherits registry-scaling from retrieval rather than from a maintained list. It's consistent with ADR-038's retrieval-not-enumeration position, and it composes with the follow-up already noted at context_ops.rs:112-117 — making context assembly depend on the routing decision, which today runs after the context block is built.

    Two things I want to verify before building it, since both are load-bearing and neither is settled by reading:

    1. Ordering. context_ops.rs:112-117 says context assembly happens before Stage-2 routing. If so, the workspace block's content is knowable at the retain in agent_loop.rs:739 — but I want to confirm that against the actual call order rather than infer it from a doc comment, since that comment is describing a limitation, not a guarantee.
    2. The core-type hole stays open either way. parse_and_filter_non_core_schemas (context_ops.rs) and skill_ops.rs:206 both drop is_core schemas, so a bare-value update against task/text still renders no block and still withholds resolve_query — regardless of which option we pick. That's a genuine scope question about the tool, not a bug to fix incidentally: either resolve_query is custom-types-only and its description should say so, or the block needs to carry core types too. My read is the former is correct for now (its examples are all custom-type: invoices, amounts, codes), but it should be stated rather than left implicit.

    Given #1802 is about to scrutinize exactly this layering, I'd rather land the narrow gate fix here — with the core-type scope written down explicitly — than pre-empt the spike with a broader restructuring of how entity types reach the prompt. If you'd rather I hold the gate fix entirely and fold it into #1802's pass, say so; it's a small enough change that either sequencing works.

  6. malibio commented on Aug 2, 2026

    @malibio
    CollaboratorAuthor

    This is a sharper diagnosis than my objection deserved — the two-independent-injection-sites finding reframes this correctly: the gate is asking "did this candidate contribute the block" when it should ask "will the assembled prompt contain the block." And the concrete failure-mode comparison (option 1 trades a loud empty-block failure for a silent wrong-type-list pass) is exactly the kind of thing that's easy to miss chasing a single green scenario — good catch.

    Agreed on all three points: revised gate (offered when either source will render the block), verify the ordering claim against actual call order rather than the doc comment describing a known limitation, and write down the core-type scope boundary explicitly rather than leave it implicit.

    On sequencing: land the narrow gate fix now, don't hold for #1802. It's small, correctly scoped, fixes a real reachability bug, and documenting the core-type boundary explicitly is exactly the kind of thing #1802 will want as settled ground truth rather than another open question to resolve from scratch. The two-injection-site asymmetry you found is real and worth flagging for #1802's broader pass regardless — but this fix doesn't foreclose that review, it just stops the immediate bug from sitting open while a much larger architectural question gets answered on its own timeline. Proceed.

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