Skip to content

Scan assistant messages for decision language at Stop time#12

Merged
baljanak merged 1 commit intomainfrom
feat/assistant-transcript-scan
Apr 10, 2026
Merged

Scan assistant messages for decision language at Stop time#12
baljanak merged 1 commit intomainfrom
feat/assistant-transcript-scan

Conversation

@baljanak
Copy link
Copy Markdown
Contributor

@baljanak baljanak commented Apr 10, 2026

Summary

  • The plugin detected decision language in user messages (capture_nudge on UserPromptSubmit) but missed decisions stated by the assistant — there's no AssistantMessage hook event in Claude Code
  • At Stop time, reads the session's JSONL transcript from disk and scans assistant text blocks for the same decision phrase patterns with identical corroboration requirements
  • Integrates as the highest-priority secondary hint in stop_nudge, before impl/plan/staleness checks

Changes

  • helpers.py: Add _discover_transcript() — locates ~/.claude/projects/{key}/{session-id}.jsonl
  • constants.py: Add TRANSCRIPT_TAIL_BYTES (64KB) and TRANSCRIPT_MAX_BLOCKS (20)
  • stop_nudge.py: Add _scan_assistant_decisions() (tail-read + pattern matching) and _assistant_decision_summary(), wire into _stop_nudge_condition() priority chain
  • tests/test_stop_nudge.py: 8 new tests — detection, corroboration, dedup with capture_nudge, missing/corrupt transcript, dismissed nudges, end-to-end

Design choices

  • Tail-read last 64KB — bounds scan time for large transcripts while capturing recent assistant turns
  • Same corroboration bar as capture_nudge (phrase + tech signal OR reasoning signal OR 2+ phrases)
  • Deduplicates against phrases already detected by capture_nudge from user input
  • Extends stop_nudge rather than adding a new policy — avoids competing for the 2/session nudge budget

Test plan

  • All 589 tests pass (make check)
  • ruff, mypy, shellcheck clean
  • Manual: run a session, have assistant state a decision, end session, verify nudge appears

🤖 Generated with Claude Code

The plugin detected decision language in user messages (capture_nudge) but
missed decisions stated by the assistant. At Stop time, read the session's
JSONL transcript from disk and scan assistant text blocks for decision
phrases with the same corroboration requirements.

- Add _discover_transcript() to locate session JSONL files
- Add _scan_assistant_decisions() with tail-read (last 64KB) for performance
- Integrate as highest-priority secondary hint in stop_nudge
- Deduplicate against phrases already detected by capture_nudge
- 8 new tests covering detection, corroboration, dedup, and edge cases

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@baljanak baljanak merged commit 8ec2dd4 into main Apr 10, 2026
5 checks passed
@baljanak baljanak deleted the feat/assistant-transcript-scan branch April 10, 2026 12:58
@baljanak baljanak mentioned this pull request Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant