Repository navigation
Description
Overview
With entity resolution shipped (#2841), a turn that names an entity already in the graph now has that entity rendered in its prompt, with its id and type. The model reads it — and still creates a duplicate.
"Add Northwind Trading to the companies we sell to", against a workspace where Northwind Trading already exists as a company_sold_to, produces create_node and a second record. Measured 3/3 reps on gemma-4-e4b-q4km, and reproduced in isolation afterwards.
The ask is not "pick the other tool". "Add X" when X exists is genuinely ambiguous — a second, distinct record is a real thing to want — so the right behaviour is to hand the choice back to the user via route_clarify, naming the existing record. That is a human-in-the-loop decision the agent should not make silently either way.
Instruction does not fix this
Three channels were tried against the locked model, with the entity rendered in MENTIONED ENTITIES and route_clarify present on the offered tool surface. All three produced create_node and a duplicate:
| Channel | Result |
|---|---|
| Node Creation skill guidance (prose) | duplicate |
create_node tool description |
duplicate |
| Both together | duplicate |
The middle row is the interesting one. ADR-064 measured a constraint stated on a tool schema at 100% compliance where the same rule in resident prose reached 87.5%, and agent_guidance.rs:214 records that gradient directly. Here the schema channel moved the outcome not at all.
The plausible reading: that measurement covered output-shape constraints ("emit this field in this form"). This is a conditional suppression — "do not take the obvious action when a condition holds" — and it appears to be a materially harder ask. Worth recording, because it bounds what the instruction-channel doctrine can be expected to buy.
Verified it is not a plumbing failure. Debug logging on the turn confirms the tier ran and resolved:
workspace_context: entity resolution count=1 query="Add Northwind Trading to the companies we sell to."
So the model had the fact, had the tool, had the instruction in the strongest available channel, and created the duplicate anyway.
Proposed direction
Make it structural rather than advisory. The system already knows the entity resolved — that is what the tier computes — so the collision is detectable deterministically before the write, with no model judgment involved:
create_nodeexecutes withnode_typeT andcontentC.- The turn's resolved entities already contain a node of type T whose title matches C.
- Reject the create and return the clarify prompt, naming the existing record's id.
This follows the same posture as the existing guard stack in agent_loop.rs (anti-fabrication, fabricated-id, narrated-tool-call, no-op-success), all of which exist on the premise that the model's account of what it did cannot be trusted. A duplicate-create guard is the same shape: the system holds a fact the model was told and did not act on, and enforces it at the boundary.
Open design questions, deliberately not decided here:
- Match strictness. Exact title match is the safe start. Anything fuzzier risks blocking a legitimately distinct record with a similar name.
- Where the guard lives. In
create_node's op, or in the agent loop alongside the existing guards? The op sees every caller; the loop sees the turn's resolved entities. - Reject vs rewrite. Return an error the model must handle, or have the system emit the clarification directly? The latter is stronger but takes the turn out of the model's hands.
- Escape hatch. A user who genuinely wants a second record with the same name needs a way through on the follow-up turn.
Acceptance criteria
- A
create_nodewhose type and title match an entity already resolved for that turn does not silently create a second record - The user is asked which they meant, with the existing record offered by id
- A create whose name does NOT match a resolved entity is unaffected — no new failure mode for ordinary creates
- A follow-up turn can still create the duplicate when the user confirms they want one
-
schema-on-menu-companyinscripts/eval/fixtures/decisions.tspasses; it currently asserts the wanted behaviour and fails, deliberately, as a known gap - Tests pass (
bun run test:all), code passesbun run quality:fix
Reference files
packages/core/src/ops/context_ops.rs—resolve_entities,EntityResolution; the resolved set a guard would consultpackages/agent/src/local_agent/agent_loop.rs— the existing guard stack this would joinpackages/agent/src/local_agent/tools.rs—def_create_node, anddef_route_clarify(the HITL mechanism)packages/agent/src/skill_pipeline.rs— Node Creation's guidance and whitelist;route_clarifywas added there so the tool is reachablescripts/eval/fixtures/decisions.ts—schema-on-menu-company, which pins this
Related
- Entity-grounded routing: resolve named entities to nodes before routing, so one lookup constrains skill, schema and operation #2841 — entity resolution, which makes this detectable at all
- ADR-064 — the instruction-channel gradient this case is evidence against extending to conditional suppression
Activity
malibio commentedon Sep 22, 2026
Frontend baseline: 262 files / 5264 tests passed