fix: set output schema when mode==task and outputs schema is set#4872
fix: set output schema when mode==task and outputs schema is set#4872sasha-gitg wants to merge 2 commits intogoogle:v2from
Conversation
Summary of ChangesHello, 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 a bug where the output schema was not being correctly applied for agents operating in 'task' mode when an 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. 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. Footnotes
|
|
Response from ADK Triaging Agent Hello @sasha-gitg, thank you for creating this PR! To help us review your contribution, could you please address the following points from our contribution guidelines:
This information will help reviewers to review your PR more efficiently. Thanks! |
There was a problem hiding this comment.
Code Review
The pull request modifies the _maybe_save_output_to_state method in src/google/adk/agents/llm_agent.py to include a condition where the event output is set when the agent mode is 'task' and the output schema is defined. This change aims to fix a unit test by ensuring the output schema is correctly applied in task mode scenarios.
src/google/adk/agents/llm_agent.py
Outdated
|
|
||
| set_output_key = bool(self.output_key) | ||
| set_event_output = self.mode == 'single_turn' | ||
| set_event_output = self.mode == 'single_turn' or (self.mode == 'task' and self.output_schema) |
There was a problem hiding this comment.
The current logic uses and which requires both conditions (self.mode == 'task' and self.output_schema) to be true. If self.output_schema is not set, the condition will evaluate to false even if the mode is 'task'. Consider using parentheses to improve readability and ensure the intended logic is correctly expressed.
Suggestion: Add parentheses to group the conditions for better clarity.
| set_event_output = self.mode == 'single_turn' or (self.mode == 'task' and self.output_schema) | |
| set_output_key = bool(self.output_key) | |
| set_event_output = self.mode == 'single_turn' or (self.mode == 'task' and self.output_schema) # clearer with parens |
fixes unit test