uniqueAgentId
Agent Runtimes / examples/utils/agentId / uniqueAgentId
Function: uniqueAgentId()
uniqueAgentId(
baseName):string
Defined in: src/examples/utils/agentId.ts:39
Build a unique agent ID by appending a random slug to a base name.
The resulting id is cached in sessionStorage under a key derived from
baseName, so a browser refresh within the same tab reuses the same
agent id. This is required for server-side per-agent state (enabled
tools, approved tools, approved skills, codemode status…) to survive a
page reload — those maps are keyed by agent_id in
agent_runtimes.streams.loop.
A fresh tab (or a sessionStorage.clear()) produces a new id, which
preserves the original "clean telemetry per run" guarantee.
Parameters
baseName
string
Returns
string
Example
uniqueAgentId('simple') // → "simple-a3f7b2" (cached)
uniqueAgentId('codemode-demo') // → "codemode-example-k9x2m1" (cached)