Add detailed ReAct loop flowchart documentation#4484
Add detailed ReAct loop flowchart documentation#4484bsamadi wants to merge 1 commit intogoogle:mainfrom
Conversation
Traces the full execution path from Runner.run_async() through BaseLlmFlow's while-True loop, covering LLM invocation, parallel tool execution, agent transfer, resumability, and loop termination conditions. Includes Mermaid diagrams and source file references. https://claude.ai/code/session_016VEahaKckWEj9PWBgqr6Yi
|
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. |
Summary of ChangesHello @bsamadi, 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 enhances the documentation for the Google ADK Python library by introducing a detailed guide to its internal ReAct (Reason + Act) loop. The new documentation provides a clear, visual, and structured explanation of the agent's core execution flow, from initial invocation through LLM interaction and tool execution, addressing the complexity of the system's multi-layered architecture. This addition aims to improve understanding for developers and contributors, making it easier to navigate and contribute to the codebase. 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
Activity
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
|
|
Response from ADK Triaging Agent Hello @bsamadi, thank you for your contribution! Before we can merge this PR, you'll need to sign the Contributor License Agreement (CLA). You can do so by following the instructions at https://cla.developers.google.com/. Once the CLA is signed, we can proceed with the review of your documentation addition. Thanks! |
There was a problem hiding this comment.
Code Review
This is an excellent documentation addition. The detailed flowcharts and source code references provide a much-needed comprehensive guide to the internal ReAct loop, which will be incredibly valuable for both new and existing developers working with the ADK. The breakdown of the loop into stages, termination conditions, and key design patterns is very clear and well-structured. I have one minor suggestion to improve the clarity of the detailed flowchart.
| AMC -- altered response --> YIELD_LLM_RESP | ||
| AMC -- no change --> YIELD_LLM_RESP["Yield LlmResponse"] |
There was a problem hiding this comment.
In the _call_llm_async() internals subgraph, the after_model_callback? decision node has two branches (altered response and no change) that both lead to the same Yield LlmResponse step. While correct, this can be simplified for better readability. Since the callback's purpose is to potentially alter the response before it's yielded, a single path from the callback to the yield step would make the diagram cleaner without losing the essential logic. The fact that the response can be altered is implicit in the nature of an after_ callback.
| AMC -- altered response --> YIELD_LLM_RESP | |
| AMC -- no change --> YIELD_LLM_RESP["Yield LlmResponse"] | |
| AMC --> YIELD_LLM_RESP["Yield LlmResponse"] |
Link to Issue or Description of Change
2. Description of Change:
Problem:
The Google ADK Python library's internal ReAct (Reason + Act) loop execution flow is complex, spanning multiple layers and files. Developers and contributors lack a comprehensive visual reference that traces the full execution path from entry point through LLM invocation, tool execution, and loop termination.
Solution:
Added a new documentation file
docs/react-loop-flowchart.mdthat provides:Runner.run_async()throughBaseAgenttoLlmAgentwhile Trueloop inBaseLlmFlow.run_async()is_final_response()logic that determines when the ReAct loop exitsThis documentation serves as a reference guide for understanding the framework's core control flow and will help contributors navigate the codebase more effectively.
Testing Plan
No testing needed — this is a documentation-only change that adds a new reference guide without modifying any source code, tests, or functionality.
Checklist
Additional context
The flowchart uses Mermaid syntax for rendering in GitHub and includes color-coded nodes to distinguish between reasoning steps (blue), action/tool execution (orange), decision points (yellow), and event yields (green). All line number references are approximate and point to the general location of key functions for easy lookup.
https://claude.ai/code/session_016VEahaKckWEj9PWBgqr6Yi