bug: Claude Code session resume causes stale context — two failure modes #577

Open
opened 2026-05-30 07:21:46 +00:00 by xiaoju · 0 comments
Owner

Observed

Thread 06F7F3AWA1BX6K6Q6MGQ0CHR3W (json-cas #27) failed after 3 developer + 2 reviewer cycles. Root cause: Claude Code --resume produces stale context.

Bug 1: Developer hallucinates completion on resume

Developer step 1 ran only 20 seconds and reported $status: done with a worktree path that didn't exist. No files were created, no commits made.

Cause: --resume restored a previous session. The agent concluded work was done based on stale session state instead of verifying filesystem.

Evidence: uwf cas get 3KKGEKGNS6M67 — detail shows minimal turns, no actual file edits.

Bug 2: Reviewer uses stale reject on re-entry

After developer step 2 genuinely completed the work (15 min, commit aefd93c), reviewer step 2 ran only 1 turn, 14 seconds and rejected again with the same "worktree doesn't exist" message.

Cause: Reviewer resumed its session from step 1 where it had already verified the path didn't exist. On resume it reused that conclusion without re-checking the filesystem.

Evidence: uwf cas get 8TZA7PES6AC6F — 1 turn, 14s, stopReason: end_turn.

Impact

Thread stuck in reject loop → developer gives up → $status: failed. The code was actually correct and complete (manually verified and merged as PR #28).

Potential Fixes

For Bug 1 (developer hallucination):

  • Post-step validation: after developer reports done, verify worktree path exists and has commits ahead of main before accepting
  • Don't resume on first visit: isFirstVisit should always spawn fresh session, never resume

For Bug 2 (reviewer stale context):

  • Never resume reviewer sessions: reviewer should always get a fresh session to inspect current filesystem state
  • Inject filesystem proof: include git worktree list and git log output in reviewer prompt so it doesn't rely on session memory

Files

  • packages/workflow-agent-claude-code/src/claude-code.ts — session resume logic
  • .workflows/solve-issue.yaml — workflow definition (reviewer role)

— 小橘 🍊(NEKO Team)

## Observed Thread `06F7F3AWA1BX6K6Q6MGQ0CHR3W` (json-cas #27) failed after 3 developer + 2 reviewer cycles. Root cause: Claude Code `--resume` produces stale context. ## Bug 1: Developer hallucinates completion on resume Developer step 1 ran only **20 seconds** and reported `$status: done` with a worktree path that didn't exist. No files were created, no commits made. **Cause:** `--resume` restored a previous session. The agent concluded work was done based on stale session state instead of verifying filesystem. **Evidence:** `uwf cas get 3KKGEKGNS6M67` — detail shows minimal turns, no actual file edits. ## Bug 2: Reviewer uses stale reject on re-entry After developer step 2 genuinely completed the work (15 min, commit `aefd93c`), reviewer step 2 ran only **1 turn, 14 seconds** and rejected again with the same "worktree doesn't exist" message. **Cause:** Reviewer resumed its session from step 1 where it had already verified the path didn't exist. On resume it reused that conclusion without re-checking the filesystem. **Evidence:** `uwf cas get 8TZA7PES6AC6F` — 1 turn, 14s, `stopReason: end_turn`. ## Impact Thread stuck in reject loop → developer gives up → `$status: failed`. The code was actually correct and complete (manually verified and merged as PR #28). ## Potential Fixes ### For Bug 1 (developer hallucination): - **Post-step validation**: after developer reports done, verify worktree path exists and has commits ahead of main before accepting - **Don't resume on first visit**: `isFirstVisit` should always spawn fresh session, never resume ### For Bug 2 (reviewer stale context): - **Never resume reviewer sessions**: reviewer should always get a fresh session to inspect current filesystem state - **Inject filesystem proof**: include `git worktree list` and `git log` output in reviewer prompt so it doesn't rely on session memory ## Files - `packages/workflow-agent-claude-code/src/claude-code.ts` — session resume logic - `.workflows/solve-issue.yaml` — workflow definition (reviewer role) — 小橘 🍊(NEKO Team)
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: uncaged/workflow#577