fix(round-trip-tracker): detect hook_success brain context#7
Open
bunny-bot-openclaw wants to merge 5 commits into
Open
fix(round-trip-tracker): detect hook_success brain context#7bunny-bot-openclaw wants to merge 5 commits into
bunny-bot-openclaw wants to merge 5 commits into
Conversation
Scrapes Anthropic's public docs for latest model versions and compares against OpenClaw config. No API keys needed. - Auto-detects ~/.openclaw/ and ~/.clawdbot/ config paths - --discord flag for formatted output - Exit code 1 if stale models found (cron-friendly) - Errors explicitly on empty scrape results
- Points at ~/.claude/projects/*/*.jsonl recursively (no more ~/.openclaw paths) - Claude Code does not write a pre-computed cost block, so we price tokens ourselves using current Anthropic rates (input / output / cache write / cache read) - Model-aware pricing table: opus-4, sonnet-4, haiku-4 (+ 3.x fallbacks) - Added MAX_10X tier ($150) alongside MAX_5X and MAX_20X - Recommendation logic walks tiers by rank so downgrades and upgrades are symmetric
Claude Code writes one growing .jsonl per session (vs openclaw's per-session files). The session-extract cron was re-reading the same tail each run, so extraction was non-incremental and ate the same turns over and over. session-delta.py walks every .jsonl under the project dir, filters user/assistant entries by timestamp > watermark, emits plain-text turns, then advances a watermark at ~/.cashew/extract-watermark.json. First run seeds watermark to now-48h so we don't replay the entire backlog. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
`extract_text` only checked for OpenClaw-style `toolCall`/`toolResult` types, so tool calls and results in Claude Code sessions (which use `tool_use`/`tool_result`) were silently skipped. Brain signal detection returned 0 hits on every Claude Code session because cashew Bash calls appeared in `tool_use` blocks that were never read. Fix: check both type names in each branch. For `tool_use`, read args from `input` (falling back to `arguments`). Also handle `attachment` entries in `load_from_jsonl` so startup hook results, which carry brain context, are included as user messages.
Two fixes for the 0% brain usage bug: 1. JSONL parser: add a branch for attachment entries where attachment.type == "hook_success", extracting content from attachment.content instead of the missing message key. 2. extract_task_chains: after building all chains, do one session-level has_brain_context(messages, 0, len(messages)) pass. Startup hook_success entries land before the first user message so per-chain checks always miss them; session-level propagation fixes this. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hook_successattachment entries because they carry content underattachment.content, not undermessage. Added a dedicated branch that extracts this content as a user-role message sohas_brain_context()can see it.has_brain_context()is called per-chain starting from the first user message, but startup brain context arrives before any user message. After all chains are built, a single session-level pass over all messages propagatesbrain_used=Trueto every chain in the session if any brain signal is found.Test plan
python3 round-trip-tracker.py --reportexits cleanly (no errors)hook_successentry with "GRAPH OVERVIEW" in content; verify the resulting chain showsbrain_used=Truebrain_used=False)🤖 Generated with Claude Code