Add disk-backed transcript parse cache (4.2x faster subagent-heavy renders) - #119
Merged
Conversation
Renders of subagent-heavy sessions re-read every agent transcript from byte 0 twice per render (fresh process each time), scaling linearly with accumulated agents: 318.6 ms for a 48-agent session vs 61.1 ms fresh. Persist parse results per session to ~/.claude/yas-cache/, keyed by (path, mtime, size) plus parse args; finished transcripts are immutable so warm renders skip them entirely. Adds totals-only parsing for conclusively-retired agents and cache-backed ToolCounts. Warm render drops to 74.8 ms (4.2x). New transcript_cache config knob, default on. Implements OpenSpec change cache-transcript-parses. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…/ path consolidation Resolves conflicts between the #120 path-consolidation (all YAS files moved under ~/.claude/yas/) and the transcript-parse-cache feature by routing the transcript cache path through a new transcript_cache_path() helper in constants.py, matching the consolidated cache_dir() convention. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
tmck-code
marked this pull request as ready for review
August 20, 2026 13:31
Co-Authored-By: Claude Sonnet 5 <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.
Context
Important
This PR implements a cache for a measured speed increase of
318.6 ms > 61.1 ms (5.2x)Changes
Transcript parse cache (
claude/yas/info/parsecache.py, new)~/.claude/yas-cache/transcripts.<session_id>.json, version-stamped, atomicos.replacewrites, 24 h retention, fail-safe: any corruption/mismatch falls back to a full re-parse.(path, mtime, size)plus parse arguments (resume_after,clear_epoch/skip_sidechain), so argument changes can't return stale results.Cache-backed readers (
subagents.py,toolcounts.py)parse_transcript, the notification/tool-result tail readers, andcount_transcriptall seed from and write back to the cache.totals_onlyparse mode for conclusively-retired agents (cold-cache fallback), with a post-visible()re-parse fail-safe so no rendered row is ever built from a stub.ToolCounts.gatherstill covers every subagent (rendered totals unchanged) — it's just satisfied from the cache.Lifecycle & config
app.render();SessionViewkeeps its no-disk-writes contract;monand tests untouched.transcript_cacheknob ([cache]inyas.toml, envYAS_TRANSCRIPT_CACHE), default on.Measured effect (real captured payloads, hyperfine): 48-agent session 318.6 ms → 74.8 ms warm (4.2×); cold render unchanged (311.6 ms); cache file 44 KB. Rendered output is byte-identical cache-on vs cache-off (frozen-clock equivalence tests).
Checklist
Screenshots / recording
Benchmark
mainPR(
make benchuses a small demo payload, so parity is expected — the gain is on subagent-heavy sessions: 318.6 ms → 74.8 ms warm on a real 48-agent session, measured with hyperfine on captured production payloads.)System info
🤖 Generated with Claude Code