Skip to content

Propagate entity resolution to the external agent surface: skill guidance, and whether a resolve verb should exist #2850

Closed

Description

@malibio

Overview

#2841 gives the local agent entity resolution by pre-resolving a named entity and rendering the fact into its context block — the model is told, never asked. That channel does not exist for external harnesses (Claude Code, Codex, the Claude Desktop Code tab, Gemini CLI, OpenCode), which reach the graph through the nodespace CLI per ADR-035.

This issue propagates the capability to the external surface, where ADR-064's fifth channel says it belongs.

Blocked on #2841. Not merely related — see What this is waiting for below.

Why guidance is the mechanism, not a fallback

ADR-064 rule 5 states the fifth channel owns "procedure expressed in CLI verbs — which command to run, in what order, and how to recover from a failed one." "Resolve a name to an id before you update it" is exactly an ordering rule, so guidance is its correct home.

Worth stating explicitly because it is easy to get backwards: the doctrine's finding that prose is the weakest channel applies to the local agent's resident prose, not here. The same ADR records that skill-file guidance arrives through the harness's prompt — the channel its measurement found most effective (100% continuation, against 44% for the same text delivered as a tool result). Guidance is not a weak substitute for a mechanism on this surface; it is the mechanism.

The rule to convey

Derived from the local agent's measured failure (#2802's baseline), which stalled with:

"I need a Node ID to update the capacity for Northwind Trading."

The ordering rule that prevents it:

Before updating or reading a node you know only by name, resolve the name to an id first. A name in the user's message is not an id. If the lookup returns nothing, the entity does not exist — that means create, not search harder.

Three properties make this belong in this channel rather than elsewhere:

  1. It is an ordering rule, which rule 5 says this channel owns.
  2. It names the failure recovery — no match means create, a distinction otherwise invisible to a harness that just sees an empty result.
  3. It does not restate argument shape the CLI's own --help already gives, which rule 5 explicitly forbids.

What this is waiting for from #2841

Three outputs, in descending confidence, and the third is why this is blocked rather than parallel:

  1. The rule's tuned wording. The substance is settled; the phrasing should follow whatever the local tier's seeded guidance proves out. The propagation rule is one-directional — seed nodes lead, SKILL.md follows, and must never trail them on substance — so writing this in parallel risks two versions of a rule neither has validated.

  2. Whether "no match means create" holds up. It is an acceptance criterion on Entity-grounded routing: resolve named entities to nodes before routing, so one lookup constrains skill, schema and operation #2841. If the eval shows the distinction does not survive contact with the model, the guidance should not assert it.

  3. Which command the guidance points at — genuinely unknown today. If Entity-grounded routing: resolve named entities to nodes before routing, so one lookup constrains skill, schema and operation #2841's resolution logic lands as a reusable op, exposing it as a nodespace resolve <name> verb is cheap and the guidance points there. If it is woven into context assembly and not separable, the guidance points at search --type <type> "<name>" instead. The guidance cannot be written without knowing which.

  4. (Less certain) Whether a rank cutoff or stopword list is established. The precision check on Entity-grounded routing: resolve named entities to nodes before routing, so one lookup constrains skill, schema and operation #2841 found a workable cutoff around -2.5 to -3.0 BM25 and a stopword leak worth filtering. If resolution lives behind a verb, external agents inherit that filtering; if it lives in the agent loop, agents calling search raw do not — and the guidance may need to say something about noise words.

Open question, deliberately not decided here

Should a nodespace resolve verb exist at all? Arguments both ways:

Resolve after #2841 lands, informed by (3) above.

First step: check whether external agents actually fail at this

The local agent's failure is documented; the external one is assumed. Claude Code, Codex and similar are substantially stronger models than the locked Gemma 4 E4B, and may already reach for search unprompted when asked to update something by name.

Before authoring guidance, run a few resolution-shaped tasks through the CLI with a strong external model — "mark the Northwind contract as signed", "what is Contoso's renewal date" — against a seeded workspace, and observe whether it resolves first or asks for an id. If it resolves unprompted, this issue is a small reinforcement rather than a fix, and should be scoped accordingly.

Acceptance Criteria

Technical Specifications

Reference Files

  • packages/skill/SKILL.md — the external guidance surface (hand-authored)
  • packages/skill/references/cli.md — generated; regenerate with bun run skill:check / skill:gen
  • packages/agent/src/skill_pipeline.rs — seed_skill_nodes(), the canonical source the external file follows
  • packages/cli/src/commands/ — where a resolve verb would live, if one is added

