fix: stabilize claude-cli extraSystemPromptHash across group turns (#69118)#91157
fix: stabilize claude-cli extraSystemPromptHash across group turns (#69118)#91157sumitaich1998 wants to merge 1 commit into
Conversation
…penclaw#69118) Co-authored-by: Cursor <cursoragent@cursor.com>
|
Codex review: needs real behavior proof before merge. Reviewed June 7, 2026, 7:41 AM ET / 11:41 UTC. Summary PR surface: Source +1, Tests +65. Total +66 across 2 files. Reproducibility: yes. at source level: current main builds groupIntro only on first/re-intro group turns but includes it in the static prompt hash that gates CLI session reuse. I did not run a live claude-cli gateway reproduction in this read-only review. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Land the narrow groupIntro fix only after real group-channel proof, and keep #69118 open or split the remaining extraSystemPromptHash triggers into explicit follow-ups before merge. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main builds groupIntro only on first/re-intro group turns but includes it in the static prompt hash that gates CLI session reuse. I did not run a live claude-cli gateway reproduction in this read-only review. Is this the best way to solve the issue? Partly yes: excluding first-turn-only groupIntro from the static hash is the narrow owner-boundary fix for this trigger while preserving the live prompt. It is not sufficient to close the broader canonical issue because comments document other extraSystemPromptHash invalidation paths. AGENTS.md: found and applied where relevant. Codex review notes: model gpt-5.5, reasoning high; reviewed against 66b91d78feb3. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +1, Tests +65. Total +66 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
Summary
On the
claude-clibackend, agent sessions reset on every turn transition ingroup-style channels (Discord channels, Telegram groups, etc.). Turn 2 is generated
against a fresh
claude -pwith no memory of turn 1, so the agent appears to have"amnesia within seconds." This is independent of gateway restarts and is the companion
to #64386 (which covered
mcpConfigHashdrift on restart).Root cause
claude-clisession reuse is gated by a fingerprint (extraSystemPromptHash) computedin
src/agents/cli-runner/prepare.tsover the static extra system prompt(
extraSystemPromptStatic). When the stored hash differs from the freshly computed one,resolveCliSessionReuse()(src/agents/cli-session.ts) returnsinvalidatedReason: "system-prompt", logged as:In
src/auto-reply/reply/get-reply-run.tsrunPreparedReply(), the hash inputextraSystemPromptStaticPartsincludedgroupIntro. ButgroupIntrois intentionallyfirst-turn-only:
So the intro is present in the hash input on turn 1 and absent on turn 2 → the fingerprint
drifts between turns →
claude-cliresets the session on every group turn.The fix
Exclude the volatile, first-turn-only
groupIntrofromextraSystemPromptStaticParts(the session-reuse hash input), while still injecting
groupIntrointo the live prompt(
extraSystemPromptParts) when appropriate. The static fingerprint is now identical acrossturn 1 (intro present in the prompt) and turn 2 (intro absent), so the session is reused and
memory is preserved — consistent with how #64386 stabilized
mcpConfigHash.src/auto-reply/reply/get-reply-run.ts: dropgroupIntrofromextraSystemPromptStaticParts;the live
extraSystemPromptPartsstill includes it. Added an inline comment documenting the invariant.This also removes spurious resets on legitimate re-intros (
groupActivationNeedsSystemIntro):the re-intro text is still injected into the prompt but no longer forces a session reset.
Verification
Work was done in an isolated linked git worktree on
fix/issue-69118-cli-groupintro-hash(based on latest
upstream/main).Added a focused colocated regression test in
src/auto-reply/reply/get-reply-run.media-only.test.tsthat drivesrunPreparedReplyfor afirst turn (groupIntro injected) and a later turn (groupIntro absent), asserting that:
extraSystemPromptStaticis identical across turns and never contains the intro.Command (run from inside the worktree):
Results:
Test Files 1 passed (1)/Tests 81 passed (81), including the new test.expected 'GROUP-CHAT-CONTEXT\n\nGROUP-INTRO' not to contain 'GROUP-INTRO', confirming it is atrue regression test.
Honest scope of testing:
pnpm dev/openclaw); the liveclaude-cligroup-channel path was not exercised end-to-end.
CHANGELOG.mdedits.Fixes #69118