Skip to content

Conversation

@ftnext
Copy link
Contributor

@ftnext ftnext commented Feb 8, 2026

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

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

Problem:
adk eval only resolved agent.root_agent, while AgentEvaluator supports both root_agent and get_agent_async. This inconsistency caused valid agent modules (for AgentEvaluator) to fail in CLI evaluation.

Solution:
Aligned adk eval agent resolution with AgentEvaluator by updating CLI loading logic to support both entry points:

  • root_agent
  • get_agent_async

Implementation details:

  • Made get_root_agent in cli_eval.py asynchronous and added fallback resolution to get_agent_async.
  • Updated cli_tools_click.py to call get_root_agent via asyncio.run(...).
  • Added/updated unit tests for both resolution paths and the error path when neither is present.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.
% pytest tests/unittests/cli

========================= 271 passed, 140 warnings in 7.69s =========================

Manual End-to-End (E2E) Tests:

No manual E2E test was run for this PR.

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.

Additional context

This PR focuses on one scoped item from #4410: agent resolution parity between adk eval and AgentEvaluator (root_agent / get_agent_async).

Align `adk eval` with `AgentEvaluator` by allowing agent modules to expose
either `root_agent` or `get_agent_async`.

- Make `cli_eval.get_root_agent` async and resolve agents from:
  - `agent.root_agent`
  - `agent.get_agent_async()`
- Update `cli_tools_click.cli_eval` to call `get_root_agent` via `asyncio.run`.
- Add unit tests for:
  - `root_agent` resolution
  - `get_agent_async` resolution
  - error when neither entrypoint is defined
- Update CLI eval tests to mock async `get_root_agent` correctly.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ftnext, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an inconsistency in how adk eval resolves agents compared to AgentEvaluator. Previously, adk eval only recognized root_agent, leading to failures for valid agent modules using get_agent_async. The changes ensure that the CLI evaluation tool can now correctly load agents defined with either of these common entry points, improving compatibility and user experience.

Highlights

  • Agent Resolution Parity: The adk eval CLI tool now aligns its agent resolution logic with AgentEvaluator, supporting both root_agent and get_agent_async entry points.
  • Asynchronous Agent Loading: The get_root_agent function in cli_eval.py has been refactored to be asynchronous and includes robust fallback logic to find the agent.
  • CLI Integration: The cli_tools_click.py module now correctly invokes the asynchronous get_root_agent using asyncio.run.
  • Comprehensive Testing: New unit tests have been added to cover both supported agent resolution paths (root_agent and get_agent_async) and the error case where neither is found.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/google/adk/cli/cli_eval.py
    • Updated import from llm_agent.Agent to base_agent.BaseAgent for broader compatibility.
    • Modified get_root_agent to be an async function.
    • Implemented logic within get_root_agent to first check for agent.root_agent, then agent.get_agent_async, and raise a ValueError if neither is present.
    • Ensured get_root_agent returns BaseAgent.
  • src/google/adk/cli/cli_tools_click.py
    • Updated the call to get_root_agent to use asyncio.run to correctly execute the now-asynchronous function.
  • tests/unittests/cli/utils/test_cli_eval.py
    • Added pytest import.
    • Introduced new asynchronous unit tests (test_get_root_agent_supports_root_agent, test_get_root_agent_supports_get_agent_async, test_get_root_agent_raises_without_supported_entrypoint) to validate the updated get_root_agent logic.
  • tests/unittests/cli/utils/test_cli_tools_click.py
    • Modified the mock_get_root_agent fixture to use mock.AsyncMock to correctly mock the asynchronous get_root_agent function.
Activity
  • The author has added and updated unit tests to cover the new agent resolution logic.
  • All unit tests passed locally, indicating the changes are functional and do not introduce regressions.
  • The author performed a self-review of the code, ensuring quality and adherence to guidelines.
  • Code comments have been added, particularly in complex areas, to improve readability and maintainability.
  • The author confirmed that no manual end-to-end tests were run for this specific change.
  • The author confirmed that dependent changes have been merged and published in downstream modules.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@adk-bot adk-bot added the eval [Component] This issue is related to evaluation label Feb 8, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully aligns adk eval with AgentEvaluator by adding support for get_agent_async to resolve the root agent. The implementation is clean, making get_root_agent asynchronous and correctly updating the call site. The unit tests are comprehensive and validate the new logic for both success and failure scenarios. I have one minor suggestion to improve code readability.

@ryanaiagent ryanaiagent self-assigned this Feb 10, 2026
@ryanaiagent
Copy link
Collaborator

Hi @ftnext , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Can you fix lint errors by running autoformat.sh and also update the branch to main.

@ryanaiagent ryanaiagent added the request clarification [Status] The maintainer need clarification or more information from the author label Feb 10, 2026
@ftnext
Copy link
Contributor Author

ftnext commented Feb 11, 2026

Hi @ryanaiagent, thank you for the review!
I've merged main into this branch. I also ran autoformat.sh locally, but no formatting changes were detected for the files in this PR.
Could you let me know which specific lint errors you're seeing? I'd be happy to fix them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eval [Component] This issue is related to evaluation request clarification [Status] The maintainer need clarification or more information from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants