Skip to main content

Module name_resolution

Module name_resolution 

Source
Expand description

The one place a typed agent name is interpreted (identity M3, docs/specs/SPEC_AGENT_IDENTITY_CARRIED_NOT_DERIVED_2026_09_23.md §5).

Callable only from surfaces where a human or a model typed the name — today the POST /agentmux/agents/resolve endpoint the MCP server calls before it enqueues work or schedules a cron job. No internal code path may call this: scripts/check-name-resolver-callers.sh is the CI grep gate that enforces it (§9.3), so §2 rule 1 is mechanical rather than a convention that erodes.

Ambiguity is surfaced, never guessed (§5.2). A name held by two agents is returned as Ambiguous with enough about each candidate for a model to retry by UID and for a human to act on. This is deliberately the opposite of agent_resolve::resolve_agent_id, which collapses “several” into “none” because its callers are internal and have nobody to ask.

What is consulted, in order. (1) A typed value that is a UID. (2) The live registry, by name — every registered block whose display or stable name matches, with its UID when it has one. (3) The store, by slug and by display name (name, instance_name, case-insensitively) over non-template, non-hidden rows — the agents that exist but are not running right now — and, when none of those match, by a slug an agent was renamed from (Store::agents_matching_name; SPEC_FORK_SLUG_MIGRATION_2026_10_22.md Phase 1), so a task or cron job addressed to an old id still reaches its agent. Live and stored candidates that share a UID are one candidate.

Spec §1.1 measured that a display name never resolves through the exact-case slug tier. That finding is about a resolver that has to pick; this one lists, so it can afford to match display names: a single match resolves, a collision is refused with the candidates, and nothing is ever misrouted.

Structs§

AgentCandidate
One agent that a typed name could mean.

Enums§

NameResolution
The answer to “which agent did they mean?” (§5.1).

Functions§

closest_ids
Which of ids a typed name nobody answers to most likely meant, best first, at most three: the id it starts with (an agent’s workspace folder is its id and a suffix, “agent2-0630f” for agent2), the id that starts with it (a name cut short), or one a typo or two away. Case and a leading @ do not count.
known_agent_ids
The ids (the names an agent is addressed by) of the agents this computer knows, running or not: the ones a name that nobody answers to is offered back from. Only agents a name may mean, as agents_matching_name holds.
resolve_name_to_uid
Resolve typed to a UID, or to the reasons it cannot be resolved.