Repository navigation
Conversation
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
|
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. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
ModuleNotFoundErrors#8347Problem:
In the Dev UI
run_evalendpoint (POST /dev/apps/{app_name}/eval-sets/{eval_set_id}/run), thetry: ... except ModuleNotFoundErrorwrapped the whole run: the lazy eval imports, but also loading the user's agent, building theLocalEvalService, inference and metric evaluation. AnyModuleNotFoundErrorfrom those steps, such as an agent importing a package that isn't installed, came back as HTTP 400Eval 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 theexceptblock up and adds a comment explaining why the guard is kept narrow (git diff -w).Testing Plan
Unit Tests:
Added
test_run_eval_agent_import_error_is_not_reported_as_missing_eval_depstotests/unittests/cli/test_fast_api.py. It uses an agent loader that raisesModuleNotFoundErrorand checks that the response doesn't contain the eval-install message. Without the fix it fails (assert 400 == 500); with the fix it passes.pre-commit run --fileson both changed files: all hooks pass.Manual End-to-End (E2E) Tests:
Setup:
pip install -e ".[eval]", an agentbadagentwhoseagent.pystarts withimport some_llm_sdk_not_installed, and an eval setevalset1with one case. Then runadk web agentsand:Before the fix:
After the fix, the response is
Internal Server Error [HTTP 500]and the server log shows the real cause: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
Additional context
The
adk evalCLI and the other places that raiseMISSING_EVAL_DEPENDENCIES_MESSAGEalready 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.