Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
0d64af9
feat(copilot): integrate agent generation locally via Claude Agent SD…
majdyz Mar 1, 2026
7034506
fix(copilot): address PR review comments - split validation, fix secu…
majdyz Mar 1, 2026
2900705
fix(copilot): address second round of PR review comments
majdyz Mar 1, 2026
2846e18
fix(copilot): defensive .get() access throughout fixer and validator
majdyz Mar 1, 2026
7029a38
fix(copilot): pass library_agents through pipeline for AgentExecutorB…
majdyz Mar 1, 2026
fd0db07
fix(copilot): use valid OpenAI model identifier in AI block fixer
majdyz Mar 1, 2026
7131178
refactor(copilot): remove external agent generator service, simplify …
majdyz Mar 3, 2026
f255e75
feat(copilot): add include_schemas param to find_block, remove Blocks…
majdyz Mar 3, 2026
f4743c4
refactor(copilot): remove unused config and block recommendation code
majdyz Mar 3, 2026
a38edca
feat(copilot): update system prompt for file-first agent generation w…
majdyz Mar 3, 2026
4090ad5
feat(copilot): add MAX_AGENT_JSON_SIZE guard to agent pipeline
majdyz Mar 3, 2026
ddefe74
fix(copilot): address PR review comments - type guard, version defaul…
majdyz Mar 3, 2026
c5875ab
refactor(copilot): make fixer sync, extract shared helpers, add unit …
majdyz Mar 3, 2026
957e4a4
fix(copilot): guard against non-string prompt fields in fix_double_cu…
majdyz Mar 3, 2026
7c1d9d0
feat(copilot): enforce IO blocks, add optimized descriptions, conditi…
majdyz Mar 3, 2026
a670373
fix(copilot): remove schema prefix from migration SQL
majdyz Mar 3, 2026
63ca2f7
fix(copilot): clear optimized description when source description cha…
majdyz Mar 3, 2026
20d387f
refactor(copilot): address PR review should-fix items
majdyz Mar 3, 2026
e21130f
fix(copilot): invalidate block cache after optimizing descriptions
majdyz Mar 3, 2026
91b2e2d
merge: resolve conflicts with origin/dev
majdyz Mar 4, 2026
34f1a7e
Merge branch 'dev' into feat/copilot-local-agent-generation
majdyz Mar 4, 2026
3fd7a32
fix(copilot): guard against null metadata in validator
majdyz Mar 4, 2026
e2d842f
Merge branch 'feat/copilot-local-agent-generation' of github.com:Sign…
majdyz Mar 4, 2026
b845a7c
fix(copilot): remove unused agent_id param from customize_agent, assi…
majdyz Mar 4, 2026
6b3f5f0
feat(copilot): support MCP blocks and AgentExecutorBlock in agent gen…
majdyz Mar 4, 2026
d6b84c2
fix(copilot): guard against None source_name in validator
majdyz Mar 4, 2026
07216a4
fix(copilot): guard against null metadata in fix_node_x_coordinates
majdyz Mar 4, 2026
b8d5023
fix(copilot): include agent generation guide in baseline service
majdyz Mar 5, 2026
a599a15
fix(copilot): ensure agents get meaningful name and description
majdyz Mar 5, 2026
979fa7e
fix(copilot): soften name/description guidance to only when needed
majdyz Mar 5, 2026
7a8adc9
Merge branch 'dev' into feat/copilot-local-agent-generation
majdyz Mar 5, 2026
102e8b1
fix(copilot): fix dynamic block links, MCP URL hints, and embedding f…
majdyz Mar 5, 2026
49d6f0f
fix(copilot): update run_block test assertions to match new error mes…
majdyz Mar 5, 2026
5c949b1
refactor(copilot): add return type annotations, downgrade fixer logs …
majdyz Mar 5, 2026
f77f207
feat(copilot): use optimized descriptions in find_block results
majdyz Mar 5, 2026
5f5148b
refactor(copilot): load optimized descriptions onto Block class at st…
majdyz Mar 5, 2026
68956a3
fix(copilot): fix find_block test mocks, use safe access for sdk_msg.…
majdyz Mar 5, 2026
2bd6927
fix(copilot): skip self-referencing links in node layout calculation
majdyz Mar 5, 2026
12ff312
Merge branch 'dev' of github.com:Significant-Gravitas/AutoGPT into fe…
majdyz Mar 5, 2026
4b7a75b
Merge remote-tracking branch 'origin/dev' into feat/copilot-local-age…
majdyz Mar 6, 2026
d38bce4
refactor(copilot): address PR review feedback for agent generation
majdyz Mar 6, 2026
1a13931
refactor(copilot): address review feedback round 4
majdyz Mar 7, 2026
e9cd28d
fix(copilot): update test assertion to match agent_json workflow
majdyz Mar 7, 2026
813b9d5
fix(copilot): thread folder_id through pipeline and fix cache race
majdyz Mar 7, 2026
2fbce41
refactor(copilot): move local imports to top-level in optimize_blocks
majdyz Mar 7, 2026
bf14ffa
fix(copilot): consider schema-default values when checking required s…
majdyz Mar 7, 2026
7129fd8
fix(copilot): address review feedback round 4
majdyz Mar 9, 2026
1b56559
Merge branch 'dev' of github.com:Significant-Gravitas/AutoGPT into fe…
majdyz Mar 9, 2026
2d53d9f
refactor(backend/db): simplify optimizedDescription reset and raise l…
majdyz Mar 9, 2026
9a9bcce
fix(copilot): restore DEFAULT_SYSTEM_PROMPT to match dev baseline
majdyz Mar 9, 2026
d1a08af
refactor(copilot): use shared OpenAI client in optimize_block_descrip…
majdyz Mar 9, 2026
777679e
feat(copilot): replace keyword-based agent guide injection with a tool
majdyz Mar 9, 2026
f4305e6
feat(copilot): extract MCP server list and auth details into get_mcp_…
majdyz Mar 9, 2026
c585cd4
refactor(copilot): group ResponseType enum by domain and rename gener…
majdyz Mar 9, 2026
738669f
refactor(copilot): normalize agent builder ResponseType prefix to AGE…
majdyz Mar 9, 2026
cdbeaa9
refactor(copilot): update frontend ResponseType keys to match AGENT_B…
majdyz Mar 9, 2026
a0397b0
fix(copilot): fix stale imports and circular import in optimize_blocks
majdyz Mar 9, 2026
53888e9
refactor(copilot): regenerate openapi.json and responseType.ts with u…
majdyz Mar 9, 2026
3ec4f01
Merge branch 'dev' of github.com:Significant-Gravitas/AutoGPT into fe…
majdyz Mar 9, 2026
6873421
fix(frontend/copilot): update stale ResponseType keys introduced by P…
majdyz Mar 9, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions autogpt_platform/backend/backend/copilot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ class ChatConfig(BaseSettings):
"history compression. Falls back to compression when unavailable.",
)

