Skip to content

fix(agent-status): recover Claude turns after blocked Stop hooks - #755

Merged
im-ian merged 1 commit into
mainfrom
fix/claude-blocked-stop-status
Aug 5, 2026
Merged

fix(agent-status): recover Claude turns after blocked Stop hooks#755
im-ian merged 1 commit into
mainfrom
fix/claude-blocked-stop-status

Conversation

@im-ian

@im-ian im-ian commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Summary

Claude sessions now leave the waiting state when a session-scoped Stop hook rejects completion and resumes the same turn.

  1. Track rejected Stop boundaries — retain Claude native Stop timestamps separately from permission and elicitation waits, and clear them on the next lifecycle event.
  2. Classify agent-owned resume evidence — expose explicit Stop hook feedback: records and in-progress assistant messages without treating late user-side tool results as proof of resumed work.
  3. Reconcile without races — require transcript evidence newer than the Stop boundary and apply the recovery through the existing source and lifecycle-revision fence.
  4. Cover negative paths — preserve genuine completed Stops when old feedback or background tool results appear later, and verify the next prompt retires the stored boundary.

Expected impact

Scenario Before After
Stop hook rejects completion and Claude continues Session could remain stuck at waiting for input Session returns to working after agent-owned transcript activity
Normal Claude Stop Waiting for input Waiting for input
Late background tool result after a completed turn Waiting state could be unsafe to clear heuristically Waiting state remains unchanged
Next user prompt after Stop Starts the next turn Starts the next turn and clears the previous Stop boundary

Design notes

  • agent_activity_timestamp is separate from the newest turn timestamp because Claude tool-result records classify the turn as working but do not prove that the main agent loop resumed.
  • Claude attention dialogs and Stop boundaries are mutually exclusive runtime evidence with different transcript recovery rules.
  • Recovery requires a confirmed Claude hook owner, a working transcript classification, activity newer than the Stop timestamp, and an unchanged lifecycle source/revision under the session-store lock.

Test plan

  • From src-tauri: cargo test --workspace -- --test-threads=1 — all workspace and doc tests pass.
  • From src-tauri: cargo test -p acorn-transcript -p acorn-session — 101 transcript and 83 session tests pass.
  • From src-tauri: cargo test -p acorn claude_ — 54 Claude-focused tests pass.
  • From src-tauri: rustfmt --edition 2021 --check crates/acorn-session/src/session.rs crates/acorn-session/src/status.rs crates/acorn-transcript/src/line.rs src/agent_hooks.rs src/commands.rs.
  • git diff origin/main...HEAD --check.

Notes

  • The full workspace suite was run serially with inherited Acorn control-session environment overrides removed so environment-sensitive tests use their isolated profile paths.
  • Existing dead-code warnings emitted by unrelated code remain unchanged and are not caused by this PR.

@im-ian im-ian added the fix Bug fix label Aug 5, 2026
@im-ian
im-ian merged commit 9380cc2 into main Aug 5, 2026
3 checks passed
@im-ian
im-ian deleted the fix/claude-blocked-stop-status branch August 5, 2026 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant