Skip to content

ci(eval): keep judge credentials away from the agent under test - #4001

Merged
kovtcharov-amd merged 1 commit into
amd:mainfrom
kovtcharov:claude/eval-ci-hardening
Sep 19, 2026
Merged

kovtcharov-amd merged 1 commit into
amd:mainfrom
kovtcharov:claude/eval-ci-hardening

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

The agent eval now keeps the Claude credentials in the one process that needs them. Its public artifact carries only scores. Before this change, the agent under test shared an environment with the judge's credentials, the judge had general-purpose tools it never used, and the job uploaded full transcripts and logs, which GitHub does not scrub the way it scrubs job logs. To triage a regression, rerun the same gaia eval agent --category command locally.

🔍 Technical details
  • Backend credentials. The Agent UI backend is started with CLAUDE_CODE_OAUTH_TOKEN and ANTHROPIC_API_KEY removed from its environment, and both are restored for the claude -p driver.
  • Driver tools. The driver runs with --tools "", which drops built-in tools and keeps MCP. Verified locally with Claude Code 2.1.271: the driver still lists and calls all 15 gaia-agent-ui MCP tools and has no Bash, Read, Write or WebFetch. test_eval_launch_contract.py pins the flag.
  • Artifact. Now eval-out/*/scorecard.json and summary.md only, kept for 14 days. A step before upload scans those files for the three secret values and refuses to upload any file that contains one.
  • Docs and comments. The upload recipes in docs/guides/eval-ci.mdx upload scorecards only, and a warning now covers the backend environment. The MCP launcher's comment no longer says its log is uploaded.

Test plan

  • pytest tests/unit/test_eval_launch_contract.py tests/unit/eval: 541 pass. The 1 failure is the existing macOS python-not-on-PATH case (fix(eval): eval gate loses all its tools where there is no bare python on PATH #3981) and is identical on main.
  • claude -p --tools "" --mcp-config <eval config> lists only mcp__gaia-agent-ui__* tools and calls them.
  • One run of this workflow on a same-repo branch. Fork PRs skip it, so a maintainer has to push the branch. Check the backend comes up healthy, the credential scan prints no credential found, and the artifact holds only scorecard.json and summary.md.

The eval's agent can run shell commands, and until now it ran in a process
that held the Claude credentials the judge uses, while the job uploaded full
transcripts and logs to a public artifact that GitHub does not scrub.

- The Agent UI backend now starts without the judge's credentials; only the
  `claude -p` driver keeps them.
- The driver runs with no built-in tools (`--tools ""`). It only ever needed the
  agent UI's MCP tools, and it no longer has shell, file or web access.
- The artifact is now scorecards and summaries only, kept 14 days, and a step
  refuses to upload any file containing a credential. Traces and logs stay on
  the runner; reproduce a regression locally to get them.
- The eval CI guide's examples upload scorecards only and warn against giving
  the backend credentials.
@github-actions github-actions Bot added documentation Documentation changes devops DevOps/infrastructure changes eval Evaluation framework changes tests Test changes performance Performance-critical changes labels Sep 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Approve with suggestions

This tightens the agent eval's blast radius in three sensible ways: the backend the agent runs in no longer inherits the judge's Claude credentials, the judge driver loses its shell/file/web tools, and the public artifact shrinks to scorecards with a pre-upload secret scan. The direction and the mechanics are right.

The one thing worth fixing before merge: the PR says the artifact now "carries only scores," but the scorecard file that still ships contains every turn's user message and agent response — the same transcript content the dropped trace files held. So removing the traces didn't remove that data from the public download; it only removed a duplicate copy and the convenience of having it split per scenario. The literal-value scan is the real protection here, and it only catches the three named secrets spelled out verbatim. Either keep the traces (they cost nothing extra now) or strip the transcript fields from the copy that gets uploaded — and either way, reword the "reproduce locally to get the traces" note, which currently misleads.

Everything else is minor: one line in the CI guide still tells readers to open a trace file to diagnose a CI regression, and the scan step prints an all-clear when it scanned zero files.

I confirmed the --tools "" flag is genuine and does what the PR claims, not just that the test pins it.

Real-world evidence

No evidence-bundle.md was produced for this PR (CI-lane evidence N/A), and the author's own test-plan item for a real workflow run is still unchecked — that run is the only thing that can show the backend still comes up healthy without the credentials and that the scan prints its clean line. I did verify the new CLI flag directly on this runner (Claude Code 2.1.271):

  --tools <tools...>                    Specify the list of available tools from
                                        the built-in set. Use "" to disable all
                                        tools, "default" to use all tools, or
                                        specify tool names (e.g.
                                        "Bash,Edit,Read").

pytest isn't installed in this review environment, so I could not re-run the unit suite; the rest of the verdict rests on static review. The PowerShell credential-handling and scan logic in particular has not been exercised anywhere — please land the same-repo workflow run before treating it as proven.

🔍 Technical details

🟡 Important

The uploaded scorecard still contains full transcripts (.github/workflows/test_eval_agent_gemma_consolidation.yml:1047)

run_scenario_subprocess's result dict is written twice: once to traces/<scenario_id>.json (src/gaia/eval/runner.py:1281) and once into scorecard["scenarios"] (src/gaia/eval/scorecard.py:178). They are the same payload. Confirmed against a committed baseline — scenarios[].turns[] carries user_message, agent_response, agent_tools, reasoning, and on ERRORED scenarios an error field holding up to 500 chars of the claude CLI's own stdout/stderr:

scenario keys: ['scenario_id', 'status', 'overall_score', 'turns', 'root_cause', ...]
turn keys: ['turn', 'user_message', 'agent_response', 'agent_tools', 'scores', ...]

Consequences:

  1. The stated threat model — "an agent that runs shell commands could put host state into a public artifact" — is unaddressed for anything the three-value Select-String scan can't match verbatim (encoded, split, or any secret other than the three named).
  2. The comment at line 1047 ("Reproduce a regression locally … to get the traces") overstates what was lost: nothing in the traces is absent from scorecard.json.

Pick one: keep traces/ (no new exposure, restores per-scenario triage), or strip turns[].user_message / turns[].agent_response / turns[].reasoning from the artifact copy and keep the full file on the runner. Don't leave the comment claiming a reduction that didn't happen.

🟢 Minor

Same doc now contradicts itself on traces (docs/guides/eval-ci.mdx:369) — the new tip at :492 says don't upload traces/, but the regression-diagnosis section still points readers at the trace file with no note that it is local-only. Per CLAUDE.md's doc-sync rule, both surfaces move together.

Regressions are highlighted and should block the PR. The trace file (`traces/simple_factual_rag.json`) contains the full conversation, dimension scores, and reasoning to help diagnose the issue — it stays on the machine that ran the eval, so re-run the same `gaia eval agent --category` command locally to produce it.

Scan reports a clean bill after scanning nothing (.github/workflows/test_eval_agent_gemma_consolidation.yml:1224) — if eval-out/ is missing or the -Include filter matches nothing, $files is empty and every secret loop continues, printing Scanned 0 file(s): no credential found. For a defense-in-depth gate, "scanned nothing" and "found nothing" should read differently in the log.

          if ($files.Count -eq 0) {
            Write-Host "::warning::No scorecard.json or summary.md under eval-out - nothing was scanned (and nothing should upload)."
          } else {
            Write-Host "Scanned $($files.Count) file(s): no credential found."
          }

The scan list and the upload list are two copies (:1205 and :1230-1231) — scorecard.json, summary.md is spelled out in the scan's -Include and again in the upload path:. Add a third file to the upload and it ships unscanned. A one-line comment on each pointing at the other is enough if you'd rather not restructure.

Strengths

  • The credential removal is placed correctly. Start-Process snapshots the child's environment at creation, so stripping the vars immediately before the call and restoring right after gives the backend a clean environment without disturbing the gaia eval agent invocation later in the same step. The restore also correctly skips vars that were originally unset/empty, which preserves the existing --bare selection logic in runner.py:961.
  • --tools "" is the right primitive and the prompts survive it. I checked the three inlined prompt files and the scenario prompt: the only tools the driver is told to use are mcp__gaia-agent-ui__*, and the corpus paths at runner.py:494-496 are handed to the MCP index_document call (server-side), not read by the driver. The pre-existing comment at runner.py:444 claimed the subprocess had no file-read tool — this PR makes that comment true rather than aspirational.
  • The web_system/vision guard comment at the category list is the kind of note that prevents a future well-meaning "let's measure more categories" PR from re-opening this.
  • retention-days: 14 cuts the exposure window from the 90-day default — small, and easy to forget.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Sep 19, 2026
Merged via the queue into amd:main with commit e97123f Sep 19, 2026
36 checks passed
@kovtcharov

Copy link
Copy Markdown
Contributor Author

Right: the scorecard carried the whole conversation, so dropping traces/ removed nothing. The artifact now holds a public copy of each scorecard, with every score and status kept but none of the conversation text. The full scorecard stays on the runner for the baseline comparison.

🔍 Technical details
  • 🟡 Transcripts in the upload. New gaia.eval.scorecard.public_scorecard() and python -m gaia.eval.scorecard IN OUT. It drops turns[].user_message, agent_response, reasoning and error, plus scenarios[].error, and keeps scores, pass, failure_category, tool names, root_cause and timing.
    • The collect step writes eval-out/<category>/scorecard.public.json next to the full copy that --compare reads, and the upload and scan use only the public copy and summary.md, which holds counts only.
    • The comment that claimed a reduction is rewritten.
    • tests/unit/eval/test_public_scorecard.py pins what is removed and kept, and checks that a line from the conversation doesn't survive the command.
  • 🟢 eval-ci.mdx:369. It now says the trace stays on the machine that ran the eval. The four example workflows make and upload the public copy too, and the best-practice bullet and warning say why.
  • 🟢 Empty scan. Zero files scanned now prints a ::warning::, not "no credential found".
  • 🟢 Two copies of the file list. The scan step and the upload step each carry a comment pointing at the other.
  • Tests: pytest tests/unit/eval tests/unit/test_eval_launch_contract.py gives 543 passed. The 1 failure is the macOS python-not-on-PATH case (fix(eval): eval gate loses all its tools where there is no bare python on PATH #3981), identical on main. util/check_doc_links.py passes, the YAML parses, and every run: body is ASCII.
  • Still open: the same-repo workflow run. It can go through the combined claude/eval-ci-combined branch, which tests ci(eval): keep judge credentials away from the agent under test #4001 and feat(eval): gate CI on the flagship agent's outcome-scored tasks #4007 together.

kovtcharov pushed a commit to kovtcharov/gaia that referenced this pull request Sep 19, 2026
Addresses review on amd#4001: dropping traces removed nothing, because
scorecard.json carries the same conversation. The eval now writes
scorecard.public.json (python -m gaia.eval.scorecard): every score and
status kept, what the simulator and agent said, the judge's reasoning and raw
CLI error text removed. Only that copy and summary.md upload; the full
scorecard stays on the runner for the compare step.

The credential scan warns when it scanned nothing instead of reporting a clean
result, and its file list and the upload's point at each other. The CI guide's
examples upload the public copy, and its regression section says traces stay
on the machine that ran the eval.
kovtcharov pushed a commit to kovtcharov/gaia that referenced this pull request Sep 19, 2026
Same fix as amd#4001's scan: zero files scanned is a warning, not a clean result, and the scan and upload lists point at each other.
kovtcharov added a commit to kovtcharov/gaia that referenced this pull request Sep 19, 2026
…#4007)

CI never ran the flagship GaiaAgent, and never checked whether its code
changes work. The only agent eval is ChatAgent answering questions about
documents, scored by an LLM's opinion. This adds a CI job that gives the
flagship four real tasks: explain a file, fix a bug with a regression
test, build a weekly CSV report, and add an env-var config option.
Coding tasks are scored by what the finished project does; question
tasks are decided by the judge against the points a correct answer must
establish. Claude grades quality in one call, and the job fails on a
missed expectation for passes, quality, honesty, tokens, steps or
runtime. Every report puts main's committed results beside the current
run. It runs on GAIA's embedded Lemonade, in the same report-by-default
/ `enforce` policy as the existing categories.

The first run on current main already finds real problems. Kimi K2
passed all 4 tasks, but quality was 3.4/5: pytest was refused before it
ran, stray `.bak` files were left behind, and one answer claimed "all
tests pass" while admitting pytest never ran.

<details>
<summary>🔍 Technical details</summary>

- **`gaia eval tasks run | judge | gate`** in
`src/gaia/eval/flagship_tasks.py`. Tasks and the `core` (4) and `full`
(8) suites live in `eval/tasks/tasks.json`; the fixture project is
`eval/tasks/toybox`.
- **Isolation.** Each task gets a fresh copy of the project in a temp
dir, and the agent's `allowed_paths` is exactly that copy. `run` pops
`CLAUDE_CODE_OAUTH_TOKEN` and `ANTHROPIC_API_KEY` from its own
environment before the agent starts. In CI those credentials exist only
in the judge step.
- **Judge.** `claude -p --tools ""` in an empty temp directory, given
the original project, the answer and the diff. A task with no usable
grade is recorded as unjudged, and the gate fails its quality checks
rather than skipping them.
- **Gate.** Expectations live in
`eval/tasks/expectations/<model>.<suite>.json`, tied to model, suite and
judge model. The file holds main's measured results (overall and per
task, with commit and runner) plus the limits. The report reads `Main |
This run | Limit`. `--propose` writes that file from a run with
headroom: one task may flip, quality may drop 0.5, tokens and steps may
grow 35%, and runtime may grow 50%. Limits move only through a reviewed
commit. No file is committed yet: the first runner run's artifact
carries the proposal.
- **Excluded tasks.** Six of the bench's 14 tasks are left out. Five
need a GitHub token inside the agent's environment, and the
shell-injection task relies on Unix shell behaviour that the Windows
runner lacks.
- **Workflow.** A new `flagship-tasks` job sits before `agent-eval`, so
it doesn't overlap amd#4001's hunks. It adds a `task_suite` dispatch input
and triggers on `eval/tasks/**`. The artifact is the scorecard plus
proposed expectations, scanned for credentials, kept 14 days. Every
`run:` body is pure ASCII.
- **Local token counts.** Gemma under-reports tokens until amd#4005 lands.
Capture expectations after it, or the token limits will be about 2-16x
too low.
</details>

## Test plan

- [x] `pytest tests/unit/eval/test_flagship_tasks.py`: 67 pass (plus the
opt-in live judge check, which passes: 10/10 verdicts in one call). Each
coding task fails on the untouched project and passes a reference
solution. Credentials never reach the agent. The judge gets no tools.
Every gate metric can fail on its own. Report vs. enforce exit codes are
covered.
- [x] `pytest tests/unit/eval tests/unit/test_cli*.py
tests/unit/test_eval*.py`: 725 pass. The 1 failure is the macOS
`python`-not-on-PATH case (amd#3981), identical on main.
- [x] End to end on Kimi K2 via Lemonade: `run` passed 4/4 in 190 s,
`judge` graded all 4, `gate` without expectations reported and exited 0,
and `--propose` followed by `gate --enforce` against that proposal
exited 0.
- [x] `pylint`, `black`, `isort`, `flake8` on the new code;
`util/check_doc_links.py` passes; the workflow YAML parses and every
`run:` body is ASCII.
- [ ] First run on the Strix Halo runner (needs a same-repo branch,
since fork PRs skip it). Check that the embedded Lemonade starts with
`llamacpp:vulkan`, all 4 tasks run, and the artifact holds
`scorecard.json` and `proposed-expectations.json`.
- [ ] Commit that proposal as
`eval/tasks/expectations/Gemma-4-E4B-it-GGUF.core.json` (after amd#4005) to
switch the gate on.

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devops DevOps/infrastructure changes documentation Documentation changes eval Evaluation framework changes performance Performance-critical changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants