feat(runner): zero-trust cost re-metering + crash-safe whole-repo output#39
Open
isPANN wants to merge 2 commits into
Open
feat(runner): zero-trust cost re-metering + crash-safe whole-repo output#39isPANN wants to merge 2 commits into
isPANN wants to merge 2 commits into
Conversation
Meter cost from token usage × declared price (not a self-reported total), and make whole-repo runs durable so an early-stop/crash keeps the found bugs. - cost: submissions carry usage_totals (4 token buckets) + prices; the backend recomputes total_cost_usd/efficiency from them and ignores the self-reported figure (mirrors the zero-trust bug re-verification). whole-repo now surfaces its session-level 4-bucket usage (was dropped). - whole-repo durability: the agent appends each certificate to TRAJECTORY_DIR/certs.txt the moment it finds it; the trajectory is persisted every step (output_path); the runner harvests certs from BOTH the trajectory and the disk log (deduped). - fix trajectory loss: output_path was unset and trajectory_dir was never passed, so the --rm'd container dropped everything. Both are now wired, with TRAJECTORY_DIR exposed as a config knob. - versioned output: submission.json stays the stable "latest" pointer; a submission-<model>-<timestamp>.json archive is written beside it so runs don't clobber each other. - envelope self-describes: adds usage_totals, prices, agent_mode. - docs (submission.env.example, skill field table + SKILL.md), schemas, and tests updated. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…, cert capture, crash salvage) The whole-repo runner mis-handled native tool-calling models (e.g. Qwen via an OpenAI-compatible endpoint), wasting the budget and scoring 0 even when the model emitted certificates. Three fixes, verified end-to-end on a real Qwen run. - observation truncation was silently dropped: the runner loaded config['agent'] but never wired config['model'], so mini-swe-agent used its DEFAULT (non- truncating) observation_template. A big command result (`pred list --rules`, ~57k chars) then flooded the context and was re-sent every step. Now _build_model threads observation_template + format_error_template through, and both configs use the SWE-agent head+tail elision (5k head + elided-count + 5k tail) instead of head-only [:8000]. Max observation dropped 57k -> 10k. - certificates from tool-calling models were unreadable: they leave content="" and narrate the CERTIFICATE block in reasoning_content. parse_certificate / parse_all_certificates now scan both channels (_message_text), and the stored trajectory folds reasoning_content into content so the backend's provenance + re-parse see it too. - whole-repo had no crash guard: a fatal model error (quota/auth/network) is not a clean LimitsExceeded, so it propagated and left a STALE submission.json. run_repo_session now catches it, salvages partial results from messages + certs.txt, and tags the envelope with run_error so a crash can't masquerade as a clean 0-bug run. Tests: +6 (reasoning-channel parse, cross-channel dedup, crash salvage). 180 pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
What
Two related runner improvements: meter cost from token usage × declared price (not a self-reported total), and make whole-repo runs durable so an early-stop/crash keeps the bugs already found.
Changes
Zero-trust cost metering (mirrors the existing zero-trust bug re-verification)
usage_totals(the 4 billed token buckets: input / output / cache_read / cache_write) + the declaredpricessnapshot.total_cost_usdand the efficiency metrics fromusage_totals × pricesand ignores the self-reported total. Legacy submissions without these fields fall back to the reported figure.Whole-repo durability
TRAJECTORY_DIR/certs.txtthe moment it finds it (new{{certs_file}}prompt slot); the runner harvests certificates from both the trajectory and that disk log (deduped by rule+source).output_pathwas unset andtrajectory_dirwas never passed, so the--rm'd container dropped the whole trajectory. Both are now wired, andoutput_pathmakes mini-swe-agent persist the trajectory after every step (crash-proof).TRAJECTORY_DIRis exposed as a config knob.Versioned output
submission.jsonstays the stable "latest" pointer (prb submitreads it); every run also writessubmission-<model>-<timestamp>.jsonbeside it, so runs don't clobber each other.usage_totals,prices,agent_mode.Docs / schema / tests
submission.env.example, the run-benchmark skill (field table + SKILL.md), and both JSON schemas updated.176 passed.Notes
benchmark/+config_repo.yamlare baked in).🤖 Generated with Claude Code