Skip to content

Reuse is neutral on tasks the agent passes anyway (1.03x, n=5), while an irrelevant memory costs 1.52x #385

Open

Description

@abogartz

What was measured

Whether a memory written by one session makes a later session on the same task cheaper. This is the reuse half of the plugin's promise, and the bench had never measured it above a 123-line repo.

Fixture: benchmark-tests/ocsi/base3 — 783 src lines across 16 modules. A real bug (mergeAllocations keeps the first part's backordered flag instead of OR-ing), a real suite that catches it (65 tests, 1 failure), and a four-read trace from symptom to cause.

Arms, 5 pairs, one seat (evo/Qwen3.8-Flash-Next), graded against the pristine suite:

arm store sessions pass median tokens
L0 empty 5 5/5 16,281
L1 empty, capture on 5 5/5 15,637
L2 L1's own store 5 5/5 18,170
L4 one irrelevant lesson 3 3/3 24,698

Pre-registered verdict on median(L2)/median(L0): HELPS < 0.85, NEUTRAL 0.85–1.15, HURTS > 1.15.

Result: NEUTRAL, and noise is dearer than signal

Median L2/L0 = 1.03x over 5 pairs, higher in 3 of 5. Per-pair ratios: 0.43, 0.78, 1.03, 1.45, 1.86.

An irrelevant memory costs 1.52x (3/3 sessions at or above 1.5x) — consistently dearer than the real row's median.

Three things were verified rather than assumed:

  1. Capture writes the answer. From a successful base3 session, capture stored the cause at rule abstraction in 4 of 5 runs: "In src/warehouse.ts mergeAllocations, per-record flags must be explicitly combined when collapsing SKU allocations; backordered should be OR-ed so any inbound part triggers split-handling shipping." Storage is not the weak link.
  2. Injection works. Row fragments were found in L2's request bytes (21 and 22 occurrences across the run; the irrelevant row 63). The row rode every request.
  3. No masking. All 18 runs edited warehouse.ts. Not one made the suite green by patching the invoice boundary instead of the cause. The fixture measures repair.

So the row is stored correctly, injected correctly, and buys nothing measurable.

Why the variance, and why the metric is still the right one

L2's spread (7,070 to 23,503 tokens) is wider than the whole effect. Repeat 4 is the control case that shows the row is not what drives cost: L1 wrote no answer-shaped row there, and L2 still cost 1.86x. Session-to-session variance in how much the agent reads swamps a memory that saves four reads.

What this does and does not rule out

It rules out: "the plugin pays for itself on tasks the agent completes anyway." On that class the ceiling is neutrality and the floor is the noise cost.

It does not rule out: value on tasks the agent fails without help. That measurement is still blocked, and base3/FIXTURE.md records why the obvious fix breaks the oracle. A test pinning the buggy flag would produce failures, and would also make grading reward masking over repair, because grading copies the pristine fixture plus the agent's src/.

Proposed direction

Cost on pass-anyway tasks is a dead end as a justification. Options, ranked:

  1. Stop selling reuse as a saving. Keep capture, and state the cost honestly: a correct memory is free-to-neutral, a wrong one is 1.5x. That makes precision the only quality metric that matters, and it makes the noise bank (arm L4) the primary test rather than an afterthought.
  2. Find a failure class that survives the oracle test. The requirement is a bug where the fix location is not reachable by a short deterministic trace and where no plausible test can pin the wrong behaviour. Not built yet; two attempts are documented in base3/FIXTURE.md.
  3. Raise n until variance resolves. 5 pairs gave 0.43–1.86. Resolving a 10% effect at that spread needs roughly 30 pairs, about 12 hours of seat time. Available, but it measures a metric whose ceiling is neutrality.

Reproduce: CHAIN_LARMS=0124 CHAIN_LREPEAT=5 CHAIN_OUT=results-reuse-base3 bun chain-learn.ts --localise. Results in results-reuse-base3/learn.json.

Activity

  1. added
    bench
    on Nov 10, 2026
  2. abogartz commented on Nov 10, 2026

    @abogartz
    OwnerAuthor

    Correction: the cost metric excluded 94% of the cost

    The 1.52x noise cost in the table above is wrong and so is the 1.03x. Both come from runSession's tokens, which sums input + output + reasoning and deliberately excludes cache.read (kept in a separate field so old comparisons stayed valid). input from this provider is only the uncached remainder. In this very run that means the reported figure captured 17,008 of 262,332 tokens actually moved — 6%.

    Recomputing the same 18 sessions from stdout.ndjson with the cache included:

    pair L0 true L2 true true historical
    1 262,332 159,159 0.61x 0.78x
    2 212,013 120,705 0.57x 0.43x
    3 174,546 287,809 1.65x 1.45x
    4 157,099 459,698 2.93x 1.86x
    5 292,352 247,132 0.85x 1.03x

    Median true ratio 0.85x, spread 0.57–2.93. The irrelevant-memory arm inverts outright: 0.75, 0.82, 1.09 → median 0.82x, not 1.52x. The direction of the finding depends entirely on which tokens you count, so neither verdict is safe at n=5 and the "noise is dearer than signal" line in the title does not hold.

    What the old metric was actually measuring

    Output + reasoning + cache misses. That is not neutral, because injecting a memory block changes the system prompt and therefore invalidates the provider's prompt cache. results-cache-audit-on vs results-cache-audit-pin shows it directly:

    profile block chars per turn invalidations total uncached input
    audit-on 675, 520, 680, 689, 520, 675 15 (prompt_reveal) 3,999
    audit-pin 236, 236, 236, 236, 236, 236 0 1,934

    Same session, same topics. An unstable memory block costs 2.1x the uncached input purely in cache invalidation, every turn. So the historical metric was not measuring what memory saves; it was partly measuring the cache damage memory does.

    What survives

    1. Capture writes the cause, at rule abstraction, in 4 of 5 runs. Storage works.
    2. The row is proven on the wire in the next session. Injection works.
    3. All 18 runs edited warehouse.ts; none masked the symptom. The fixture measures repair.
    4. No cost verdict of any kind is supportable until the metric bills cache. Every cost number in this repo's history that came from runSession().tokens — including the Cheaper auto-capture: measure the cost and add the two switches #365 median drop from 20,506 to 10,009 — is a cache-state artifact and should be retracted rather than explained.

    Consequence for the plan

    Two things follow, in order. First, fix the metric: bill input + output + reasoning + cache.read + cache.write, and record capture's own calls, which were never in the session total either. Second, make the injected block stable, because that is a measured 2.1x on uncached input and it is available now regardless of whether memory turns out to help.

  3. added
    severity:low
    on Nov 14, 2026
  4. added
    tier:standard
    enhancement
    on Nov 23, 2026
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

    benchenhancementseverity:lowtier:standard

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions