Skip to content

Program: save more money without hurting agents, and show users what we do (umbrella) #433

Open

Description

@OsherElhadad

Umbrella issue for the research, improvement and product program. Live status is updated here; each task has its own issue.

Context Guru program — plan

Goal: save users much more money without hurting agent task success, and make it obvious what Context Guru does for them.

Data: production snapshot 2026-10-10T23:48Z (189,207 requests, 2026-08-17 → 10-10, 16 tenants, 2,362 sessions), plus a deduplicated union of four earlier snapshots (production deletes request rows when it archives a session; the current snapshot holds ~53% of the all-time bill). Production is read-only; all experiments run on separate proxies.

Where the money is (observed, snapshot window, deployed gateway rates)

USD share
cache read 11,528 45.7%
cache write 11,542 45.7%
output 1,952 7.7%
fresh input 223 0.9%
total booked 25,341
lever today net class
compaction (all components) +$89.82 (0.35%) counterfactual, uncorrected (pre-#255 binary)
keep-alive pings (1,895 pings, $131.99) +$150.67, ROI 2.14× credit is a ceiling, not causal

Cache mechanics are ~91% of the bill. Compaction pays mainly by shrinking future cache reads/writes, not fresh input.

Recon findings that set the plan

  1. The deployed binary is old (Sep 3 build, not an ancestor of main). Snapshot behaviour ≠ main's code. Several main components have zero rows by construction.
  2. Keep-alive campaign windows were shifted by +3h (UTC hours stored without timezone, read as Asia/Jerusalem) — fixed in fix(campaign): write UTC timezone on generated keep-alive windows #432.
  3. The kvcache simulator does not reconcile to the bill (fixed-5m replay $38.8K vs $25.2K booked); no replay dollar figure is trustworthy until fixed.
  4. Cold turns are under-compacted: ttl_expiry turns are 21% of the bill, but compaction removed 1.4% of their tokens; extract_llm uses the warm-cache gate on cold turns.
  5. Keep-alive bar to beat: ping-everyone / cap-2 (+5.7% vs fixed-5m on the Sep-28 replay). No learned gate has beaten it. 652 of 709 pinged sessions lost money; second pings rescue below break-even.
  6. 1h tier: never granted on sonnet-5/opus-5 by the gateway (The gateway silently downgrades every ephemeral_1h request for sonnet-5/opus-5, and 78.9% of all TTL-expiry loss is in the 5min-1h band it would rescue (~$1,134/41d) #330); cache_write_1h is 0 on every row.
  7. Accounting holes: 1,566 "hit"-labelled full-prefix rewrites ($2,827); bare claude-sonnet-5 possibly priced at the sonnet-4 rate (~$678); failed requests book $0; cache_saved_usd is the provider mechanism, not ours.
  8. Plugins: the Codex setup breaks Codex when the proxy is down; Codex insights is a stub; the status line $X of $Y is ambiguous; the unused-tool nudge ranks by use count and once told users to remove our own skill; the default preset is off.
  9. Missing instrumentation: pending tool name/elapsed, thread id, parent/child, ping events, gap, granted TTL.

Workstreams and first-round tasks

A — tail compaction

  • A-cold: compaction on proven-cold turns (deployable "will be cold" rule, precision/recall, $ with CIs).
  • A-unused-tools: dollars carried by never-called tool declarations; client advice vs proxy toolfilter on cold turns.
  • A-harm: expand / re-read / retry / abandonment after compaction, per component.
  • A-missed: uncompressed_reason priced; content types that pass untouched; near-duplicates.
  • A-competitors: Headroom, RTK, context-mode, Caveman techniques replayed on our outputs.
  • Next: preset redesign + joint offline replay → paired benchmarks (≥5 seeds) → real sessions through an experimental proxy.

B — cache keep-alive and lifecycle

  • B-tz: campaign timezone fix (fix(campaign): write UTC timezone on generated keep-alive windows #432).
  • B-sim: simulator reconciled to the bill within ±2%, then all baselines with CIs.
  • Next: per-user survival / cross-conversation features vs ping-everyone; just-in-time pings; economic gate per provider; instrumentation PR (pending tool, thread id, ping events); live randomized holdout on an experimental proxy; joint replay with compaction.

C — plugins

  • Reference study done for status lines/HUDs (in progress); redesign of the status line, insights, doctor, onboarding; Codex parity and the "dead proxy blocks Codex" fix.

D — dashboard

  • Tab-by-tab audit with screenshots (in progress); observability/cost dashboard reference study (in progress); redesign around a bottom line + ranked recommendations.

Process

Main agent plans and integrates; worker subagents per task; a Reviewer reviews every PR before squash-merge; a Verifier re-derives every headline number before publication; a Red-team attacks each claimed result. Corrections go to analysis/CORRECTIONS.md. Merging is allowed; deployment to production is left to the owners.

Decisions taken without asking (rationale)

  • "Do not send load to the upstream gateway": read as "no harmful volume". Every real LLM call goes through it, so modest experimental calls (probes, paced benchmarks) are allowed.
  • Agents run via the Agent tool (~10 concurrent), not the Workflow tool, which needs explicit opt-in.
  • Analysis uses the union of snapshots where history matters; the current snapshot is the reference for current behaviour.

Status

Activity

  1. added
    designA decision about how something should work, not a defect
    on Oct 11, 2026
  2. OsherElhadad commented on Oct 11, 2026

    @OsherElhadad
    CollaboratorAuthor

    Status update — round 1

    Merge gate. Branch protection on main needs an approving review from a second GitHub account, and auto-merge is off for this repo. Program PRs are reviewed by an independent reviewer agent. When that review passes and CI is green, the PR gets the ready-to-merge label and waits for one maintainer approval. We do not use admin merges.

    PR what state
    #432 keep-alive campaign windows were 3 h off (UTC hours stored as Asia/Jerusalem) ready-to-merge
    #438 kvcache replay: rejected requests no longer erase the live cache entry ready-to-merge
    #440 Codex plugin: a dead proxy no longer blocks Codex; launcher; shared insights; doctor and onboarding ready-to-merge
    #441 plugin cost commands (today, unused, cold, compact, trends) and two tenant-scoped endpoints ready-to-merge
    #442 status line redesign: layouts, server cache state, hint when sending into a cold cache ready-to-merge
    #445 dashboard endpoints 2–17× faster (golden-tested, identical outputs) in review
    #439 reversible per-file grep cap (searchcap, off by default) changes requested
    #443 dashboard bottom line, recommendations and navigation regroup changes requested
    #444 recommended keep-alive defaults draft, waiting for verification and live validation

    Data. Production deletes request rows when it archives sessions, so the current snapshot covers about 53% of the bill. We built a deduplicated union of four snapshots: 411,863 requests from 2026-08-17 to 10-10.

    Live cache facts (real gateway calls, synthetic prefixes, about $100 total). TTL is a hard cliff between 290 s and 300 s on haiku, sonnet-5, opus-5-5 and opus-5. A 1-token ping fully resets it. Only haiku honours the 1h tier (#330).

    Keep-alive policy numbers are going through independent verification and red-team review before we publish them. That review has already corrected the first-round headline: pings on a session's final, censored gap must be paid. Workstream details: #434, #435, #436, #437.

  3. OsherElhadad commented on Oct 11, 2026

    @OsherElhadad
    CollaboratorAuthor

    Status update — round 2

    Approved by the program reviewer, CI green, labelled ready-to-merge. Each one still needs a maintainer's approval (branch protection). Suggested merge order: #445 before #441, because they conflict in dash/api.go.

    PR area what
    #432 cache keep-alive campaign windows were shifted 3 h (UTC hours stored as Asia/Jerusalem)
    #438 cache replay: rejected requests no longer erase the live cache entry
    #444 cache recommended keep-alive defaults: 270 s, 2 pings, 80K floor, $0.50 ceiling (#446)
    #447 cache lifecycle signals behind a flag: thread id, previous tools, gaps, granted TTL
    #450 compaction fix the 400 after streaming expands (#451)
    #439 compaction reversible per-file grep cap, off by default
    #449 compaction tool-declaration auto filter with a context_guru_tools restore stub, off by default, per-thread
    #440 plugin Codex: no lock-out when the proxy is down; launcher; shared insights; doctor
    #441 plugin cost commands: today, unused, cold, compact, trends
    #442 plugin status line redesign
    #443 dashboard bottom line + recommendations; honest estimated/upper-bound labels
    #445 dashboard endpoints 2–17× faster, golden-tested

    Draft: #448 (house2-lite). Waiting on the paired benchmark.

    Findings published.

    Workstream conclusions so far.

    • B (keep-alive): feature search saturated after three rounds. The three-knob rule is the deployable policy. Remaining work needs deployment: a live 270 vs 280 test under production queueing, and data from feat(dash): opt-in lifecycle signals (thread, wait cause inputs, gaps, granted TTL) #447.
    • A (compaction): deterministic, content-aware, reversible compaction is close to saturated, at about 0.8% of input cost on SWE-shaped replay. The levers that would save more are age- or size-based, and they fail the information bound. A paired live benchmark (opus-5, 20 SWE-bench tasks) is running to test whether reversible removals still pay when the agent can expand them: off / house / house2-lite / +collapse / +readlifecycle-cold / +toolfilter-auto. Baseline with compaction off: 19/20 solved, $0.80 per task.
  4. OsherElhadad commented on Oct 11, 2026

    @OsherElhadad
    CollaboratorAuthor

    Final summary: #466. Findings: #446 (keep-alive), #451 (expand bug), #465 (tool declarations).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    designA decision about how something should work, not a defect

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions