GitNexus/eval/workflow_bench/session_budget.py
Gergő Magyar f6127c5aee
feat(eval): measure cost drivers in evaluation summaries (#3773)
* feat(eval): add cost diagnostics and trials

* style(eval): format retrieval case fixtures

* fix(eval): address review and CI failures

Refs #3773. Validate locked uv commands, model aliases and oversized budgets. Stop the fake MCP server before releasing its listener and replace the wall-clock staleness assertion with a concurrent result check.

Note: pre-existing failure in test_oracle_assets.py reference-checkout type resolution not addressed by this PR.

* feat(eval): publish detailed run measurements

Collect per-sweep provider ledgers and publish sanitized measurements in the Actions summary and artifacts. Validate experiment tasks with the runner and withhold incomplete token totals. Refs #3773.

Note: pre-existing failure in test_oracle_assets.py reference-checkout type resolution not addressed by this PR.

* fix(eval): validate inputs and quoted commands

Reject non-mapping task YAML before reading fields. Attribute literal quoted CLI queries while preserving Bash attribution for shell operators and expansions. Refs #3773.

* fix(eval): count empty filtered query results

* fix(eval): handle alternate event content

---------

Co-authored-by: Gergo Magyar <gergomagyar0@gmail.com>
2026-10-30 12:58:34 +00:00

20 lines
589 B
Python

"""Validate opt-in CLI-reported session budgets, not provider billing caps."""
from __future__ import annotations
import math
def session_budget(value: float | None) -> float | None:
if value is None:
return None
message = "--max-budget-usd must be finite and greater than zero"
if type(value) not in (int, float):
raise ValueError(message)
try:
budget = float(value)
except OverflowError as exc:
raise ValueError(message) from exc
if not math.isfinite(budget) or budget <= 0:
raise ValueError(message)
return budget