Repository navigation
feat(session-flow): skip the observer's analysis for short sessions and record its usage - #18951
Conversation
…ord run usage Add observer_min_lines (default 300): the detached observer skips the post-session claude -p analysis when fewer distilled transcript lines are pending, records the skip in its status file and log, writes no ledger, and keeps the observations so a resumed session counts them. Threaded through the SessionStart hook, the running-retro arm block, the launcher and observer.py; the default lives only in plugin.json. Each analysis run that returns JSON, failed runs included, now writes its reported usage tokens, duration_ms and total_cost_usd under the status file's analysis key and one log line. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0faaf1c599
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
PR body contract — issue linkage This PR body does not yet satisfy the issue-linkage contract:
Edit the body and this comment updates itself on the next run. |
|
claude-review reviewed Code review (incremental, blocking only):
|
|
claude-security-review reviewed Security review: PR #18951, incremental since
|
…ry run's usage The size gate now applies only to a session with no ledger yet, so a short follow-up to an analyzed session is analyzed instead of skipped. Run and skip records accumulate in the status file's analysis_runs list, which every status write carries, so per-poll rewrites, resumed watches and re-arms no longer drop earlier runs. The analysis-run tests now derive their JSON from a real captured claude -p --output-format json result, ids and expiry blanked. Co-Authored-By: Claude Opus 5.5 <[email protected]>
No related issue: owner turned the observer on for every session (melodic-software/dotfiles#1803); this keeps short automated sessions from each costing an analysis run and makes the cost measurable.
Summary
The session-flow detached observer now skips its post-session analysis for short sessions and records each run's token usage.
Fix
observer_min_lines(default 300; 0 analyzes every session): below it, the observer logs and recordsanalysis: {"skipped": ..., "lines": N}in its status file, runs noclaude -pand writes no ledger. Observations are kept, so a resumed session counts its earlier lines. Threaded throughobserver-arm.sh,arm_observer.py, the running-retroarmblock, plugin.json and the Config table inreference/observer.md.duration_ms,total_cost_usd) is merged into the status file and logged, failed runs included.status-replay-de32eb16.jsonlines_observed); automated sweeps that run as interactive sessions are far shorter. It is a default the user can change.Verification
observer.test.sh: 93 tests OK, 5 new (below the threshold skips and records; at the threshold runs; unset takes the plugin.json default; usage stored; usage stored on a failed run). With the check disabled the skip test fails, and with<changed to<=the at-threshold test fails; both restored.validate-plugins.sh --only session-flow, changelog fragments,sync-plugin-options-docs.py --check, ruff check and shellcheck pass.🤖 Generated with Claude Code