Introduce Retry and Reflect pluging#564
Conversation
Summary of ChangesHello @caglar10ur, 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 new Go plugin designed to enhance the robustness of tool interactions by implementing a retry and reflection mechanism. It allows tools to gracefully handle failures, providing structured guidance for self-correction and preventing infinite loops of failed attempts. The plugin is configurable to suit different error handling strategies and ensures concurrent-safe tracking of tool failures. Highlights
🧠 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
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.
Code Review
This pull request introduces a Go version of the Python RetryAndReflect plugin, which provides self-healing and error recovery for tool failures. My review focuses on improving the public API of this new plugin by adopting the idiomatic functional options pattern for its constructor, which will enhance flexibility and usability. I've also suggested a minor naming change for consistency and pointed out an opportunity to reduce code duplication by extracting a helper method. These changes aim to make the new plugin more robust and maintainable.
71c8e51 to
a375636
Compare
|
dpasiukevich
left a comment
There was a problem hiding this comment.
Thanks for the PR!
+1 to both comments from @verdverm 2nd point could be left to be done later, but if you have the possibility to add this, this would've been perfect! |
For the 1 - the main reason I used separate printfs way was to be able to use backticks and use the same exact prompt that adk-python uses, the multiline string does not support `s and I didn't want to create additional files for template texts. I can make them something like this but I personally find the multiple printfs more readable. Let me know if you have any preferences? For the 2 - I probably want to do that as a follow up (so thatI can start using this immediately). |
7fa6b64 to
7eda14f
Compare
|
Honestly, it's all the operators and function calls that make it unreadable. In example: are those quotes, plus signs, and ticks in the message or not? I have to do far too much mental parsing, gofmt whitespace rules are going to undo any readability whitespace introduced. I'd personally put the content in a file and then My general preference is to align with Go practices over Python for the sake of keeping things visually the same between implementations. As the number of languages increase (there are now 4), it's going to become impossible anyway. |
|
I agree, Let me know if it looks good to you and it would be ok to update this, otherwise I could update it later. I don't have a strong preference here. Thanks! |
7eda14f to
67882a5
Compare
|
@verdverm @dpasiukevich PTAL - I moved them into templates as you suggested. |
|
@caglar10ur, lgtm Clarifying question, these templates are part of the tool response payload the agent sees on the next turn and do not create additional LLM calls, correct? (i.e. there are now additional fields it can pay attention to) Are there docs on how to use this in my application? (even if for python) |
|
@verdverm correct - the guidance is added to the response so that model can figure out what to do next. That being said using the pluging will cause additional LLM and tool calls. Its purpose is to provide reflection guide to the model for retry. E.g. Without this plugin you call a tool and it returns some kind of resource exhausted error and agent will probably return the error to you. With the plugin enabled, the plugin will recommend model to understand and course correct, model will think the resource exhausted is not permanent and try calling the tool again. There is https://google.github.io/adk-docs/integrations/reflect-and-retry/ (but obviously only for python). |
|
ok, the retry is certainly expected, I had wondered before reading closer if those were prompts to some "micro" agent that keeps the retry and extra events out of the main session history and main agent context, which would be cool too |
This is the Go version of the Python plugin (https://github.com/google/adk-python/blob/main/src/google/adk/plugins/reflect_retry_tool_plugin.py)