Expand description
Non-Human Identity (NHI) resolution for agent_id.
Every stored memory carries metadata.agent_id — a best-effort identifier
for the agent (AI, human, or system) that wrote it. This module encapsulates
the precedence chain and default-id synthesis for all three entry points
(CLI, MCP, HTTP) so that the identity format is uniform.
§Precedence (CLI / MCP)
- Explicit id passed by the caller (
--agent-id, MCP tool param) AI_MEMORY_AGENT_IDenvironment variable- (MCP only)
initialize.clientInfo.namecaptured at handshake time →ai:<client>@<hostname>:pid-<pid> host:<hostname>:pid-<pid>-<uuid8>— stable per-processanonymous:pid-<pid>-<uuid8>— fallback if hostname is unavailable
§Precedence (HTTP)
HTTP serve is multi-tenant; no process-level default is ever cached.
- Request body
agent_idfield X-Agent-Idrequest header- Per-request
anonymous:req-<uuid8>(emits aWARNlog line)
§Trust
agent_id is a claimed identity, not an attested one. Do not use it
for security decisions without pairing it with agent registration (Task
1.3) and, eventually, signed attestations.
Modules§
- attest
- Store-path agent attestation glue (#626 Layer-3, Task 1.3 / C4).
- keypair
- Per-agent Ed25519 keypair lifecycle (Track H, Task H1).
- replay
- H5 (v0.7.0 round-2) — Ed25519 verify-link replay protection.
- sentinels
- Reserved caller-identity sentinels — the SSOT for every internal / system principal string the substrate compares against, stamps on rows, or carves out of cross-tenant ownership gates (#1558 identity-sentinel remediation).
- sign
- Outbound Ed25519 signing for
memory_links(Track H, Task H2). - verify
- Inbound Ed25519 verification for federated
memory_links(Track H, Task H3).
Constants§
- ENV_
ANONYMIZE - Environment variable opt-out for the hostname-revealing default (#198).
When truthy (
1,true,yes,on), thehost:<hostname>:pid-...fallback is skipped andanonymous:pid-...is used instead.pubsince #1558 so the daemon bootstrap (which maps the config flag onto this env var) shares the spelling.AppConfig::effective_anonymize_default()mirrors the same semantics from the config file, and CLI startup maps config → this env var so the downstream resolution stays env-only.
Functions§
- anonymous_
request_ id - Resolve
agent_idfor a single HTTP request. - preserve_
agent_ id - Preserve
existing.agent_idthrough update/dedup. - process_
discriminator - Returns a stable-for-this-process discriminator of the form
<pid>-<uuid8>. Used to make process-level defaults collision-free when many agents share a host (e.g., 25 MCP clients on one machine). - resolve_
agent_ id - Resolve
agent_idfor CLI and MCP paths. - resolve_
http_ agent_ id - resolve_
read_ visibility_ caller - v0.7.0 #1468/#1469 — resolve the visibility caller for MCP read
paths (
memory_session_start/memory_list/memory_search/memory_recall).