Related

Activity

  1. added
    enhancement
    on Sep 22, 2026
  2. malibio commented on Sep 22, 2026

    @malibio
    CollaboratorAuthor

    Frontend: 262 files / 5264 tests passed

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

    @malibio
    CollaboratorAuthor

    Measurement: do external agents resolve names unprompted? (first acceptance criterion)

    Short answer: yes. The local failure does not reproduce. But the command SKILL.md points them at can't find entities, so they get there by trial and error.

    Setup

    • Five scenarios, each run against a fresh, isolated nodespaced built from main @ 6bc23eb0. Every run gets a throwaway NODESPACE_HOME/socket.
    • Seeded workspace: a company schema, plus Northwind Trading, Northwind Logistics and Contoso Ltd (with properties). There are also noise-word decoys ("Trading terms for new customers…", "The companies we sell to…"), a Contoso call note and a Northwind task.
    • Harness: claude -p, with the current, unmodified packages/skill/SKILL.md appended to the system prompt. Tools were Bash(nodespace:*), jq and Read, with the Skill tool disabled so the installed copy could not substitute.
    • Graded on the database state after each run plus the transcript.
    Scenario Prompt Correct outcome
    update "Mark the Northwind Trading contract as signed." update the existing node
    read "What is Contoso's renewal date?" answer 2027-03-15
    ambiguous "Set Northwind's seat count to 55." ask which Northwind, no write
    create "Add Fabrikam to the companies we sell to — they're a prospect." one new company
    duplicate "Add Northwind Trading to the companies we sell to." no silent duplicate

    Results

    Sonnet, 2 reps: 10/10 correct outcomes. It never asked for an id, never made a duplicate, and asked which Northwind both times.

    Scenario rep 1 calls rep 2 calls First lookup tried Did it find the entity?
    update 5 7 search "Northwind Trading contract" ❌, then fell back to node query --title-contains / query --type company
    read 5 3 search "Contoso renewal date" ❌, then fell back to node query --title-contains / node get
    ambiguous 3 3 search "Northwind" ❌, then fell back to node query --title-contains
    create 4 4 search "" --type company (enumerate) n/a, enumeration showed no Fabrikam
    duplicate 3 3 search "" --type company (enumerate) ✅ via enumeration

    Haiku, 1 rep: 1/5. This is not a resolution failure. On the four prompts that don't say "contract", it didn't recognise NodeSpace as the data store and searched the empty working directory instead. That's a skill-triggering artefact of my harness (skill appended rather than invoked), so I'm not counting it for or against resolution. On the one it did recognise (update), it went through the same search miss and fallback in 7 calls before updating correctly.

    The finding that changes the issue: search can't reach entities

    Every miss above has one cause, and it's by design, not a bug. nodespace search is embedding-only, and embeddings cover only the embeddable types (text/header/code-block/schema/table, ADR-029). The include_title_matches keyword half exists in search_semantic, but the CLI path passes None. So a task or any user-defined entity type has no vector and is unreachable by search at any query. I checked this directly against the seeded daemon:

    search "Northwind Trading" --type company   → []
    search "Contoso"           --type company   → []
    search "Northwind Trading"                  → ["Trading terms for new customers…"]   (the decoy)
    node query --title-contains "Northwind"     → Northwind Trading, Northwind Logistics, Send Northwind the revised order form
    node query --title-contains "Fabrikam"      → count 0
    

    Consequences for this issue:

    1. The issue's fallback, search --type <type> "<name>", is the wrong target, and a dangerous one. For entity types it returns empty whether the entity exists or not. Combined with "no match means create", it would turn every add-by-name into a duplicate. The guidance must not point there.
    2. SKILL.md currently sends agents to search first ("Find nodes by keywords or meaning → nodespace search"). That's the source of every wasted call above. Sonnet recovered each time because it's persistent, not because the skill told it how.
    3. node query --title-contains is already a deterministic title lookup. It's empty when absent and returns node_type, which is what you need to tell two same-named entities apart. Sonnet reached for it on its own after search failed.
    4. "No match means create" holds, as no result is that entity, not as results are empty. --title-contains uses a stem fallback, so a query shaped like "Northwind Trading Co" also returns the Northwind task and the "Trading terms" decoy. An empty-list test would be wrong in the other direction. The local tier's tuned wording already frames it this way ("same name, same type"), and the external rule should follow it.

    Side observation, not in scope here

    In a fresh database, search returns the seeded skill/guidance nodes (e.g. one whose content is just TOOL STRATEGY:). Sonnet flagged these as prompt injection in 4 of 10 runs, and in one run it treated the whole database with suspicion. External agents will meet these on every broad search. Noted here, not addressed in this issue.

  5. malibio commented on Sep 22, 2026

    @malibio
    CollaboratorAuthor

    Decision and re-measurement

    The resolve verb question: no new verb. The guidance points at nodespace node query --title-contains "<name>", the existing lexical title lookup. It already returns empty when the name is absent and carries node_type, which is all the "same name, same type" judgment needs. A resolve verb would duplicate it for any caller able to pull the name out of the message itself, which an external model can. The token selection and stop-word filtering in resolve_entities_by_title exist because the local tier feeds it a whole message, and external agents don't need that. search --type (the issue's fallback) is ruled out by the measurement above.

    The rule's wording follows the local tier's tuned guidance: "same name, same type" and "none found means it doesn't exist". It lives as one shared skill_rules::NAMED_RECORD_RESOLUTION:

    • the seeded Node Creation guidance interpolates its imperative form (output byte-identical; prompt golden unchanged)
    • SKILL.md carries the prose form
    • the existing skill_md_still_mentions_every_interaction_rule test pins the pairing, and it was mutation-checked by removing the phrase and watching it fail

    Same harness, same scenarios, only SKILL.md changed

    Baseline New SKILL.md
    Sonnet outcomes (2 reps) 10/10 10/10
    Sonnet: runs that started with a search miss 6 of 6 name lookups 0, with the first lookup --title-contains every time
    Sonnet calls (update / read / ambiguous) 5,7 / 5,3 / 3,3 3,4 / 2,2 / 2,2
    Haiku outcomes (1 rep) 1/5 3/5

    Haiku's remaining two failures, stated plainly:

    • ambiguous: it found both Northwinds and updated Trading without asking.
    • create: it correctly found no Fabrikam, but created a text note in a companies:prospects collection instead of a company. That's a type-selection error, not a resolution one.

    This is one rep, so I did not tune the wording against it.

    Acceptance criteria

    • Measured whether external agents fail unprompted, recorded above before the guidance was written
    • Ordering rule added to SKILL.md, derived from the local tier's tuned guidance
    • States the no-match-means-create recovery, framed as no result is that record, which is the form the local tier uses
    • Points at node query --title-contains, with no argument shape restated beyond the command itself
    • resolve verb regenerates cli.md N/A, no verb added (skill:check is clean)
    • SKILL.md does not trail the seed nodes: both render from one skill_rules const
    • Tests pass via the pre-push gate; quality:fix clean
  6. malibio commented on Sep 22, 2026

    @malibio
    CollaboratorAuthor

    Correction to the measurement comment above: the behaviour stands, the stated cause does not.

    I wrote that user-defined entity types have no vector (ADR-029) and are therefore unreachable by search. The first half is wrong. User-defined types go through CustomNodeBehavior, which embeds any non-empty content. What hides them is the default knowledge search scope: a query-bearing CLI search keeps only text | header | code-block | schema | table rows, and the CLI path passes no include_title_matches. Tasks are the only type genuinely left unembedded.

    The observed result is unchanged, and so is the guidance: a search for an entity's name returns nothing for tasks or typed records. The empty-query search "" --type <type> listing skips the scope filter and does list them, which is why Sonnet's enumeration fallback worked. The skill_rules doc comment in #2860 now states the actual mechanism (caught in review).

  7. malibio commented on Sep 23, 2026

    @malibio
    CollaboratorAuthor

    Correction to the side observation in the measurement comment: the fragments were not skill guidance.

    They are child lines of agent-guidance roots, the local agent's system-prompt templates (TOOL STRATEGY:, RESPONSE RULES:, the {{ current_date }} template). Skill text can't surface in general search at all: a keyword hit inside a skill walks up to the skill root, which the default scope filters out. The prompt templates leak only because agent-guidance is on NON_EMBEDDABLE_CONTAINER_TYPES, which makes each child line count as its own root.

    The real cause is broader than guidance. Search's keyword half matches node.content at every depth instead of root titles. Filed as #2867.

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

Metadata

Metadata

Assignees

Labels

enhancementfoundation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions