Repository navigation
Per-leaf run cost report from pi session streams (E6/E1) - #139
Merged
Merged
Conversation
Adds authoritative per-leaf token/cost capture for the SWE-bench sharing run. The in-harness usage field is unreliable on the pinned pi build (getSessionStats and the getBranch fallback both throw), but the pi session stream in Redis (session:<sessionId>) carries per-assistant-turn usage + pi's own model-accurate cost.total. Every leaf the drivers dispatch uses a sessionId ending in the driver pid (-$$), so a session:*-<pid> scan captures exactly one run's leaves — curve, sweep, and benefit arms alike — with no hot-loop sid threading. - deploy/knative/session-usage.py: brace-matches and sums a leaf's usage stream (input/output/cacheRead/cacheWrite + costUsd from cost.total). - lib.sh: LIB_DIR (locate co-located scripts) + run_cost_report <pid> <outfile> (scan session:*-<pid>, sum each, echo a COST_REPORT summary line). - e6-saturation.sh / e1-benefit.sh: emit COST_REPORT + per-leaf usage on the E6_RESULT/E1B_RESULT lines and into EXPERIMENTS.md. Gated to WORKLOAD=swebench in e6 so the synthetic path output is unchanged. Live-validated on OCP 4.20 against the costed-pilot leaves (haiku): 6 leaves, $0.555/leaf avg, per-leaf costs match pi cost.total exactly. shellcheck + bash -n clean; session-usage.py py_compile clean. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Paolo Dettori <[email protected]>
webchang
added a commit
to webchang/moca
that referenced
this pull request
Nov 23, 2026
…octl#338) CodeQL on PR C (rossoctl#137 js/polynomial-redos, rossoctl#138 and rossoctl#139 js/file-access-to-http, relay-release.ts:62/65/67): - The listener's base URL loses its trailing slashes in a loop (releaseUrl), not with /\/+$/, which backtracks on many slashes. - The release URL and bearer now travel as the control plane's other secrets do: configFromEnv reads them into the config (CpConfig.relayRelease, every profile, with the same boot checks), and the request that needs them builds the releaser from deps.config (releaserOf), as the operator inference token reaches its upstream. Before, depsFromEnv built a releaser that closed over values read from withCredentials' merged env, whose dynamic property writes of file data CodeQL counts as tainting every value read from it, the URL included. deps.relayRelease stays as the test seam. A local CodeQL 2.27.5 run (security-extended, as CI) over the control plane reports the three alerts at the previous head and none here. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: Rong Chang <[email protected]>
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.
Summary
Adds authoritative per-leaf token/cost capture for the SWE-bench sharing run, so E6/E1 report run cost automatically.
The in-harness
usagefield is unreliable on the pinned pi build (bothgetSessionStatsand thegetBranchfallback throw), but the pi session stream in Redis (session:<sessionId>) carries per-assistant-turn usage plus pi's own model-accuratecost.total. Every leaf the drivers dispatch uses a sessionId ending in the driver pid (-$$), so asession:*-<pid>scan captures exactly one run's leaves — curve, sweep, and benefit arms alike — with no hot-loop sid threading.Changes
deploy/knative/session-usage.py— brace-matches and sums one leaf's usage stream →{sid,turns,input,output,cacheRead,cacheWrite,total,costUsd}.lib.sh—LIB_DIR(locate co-located scripts) +run_cost_report <pid> <outfile>: scansession:*-<pid>, sum each leaf, write per-leaf JSONL, echo aCOST_REPORT leaves=… totalTokens=… costUsd=… avgUsdPerLeaf=…summary.e6-saturation.sh/e1-benefit.sh— emitCOST_REPORTon theE6_RESULT/E1B_RESULTlines and intoEXPERIMENTS.md. Gated toWORKLOAD=swebenchin E6 so the synthetic path output is byte-identical.Validation
Live on OCP 4.20 against the costed-pilot leaves (haiku): 6 leaves, $0.555/leaf avg; per-leaf costs match pi's
cost.totalexactly, and the sweep leaves are now captured alongside the curve leaves.shellcheck+bash -nclean;session-usage.pypy_compileclean. No image rebuild — driver-side + a host-run script reading Redis.Assisted-By: Claude Code