Repository navigation
feat(bench): name the counterfactual behind code-execution savings - #1203
Merged
Merged
Conversation
CodeExecSavingFor documented its baseline as "what an agent would have
paid making this call itself" and silently meant "through this proxy".
Those are two different questions with two different answers from the
same log, and a saving whose denominator is unstated cannot be quoted.
BaselineMode makes the choice explicit:
direct (new default) — the agent is wired straight to the upstream MCP
servers, no proxy in the path, so nothing truncates and a sub-call's
full pre-truncation response_bytes is exactly what it reads. The
recorded truncation is an artefact of the RECORD, not the workload:
subCallActivityResponseLimit cuts the stored string at 8KB while
subCallByteSizes measures the whole result.
proxy — the previous behaviour, bit for bit. The agent calls through
call_tool_*, where forwardContentResult cuts each content block at
tool_response_limit, so counting the full size overstates the
baseline and a truncated sub-call withholds the whole call.
Changing the default changes published meaning, deliberately.
tool_response_limit is an mcpproxy feature, so charging the
counterfactual agent for it answers "what did code execution save over
call_tool_*" rather than "what did mcpproxy save me". It also aligns
this figure with the harness's own denominator — modematrix's
baselineCell, "the same agent doing the same tasks with every upstream
tool inline". And the withhold it replaces was not statistically
neutral: it fired precisely on the largest responses, so the surviving
population was biased small with no counter showing the magnitude.
Direct mode never contributes silently. TruncatedSubCalls and
TruncatedBaseline carry the component magnitude, TruncatedCalls and
TruncatedCallSaving the whole-call figures proxy mode would have
discarded, and the CLI prints both beside any total that rests on them.
PricedSavingUSD now refuses a saving that tolerated truncation rather
than relying on the loader happening never to tokenize cut text.
A truncated parent still withholds in both modes: its response is the
proxy term and mcpproxy really did cut it, which no baseline repairs.
ReasonTruncatedRetrieveOverstates is untouched — that is the opposite
direction, where the log stores more than the agent consumed.
Withheld-by-reason tallies are not comparable across modes: a call that
reported truncated_sub_call_overstates_saving may now report the reason
it was always going to hit second.
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
CodeExecSavingFordocuments its baseline as "what an agent would have paid making this call itself" and silently means through this proxy. Those are two different questions, with two different answers from the same log — and a saving whose denominator is unstated cannot be quoted.This adds
BaselineModeand a-baselineflag tocodeexecsaving:direct(new default) — the agent is wired straight to the upstream MCP servers, no proxy in the path. Nothing truncates, so a sub-call's full pre-truncationresponse_bytesis exactly what it reads. The recorded truncation is an artefact of the record:subCallActivityResponseLimitcuts the stored string at 8 KB whilesubCallByteSizesmeasures the whole result, and the value handed to the sandbox is never cut.proxy— today's behaviour, bit for bit. The agent calls throughcall_tool_*, whereforwardContentResultcuts each content block attool_response_limit, so counting the full size overstates the baseline and a truncated sub-call withholds the whole call.Why the default changes
tool_response_limitis an mcpproxy feature. Charging the counterfactual agent for it answers "what did code execution save overcall_tool_*" rather than "what did mcpproxy save me" — and the latter is what users mean. It also brings this figure into line with the harness's own denominator,modematrix'sbaselineCell: "the same agent doing the same tasks with every upstream tool inline".The withhold it replaces is also not statistically neutral: it fires precisely on the largest responses, the ones with the most to save, so the surviving population was biased small in a way no exclusion counter showed as a magnitude. On a real 69-sub-call workload it withheld the entire measurement.
Direct mode never contributes silently
TruncatedSubCalls/TruncatedBaselinecarry the component magnitude;TruncatedCalls/TruncatedCallSavingcarry the whole-call figuresproxywould have discarded (it drops the whole call, not the component — reporting only the component understates what the mode change bought). The CLI prints both beside any total that rests on them.PricedSavingUSDnow enforces that money never rests on tolerated data, instead of relying on the loader happening never to tokenize cut text.Unchanged in both modes: a truncated parent still withholds — its response is the proxy term and mcpproxy really did cut it, which no baseline choice repairs.
ReasonTruncatedRetrieveOverstatesis untouched; that is the opposite direction, where the log stores more than the agent consumed.truncated_sub_call_overstates_savingmay now report the reason it was always going to hit second (mixed_cost_basis,sub_call_zero_bytes). That is a relabelling, not a change in the data.Naming
internal/configalready usesRoutingModeDirect = "direct"for a proxied mode that does truncate, so the value is glossed everywhere it is printed and the collision is called out in theBaselineDirectdoc comment. Happy to rename tounproxiedif you'd prefer the ambiguity gone permanently.Testing
go build ./bench/...,go vet ./bench/...,go test ./bench/...andgo test -race ./bench/...all clean. Changes are confined tobench/(5 files).Existing truncation tests were renamed, not deleted, and now pass
BaselineProxyexplicitly so they keep asserting the old semantics. New coverage: direct/proxy disagreement on one fixture, the zero value resolving todirectin one place, thebaseline_modestamp asserted on the struct tag (not a marshalled instance, which can never carry the zero value), and the proxy pre-pass pinned by reason ordering — without it that fixture reportsmixed_cost_basis, so asserting the withhold alone would pass either way.