Problem
The Runtime: header injected into the system prompt includes agent=main, host=..., model=..., channel=..., etc., but does not include the session key or session ID. This means the agent has no reliable way to know which session it is actually running in.
Current behavior
Runtime: agent=main | host=DESKTOP-70B9P5V | repo=... | os=... | model=... | channel=webchat | capabilities=none | thinking=high
The agent sees agent=main and may infer it is in session agent:main:main, but it does not actually know:
- Its
sessionKey (e.g., agent:main:main, agent:main:subagent:uuid, agent:main:openclaw-weixin:direct:...)
- Its
sessionId (the stable UUID for the session)
This leads to the agent misleadingly claiming it knows its session when it doesn't, or confusing itself about which session it is in when:
- Receiving heartbeat checks from other sessions
- Being asked to report its session status
- Spawning subagents and needing to route messages back
- Handling cron jobs that target specific sessions
Impact
- Self-identity confusion: The agent says things like "I am in agent:main:main" when it only knows
agent=main — the rest is inference/guesswork.
- Heartbeat debugging: When a heartbeat arrives from another session, the agent cannot accurately identify its own session vs. the source session.
- Subagent orchestration: The agent cannot tell a subagent "report back to THIS session" because it doesn't know its own session key.
- Session routing: When asked to send a message to a specific session, the agent may guess wrong about its own session key.
Proposed solution
Add sessionKey and sessionId to the RuntimeInfoInput type and include them in the Runtime: header, e.g.:
Runtime: agent=main | session=agent:main:main | sessionId=23ae7fce-3c27-4a51-b58e-d800d8ca091f | host=... | os=... | model=... | channel=... | capabilities=... | thinking=...
Files involved
src/agents/system-prompt-params.ts — RuntimeInfoInput type and buildSystemPromptParams()
src/agents/system-prompt.ts — buildRuntimeLine() function
src/agents/embedded-agent-runner/run/attempt.ts — where runtimeInfo is constructed and passed
This is a small, additive change that would eliminate an entire class of session-identity confusion without affecting any other functionality.
Problem
The
Runtime:header injected into the system prompt includesagent=main,host=...,model=...,channel=..., etc., but does not include the session key or session ID. This means the agent has no reliable way to know which session it is actually running in.Current behavior
The agent sees
agent=mainand may infer it is in sessionagent:main:main, but it does not actually know:sessionKey(e.g.,agent:main:main,agent:main:subagent:uuid,agent:main:openclaw-weixin:direct:...)sessionId(the stable UUID for the session)This leads to the agent misleadingly claiming it knows its session when it doesn't, or confusing itself about which session it is in when:
Impact
agent=main— the rest is inference/guesswork.Proposed solution
Add
sessionKeyandsessionIdto theRuntimeInfoInputtype and include them in theRuntime:header, e.g.:Files involved
src/agents/system-prompt-params.ts—RuntimeInfoInputtype andbuildSystemPromptParams()src/agents/system-prompt.ts—buildRuntimeLine()functionsrc/agents/embedded-agent-runner/run/attempt.ts— whereruntimeInfois constructed and passedThis is a small, additive change that would eliminate an entire class of session-identity confusion without affecting any other functionality.