Skip to main content

resolve_session_key

Function resolve_session_key 

Source
pub fn resolve_session_key() -> Option<(String, &'static str)>
Expand description

v0.13: resolve a stable per-session key — host-agnostic, with a Claude Code adapter and the path left open for other hosts. Order:

  1. WIRE_SESSION_ID — explicit universal override (any harness).
  2. CLAUDE_CODE_SESSION_ID — Claude Code adapter (stable per conversation; the same id the auto-memory system keys off).
  3. CODEX_SESSION_ID — OpenAI Codex CLI adapter. Stable per Codex thread (the same UUIDv7 emitted in thread.started and used as the rollout-file suffix under $CODEX_HOME/sessions/). Codex does not yet forward this var to MCP children out of the box — operators must set it via [mcp_servers.<name>.env] in ~/.codex/config.toml (or upstream Codex must add it to the MCP child env). Wiring the name in advance means once Codex ships the env, wire picks it up with zero further code change.
  4. COPILOT_AGENT_SESSION_ID — GitHub Copilot CLI (gh copilot / copilot) adapter. Set by the Copilot CLI host for every session; stable per conversation; UUID-shaped.
  5. VSCODE_GIT_REPOSITORY_ROOT — VS Code/GitHub Copilot workspace-based identity (stable per workspace).
  6. None — caller falls back to legacy cwd-detect (bare CLI / pre-v0.13 hosts). Future host adapters slot in before this.

Returns (key, source-label).