Skip to content

perf(dashboard): cache the derived payload so agent toggles stop rebuilding it - #12

Merged
contactacefleetdev merged 1 commit into
mainfrom
fix/agent-scoped-cards-and-build-cache
Aug 15, 2026
Merged

perf(dashboard): cache the derived payload so agent toggles stop rebuilding it#12
contactacefleetdev merged 1 commit into
mainfrom
fix/agent-scoped-cards-and-build-cache

Conversation

@contactacefleetdev

@contactacefleetdev contactacefleetdev commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Description

Switching the agent tab re-derived the whole page from the same transcripts: 4.0s for Claude, 1.3s for All Agents, every single toggle. Nothing about that work depends on which tab was clicked last, so it is now memoised.

insights.build splits into _build_payload — the transcript-derived half — and a thin wrapper that caches it under (range, agent, transcript fingerprint, store, capture). The fingerprint comes from sessions(), so appending a turn retires every entry derived from the older transcripts and a stale payload cannot outlive its data. The live telemetry counters stay outside the cached dict and are re-read per request; they move on each proxied turn rather than when a transcript is written, and caching them would freeze the one number on the page meant to be live. The cache is bounded, since entries keyed on a retired fingerprint are dead weight.

Two scans behind it were also repeating work:

  • sessions() rebuilt its fingerprint by walking and stat-ing every transcript on cache hits as much as misses (~0.35s). A short freshness window lets a burst of toggles reuse it, well under the time it takes to notice a missing turn.
  • skill_miner._scan_transcript_logs parses every line of every transcript — 179k json.loads here — and ignores the sessions it is handed, so it returned an identical answer for each tab and was rerun for each. Memoised on the same fingerprint shape.

Measured over HTTP against a real transcript directory: a repeat toggle goes from 4.0s to 1.2ms, and a first visit to the Antigravity tab from 1.45s to 0.35s. The suite gained seven tests and still got faster, 11.9s to 10.2s.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Verification

Describe the tests and checks performed to verify changes:

  • pytest passes cleanly.
  • python -m build and twine check dist/* pass.
  • E2E test script scripts/e2e_test.py passes.

Checklist

  • My code follows the code style of this project.
  • I have updated documentation where necessary.
  • I have updated CHANGELOG.md with my changes.

…ilding it

Switching the agent tab re-derived the whole page from the same transcripts:
4.0s for Claude, 1.3s for All Agents, every single toggle. Nothing about that
work depends on which tab was clicked last, so it is now memoised.

insights.build splits into _build_payload — the transcript-derived half — and a
thin wrapper that caches it under (range, agent, transcript fingerprint, store,
capture). The fingerprint comes from sessions(), so appending a turn retires
every entry derived from the older transcripts and a stale payload cannot
outlive its data. The live telemetry counters stay outside the cached dict and
are re-read per request; they move on each proxied turn rather than when a
transcript is written, and caching them would freeze the one number on the page
meant to be live. The cache is bounded, since entries keyed on a retired
fingerprint are dead weight.

Two scans behind it were also repeating work:

  * sessions() rebuilt its fingerprint by walking and stat-ing every transcript
    on cache hits as much as misses (~0.35s). A short freshness window lets a
    burst of toggles reuse it, well under the time it takes to notice a missing
    turn.
  * skill_miner._scan_transcript_logs parses every line of every transcript —
    179k json.loads here — and ignores the sessions it is handed, so it returned
    an identical answer for each tab and was rerun for each. Memoised on the
    same fingerprint shape.

Measured over HTTP against a real transcript directory: a repeat toggle goes
from 4.0s to 1.2ms, and a first visit to the Antigravity tab from 1.45s to
0.35s. The suite gained seven tests and still got faster, 11.9s to 10.2s.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@contactacefleetdev
contactacefleetdev merged commit 4c8aaca into main Aug 15, 2026
1 check passed
@contactacefleetdev
contactacefleetdev deleted the fix/agent-scoped-cards-and-build-cache branch August 15, 2026 19:12
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