-
Notifications
You must be signed in to change notification settings - Fork 46.2k
feat(blocks): add SmartAgentBlock using Claude Agent SDK #11628
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: master
Are you sure you want to change the base?
Conversation
… autonomous tool execution loops (#11547) ## Summary <img width="2072" height="1836" alt="image" src="https://github.com/user-attachments/assets/9d231a77-6309-46b9-bc11-befb5d8e9fcc" /> **🚀 Major Feature: Agent Mode Support** Adds autonomous agent mode to SmartDecisionMakerBlock, enabling it to execute tools directly in loops until tasks are completed, rather than just yielding tool calls for external execution. ## ⭐ **Key New Features** ### 🤖 **Agent Mode with Tool Execution Loops** - **New `agent_mode_max_iterations` parameter** controls execution behavior: - `0` = Traditional mode (single LLM call, yield tool calls) - `1+` = Agent mode with iteration limit - `-1` = Infinite agent mode (loop until finished) ### 🔄 **Autonomous Tool Execution** - **Direct tool execution** instead of yielding for external handling - **Multi-iteration loops** with conversation state management - **Automatic completion detection** when LLM stops making tool calls - **Iteration limit handling** with graceful completion messages ### 🏗️ **Proper Database Operations** - **Replace manual execution ID generation** with proper `upsert_execution_input`/`upsert_execution_output` - **Real NodeExecutionEntry objects** from database results - **Proper execution status management**: QUEUED → RUNNING → COMPLETED/FAILED ### 🔧 **Enhanced Type Safety** - **Pydantic models** replace TypedDict: `ToolInfo` and `ExecutionParams` - **Runtime validation** with better error messages - **Improved developer experience** with IDE support ## 🔧 **Technical Implementation** ### Agent Mode Flow: ```python # Agent mode enabled with iterations if input_data.agent_mode_max_iterations != 0: async for result in self._execute_tools_agent_mode(...): yield result # "conversations", "finished" return # Traditional mode (existing behavior) # Single LLM call + yield tool calls for external execution ``` ### Tool Execution with Database Operations: ```python # Before: Manual execution IDs tool_exec_id = f"{node_exec_id}_tool_{sink_node_id}_{len(input_data)}" # After: Proper database operations node_exec_result, final_input_data = await db_client.upsert_execution_input( node_id=sink_node_id, graph_exec_id=execution_params.graph_exec_id, input_name=input_name, input_data=input_value, ) ``` ### Type Safety with Pydantic: ```python # Before: Dict access prone to errors execution_params["user_id"] # After: Validated model access execution_params.user_id # Runtime validation + IDE support ``` ## 🧪 **Comprehensive Test Coverage** - **Agent mode execution tests** with multi-iteration scenarios - **Database operation verification** - **Type safety validation** - **Backward compatibility** for traditional mode - **Enhanced dynamic fields tests** ## 📊 **Usage Examples** ### Traditional Mode (Existing Behavior): ```python SmartDecisionMakerBlock.Input( prompt="Search for keywords", agent_mode_max_iterations=0 # Default ) # → Yields tool calls for external execution ``` ### Agent Mode (New Feature): ```python SmartDecisionMakerBlock.Input( prompt="Complete this task using available tools", agent_mode_max_iterations=5 # Max 5 iterations ) # → Executes tools directly until task completion or iteration limit ``` ### Infinite Agent Mode: ```python SmartDecisionMakerBlock.Input( prompt="Analyze and process this data thoroughly", agent_mode_max_iterations=-1 # No limit, run until finished ) # → Executes tools autonomously until LLM indicates completion ``` ## ✅ **Backward Compatibility** - **Zero breaking changes** to existing functionality - **Traditional mode remains default** (`agent_mode_max_iterations=0`) - **All existing tests pass** - **Same API for tool definitions and execution** This transforms the SmartDecisionMakerBlock from a simple tool call generator into a powerful autonomous agent capable of complex multi-step task execution! 🎯 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: Claude <[email protected]>
## Changes 🏗️ We have the setup for light/dark mode support ( Tailwind + `next-themes` ), but not the capacity yet from contributions to make the app dark-mode ready. First, we need to make it look good in light mode 😆 This disables `dark:` mode classes on the code, to prevent the app looking oopsie when the user is seeing it with a browser with dark mode preference: ### Before these changes <img width="800" height="739" alt="Screenshot 2025-12-14 at 17 09 25" src="https://github.com/user-attachments/assets/76333e03-930a-40b6-b91e-47ee01bf2c00" /> ### After <img width="800" height="722" alt="Screenshot 2025-12-14 at 16 55 46" src="https://github.com/user-attachments/assets/34d85359-c68f-474c-8c66-2bebf28f923e" /> ## Checklist 📋 ### For code changes - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: - [x] Run the app on a browser with dark mode preference - [x] It still looks in light mode without broken styles
## Changes 🏗️ The main goal of this PR is to improve how we display inputs used for a given task. Agent inputs can be of many types (text, long text, date, select, file, etc.). Until now, we have tried to display them as text, which has not always worked. Given we already have `<RunAgentInputs />`, which uses form elements to display the inputs ( _prefilled with data_ ), most of the time it will look better and less buggy than text. ### Before <img width="800" height="614" alt="Screenshot 2025-12-14 at 17 45 44" src="https://github.com/user-attachments/assets/3d851adf-9638-46c1-adfa-b5e68dc78bb0" /> ### After <img width="800" height="708" alt="Screenshot 2025-12-14 at 17 45 21" src="https://github.com/user-attachments/assets/367f32b4-2c30-4368-8d63-4cad06e32437" /> ### Other improvements - 🗑️ Removed `<EditInputsModal />` - it is not used given the API does not support editing inputs for a schedule yt - Made `<InformationTooltip />` icon size customisable ### Checklist 📋 #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: - [x] Run the app locally - [x] Check the new view tasks use the form elements instead of text to display inputs
## Changes 🏗️ https://github.com/user-attachments/assets/7e49ed5b-c818-4aa3-b5d6-4fa86fada7ee When the content of Summary + Outputs + Inputs is long enough, it will show in this new `<ScrollableTabs />` component, which auto-scrolls the content as you click on a tab. ## Checklist 📋 ### For code changes - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: - [x] Run the app locally - [x] Check the new page with scrollable tabs
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
This PR targets the Automatically setting the base branch to |
✅ Deploy Preview for auto-gpt-docs canceled.
|
|
Thanks for submitting this PR to add Claude Agent SDK integration to AutoGPT! Missing items
Scope concerns
Technical feedback
Please update your PR description to address these points. Once you've completed the checklist and clarified the scope of changes, we can proceed with the review. |
Implements a new AI agent block that bridges Claude Agent SDK with AutoGPT's tool ecosystem: - Uses Claude Agent SDK for native agent capabilities - Discovers and executes connected AutoGPT tool nodes - Supports iterative agent mode with conversation management - Proper credential validation for Anthropic API keys - Configurable models (Claude 4.x and 3.x series) - Zero-warning block registration and validation Block features: - Agent mode execution with tool discovery - Integration with AutoGPT's execution manager - Robust async error handling - Support for max iterations and working directory configuration 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
|
Here's the code health analysis summary for commits Analysis Summary
|
Summary
This PR introduces the SmartAgentBlock, a new AI agent block that bridges Claude Agent SDK with AutoGPT's tool ecosystem, providing native agent capabilities while seamlessly integrating with existing AutoGPT tools.
Key Features
Implementation Details
c1a2u3d4-e5a6-g7e8-n9t0-b1l2o3c4k5d6claude-agent-sdk = "^0.1.17"Technical Approach
The SmartAgentBlock combines:
_create_tool_node_signatures()Usage
Users can:
Test Plan
test_available_blocks[SmartAgentBlock]passesFiles Changed
backend/blocks/smart_agent.py- Main block implementationpyproject.toml- Added Claude Agent SDK dependencypoetry.lock- Dependency lock file update🤖 Generated with Claude Code