Skip to content

Navigation Menu

Sign in
Sign up

fix(eval): capture stdout when a scenario subprocess fails #3375

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
kovtcharov-amd wants to merge 1 commit into main
base: main
Choose a base branch
Loading
from fix/eval-runner-error-capture
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/gaia/eval/runner.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -984,16 +984,26 @@ def run_scenario_subprocess(
elapsed = time.time() - start

if proc.returncode != 0:
# `--output-format json` puts the CLI's own error on stdout, so stderr
# is routinely empty here — capture both or the failure is unreadable.
detail = (
"\n".join(
f"{name}: {text.strip()[:500]}"
for name, text in (("stderr", proc.stderr), ("stdout", proc.stdout))
if text and text.strip()
)
or f"no output on either stream (exit {proc.returncode})"
)
print(
f"[ERROR] {scenario_id} — exit code {proc.returncode}", file=sys.stderr
)
print(proc.stderr[:500], file=sys.stderr)
print(detail, file=sys.stderr)
result = {
"scenario_id": scenario_id,
"status": "ERRORED",
"overall_score": None,
"turns": [],
"error": proc.stderr[:500],
"error": detail,
"elapsed_s": elapsed,
"cost_estimate": {"turns": 0, "estimated_usd": 0.0},
}
Expand Down
29 changes: 27 additions & 2 deletions tests/test_eval.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1020,14 +1020,14 @@ def _minimal_scenario(self):
"turns": [{"turn": 1, "objective": "x", "success_criteria": "ok"}],
}

def _run(self, mocker, stdout, returncode=0):
def _run(self, mocker, stdout, returncode=0, stderr=""):
import tempfile

from gaia.eval.runner import run_scenario_subprocess

mock_proc = mocker.MagicMock()
mock_proc.stdout = stdout
mock_proc.stderr = ""
mock_proc.stderr = stderr
mock_proc.returncode = returncode
mocker.patch("subprocess.run", return_value=mock_proc)

Expand Down Expand Up @@ -1074,6 +1074,31 @@ def test_nonzero_exit_returns_errored(self, mocker):
assert result["status"] == "ERRORED"
assert result["overall_score"] is None

def test_nonzero_exit_captures_stdout(self, mocker):
"""`--output-format json` puts the CLI's error on stdout, not stderr.

Regression guard for the CI signature where every scenario ERRORED with
an empty `error` field, making the failure impossible to triage.
"""
result = self._run(
mocker,
'{"type":"result","subtype":"error_during_execution"}',
returncode=1,
)
assert result["status"] == "ERRORED"
assert "error_during_execution" in result["error"]

def test_nonzero_exit_captures_both_streams(self, mocker):
result = self._run(mocker, "on-stdout", returncode=1, stderr="on-stderr")
assert "on-stderr" in result["error"]
assert "on-stdout" in result["error"]

def test_nonzero_exit_error_never_empty(self, mocker):
"""A silent exit must still say something — an empty string explains nothing."""
result = self._run(mocker, "", returncode=3, stderr="")
assert result["error"].strip()
assert "exit 3" in result["error"]

def test_missing_status_field_defaulted(self, mocker):
"""Eval agent returning JSON without 'status' should be defaulted to ERRORED."""
payload = {
Expand Down
Loading

AltStyle によって変換されたページ (->オリジナル) /