AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
refactor(backend/copilot): centralize prompt building in prompting.py (#12324)
Zamil Majdy8cfabcf4fdaf
diff --git a/autogpt_platform/backend/backend/copilot/baseline/service.py b/autogpt_platform/backend/backend/copilot/baseline/service.pyindex 2438ac7a65..b587479fee 100644--- a/autogpt_platform/backend/backend/copilot/baseline/service.py+++ b/autogpt_platform/backend/backend/copilot/baseline/service.py@@ -22,6 +22,7 @@ from backend.copilot.model import (update_session_title,upsert_chat_session,)+from backend.copilot.prompting import get_baseline_supplementfrom backend.copilot.response_model import (StreamBaseResponse,StreamError,@@ -176,14 +177,17 @@ async def stream_chat_completion_baseline(# changes from concurrent chats updating business understanding.is_first_turn = len(session.messages) <= 1if is_first_turn:- system_prompt, _ = await _build_system_prompt(+ base_system_prompt, _ = await _build_system_prompt(user_id, has_conversation_history=False)else:- system_prompt, _ = await _build_system_prompt(+ base_system_prompt, _ = await _build_system_prompt(user_id=None, has_conversation_history=True)+ # Append tool documentation and technical notes+ system_prompt = base_system_prompt + get_baseline_supplement()+# Compress context if approaching the model's token limitmessages_for_context = await _compress_session_messages(session.messages)diff --git a/autogpt_platform/backend/backend/copilot/prompting.py b/autogpt_platform/backend/backend/copilot/prompting.pynew file mode 100644index 0000000000..7c42233686--- /dev/null+++ b/autogpt_platform/backend/backend/copilot/prompting.py@@ -0,0 +1,191 @@+"""Centralized prompt building logic for CoPilot.++This module contains all prompt construction functions and constants,+handling the distinction between:+- SDK mode vs Baseline mode (tool documentation needs)+- Local mode vs E2B mode (storage/filesystem differences)+"""++from backend.copilot.tools import TOOL_REGISTRY++# Shared technical notes that apply to both SDK and baseline modes+_SHARED_TOOL_NOTES = """\++### Sharing files with the user+After saving a file to the persistent workspace with `write_workspace_file`,+share it with the user by embedding the `download_url` from the response in+your message as a Markdown link or image:++- **Any file** — shows as a clickable download link:+ `[report.csv](workspace://file_id#text/csv)`+- **Image** — renders inline in chat:+ ``+- **Video** — renders inline in chat with player controls:+ ``++The `download_url` field in the `write_workspace_file` response is already+in the correct format — paste it directly after the `(` in the Markdown.++### Sub-agent tasks+- When using the Task tool, NEVER set `run_in_background` to true.+ All tasks must run in the foreground.+"""+++# Environment-specific supplement templates+def _build_storage_supplement(+ working_dir: str,+ sandbox_type: str,+ storage_system_1_name: str,+ storage_system_1_characteristics: list[str],+ storage_system_1_persistence: list[str],+ file_move_name_1_to_2: str,+ file_move_name_2_to_1: str,+) -> str:+ """Build storage/filesystem supplement for a specific environment.++ Template function handles all formatting (bullets, indentation, markdown).+ Callers provide clean data as lists of strings.++ Args:+ working_dir: Working directory path+ sandbox_type: Description of bash_exec sandbox+ storage_system_1_name: Name of primary storage (ephemeral or cloud)+ storage_system_1_characteristics: List of characteristic descriptions+ storage_system_1_persistence: List of persistence behavior descriptions+ file_move_name_1_to_2: Direction label for primary→persistent+ file_move_name_2_to_1: Direction label for persistent→primary+ """+ # Format lists as bullet points with proper indentation+ characteristics = "\n".join(f" - {c}" for c in storage_system_1_characteristics)+ persistence = "\n".join(f" - {p}" for p in storage_system_1_persistence)++ return f"""++## Tool notes++### Shell commands+- The SDK built-in Bash tool is NOT available. Use the `bash_exec` MCP tool+ for shell commands — it runs {sandbox_type}.++### Working directory+- Your working directory is: `{working_dir}`+- All SDK file tools AND `bash_exec` operate on the same filesystem+- Use relative paths or absolute paths under `{working_dir}` for all file operations++### Two storage systems — CRITICAL to understand++1. **{storage_system_1_name}** (`{working_dir}`):+{characteristics}+{persistence}++2. **Persistent workspace** (cloud storage):+ - Files here **survive across sessions indefinitely**++### Moving files between storages+- **{file_move_name_1_to_2}**: Copy to persistent workspace+- **{file_move_name_2_to_1}**: Download for processing++### File persistence+Important files (code, configs, outputs) should be saved to workspace to ensure they persist.+{_SHARED_TOOL_NOTES}"""+++# Pre-built supplements for common environments+def _get_local_storage_supplement(cwd: str) -> str:+ """Local ephemeral storage (files lost between turns)."""+ return _build_storage_supplement(+ working_dir=cwd,+ sandbox_type="in a network-isolated sandbox",+ storage_system_1_name="Ephemeral working directory",+ storage_system_1_characteristics=[+ "Shared by SDK Read/Write/Edit/Glob/Grep tools AND `bash_exec`",+ ],+ storage_system_1_persistence=[+ "Files here are **lost between turns** — do NOT rely on them persisting",+ "Use for temporary work: running scripts, processing data, etc.",+ ],+ file_move_name_1_to_2="Ephemeral → Persistent",+ file_move_name_2_to_1="Persistent → Ephemeral",+ )+++def _get_cloud_sandbox_supplement() -> str:+ """Cloud persistent sandbox (files survive across turns in session)."""+ return _build_storage_supplement(+ working_dir="/home/user",+ sandbox_type="in a cloud sandbox with full internet access",+ storage_system_1_name="Cloud sandbox",+ storage_system_1_characteristics=[+ "Shared by all file tools AND `bash_exec` — same filesystem",+ "Full Linux environment with internet access",+ ],+ storage_system_1_persistence=[+ "Files **persist across turns** within the current session",+ "Lost when the session expires (12 h inactivity)",+ ],+ file_move_name_1_to_2="Sandbox → Persistent",+ file_move_name_2_to_1="Persistent → Sandbox",+ )+++def _generate_tool_documentation() -> str:+ """Auto-generate tool documentation from TOOL_REGISTRY.++ NOTE: This is ONLY used in baseline mode (direct OpenAI API).+ SDK mode doesn't need it since Claude gets tool schemas automatically.++ This generates a complete list of available tools with their descriptions,+ ensuring the documentation stays in sync with the actual tool implementations.+ All workflow guidance is now embedded in individual tool descriptions.++ Only documents tools that are available in the current environment+ (checked via tool.is_available property).+ """+ docs = "\n## AVAILABLE TOOLS\n\n"++ # Sort tools alphabetically for consistent output+ # Filter by is_available to match get_available_tools() behavior+ for name in sorted(TOOL_REGISTRY.keys()):+ tool = TOOL_REGISTRY[name]+ if not tool.is_available:+ continue+ schema = tool.as_openai_tool()+ desc = schema["function"].get("description", "No description available")+ # Format as bullet list with tool name in code style+ docs += f"- **`{name}`**: {desc}\n"++ return docs+++def get_sdk_supplement(use_e2b: bool, cwd: str = "") -> str:+ """Get the supplement for SDK mode (Claude Agent SDK).++ SDK mode does NOT include tool documentation because Claude automatically+ receives tool schemas from the SDK. Only includes technical notes about+ storage systems and execution environment.++ Args:+ use_e2b: Whether E2B cloud sandbox is being used+ cwd: Current working directory (only used in local_storage mode)++ Returns:+ The supplement string to append to the system prompt+ """+ if use_e2b:+ return _get_cloud_sandbox_supplement()+ return _get_local_storage_supplement(cwd)+++def get_baseline_supplement() -> str:+ """Get the supplement for baseline mode (direct OpenAI API).++ Baseline mode INCLUDES auto-generated tool documentation because the+ direct API doesn't automatically provide tool schemas to Claude.+ Also includes shared technical notes (but NOT SDK-specific environment details).++ Returns:+ The supplement string to append to the system prompt+ """+ tool_docs = _generate_tool_documentation()+ return tool_docs + _SHARED_TOOL_NOTESdiff --git a/autogpt_platform/backend/backend/copilot/sdk/service.py b/autogpt_platform/backend/backend/copilot/sdk/service.pyindex f2b46a2d16..cf4326c9ab 100644--- a/autogpt_platform/backend/backend/copilot/sdk/service.py+++ b/autogpt_platform/backend/backend/copilot/sdk/service.py@@ -44,6 +44,7 @@ from ..model import (update_session_title,upsert_chat_session,)+from ..prompting import get_sdk_supplementfrom ..response_model import (StreamBaseResponse,StreamError,@@ -146,140 +147,6 @@ _SDK_CWD_PREFIX = WORKSPACE_PREFIX_HEARTBEAT_INTERVAL = 10.0 # seconds-# Appended to the system prompt to inform the agent about available tools.-# The SDK built-in Bash is NOT available — use mcp__copilot__bash_exec instead,-# which has kernel-level network isolation (unshare --net).-_SHARED_TOOL_NOTES = """\--### Sharing files with the user-After saving a file to the persistent workspace with `write_workspace_file`,-share it with the user by embedding the `download_url` from the response in-your message as a Markdown link or image:--- **Any file** — shows as a clickable download link:- `[report.csv](workspace://file_id#text/csv)`-- **Image** — renders inline in chat:- ``-- **Video** — renders inline in chat with player controls:- ``--The `download_url` field in the `write_workspace_file` response is already-in the correct format — paste it directly after the `(` in the Markdown.--### Long-running tools-Long-running tools (create_agent, edit_agent, etc.) are handled-asynchronously. You will receive an immediate response; the actual result-is delivered to the user via a background stream.--### Large tool outputs-When a tool output exceeds the display limit, it is automatically saved to-the persistent workspace. The truncated output includes a-`<tool-output-truncated>` tag with the workspace path. Use-`read_workspace_file(path="...", offset=N, length=50000)` to retrieve-additional sections.--### Sub-agent tasks-- When using the Task tool, NEVER set `run_in_background` to true.- All tasks must run in the foreground.-"""---_LOCAL_TOOL_SUPPLEMENT = (- """--## Tool notes--### Shell commands-- The SDK built-in Bash tool is NOT available. Use the `bash_exec` MCP tool- for shell commands — it runs in a network-isolated sandbox.--### Working directory-- Your working directory is: `{cwd}`-- All SDK Read/Write/Edit/Glob/Grep tools AND `bash_exec` operate inside this- directory. This is the ONLY writable path — do not attempt to read or write- anywhere else on the filesystem.-- Use relative paths or absolute paths under `{cwd}` for all file operations.--### Two storage systems — CRITICAL to understand--1. **Ephemeral working directory** (`{cwd}`):- - Shared by SDK Read/Write/Edit/Glob/Grep tools AND `bash_exec`- - Files here are **lost between turns** — do NOT rely on them persisting- - Use for temporary work: running scripts, processing data, etc.--2. **Persistent workspace** (cloud storage):- - Files here **survive across turns and sessions**- - Use `write_workspace_file` to save important files (code, outputs, configs)- - Use `read_workspace_file` to retrieve previously saved files- - Use `list_workspace_files` to see what files you've saved before- - Call `list_workspace_files(include_all_sessions=True)` to see files from- all sessions--### Moving files between ephemeral and persistent storage-- **Ephemeral → Persistent**: Use `write_workspace_file` with either:- - `content` param (plain text) — for text files- - `source_path` param — to copy any file directly from the ephemeral dir-- **Persistent → Ephemeral**: Use `read_workspace_file` with `save_to_path`- param to download a workspace file to the ephemeral dir for processing--### File persistence workflow-When you create or modify important files (code, configs, outputs), you MUST:-1. Save them using `write_workspace_file` so they persist-2. At the start of a new turn, call `list_workspace_files` to see what files- are available from previous turns-"""- + _SHARED_TOOL_NOTES-)---_E2B_TOOL_SUPPLEMENT = (- """--## Tool notes--### Shell commands-- The SDK built-in Bash tool is NOT available. Use the `bash_exec` MCP tool- for shell commands — it runs in a cloud sandbox with full internet access.--### Working directory-- Your working directory is: `/home/user` (cloud sandbox)-- All file tools (`read_file`, `write_file`, `edit_file`, `glob`, `grep`)- AND `bash_exec` operate on the **same cloud sandbox filesystem**.-- Files created by `bash_exec` are immediately visible to `read_file` and- vice-versa — they share one filesystem.-- Use relative paths (resolved from `/home/user`) or absolute paths.--### Two storage systems — CRITICAL to understand--1. **Cloud sandbox** (`/home/user`):- - Shared by all file tools AND `bash_exec` — same filesystem- - Files **persist across turns** within the current session- - Full Linux environment with internet access- - Lost when the session expires (12 h inactivity)--2. **Persistent workspace** (cloud storage):- - Files here **survive across sessions indefinitely**- - Use `write_workspace_file` to save important files permanently- - Use `read_workspace_file` to retrieve previously saved files- - Use `list_workspace_files` to see what files you've saved before- - Call `list_workspace_files(include_all_sessions=True)` to see files from- all sessions--### Moving files between sandbox and persistent storage-- **Sandbox → Persistent**: Use `write_workspace_file` with `source_path`- to copy from the sandbox to permanent storage-- **Persistent → Sandbox**: Use `read_workspace_file` with `save_to_path`- to download into the sandbox for processing--### File persistence workflow-Important files that must survive beyond this session should be saved with-`write_workspace_file`. Sandbox files persist across turns but are lost-when the session expires.-"""- + _SHARED_TOOL_NOTES-)--STREAM_LOCK_PREFIX = "copilot:stream:lock:"@@ -460,13 +327,14 @@ def _format_sdk_content_blocks(blocks: list) -> list[dict[str, Any]]:})elif isinstance(block, ToolResultBlock):- result.append(- {- "type": "tool_result",- "tool_use_id": block.tool_use_id,- "content": block.content,- }- )+ tool_result_entry: dict[str, Any] = {+ "type": "tool_result",+ "tool_use_id": block.tool_use_id,+ "content": block.content,+ }+ if block.is_error:+ tool_result_entry["is_error"] = True+ result.append(tool_result_entry)elif isinstance(block, ThinkingBlock):result.append({@@ -965,10 +833,9 @@ async def stream_chat_completion_sdk()use_e2b = e2b_sandbox is not None- system_prompt = base_system_prompt + (- _E2B_TOOL_SUPPLEMENT- if use_e2b- else _LOCAL_TOOL_SUPPLEMENT.format(cwd=sdk_cwd)+ # Append appropriate supplement (Claude gets tool schemas automatically)+ system_prompt = base_system_prompt + get_sdk_supplement(+ use_e2b=use_e2b, cwd=sdk_cwd)# Process transcript download resultdiff --git a/autogpt_platform/backend/backend/copilot/sdk/service_test.py b/autogpt_platform/backend/backend/copilot/sdk/service_test.pyindex 25279ed57e..a0cda8aeab 100644--- a/autogpt_platform/backend/backend/copilot/sdk/service_test.py+++ b/autogpt_platform/backend/backend/copilot/sdk/service_test.py@@ -145,3 +145,103 @@ class TestPrepareFileAttachments:assert "Read tool" not in result.hintassert len(result.image_blocks) == 1+++class TestPromptSupplement:+ """Tests for centralized prompt supplement generation."""++ def test_sdk_supplement_excludes_tool_docs(self):+ """SDK mode should NOT include tool documentation (Claude gets schemas automatically)."""+ from backend.copilot.prompting import get_sdk_supplement++ # Test both local and E2B modes+ local_supplement = get_sdk_supplement(use_e2b=False, cwd="/tmp/test")+ e2b_supplement = get_sdk_supplement(use_e2b=True, cwd="")++ # Should NOT have tool list section+ assert "## AVAILABLE TOOLS" not in local_supplement+ assert "## AVAILABLE TOOLS" not in e2b_supplement++ # Should still have technical notes+ assert "## Tool notes" in local_supplement+ assert "## Tool notes" in e2b_supplement++ def test_baseline_supplement_includes_tool_docs(self):+ """Baseline mode MUST include tool documentation (direct API needs it)."""+ from backend.copilot.prompting import get_baseline_supplement++ supplement = get_baseline_supplement()++ # MUST have tool list section+ assert "## AVAILABLE TOOLS" in supplement++ # Should NOT have environment-specific notes (SDK-only)+ assert "## Tool notes" not in supplement++ def test_baseline_supplement_includes_key_tools(self):+ """Baseline supplement should document all essential tools."""+ from backend.copilot.prompting import get_baseline_supplement+ from backend.copilot.tools import TOOL_REGISTRY++ docs = get_baseline_supplement()++ # Core agent workflow tools (always available)+ assert "`create_agent`" in docs+ assert "`run_agent`" in docs+ assert "`find_library_agent`" in docs+ assert "`edit_agent`" in docs++ # MCP integration (always available)+ assert "`run_mcp_tool`" in docs++ # Folder management (always available)+ assert "`create_folder`" in docs++ # Browser tools only if available (Playwright may not be installed in CI)+ if (+ TOOL_REGISTRY.get("browser_navigate")+ and TOOL_REGISTRY["browser_navigate"].is_available+ ):+ assert "`browser_navigate`" in docs++ def test_baseline_supplement_includes_workflows(self):+ """Baseline supplement should include workflow guidance in tool descriptions."""+ from backend.copilot.prompting import get_baseline_supplement++ docs = get_baseline_supplement()++ # Workflows are now in individual tool descriptions (not separate sections)+ # Check that key workflow concepts appear in tool descriptions+ assert "suggested_goal" in docs or "clarifying_questions" in docs+ assert "run_mcp_tool" in docs++ def test_baseline_supplement_completeness(self):+ """All available tools from TOOL_REGISTRY should appear in baseline supplement."""+ from backend.copilot.prompting import get_baseline_supplement+ from backend.copilot.tools import TOOL_REGISTRY++ docs = get_baseline_supplement()++ # Verify each available registered tool is documented+ # (matches _generate_tool_documentation which filters by is_available)+ for tool_name, tool in TOOL_REGISTRY.items():+ if not tool.is_available:+ continue+ assert (+ f"`{tool_name}`" in docs+ ), f"Tool '{tool_name}' missing from baseline supplement"++ def test_baseline_supplement_no_duplicate_tools(self):+ """No tool should appear multiple times in baseline supplement."""+ from backend.copilot.prompting import get_baseline_supplement+ from backend.copilot.tools import TOOL_REGISTRY++ docs = get_baseline_supplement()++ # Count occurrences of each available tool in the entire supplement+ for tool_name, tool in TOOL_REGISTRY.items():+ if not tool.is_available:+ continue+ # Count how many times this tool appears as a bullet point+ count = docs.count(f"- **`{tool_name}`**")+ assert count == 1, f"Tool '{tool_name}' appears {count} times (should be 1)"diff --git a/autogpt_platform/backend/backend/copilot/service.py b/autogpt_platform/backend/backend/copilot/service.pyindex 2bcba33abd..7a7221ca62 100644--- a/autogpt_platform/backend/backend/copilot/service.py+++ b/autogpt_platform/backend/backend/copilot/service.py@@ -34,8 +34,9 @@ client = LangfuseAsyncOpenAI(api_key=config.api_key, base_url=config.base_url)langfuse = get_client()# Default system prompt used when Langfuse is not configured-# This is a snapshot of the "CoPilot Prompt" from Langfuse (version 11)-DEFAULT_SYSTEM_PROMPT = """You are **Otto**, an AI Co-Pilot for AutoGPT and a Forward-Deployed Automation Engineer serving small business owners. Your mission is to help users automate business tasks with AI by delivering tangible value through working automations—not through documentation or lengthy explanations.+# Provides minimal baseline tone and personality - all workflow, tools, and+# technical details are provided via the supplement.+DEFAULT_SYSTEM_PROMPT = """You are an AI automation assistant helping users build and run automations.Here is everything you know about the current user from previous interactions:@@ -43,113 +44,12 @@ Here is everything you know about the current user from previous interactions:{users_information}</users_information>-## YOUR CORE MANDATE+Your goal is to help users automate tasks by:+- Understanding their needs and business context+- Building and running working automations+- Delivering tangible value through action, not just explanation-You are action-oriented. Your success is measured by:-- **Value Delivery**: Does the user think "wow, that was amazing" or "what was the point"?-- **Demonstrable Proof**: Show working automations, not descriptions of what's possible-- **Time Saved**: Focus on tangible efficiency gains-- **Quality Output**: Deliver results that meet or exceed expectations--## YOUR WORKFLOW--Adapt flexibly to the conversation context. Not every interaction requires all stages:--1. **Explore & Understand**: Learn about the user's business, tasks, and goals. Use `add_understanding` to capture important context that will improve future conversations.--2. **Assess Automation Potential**: Help the user understand whether and how AI can automate their task.--3. **Prepare for AI**: Provide brief, actionable guidance on prerequisites (data, access, etc.).--4. **Discover or Create Agents**:- - **Always check the user's library first** with `find_library_agent` (these may be customized to their needs)- - Search the marketplace with `find_agent` for pre-built automations- - Find reusable components with `find_block`- - **For live integrations** (read a GitHub repo, query a database, post to Slack, etc.) consider `run_mcp_tool` — it connects directly to external services without building a full agent- - Create custom solutions with `create_agent` if nothing suitable exists- - Modify existing library agents with `edit_agent`- - **When `create_agent` returns `suggested_goal`**: Present the suggestion to the user and ask "Would you like me to proceed with this refined goal?" If they accept, call `create_agent` again with the suggested goal.- - **When `create_agent` returns `clarifying_questions`**: After the user answers, call `create_agent` again with the original description AND the answers in the `context` parameter.--5. **Execute**: Run automations immediately, schedule them, or set up webhooks using `run_agent`. Test specific components with `run_block`.--6. **Show Results**: Display outputs using `agent_output`.--## AVAILABLE TOOLS--**Understanding & Discovery:**-- `add_understanding`: Create a memory about the user's business or use cases for future sessions-- `search_docs`: Search platform documentation for specific technical information-- `get_doc_page`: Retrieve full text of a specific documentation page--**Agent Discovery:**-- `find_library_agent`: Search the user's existing agents (CHECK HERE FIRST—these may be customized)-- `find_agent`: Search the marketplace for pre-built automations-- `find_block`: Find pre-written code units that perform specific tasks (agents are built from blocks)--**Agent Creation & Editing:**-- `create_agent`: Create a new automation agent-- `edit_agent`: Modify an agent in the user's library--**Execution & Output:**-- `run_agent`: Run an agent now, schedule it, or set up a webhook trigger-- `run_block`: Test or run a specific block independently-- `agent_output`: View results from previous agent runs--**MCP (Model Context Protocol) Servers:**-- `run_mcp_tool`: Connect to any MCP server to discover and run its tools-- **Two-step flow:**- 1. `run_mcp_tool(server_url)` → returns a list of available tools. Each tool has `name`, `description`, and `input_schema` (JSON Schema). Read `input_schema.properties` to understand what arguments are needed.- 2. `run_mcp_tool(server_url, tool_name, tool_arguments)` → executes the tool. Build `tool_arguments` as a flat `{{key: value}}` object matching the tool's `input_schema.properties`.-- **Authentication:** If the MCP server requires credentials, the UI will show an OAuth connect button. Once the user connects and clicks Proceed, they will automatically send you a message confirming credentials are ready (e.g. "I've connected the MCP server credentials. Please retry run_mcp_tool..."). When you receive that confirmation, **immediately** call `run_mcp_tool` again with the exact same `server_url` — and the same `tool_name`/`tool_arguments` if you were already mid-execution. Do not ask the user what to do next; just retry.-- **Finding server URLs (fastest → slowest):**- 1. **Known hosted servers** — use directly, no lookup:- - Notion: `https://mcp.notion.com/mcp`- - Linear: `https://mcp.linear.app/mcp`- - Stripe: `https://mcp.stripe.com`- - Intercom: `https://mcp.intercom.com/mcp`- - Cloudflare: `https://mcp.cloudflare.com/mcp`- - Atlassian (Jira/Confluence): `https://mcp.atlassian.com/mcp`- 2. **`web_search`** — use `web_search("{{service}} MCP server URL")` for any service not in the list above. This is the fastest way to find unlisted servers.- 3. **Registry API** — `web_fetch("https://registry.modelcontextprotocol.io/v0.1/servers?search={{query}}&limit=10")` to browse what's available. Returns names + GitHub repo URLs but NOT the endpoint URL; follow up with `web_search` to find the actual endpoint.- - **Never** `web_fetch` the registry homepage — it is JavaScript-rendered and returns a blank page.-- **When to use:** Use `run_mcp_tool` when the user wants to interact with an external service (GitHub, Slack, a database, a SaaS tool, etc.) via its MCP integration. Unlike `web_fetch` (which just retrieves a raw URL), MCP servers expose structured typed tools — prefer `run_mcp_tool` for any service with an MCP server, and `web_fetch` only for plain URL retrieval with no MCP server involved.-- **CRITICAL**: `run_mcp_tool` is **always available** in your tool list. If the user explicitly provides an MCP server URL or asks you to call `run_mcp_tool`, you MUST use it — never claim it is unavailable, and never substitute `web_fetch` for an explicit MCP request.--## BEHAVIORAL GUIDELINES--**Be Concise:**-- Target 2-5 short lines maximum-- Make every word count—no repetition or filler-- Use lightweight structure for scannability (bullets, numbered lists, short prompts)-- Avoid jargon (blocks, slugs, cron) unless the user asks--**Be Proactive:**-- Suggest next steps before being asked-- Anticipate needs based on conversation context and user information-- Look for opportunities to expand scope when relevant-- Reveal capabilities through action, not explanation--**Use Tools Effectively:**-- Select the right tool for each task-- **Always check `find_library_agent` before searching the marketplace**-- Use `add_understanding` to capture valuable business context-- When tool calls fail, try alternative approaches-- **For MCP integrations**: Known URL (see list) or `web_search("{{service}} MCP server URL")` → `run_mcp_tool(server_url)` → `run_mcp_tool(server_url, tool_name, tool_arguments)`. If credentials needed, UI prompts automatically; when user confirms, retry immediately with same arguments.--**Handle Feedback Loops:**-- When a tool returns a suggested alternative (like a refined goal), present it clearly and ask the user for confirmation before proceeding-- When clarifying questions are answered, immediately re-call the tool with the accumulated context-- Don't ask redundant questions if the user has already provided context in the conversation--## CRITICAL REMINDER--You are NOT a chatbot. You are NOT documentation. You are a partner who helps busy business owners get value quickly by showing proof through working automations. Bias toward action over explanation."""+Be concise, proactive, and action-oriented. Bias toward showing working solutions over lengthy explanations."""# ---------------------------------------------------------------------------diff --git a/autogpt_platform/backend/backend/copilot/tools/create_agent.py b/autogpt_platform/backend/backend/copilot/tools/create_agent.pyindex 597ba41f62..a2fee7bd22 100644--- a/autogpt_platform/backend/backend/copilot/tools/create_agent.py+++ b/autogpt_platform/backend/backend/copilot/tools/create_agent.py@@ -39,9 +39,13 @@ class CreateAgentTool(BaseTool):return ("Create a new agent workflow from a natural language description. ""First generates a preview, then saves to library if save=true. "- "\n\nIMPORTANT: Before calling this tool, search for relevant existing agents "- "using find_library_agent that could be used as building blocks. "- "Pass their IDs in the library_agent_ids parameter so the generator can compose them."+ "\n\nWorkflow: (1) Always check find_library_agent first for existing building blocks. "+ "(2) Call create_agent with description and library_agent_ids. "+ "(3) If response contains suggested_goal: Present to user, ask for confirmation, "+ "then call again with the suggested goal if accepted. "+ "(4) If response contains clarifying_questions: Present to user, collect answers, "+ "then call again with original description AND answers in the context parameter. "+ "\n\nThis feedback loop ensures the generated agent matches user intent.")@propertydiff --git a/autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py b/autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.pyindex 45b411857d..25522a44ec 100644--- a/autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py+++ b/autogpt_platform/backend/backend/copilot/tools/run_mcp_tool.py@@ -53,11 +53,15 @@ class RunMCPToolTool(BaseTool):def description(self) -> str:return ("Connect to an MCP (Model Context Protocol) server to discover and execute its tools. "- "Call with just `server_url` to see available tools. "- "Then call again with `server_url`, `tool_name`, and `tool_arguments` to execute. "- "If the server requires authentication, the user will be prompted to connect it. "- "Find MCP servers at https://registry.modelcontextprotocol.io/ — hundreds of integrations "- "including GitHub, Postgres, Slack, filesystem, and more."+ "Two-step workflow: (1) Call with just `server_url` to discover available tools. "+ "(2) Call again with `server_url`, `tool_name`, and `tool_arguments` to execute. "+ "Known hosted servers (use directly): Notion (https://mcp.notion.com/mcp), "+ "Linear (https://mcp.linear.app/mcp), Stripe (https://mcp.stripe.com), "+ "Intercom (https://mcp.intercom.com/mcp), Cloudflare (https://mcp.cloudflare.com/mcp), "+ "Atlassian/Jira (https://mcp.atlassian.com/mcp). "+ "For other services, search the MCP registry at https://registry.modelcontextprotocol.io/. "+ "Authentication: If the server requires credentials, user will be prompted to complete the MCP credential setup flow."+ "Once connected and user confirms, retry the same call immediately.")@property