Repository navigation
Open
Labels
captureAuto-capture pipeline: envelope compatibility, trigger coverage, trigger economicsenhancementNew feature or requestseverity:mediumReal but narrow: robustness, hygiene, or gated behind multiple preconditionstier:standardBehavior inside an existing pattern: fixer plus full review, no blind arch
Description
Part of #386. Spawned by #387 / PR #394.
Goal
Capture's model call carries a real provider receipt, so the plugin can report its own cost instead of estimating it.
Findings
PR #394 ships an estimate (chars/4, labelled receipt=none) because no receipt exists. This is what was measured, with a throwaway plugin against a running host on 2026-11-11:
ctx.generateexposes exactly one member:text.generate.text({ model, prompt })resolves to{ text }— nousage, notokens.- Capture emits no usage event of its own. Every bench store holds one
status/<session>.jsonand itsmeasuredcovers only the session's turns, so there is no second session to attribute either. ctx.sessionexposescreate,prompt,wait,get.session.createworks from a plugin;session.prompt({ sessionID, model, text })accepted the call and blocked — it did not return within the probe window.
Cost of the thing being measured: roughly 4.7k tokens per session on the bench seat, about a third of the session's own generation, 94% of it reasoning. The estimate cannot see reasoning at all, so it understates.
Acceptance criteria
- A capture call produces provider-reported token counts (input, output, reasoning, cache read) inside the plugin process, not an estimate.
capture_costevidence switches fromreceipt=noneto a named source, andcaptureCost()keeps both kinds distinguishable — a window with mixed sources must not present one as the other.- The
base4transport result is re-verified after the change (empty store 0/5, seeded 5/5). If moving capture onto a session changes what capture writes, that is a behaviour change and the transport result is the thing that would show it. - The estimate path is kept, not deleted: a host that still exposes no receipt must degrade to the labelled estimate rather than to zero.
- The bench's
billedFromand the plugin's own number agree within 2% on the same wire log — this is AC 4 of Bill capture and cache: per-session token accounting the plugin can report itself #387, unreachable until criterion 1 is met.
Two routes, and the cost of each
- Upstream. Ask for
usageon thegenerate.textresult. Cheapest by far; outside this repo's control. ctx.session.create+prompt+wait. Works without upstream, but capture stops being a fire-and-forget text call: it becomes a session, with an agent, a system prompt and a lifecycle. That is a behaviour change to the one component whose output the transport benchmark measures, so criterion 3 is not optional.
Explicit non-goal
Do not raise the estimate's confidence. A chars/4 number does not become a receipt by being rounded, renamed, or moved into a column that looks like the session's.
Metadata
Metadata
Assignees
Labels
captureAuto-capture pipeline: envelope compatibility, trigger coverage, trigger economicsenhancementNew feature or requestseverity:mediumReal but narrow: robustness, hygiene, or gated behind multiple preconditionstier:standardBehavior inside an existing pattern: fixer plus full review, no blind arch
Activity
abogartz commentedon Nov 11, 2026
Partial implementation in #401 — the host limitation is now pinned in CI; AC 1 still needs route 1 (upstream) or a deliberate route-2 decision.
Machine-checked premise. The fake model attaches
usage: {prompt_tokens: 111, completion_tokens: 22, total_tokens: 133}to every final chunk; a standalone probe plugin inside a real host (v2.2.5) on thesession.contextseam records whatctx.generate.textresolves to:generateKeys=["text"],resultKeys=["text"],usage=null— with the provider's numbers on the wire. The gap is the host's contract, not the provider's silence. When upstream ships usage the test fails on purpose and becomes the trigger to flipcapture_costoffreceipt=none.Route 2 not taken, deliberately:
session.create+prompt+waitmakes capture a session with an agent and lifecycle — a behaviour change to the one component the transport benchmark measures — and the original probe foundsession.promptblocked within the probe window. AC 3 exists for exactly that risk; taking it needs a quiet seat with the transport arm ready (F19).AC 4 already met by #394: no receipt degrades to the labelled chars/4 estimate, never a zero; #401 touches no production path.
The upstream ask (route 1), for forwarding: Please expose provider-reported
usage(input, output, reasoning, cache read/write) on thegenerate.textresult in the plugin context. Capture cost is currently unbillable: the provider sends usage on the wire, the host drops it at the plugin boundary, and a chars/4 estimate cannot see reasoning at all — which is 94% of the capture call. Probe and repro: #401.test(e2e): prove the receipt-gap premise from the provider side (#395)
Merge pull request #401 from abogartz/395-receipt-characterization