-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(agents): Add CodingAgent (agents that think in code) #4259
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
Conversation
…ngAgent - Add save_chart tool to save visualizations to host filesystem - Add list_saved_charts tool to list saved charts - Add _is_real_error method to distinguish between warnings and errors - Fix pip warnings being treated as execution errors - Update system prompt with package installation instructions - Add base64 to authorized imports for chart encoding - Update README with new tool documentation - Create GitHub issue template for CodingAgent feature
…epth - Add research foundation from CodeAct (ICML 2024) and DynaSaur (COLM 2025) - Reference HuggingFace smolagents as inspiration (25k+ GitHub stars) - Expand problem statement with context window bottleneck analysis - Add detailed alternatives considered section with rationale - Include future roadmap for stateful execution and alternative sandboxes - Add concrete user pain points and how CodingAgent solves them
- Refocus motivation on arXiv:2512.24601 long-context external environment framing - Keep smolagents as primary inspiration for code-thinking agents - Tighten solution, alternatives, and future directions per ADK template
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 significantly enhances the ADK framework by introducing 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 is an impressive and comprehensive pull request that introduces the CodingAgent. The architecture is well-thought-out, with a secure-by-default approach using sandboxed execution and an import allowlist. The code is clean, well-documented, and includes a great sample agent that showcases the new capabilities. I have a couple of suggestions for improvement regarding code duplication and error handling to further enhance the robustness of this new feature.
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…y with upstream Addresses Gemini code review suggestion (PR google#4259): - Remove duplicate DEFAULT_SAFE_IMPORTS from coding_agent_config.py - Import DEFAULT_SAFE_IMPORTS from allowlist_validator.py (canonical source) - Create _DATA_SCIENCE_IMPORTS for numpy/pandas/scipy/matplotlib packages - Create _EXTENDED_SAFE_IMPORTS combining both for CodingAgentConfig default Resolves merge conflict in telemetry/tracing.py: - Sync with upstream main (new OTEL improvements, proper semconv imports) - Add CodingAgent-specific tracing functions: trace_code_generation, trace_code_execution, trace_import_validation, trace_tool_ipc Updates test to use _EXTENDED_SAFE_IMPORTS from coding_agent_config.py
|
Closing in favor of a new PR from New PR can be found here - #4262 |
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 - This PR implements the feature request described in issue #4198.
Description
Problem:
ADK's current default agent interaction pattern is "tool selection from a fixed action set." This breaks down for several increasingly common workloads:
Long-context work beyond model context windows: Many real tasks require operating over very large corpora (codebases, logs, datasets, multi-file configs). If the agent must keep all relevant content in the LLM context, it becomes context-window bound and expensive.
Expressiveness and composability limits of pure tool-calling: Tool-calling assumes enumerable actions. Open-ended tasks require composing operations, iterating, caching intermediate artifacts, and implementing one-off transformations without requiring new bespoke tools each time.
Developer experience gap for building "coding agents": Users want agent systems like Claude Code/OpenCode with multi-step coding workflows, sub-agents, and strong "think in code" execution capabilities.
Solution:
Introduce a new experimental agent type:
CodingAgent- an agent that generates and executes Python code as its primary action representation.Key features:
ContainerCodeExecutorfor securityToolExecutionServerrunning on the hostAllowlistValidatorensures only authorized imports are allowedArchitecture:
New files introduced:
src/google/adk/agents/coding_agent.py- Main CodingAgent classsrc/google/adk/agents/coding_agent_config.py- Pydantic configurationsrc/google/adk/code_executors/coding_agent_code_executor.py- Executor wrapper with tool injectionsrc/google/adk/code_executors/tool_execution_server.py- FastAPI server for tool IPCsrc/google/adk/code_executors/tool_code_generator.py- System prompt and stub generationsrc/google/adk/code_executors/allowlist_validator.py- Import validationcontributing/samples/coding_agent/- Sample data analysis agent with documentationTesting Plan
Unit Tests:
Test files added:
tests/unittests/agents/test_coding_agent.py- Tests for CodingAgent, CodingAgentConfig, CodingAgentStatetests/unittests/code_executors/test_tool_code_generator.py- Tests for prompt generation, tool stubs, runtime headertests/unittests/code_executors/test_allowlist_validator.py- Tests for import validationTest coverage includes:
pytest summary:
Manual End-to-End (E2E) Tests:
Prerequisites:
GOOGLE_API_KEYenvironment variable setTest the sample agent:
Example test interactions:
Basic data analysis:
Visualization with chart saving:
Multi-step analysis:
Checklist
Additional context
Design decisions:
Experimental decorator:
CodingAgentis marked with@experimentalto indicate this is a new feature that may evolve.Default to ContainerCodeExecutor: Security-first approach - code executes in isolated Docker containers by default. Users can supply custom executors if needed.
HTTP IPC over direct execution: Tools run on the host, not in containers. This maintains security isolation while allowing full ToolContext capabilities.
Import allowlist:
DEFAULT_SAFE_IMPORTSprovides a conservative set of safe modules. Users can extend this for specific use cases (e.g., addingpandas.*for data analysis).ReAct-style iteration: The agent can observe execution results and iteratively refine its approach, similar to how human developers debug code.
Future enhancements enabled by this architecture:
Related inspiration:
Documentation:
contributing/samples/coding_agent/README.mdLink 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 - This PR implements the feature request described in issue #4198.
Description
Problem:
ADK's current default agent interaction pattern is "tool selection from a fixed action set." This breaks down for several increasingly common workloads:
Long-context work beyond model context windows: Many real tasks require operating over very large corpora (codebases, logs, datasets, multi-file configs). If the agent must keep all relevant content in the LLM context, it becomes context-window bound and expensive.
Expressiveness and composability limits of pure tool-calling: Tool-calling assumes enumerable actions. Open-ended tasks require composing operations, iterating, caching intermediate artifacts, and implementing one-off transformations without requiring new bespoke tools each time.
Developer experience gap for building "coding agents": Users want agent systems like Claude Code/OpenCode with multi-step coding workflows, sub-agents, and strong "think in code" execution capabilities.
Solution:
Introduce a new experimental agent type:
CodingAgent- an agent that generates and executes Python code as its primary action representation.Key features:
ContainerCodeExecutorfor securityToolExecutionServerrunning on the hostAllowlistValidatorensures only authorized imports are allowedArchitecture:
New files introduced:
src/google/adk/agents/coding_agent.py- Main CodingAgent classsrc/google/adk/agents/coding_agent_config.py- Pydantic configurationsrc/google/adk/code_executors/coding_agent_code_executor.py- Executor wrapper with tool injectionsrc/google/adk/code_executors/tool_execution_server.py- FastAPI server for tool IPCsrc/google/adk/code_executors/tool_code_generator.py- System prompt and stub generationsrc/google/adk/code_executors/allowlist_validator.py- Import validationcontributing/samples/coding_agent/- Sample data analysis agent with documentationTesting Plan
Unit Tests:
Test files added:
tests/unittests/agents/test_coding_agent.py- Tests for CodingAgent, CodingAgentConfig, CodingAgentStatetests/unittests/code_executors/test_tool_code_generator.py- Tests for prompt generation, tool stubs, runtime headertests/unittests/code_executors/test_allowlist_validator.py- Tests for import validationTest coverage includes:
pytest summary:
Manual End-to-End (E2E) Tests:
Prerequisites:
GOOGLE_API_KEYenvironment variable setTest the sample agent:
Example test interactions:
Basic data analysis:
Visualization with chart saving:
Multi-step analysis:
Checklist
Additional context
Design decisions:
Experimental decorator:
CodingAgentis marked with@experimentalto indicate this is a new feature that may evolve.Default to ContainerCodeExecutor: Security-first approach - code executes in isolated Docker containers by default. Users can supply custom executors if needed.
HTTP IPC over direct execution: Tools run on the host, not in containers. This maintains security isolation while allowing full ToolContext capabilities.
Import allowlist:
DEFAULT_SAFE_IMPORTSprovides a conservative set of safe modules. Users can extend this for specific use cases (e.g., addingpandas.*for data analysis).ReAct-style iteration: The agent can observe execution results and iteratively refine its approach, similar to how human developers debug code.
Future enhancements enabled by this architecture:
Related inspiration:
Documentation:
contributing/samples/coding_agent/README.md