Skip to main content

split_agent_identity_env

Function split_agent_identity_env 

Source
pub(crate) fn split_agent_identity_env(
    env_vars: &mut HashMap<String, String>,
    display_name: &str,
    persisted_slug: Option<&str>,
)
Expand description

Identity M0 — SPEC_AGENT_IDENTITY_CARRIED_NOT_DERIVED_2026_09_23.md §9.1: make the display name and the slug two explicit variables, present on every launch path.

Why. AGENTMUX_AGENT_ID means two different things depending on who spawned the agent (spec §0.2): the frontend’s launchAgentDefinition writes the definition slug into it (agent-model.ts), while this server path’s fallback wrote the display name (block.meta["agentName"]) until carry_agent_id_env (2026-10-12), which writes the slug too when the row has one. Nothing downstream could tell which it got. The frontend path already sets AGENTMUX_AGENT_DISPLAY and AGENTMUX_AGENT_SLUG alongside it; this path set neither, so a reader that wanted the unambiguous form had nothing to read. After this, both are always present when the server knows them, and later phases can migrate readers off AGENTMUX_AGENT_ID one at a time.

Precedence. The server’s own knowledge wins, cmd:env is the fallback — the reverse of the “user-provided values take precedence” rule the surrounding identity variables follow, deliberately:

  • display_name is block.meta["agentName"], the value the primary reactive registration is keyed on (see the Register-tail of run_agent_turn) and the name the pane header shows. A cmd:env copy is a launch-time snapshot that a rename (setViewName) leaves stale.
  • persisted_slug is db_agents.slug for this block’s agent — the collision-resolved value agent_def_insert minted. A cmd:env copy is whatever the frontend computed before that row existed.

When the two disagree it is logged, not silently resolved: a disagreement is exactly the kind of signal spec §9.2 says a phase must be able to observe.

What this does not do. AGENTMUX_AGENT_ID is never read or written here. Spec §9.4 keeps its present value on both paths through M4; the git identity, MUXBUS_AGENT_ID, the PR-body tag and the OSC prompt hook all still derive from it, unchanged.