Skip to content

Conversation

@voborl00
Copy link

@voborl00 voborl00 commented Dec 1, 2025

This PR enhances AgentTool to support hierarchical agent execution with shared context and persistence with unbroken backward-compatibility.
Currently, AgentTool always instantiates fresh in-memory services (Session, Artifact, Memory) and no plugins for the sub-agent. This change adds a new factory method AgentTool.create(...) that allows injecting existing service instances and a list of plugins.
This enables scenarios where a parent agent needs to share a specific session store or memory context with a sub-agent, or when specific plugins (like logging or observability) need to be propagated to the sub-agent's runner.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @voborl00, 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 significantly upgrades the AgentTool's flexibility by allowing developers to define and pass custom service implementations and plugins to sub-agents. This capability is crucial for building more sophisticated and interconnected agent systems where state, data, and extended functionalities need to be consistently managed across different levels of agent interaction. The update ensures that agents can operate within a shared environment, improving overall system coherence and extensibility.

Highlights

  • Hierarchical Agent Execution: The AgentTool now supports hierarchical agent execution, allowing sub-agents to inherit or share services and plugins from their parent agents.
  • Injectable Services and Plugins: A new factory method AgentTool.create(...) has been introduced, enabling the injection of existing Session, Artifact, and Memory service instances, as well as a list of BasePlugin implementations, into sub-agents.
  • Shared Context and Persistence: This enhancement facilitates scenarios where parent agents need to share specific session stores, memory contexts, or propagate plugins (like logging or observability) to their sub-agents, ensuring consistent context and persistence.
  • Backward Compatibility: The changes maintain unbroken backward compatibility, meaning existing AgentTool usages without explicit service/plugin injection will continue to function as before, using in-memory defaults.
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.

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 enhances AgentTool to support custom services and plugins, which is a great step towards more flexible and hierarchical agent execution. The changes introduce a new factory method for AgentTool and update the runner to use injected services, maintaining backward compatibility. The implementation is solid, but I've identified one area for improvement regarding error handling that could make the code more robust.

@voborl00
Copy link
Author

voborl00 commented Dec 1, 2025

/gemini review main...appsatori:adk-java:main

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 enhances AgentTool to support custom services and plugins, which is a valuable improvement for enabling hierarchical agent execution with shared context. The changes are well-implemented, adding a new factory method for dependency injection while maintaining backward compatibility. The accompanying tests effectively validate the new functionality. I have a couple of suggestions to enhance robustness and code clarity.

@voborl00 voborl00 force-pushed the main branch 2 times, most recently from de22d3d to 7b524cf Compare December 1, 2025 18:11
@voborl00
Copy link
Author

voborl00 commented Dec 1, 2025

/gemini review
i have implemented all requested changes and squashed into single commit, should be all good now

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 effectively enhances AgentTool to support custom services and plugins, which is a great step towards more flexible and hierarchical agent compositions. The changes maintain backward compatibility and are well-tested. I have a couple of minor suggestions to improve code clarity by adding @Nullable annotations to the new methods, aligning with the existing coding style.

@voborl00
Copy link
Author

voborl00 commented Dec 1, 2025

Nullable annotations added
/gemini review

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 enhances AgentTool to support custom services and plugins, enabling hierarchical agent execution with a shared context. The changes are well-implemented, maintaining backward compatibility by providing default in-memory services when none are injected. The new factory method provides a clean way to extend AgentTool's functionality. I've added a couple of suggestions to improve the test coverage for the new user ID propagation logic.

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.

1 participant