Skip to content

feat(tier3): add run budget limits with admission control and partial results - #404

Merged
chrisknvidia merged 18 commits into
mainfrom
feat/christopherk/run-budget
Nov 10, 2026
Merged

chrisknvidia merged 18 commits into
mainfrom
feat/christopherk/run-budget

Conversation

@chrisknvidia

@chrisknvidia chrisknvidia commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Tier 3 could limit attempts, concurrency and time, but it had no budget for what a run consumes. This PR adds limits on what the evaluator can measure, enforced before new paid work starts. It does not just report totals afterwards.

  • New options for tier3 evaluate, also settable in the evals config:
    • --max-attempts-total N counts logical attempts across cases, attempts, arms and agents.
    • --max-agent-tokens N uses observed agent tokens.
    • --max-judge-calls N.
    • --max-cost-usd X is allowed only with --price-file PATH, a JSON file of per-model input/output prices per million tokens. A model with no price is an error.
  • Before the run, the planned work is printed. If it already exceeds --max-attempts-total, the run fails fast and no paid work starts.
  • Admission control: each new attempt is checked against usage so far. Once a limit is reached, no new attempts start, and in-flight attempts finish. Unstarted attempts are recorded as not_run with reason budget_exhausted. They are not scored, not counted as failures, and the result is marked partial.
  • The run JSON gets a budget block (limits, used, status, which limit was hit, attempts not run). The CLI and HTML show one line when the budget is exhausted. Usage that couldn't be measured is shown as "not measured", not 0.
  • Docs list what each limit covers and excludes. Setup and container time are not counted.

Verification

  • I am familiar with the Contributing Guidelines
  • Added or updated focused tests
  • Updated documentation for user-visible changes
  • Ran make lint (ruff check and format on the changed files)
  • Ran make test (focused run-budget tests)
  • Ran make build
  • Did not add credentials, private datasets, or proprietary benchmark content

Release Impact

  • No user-visible release note needed
  • Updated CHANGELOG.md

@rng1995 rng1995 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review: 16 findings (3 P1, 7 P2, 6 P3); 16 posted inline.

Checked admission control, usage and cost accounting, the budgeted runner loop, collection of exhausted runs, and the budget wiring through tier3 evaluate, tier3 PATH, validate, catalog children and evals/config.yml, using probes that drive run_harbor_eval and _run_agent_pair with fake Harbor jobs and the real collector.
Tests at 2d236d0: test_run_budget 8 passed; Tier 3 progress, evals config, workflow, stop-on-pass concurrency, timeout recovery, skip-with-skill and runner status suites 414 passed (2 skipped) and 217 passed; CLI surface, result display and command tests 66, 93 and 4 passed.
Merges cleanly into main. Real file conflicts: #384/#388 (cli.py, evaluation/options.py), #387 (cli.py, options.py, tier3/result_display.py), #225 (evaluation/options.py), #400 and #406 (tier3/harbor/runner.py, adjacent appends after results.update), #405 (runner.py, result_display.py) and #398 (docs/tier3-live-evaluation.mdx). The other open PRs conflict at most in CHANGELOG.md; #333 and #368 already conflict with main on their own.
#384: run_config["budget"] is not in _NON_COMPARISON_FIELDS, so any budgeted run is rejected as a baseline source, and planned_attempts is computed before --reuse-baseline sets skip_baseline. Land after #384 (and #387/#388), move the budget block after the reuse decision and exclude budget from the comparison identity.
#384: _budget_usage is a second token reader that disagrees with #384's measured_condition_usage on crashed trials (partial sums vs None), and it leaves our earlier P3 on that function's undercount unaddressed.
#225: --backend nemo-gym ignores the budget flags and harbor.max_* keys and runs unbudgeted with no budget block; whichever PR lands second should pass the budget to Gym or reject the flags there.
#406: not-run attempts stay in expected_attempts, so #406 reports budget_exhausted attempts as execution failures.

Comment thread docs/tier3-live-evaluation.mdx Resolved
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Evaluation run

SkillEvaluator CI results

Required gate: Skipped

Only Tier 1 blocks CI; Tier 2 and Tier 3 are advisory.

Skill Tier 1: Static and Security Validation Tier 2: Deduplication Tier 3: Live Agent Evaluation Report
No skills evaluated SKIPPED · issues unknown · No selected skills changed; Tier 1 evaluation did not run. INCOMPLETE · issues unknown · The tier did not produce retained evidence; inspect its failed or cancelled CI job. INCOMPLETE · issues unknown · The tier did not produce retained evidence; inspect its failed or cancelled CI job. Report

Commit: 1244dc3deaa526cb8b4df4df684ccfb726e92d1f · Environment: docker

Signed-off-by: Christopher Kevin <[email protected]>
…-budget

Signed-off-by: Christopher Kevin <[email protected]>

# Conflicts:
#	CHANGELOG.md
#	docs/tier3-live-evaluation.mdx
…-budget

Signed-off-by: Christopher Kevin <[email protected]>

# Conflicts:
#	CHANGELOG.md
…-budget

Signed-off-by: Christopher Kevin <[email protected]>

