-
Notifications
You must be signed in to change notification settings - Fork 162
fix(eval): drive the agent eval with the OAuth token, and probe it for real #3403
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
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
08c3f18
fix(eval): drive the agent eval with the OAuth token, and probe it fo...
7ccaeab
fix(eval): launch the eval MCP server with the interpreter that has GAIA
d06ae59
fix(eval): warm the MCP import and widen its startup window
b7b6a42
Revert "fix(eval): warm the MCP import and widen its startup window"
b21078b
fix(eval): keep the MCP server's stderr instead of discarding it
8eccb9f
fix(eval): install the mcp extra the gate depends on
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| #!/usr/bin/env python | ||
| # Copyright(C) 2026 Advanced Micro Devices, Inc. All rights reserved. | ||
| # SPDX-License-Identifier: MIT | ||
| """Launch the Agent UI MCP server with its stderr preserved. | ||
|
|
||
| The eval spawns this server once per scenario, as a grandchild: the runner | ||
| starts ``claude -p``, and ``claude -p`` starts the server. When the server dies | ||
| the client reports only ``CONNECTION_CLOSED``, and the server's own stderr goes | ||
| nowhere — it is not the scenario subprocess, so capturing *that* process's | ||
| output (#3375) does not reach it either. | ||
|
|
||
| Three runs of the eval gate were spent inferring a cause from timings that one | ||
| line of this log would have stated outright. So: exec the real server in-process | ||
| with stderr tee'd to a file the workflow uploads. | ||
|
|
||
| stdout is untouched and unbuffered. It carries the MCP protocol, and a single | ||
| stray byte on it desynchronises the client — which is why the diagnostics go to | ||
| a file rather than to stderr-as-console or, worse, to stdout. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import os | ||
| import runpy | ||
| import sys | ||
| import traceback | ||
| from datetime import datetime, timezone | ||
| from pathlib import Path | ||
|
|
||
| #: Where to tee stderr. The workflow uploads this directory as an artifact. | ||
| _LOG_DIR = Path(os.environ.get("GAIA_MCP_LOG_DIR", "eval-out")) | ||
| _LOG_PATH = _LOG_DIR / "mcp-server.err.log" | ||
|
|
||
|
|
||
| class _Tee: | ||
| """Write to both the real stderr and the log, so neither is lost.""" | ||
|
|
||
| def __init__(self, *streams): | ||
| self._streams = streams | ||
|
|
||
| def write(self, data): | ||
| for stream in self._streams: | ||
| try: | ||
| stream.write(data) | ||
| stream.flush() | ||
| except Exception: # noqa: BLE001 - a broken tee must not kill the server | ||
| pass | ||
| return len(data) | ||
|
|
||
| def flush(self): | ||
| for stream in self._streams: | ||
| try: | ||
| stream.flush() | ||
| except Exception: # noqa: BLE001 | ||
| pass | ||
|
|
||
|
|
||
| def main() -> int: | ||
| try: | ||
| _LOG_DIR.mkdir(parents=True, exist_ok=True) | ||
| log = open(_LOG_PATH, "a", encoding="utf-8", errors="replace") | ||
| except OSError: | ||
| # A log we cannot open must not stop the server from starting. | ||
| log = None | ||
|
|
||
| if log is not None: | ||
| sys.stderr = _Tee(sys.stderr, log) | ||
| stamp = datetime.now(timezone.utc).isoformat(timespec="seconds") | ||
| print( | ||
| f"\n=== MCP server launch {stamp} pid={os.getpid()} " | ||
| f"python={sys.executable} ===", | ||
| file=sys.stderr, | ||
| ) | ||
|
|
||
| # argv[0] must look like the module's own invocation, and the --stdio flag | ||
| # the config passes has to survive. | ||
| sys.argv = ["gaia.mcp.servers.agent_ui_mcp", *sys.argv[1:]] | ||
| try: | ||
| runpy.run_module("gaia.mcp.servers.agent_ui_mcp", run_name="__main__") | ||
| except SystemExit as exc: | ||
| code = exc.code if isinstance(exc.code, int) else 0 | ||
| print(f"=== MCP server exited with {code} ===", file=sys.stderr) | ||
| return code | ||
| except BaseException: # noqa: BLE001 - the whole point is to record it | ||
| print("=== MCP server raised ===", file=sys.stderr) | ||
| traceback.print_exc(file=sys.stderr) | ||
| return 1 | ||
| return 0 | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| sys.exit(main()) |
Oops, something went wrong.
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.