Repository navigation
Description
Summary
After a gateway restart (or any event that kills live claude-stdio processes), cli-backend session entries in agents/<id>/sessions/sessions.json retain systemSent: true. The next turn that spawns a fresh claude process (most visibly after the /new chat command, whose new session entry inherits systemSent from the reusable entry) is then executed without the agent's system/identity prompt. The model falls back to its raw CLI persona and denies having the agent's tools/memory — to the end user it looks like the assistant was "wiped".
Environment
- OpenClaw 2026.7.1 (2d2ddc4), macOS 12.7.6, Node 22.23.1
- cli-backend: claude-cli (claude-stdio live sessions,
sessionMode: always), claude CLI 2.1.209
Reproduction (observed live)
- Gateway restart at 16:47 (drain-safe, detached-handoff) — live claude processes die; sessions.json entries keep
systemSent: true. - User sends
/newon WhatsApp at 17:31 → new session entry created,systemSentinherited astrue. - First real message at 17:34 →
cli exec: … trigger=user useResume=false session=none resumeSession=none reuse=none historyPrompt=none promptChars=906— fresh spawn, no system prompt sent (906 chars = wrapper + user text only). - Reply comes back in the raw "I'm Claude Code, a CLI coding assistant…" persona, denying the agent's tools and history.
- Subsequent turns that hit the resume path (
useResume=true historyPrompt=present) recover identity, because the resumed claude session still contains the original system prompt — which masks the bug intermittently.
Code pointers (dist, 2026.7.1)
agent-runner.runtime-*.js / get-reply-*.js:
- send-gate:
…systemSent === true || params.entry?.sessionId !== params.sessionId) return false - inheritance:
systemSent = reusableEntry.systemSent ?? false
The flag describes a property of a process/claude-session, but it is persisted on the gateway-side session entry and survives the death of the process it described. Suggested fix: key systemSent to the spawned claude sessionId (reset whenever session=none/fresh spawn), or always send the system prompt when useResume=false && reuse=none.
Workaround
Stop the gateway, set "systemSent": false on all entries in agents/*/sessions/sessions.json, start the gateway. Verified: the next fresh spawn re-sends the system prompt and the persona returns.
Impact
High user-visible severity: the assistant appears amnesiac/identity-less after every gateway restart + /new (also reproduced this morning after the 2026.5.27→2026.7.1 auto-update restarts, before any manual restarts).
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jul 15, 2026
Thanks for the context here. I did a careful shell check against current
main, and this is already implemented.Current main prevents stale session metadata from suppressing a Claude CLI system prompt on either fresh or resumed processes, so this issue no longer needs active backlog attention.
So I’m closing this as already implemented rather than keeping a duplicate issue open.
Review details
Best possible solution:
Keep the current process-bound prompt delivery rule: fresh CLI processes always receive the prompt, and the bundled Anthropic backend re-emits it for resumed turns.
Do we have a high-confidence way to reproduce the issue?
No on current main: fresh CLI invocations send the prompt whenever they are not resumed, and the bundled Claude backend also uses always mode for resumed turns. The historical live environment was not rerun because the current source rules out the reported mechanism.
Is this the best way to solve the issue?
Yes: current code removes the stale-state dependency at the CLI prompt-delivery boundary instead of attempting to repair every persisted session entry after restart.
Security review:
Security review: This issue reports prompt-delivery behavior, not a security-sensitive change.
AGENTS.md: found and applied where relevant.
What I checked:
extensions/anthropic/cli-backend.ts:242, 34bfcdba5824)src/agents/cli-runner/execute.ts:152, 34bfcdba5824)src/agents/cli-runner/helpers.ts:471, 34bfcdba5824)src/agents/cli-runner/helpers.system-prompt-resume.test.ts:89, 34bfcdba5824)src/agents/cli-runner/execute.ts:152, 56f594aa97b5)extensions/anthropic/cli-backend.ts:242, 84e62824f683)Likely related people:
extensions/anthropic/cli-backend.ts,src/agents/cli-runner/execute.ts,src/agents/cli-runner/helpers.ts)extensions/anthropic/cli-backend.ts,src/agents/cli-runner/execute.ts,src/agents/cli-runner/helpers.ts)Codex review notes: model internal, reasoning high; reviewed against 08786d32b21b; fix evidence: commit 56f594aa97b5, main fix timestamp 2026-08-16T16:20:56Z.