# Conflicts:
#	tests/test_evaluation_service.py
…-budget

Signed-off-by: Christopher Kevin <[email protected]>

# Conflicts:
#	CHANGELOG.md
…-budget

Signed-off-by: Christopher Kevin <[email protected]>

# Conflicts:
#	CHANGELOG.md
#	src/skillevaluator/tier3/harbor/runner.py
#	src/skillevaluator/tier3/result_display.py
…-budget

Signed-off-by: Christopher Kevin <[email protected]>

# Conflicts:
#	CHANGELOG.md
Signed-off-by: Christopher Kevin <[email protected]>
Signed-off-by: Christopher Kevin <[email protected]>
Signed-off-by: Christopher Kevin <[email protected]>
Signed-off-by: Christopher Kevin <[email protected]>
Signed-off-by: Christopher Kevin <[email protected]>
Signed-off-by: Christopher Kevin <[email protected]>
@chrisknvidia
chrisknvidia merged commit e6d8c61 into main Nov 10, 2026
22 checks passed
@chrisknvidia
chrisknvidia deleted the feat/christopherk/run-budget branch November 10, 2026 12:48
rng1995 added a commit that referenced this pull request Nov 11, 2026
The RAGAS evidence entries saved each HTTP request RAGAS makes as its own
`ragas` entry in judge_attempts.json. The --max-judge-calls counter added
by #404 counts every non-salvage entry, so one RAGAS score counted as two
judge calls, and an SDK retry after a 503 as three. That contradicts the
documented budget, which leaves out transport retries and requests RAGAS
makes internally.

_budget_usage now skips `ragas` entries that carry a prompt. The entry
without a prompt, which holds RAGAS's score or failure, stays the single
counted call, as on main.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
rng1995 added a commit that referenced this pull request Nov 12, 2026
…ttempts.json (#429)

* feat(tier3): save RAGAS goal-accuracy requests and replies as judge evidence

The RAGAS goal scorer builds its own prompts and parses its own replies,
so judge_attempts.json held only its final score. The AsyncOpenAI client
handed to RAGAS now uses the SDK's default async HTTP client with a
response hook that saves each request and the judge's reply, or the HTTP
error, as a redacted goal_accuracy attempt with method "ragas" and status
"replied" or "error". Evidence failures are only logged and never change
a score; the judge deadline alarm still passes through.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(tier3): describe the saved RAGAS judge requests and replies

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(tier3): make the RAGAS evidence provider stub fail closed

The provider stub patched only httpx.AsyncHTTPTransport. An OpenAI SDK
whose default async client is built on another HTTP stack would skip the
stub and send the tests' requests to the real provider with the fake key.

- The stub now patches the transport class of the SDK's own
  DefaultAsyncHttpxClient, and fails the test before any request when that
  client is not an httpx.AsyncClient.
- An autouse fixture refuses DNS lookups and connections beyond loopback
  and fails the test if one was tried.
- The tests that ignored the stub's request count now check it.
- A failed judge_attempts.json write is logged by _record_judge_attempt
  ("Could not save judge evidence"), not as a RAGAS evidence failure; a
  new test pins that.
- The deadline test is renamed: it pins only that _record_ragas_exchange
  re-raises TimeoutError. In a real request the SDK treats the re-raised
  error as a connection error and retries; the RAGAS time budget
  (asyncio.wait_for) still bounds the run. The earlier commit message
  said more than that.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* test(tier3): keep the RAGAS evidence tests proxy-proof and pin three edge cases

The network-guard test failed when the shell set HTTPS_PROXY: the unstubbed
client looked up the proxy host, not api.openai.com. With ALL_PROXY set to a
SOCKS proxy and no socksio, every stubbed test errored because the clients
could not be built.

- no_network clears HTTP_PROXY, HTTPS_PROXY, ALL_PROXY and NO_PROXY in both
  spellings and sets NO_PROXY=*, so the verifier's client ignores env and
  system proxies.
- The stub's class probe and the guard test's client use trust_env=False.
- The guard test also runs with an HTTPS and a SOCKS proxy set, and a new
  test runs RAGAS through the stub with each proxy set.

New cases pin behavior no test covered:
- _ragas_evidence_http_client re-raises a TimeoutError from the client
  constructor and logs nothing.
- A configured key that straddles the 2000th character of an error body is
  masked whole.
- An unreadable request body names the selected judge model.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(tier3): count one judge call per RAGAS score, not per RAGAS request

The RAGAS evidence entries saved each HTTP request RAGAS makes as its own
`ragas` entry in judge_attempts.json. The --max-judge-calls counter added
by #404 counts every non-salvage entry, so one RAGAS score counted as two
judge calls, and an SDK retry after a 503 as three. That contradicts the
documented budget, which leaves out transport retries and requests RAGAS
makes internally.

_budget_usage now skips `ragas` entries that carry a prompt. The entry
without a prompt, which holds RAGAS's score or failure, stays the single
counted call, as on main.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(tier3): say RAGAS request entries do not count toward --max-judge-calls

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Signed-off-by: Narendran Raghavan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants