-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat(web): add list-apps-detailed endpoint #3430
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
Conversation
Summary of ChangesHello @dylan-apex, 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 introduces a significant enhancement to the web server by providing a new endpoint that offers detailed information about registered agents. This addresses the limitation of the existing basic listing endpoint, allowing users to retrieve richer metadata for each agent, including its display name, description, and type. The design ensures efficiency by integrating with the existing agent loading and caching mechanisms, providing a more informative user experience without sacrificing performance. Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this 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 introduces a new /list-apps-detailed endpoint to provide more metadata about available agents, which is a great enhancement. The implementation is mostly solid, with new Pydantic models, a new method in the AgentLoader, and corresponding unit tests.
My review includes a few key points:
- A critical issue in
agent_loader.pywhere a cached agent's state is modified. This could lead to unpredictable behavior elsewhere. - An invalid type hint in the
base_agent_loader.pyabstract method. - A suggestion to improve the robustness of the agent type detection logic.
These changes will improve the correctness and maintainability of the new feature.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
@boyangsvl |
|
@boyangsvl recommended changes made, autoformat ran, and all unit tests pass |
|
@dylan-apex You also need to implement it for InMemoryAgentLoader. Right now, it's failing some tests. Please help fix. |
|
@hangfei I don't have access to see which tests are failing. I also assume you mean I found this commit which hints at an InMemory implementation, but not sure if this is what you mean. |
i meant this one: https://github.com/google/adk-python/pull/3430/files#r2547636742. Thanks. |
|
@hangfei added a default implementation that just pulls the name from the regular |
Merge #3430 **Please ensure you have read the [contribution guide](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) before creating a pull request.** ### Link to Issue or Description of Change **1. Link to an existing issue (if applicable):** - Closes: #3429 **2. Or, if no issue exists, describe the change:** _If applicable, please follow the issue templates to provide as much detail as possible._ **Problem:** The existing `/list-apps` endpoint only returns the name of the folder that each agent is in **Solution:** This adds a new endpoint `/list-apps-detailed` which will load each agent using the existing `AgentLoader.load_agent` method, and then return the folder name, display name (with underscores replaced with spaces for a more readable version), description, and the agent type. This does introduce overhead if you had multiple agents since they all need to be loaded, but by maintaining the existing `/list-apps` endpoint, users can choose which one to hit if they don't want to load all agents. Since the existing `load_agents` method will cache results, there's only a penalty on the first hit. ### Testing Plan Created a unit test for this, similar to the `/list-apps`. Also tested this with my own ADK instance to verify it loaded correctly. ``` curl --location "localhost:8000/list-apps-detailed" ``` ```json { "apps": [ { "name": "agent_1", "displayName": "Agent 1", "description": "A test description for a test agent", "agentType": "package" }, { "name": "agent_2", "displayName": "Agent 2", "description": "A test description for a test agent ", "agentType": "package" }, { "name": "agent_3", "displayName": "Agent 3", "description": "A test description for a test agent", "agentType": "package" } ] } ``` **Unit Tests:** - [X] I have added or updated unit tests for my change. - [X] All unit tests pass locally. 3054 passed, 2383 warnings in 46.96s ### Checklist - [X] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) document. - [X] I have performed a self-review of my own code. - [X] I have commented my code, particularly in hard-to-understand areas. - [X] I have added tests that prove my fix is effective or that my feature works. - [X] New and existing unit tests pass locally with my changes. - [X] I have manually tested my changes end-to-end. - [X] Any dependent changes have been merged and published in downstream modules. COPYBARA_INTEGRATE_REVIEW=#3430 from dylan-apex:more-detailed-list-apps e6864fd PiperOrigin-RevId: 834907771
|
Thank you @dylan-apex for your contribution! 🎉 Your changes have been successfully imported and merged via Copybara in commit b57fe5f. Closing this PR as the changes are now in the main branch. |
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):
2. Or, if no issue exists, describe the change:
If applicable, please follow the issue templates to provide as much detail as
possible.
Problem:
The existing
/list-appsendpoint only returns the name of the folder that each agent is inSolution:
This adds a new endpoint
/list-apps-detailedwhich will load each agent using the existingAgentLoader.load_agentmethod, and then return the folder name, display name (with underscores replaced with spaces for a more readable version), description, and the agent type.This does introduce overhead if you had multiple agents since they all need to be loaded, but by maintaining the existing
/list-appsendpoint, users can choose which one to hit if they don't want to load all agents. Since the existingload_agentsmethod will cache results, there's only a penalty on the first hit.Testing Plan
Created a unit test for this, similar to the
/list-apps. Also tested this with my own ADK instance to verify it loaded correctly.{ "apps": [ { "name": "agent_1", "displayName": "Agent 1", "description": "A test description for a test agent", "agentType": "package" }, { "name": "agent_2", "displayName": "Agent 2", "description": "A test description for a test agent ", "agentType": "package" }, { "name": "agent_3", "displayName": "Agent 3", "description": "A test description for a test agent", "agentType": "package" } ] }Unit Tests:
3054 passed, 2383 warnings in 46.96s
Checklist