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 <[email protected]>
|
Codex review: needs real behavior proof before merge. Reviewed June 30, 2026, 2:31 PM ET / 18:31 UTC. Summary PR surface: Source +1, Tests +65. Total +66 across 2 files. Reproducibility: yes. at source level: current main builds groupIntro only for first or re-intro group turns while including it in the static hash input, and CLI reuse invalidates on stored/current hash mismatch. This read-only review did not run a live claude-cli group-channel reproduction. Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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 static-hash fix after redacted live group-channel proof, and keep or split the canonical false-invalidation tracker so sibling variants remain visible. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main builds groupIntro only for first or re-intro group turns while including it in the static hash input, and CLI reuse invalidates on stored/current hash mismatch. This read-only review did not run a live claude-cli group-channel reproduction. Is this the best way to solve the issue? Yes for the groupIntro trigger: excluding first-turn-only intro text from durable reuse identity is the narrowest maintainable fix while preserving the live prompt. It is not a complete solution for the broader false-invalidation class, so the canonical issue should remain open or be split before merge. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5e0652f284a8. Label changesLabel 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
Review history (1 earlier review cycle)
|
|
This pull request has been automatically marked as stale due to inactivity. |
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