-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(code_executors): Fix JSON field mismatches in AgentEngineSandboxCodeExecutor #4261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @Sudhendra, 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 critical communication issues within 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. 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.
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 correctly addresses two JSON field mismatches in AgentEngineSandboxCodeExecutor. The changes to handle msg_out/msg_err with a fallback to stdout/stderr for response parsing, and to fix the input file payload keys to content and mime_type, are well-implemented. The addition of a comprehensive suite of unit tests is excellent and ensures these fixes are robust and protected against future regressions. I have one suggestion to further improve the robustness of the JSON response parsing.
src/google/adk/code_executors/agent_engine_sandbox_code_executor.py
Outdated
Show resolved
Hide resolved
…odeExecutor - Fix input file payload keys: contents -> content, mimeType -> mime_type - Fix response parsing: read msg_out/msg_err with fallback to stdout/stderr - Add defensive type check for JSON response to prevent AttributeError Fixes google#3690
17a0295 to
7444ff9
Compare
|
/gemini review |
There was a problem hiding this 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 addresses two critical JSON field mismatches in the AgentEngineSandboxCodeExecutor, ensuring correct interaction with the Vertex AI Agent Engine sandbox API. The fixes for both the input file payload and the response parsing are well-implemented. I particularly appreciate the addition of backward compatibility for stdout/stderr and the comprehensive suite of new unit tests, which significantly improves the robustness and reliability of the executor. I've included one suggestion to further improve the handling of null values from the API to prevent potential type errors.
src/google/adk/code_executors/agent_engine_sandbox_code_executor.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this 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 addresses two critical JSON field mismatches in the AgentEngineSandboxCodeExecutor, ensuring correct parsing of API responses and proper construction of input file payloads. The changes are well-implemented, including backward compatibility for response parsing. The addition of a comprehensive suite of unit tests is excellent and covers the fixes thoroughly. I have one suggestion to further improve the robustness of the response parsing by handling potential JSON decoding errors.
|
Hi @Sudhendra , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Can you pls address the comment. |
…or.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
|
@ryanaiagent Addressed the comment and committed the suggestion. Please take a look. |
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
2. Or, if no issue exists, describe the change:
N/A - Issue #3690 exists.
Problem:
AgentEngineSandboxCodeExecutorhas two JSON field mismatches that cause silent failures:msg_out/msg_err, but the code readsstdout/stderr, resulting in empty output.content/mime_type, but the code sendscontents/mimeType, causing input files to be unreadable in the sandbox.Solution:
msg_out/msg_erras primary fields, with fallback tostdout/stderrfor backward compatibility.contentandmime_type.Testing Plan
Unit Tests:
Added 10 new test cases covering:
test_execute_code_with_msg_out_msg_err- Primary API response fieldstest_execute_code_fallback_to_stdout_stderr- Backward compatibilitytest_execute_code_msg_out_takes_precedence_over_stdout- Precedence logictest_execute_code_partial_response_only_msg_out- Partial response (stdout only)test_execute_code_partial_response_only_msg_err- Partial response (stderr only)test_execute_code_empty_response- Empty response handlingtest_execute_code_with_input_files_uses_correct_payload_keys- Request payload validationtest_execute_code_without_input_files_no_files_key- No files in payloadtest_execute_code_output_files_metadata_preserved- Output file metadataFull code_executors test suite:
Manual End-to-End (E2E) Tests:
Tested against a real Vertex AI Agent Engine sandbox:
Before fix:
After fix:
Both issues are resolved:
file contents: col1,col2...in output)Checklist
Additional context
The fix maintains backward compatibility by using a fallback pattern:
This ensures existing integrations that may return
stdout/stderrcontinue to work while supporting the actual API response format (msg_out/msg_err).