# Agent generation: local (Claude Agent SDK as brain) vs external service
agent_generator_use_local: bool = Field(
default=True,
description="Use local agent generation (Claude Agent SDK generates JSON, "
"validated/fixed locally). When False, falls back to the external "
"AgentGenerator service for decomposition and generation.",
)

Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
# Extended thinking configuration for Claude models
thinking_enabled: bool = Field(
default=True,
Expand Down Expand Up @@ -130,6 +138,15 @@ def get_base_url(cls, v):
v = "https://openrouter.ai/api/v1"
return v

@field_validator("agent_generator_use_local", mode="before")
@classmethod
def get_agent_generator_use_local(cls, v):
"""Get agent_generator_use_local from environment if not provided."""
env_val = os.getenv("CHAT_AGENT_GENERATOR_USE_LOCAL", "").lower()
if env_val:
return env_val in ("true", "1", "yes", "on")
return True if v is None else v

@field_validator("use_claude_agent_sdk", mode="before")
@classmethod
def get_use_claude_agent_sdk(cls, v):
Expand Down
80 changes: 80 additions & 0 deletions autogpt_platform/backend/backend/copilot/sdk/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,86 @@ def _build_sdk_tool_supplement(cwd: str) -> str:
### Sub-agent tasks
- When using the Task tool, NEVER set `run_in_background` to true.
All tasks must run in the foreground.

## Agent Generation Guide

You can create, edit, and customize agents directly. You ARE the brain —
generate the agent JSON yourself using the block schemas, then validate and save.

### Agent JSON Structure

```json
{{
"id": "<UUID v4>", // auto-generated if omitted
"version": 1,
"is_active": true,
"name": "Agent Name",
"description": "What the agent does",
"nodes": [
{{
"id": "<UUID v4>",
"block_id": "<block UUID from get_blocks_for_goal>",
"input_default": {{
"field_name": "design-time value"
}},
"metadata": {{
"position": {{"x": 0, "y": 0}},
"customized_name": "Optional display name"
}}
}}
],
"links": [
{{
"id": "<UUID v4>",
"source_id": "<source node UUID>",
"source_name": "output_field_name",
"sink_id": "<sink node UUID>",
"sink_name": "input_field_name",
"is_static": false
}}
]
}}
```

### Workflow for Creating/Editing Agents

1. **Discover blocks**: Call `get_blocks_for_goal` with the user's goal
2. **Generate JSON**: Build the agent JSON using block schemas:
- Use block IDs from step 1 as `block_id` in nodes
- Wire outputs to inputs using links
- Set design-time config in `input_default`
- Use `AgentInputBlock` for values the user provides at runtime
3. **Validate**: Call `validate_agent_graph` to check correctness
4. **Fix if needed**: Call `fix_agent_graph` to auto-fix common issues,
or fix manually based on error descriptions
5. **Save**: Call `create_agent` (new) or `edit_agent` (existing) with
`agent_json` parameter

### Key Rules

- **Design-time vs runtime**: `input_default` = values known at build time.
For user-provided values, create an `AgentInputBlock` node and link its
output to the consuming block's input.
- **Never hardcode secrets**: Use `AgentInputBlock` for API keys, passwords, etc.
- **Node spacing**: Position nodes with at least 800 X-units between them.
- **Nested properties**: Use `parentField_#_childField` notation in link
sink_name/source_name to access nested object fields.
- **is_static links**: Set `is_static: true` when the link carries a
design-time constant (matches a field in inputSchema with a default).
- **ConditionBlock**: Needs a `StoreValueBlock` wired to its `value2` input.
- **Prompt templates**: Use `{{{{variable}}}}` (double curly braces) for
literal braces in prompt strings — single `{{` and `}}` are for
template variables.
- **AgentExecutorBlock**: When composing sub-agents, set `graph_id` and
`graph_version` in input_default, and wire inputs/outputs to match
the sub-agent's schema.

### Example: Simple AI Text Processor

A minimal agent that takes user input, processes it with AI, and outputs result:
- Node 1: `AgentInputBlock` (block for user input, output: "result")
- Node 2: `AITextGeneratorBlock` (input: "prompt" linked from Node 1)
- Node 3: `AgentOutputBlock` (input: "value" linked from Node 2's output)
"""


Expand Down
7 changes: 7 additions & 0 deletions autogpt_platform/backend/backend/copilot/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
from .find_agent import FindAgentTool
from .find_block import FindBlockTool
from .find_library_agent import FindLibraryAgentTool
from .fix_agent import FixAgentGraphTool
from .get_blocks import GetBlocksForGoalTool
from .get_doc_page import GetDocPageTool
from .run_agent import RunAgentTool
from .run_block import RunBlockTool
from .search_docs import SearchDocsTool
from .validate_agent import ValidateAgentGraphTool
from .web_fetch import WebFetchTool
from .workspace_files import (
DeleteWorkspaceFileTool,
Expand Down Expand Up @@ -56,6 +59,10 @@
# Feature request tools
"search_feature_requests": SearchFeatureRequestsTool(),
"create_feature_request": CreateFeatureRequestTool(),
# Agent generation tools (local validation/fixing/block discovery)
"get_blocks_for_goal": GetBlocksForGoalTool(),
"validate_agent_graph": ValidateAgentGraphTool(),
"fix_agent_graph": FixAgentGraphTool(),
# Workspace tools for CoPilot file operations
"list_workspace_files": ListWorkspaceFilesTool(),
"read_workspace_file": ReadWorkspaceFileTool(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@
from .errors import get_user_message_for_error
from .service import health_check as check_external_service_health
from .service import is_external_service_configured
from .validation import AgentFixer, AgentValidator

__all__ = [
"AgentFixer",
"AgentGeneratorNotConfiguredError",
"AgentValidator",
"AgentJsonValidationError",
"AgentSummary",
"DecompositionResult",
Expand Down
Loading
Loading