Skip to content

fix(cli): stop reporting agent import errors as missing eval extra - #8356

Open
adri0 wants to merge 1 commit into
google:mainfrom
adri0:fix/run-eval-missing-eval-deps-message
Open

adri0 wants to merge 1 commit into
google:mainfrom
adri0:fix/run-eval-missing-eval-deps-message

Conversation

@adri0

@adri0 adri0 commented Nov 25, 2026

Copy link
Copy Markdown

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

Problem:
In the Dev UI run_eval endpoint (POST /dev/apps/{app_name}/eval-sets/{eval_set_id}/run), the try: ... except ModuleNotFoundError wrapped the whole run: the lazy eval imports, but also loading the user's agent, building the LocalEvalService, inference and metric evaluation. Any ModuleNotFoundError from those steps, such as an agent importing a package that isn't installed, came back as HTTP 400 Eval module is not installed, please install via pip install "google-adk[eval]", even when the eval extra was installed.

Solution:
Limit the handler to the five eval imports it is meant to guard, and move the rest of the function out of the try. Errors raised later now surface as themselves, the same way other dev endpoints that load the agent (e.g. add-session) already behave. Ignoring whitespace, the diff only moves the except block up and adds a comment explaining why the guard is kept narrow (git diff -w).

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Added test_run_eval_agent_import_error_is_not_reported_as_missing_eval_deps to tests/unittests/cli/test_fast_api.py. It uses an agent loader that raises ModuleNotFoundError and checks that the response doesn't contain the eval-install message. Without the fix it fails (assert 400 == 500); with the fix it passes.

$ pytest tests/unittests/cli
1616 passed, 5 skipped, 1 xfailed, 515 warnings in 66.08s

pre-commit run --files on both changed files: all hooks pass.

Manual End-to-End (E2E) Tests:

Setup: pip install -e ".[eval]", an agent badagent whose agent.py starts with import some_llm_sdk_not_installed, and an eval set evalset1 with one case. Then run adk web agents and:

curl -X POST localhost:8000/dev/apps/badagent/eval-sets/evalset1/run \
  -H 'content-type: application/json' \
  -d '{"eval_metrics":[{"metric_name":"response_match_score","threshold":0.8}]}'

Before the fix:

{"detail":"Eval module is not installed, please install via `pip install \"google-adk[eval]\"`."}   [HTTP 400]

After the fix, the response is Internal Server Error [HTTP 500] and the server log shows the real cause:

ModuleNotFoundError: Fail to load 'badagent' module. No module named 'some_llm_sdk_not_installed'

I also checked that a normal agent with no API key still works as before: the eval returns 200 with the case marked failed, and the inference error is logged.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules. (N/A)

Additional context

The adk eval CLI and the other places that raise MISSING_EVAL_DEPENDENCIES_MESSAGE already guard only their imports, so they are unaffected.

After this change, a failed agent load during a Dev UI eval returns a plain 500, with the real error in the server log, matching the other agent-loading endpoints. Returning the underlying error text in the response would be a separate change.

The `except ModuleNotFoundError` in the Dev UI `run_eval` endpoint wrapped
the whole run, including loading the user's agent, so a missing package
imported by the agent was reported as "Eval module is not installed".
Guard only the eval imports, and let later errors surface as themselves.

Fixes google#8347
@google-cla

google-cla Bot commented Nov 25, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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.

Dev UI eval reports "Eval module is not installed" for unrelated ModuleNotFoundErrors

1 participant