fix: _EvalMetricResultWithInvocation handles expected_invocation gracefully#4665
fix: _EvalMetricResultWithInvocation handles expected_invocation gracefully#4665morganroux wants to merge 5 commits intogoogle:mainfrom
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 an issue where the 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 @morganroux, thank you for creating this PR! Could you please provide a summary of passed |
There was a problem hiding this comment.
Code Review
This pull request correctly makes expected_invocation optional to handle cases where it might be None. The added null-guards for expected_invocation are appropriate. However, the pull request also introduces unnecessary null-guards for actual_invocation, which is a non-optional field. I've added specific comments to address this and suggest removing the redundant checks to maintain code clarity and correctness according to the data model.
| "actual_response": AgentEvaluator._convert_content_to_text( | ||
| per_invocation_result.actual_invocation.final_response | ||
| ), | ||
| ) if per_invocation_result.actual_invocation else None, |
There was a problem hiding this comment.
The null check for actual_invocation is unnecessary. According to the type definition for _EvalMetricResultWithInvocation, actual_invocation is a required field and not optional. This check is confusing and should be removed to align with the type definitions.
| "actual_response": AgentEvaluator._convert_content_to_text( | |
| per_invocation_result.actual_invocation.final_response | |
| ), | |
| ) if per_invocation_result.actual_invocation else None, | |
| "actual_response": AgentEvaluator._convert_content_to_text( | |
| per_invocation_result.actual_invocation.final_response | |
| ), |
| "actual_tool_calls": AgentEvaluator._convert_tool_calls_to_text( | ||
| per_invocation_result.actual_invocation.intermediate_data | ||
| ), | ||
| ) if per_invocation_result.actual_invocation else None, |
There was a problem hiding this comment.
Similar to actual_response, the null check for actual_invocation here is unnecessary because actual_invocation is a required, non-optional field.
| "actual_tool_calls": AgentEvaluator._convert_tool_calls_to_text( | |
| per_invocation_result.actual_invocation.intermediate_data | |
| ), | |
| ) if per_invocation_result.actual_invocation else None, | |
| "actual_tool_calls": AgentEvaluator._convert_tool_calls_to_text( | |
| per_invocation_result.actual_invocation.intermediate_data | |
| ), |
8a70eb8 to
9e55132
Compare
Link to Issue or Description of Change
_EvalMetricResultWithInvocationfails withconversation_scenario(user simulation) - expected_invocation is None #4283Problem:
_EvalMetricResultWithInvocationexpectsexpected_invocationto be set.Needs to handle None value gracefully
Solution:
The two changes are in evaluation/agent_evaluator.py:
(1) line 93 — expected_invocation: Optional[Invocation] = None, and
(2) _print_details() lines 440-449 —null-guard all accesses to expected_invocation fields since it's None for conversation_scenario runs.
In order not to break the
tabulatel.465 the concerned strings are defaulted to empty string.Testing Plan
2 tests are created to validate this PR.
Unit Tests:
Manual End-to-End (E2E) Tests:
N/A
Checklist
Additional context
N/A