feat: add scheduled agent run analytics - #445
Conversation
- Apply cache_control to conversation history blocks - Track cache miss/creation tokens - Add UI indicator for silent cache degradation - Add Cached Tokens column to Executions list view
c83e832 to
983e4c7
Compare
Cache Analytics FinalizationThis resolves the final gaps in the caching pipeline (completed by Antigravity via withkids):
Tests Executed: |
c6edad3 to
84ad4b0
Compare
Adds segment_tokens (system/tools/knowledge/history/message token composition) and prefix_breakpoints (per-breakpoint cache prefix hashes) into the existing usage_snapshot field, plus a compute_run_metrics helper producing cache read share, effective input multiplier, wasted-writes tracking, prefix stability, and counterfactual savings. Adds a get_run_context_metrics API and a reusable ContextBar component wired into the Agent Run detail page's new Context card.
|
Follow-up commit adds context/cache observability on top of this PR's usage_snapshot foundation:
Chat-header and agent/fleet-level views intentionally deferred to a follow-up — same component, once this surface is validated. Verification done: |
|
Screenshot proof of the Context card (ContextBar component, real code, rendered with representative data — see caveat below): This is the actual shipped Side note for whoever's on bench |


Summary
Adds a mergeable execution-analytics foundation without browser-side aggregation of raw runs.
Validation
python3 -m py_compilefor changed backend modulesyarn typecheckyarn buildon isolated benchbench --site huf.localhost migrateon isolated 16_2 benchbench --site huf.localhost run-tests --app huf --module huf.ai.tests.test_agent_run_analytics(2/2)Notes
cached_tokens/costcompatibility fields while adding an authoritative null-aware usage snapshot.