Skip to main content
Glama

create_agent

Generate a new AutoGen agent with a unique name, type, system message, and LLM configuration to enable collaborative multi-agent conversations through the AutoGen MCP Server.

Instructions

Create a new AutoGen agent

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
llm_configNoLLM configuration
nameYesUnique name for the agent
system_messageNoSystem message
typeYesAgent type

Implementation Reference

  • Core handler function that implements the create_agent tool logic. Parses arguments, creates specific AutoGen agent types (AssistantAgent, UserProxyAgent, ConversableAgent, etc.), registers tools if provided, adds to agent manager, and returns success info.
    async def _create_agent(self, args: Dict[str, Any]) -> Dict[str, Any]:
        """Create an enhanced AutoGen agent."""
        name = args["name"]
        agent_type = args["type"]
        system_message = args.get("system_message", "You are a helpful AI assistant.")
        llm_config = args.get("llm_config", self.server_config.default_llm_config)
        code_execution_config = args.get("code_execution_config", self.server_config.default_code_execution_config)
        human_input_mode = args.get("human_input_mode", "NEVER")
        tools = args.get("tools", [])
        teachability_config = args.get("teachability", {})
    
        try:
            if agent_type == "assistant":
                agent = AssistantAgent(
                    name=name,
                    system_message=system_message,
                    llm_config=llm_config,
                    human_input_mode=human_input_mode,
                )
            elif agent_type == "user_proxy":
                agent = UserProxyAgent(
                    name=name,
                    system_message=system_message,
                    code_execution_config=code_execution_config,
                    human_input_mode=human_input_mode,
                )
            elif agent_type == "conversable":
                agent = ConversableAgent(
                    name=name,
                    system_message=system_message,
                    llm_config=llm_config,
                    human_input_mode=human_input_mode,
                )
            elif agent_type == "teachable" and TeachableAgent:
                agent = TeachableAgent(
                    name=name,
                    system_message=system_message,
                    llm_config=llm_config,
                    teach_config=teachability_config,
                )
            elif agent_type == "retrievable" and RetrieveUserProxyAgent:
                agent = RetrieveUserProxyAgent(
                    name=name,
                    system_message=system_message,
                    code_execution_config=code_execution_config,
                    retrieve_config=args.get("retrieve_config", {}),
                )
            else:
                return {"error": f"Unknown or unsupported agent type: {agent_type}"}
    
            # Register tools if provided
            if tools:
                for tool in tools:
                    if hasattr(agent, 'register_for_execution'):
                        agent.register_for_execution(name=tool["name"])(tool["function"])
    
            self.agent_manager.add_agent(name, agent)
            
            return {
                "success": True,
                "message": f"Agent '{name}' created successfully",
                "agent_info": {
                    "name": name,
                    "type": agent_type,
                    "capabilities": {
                        "llm_enabled": hasattr(agent, "llm_config") and agent.llm_config is not None,
                        "code_execution": hasattr(agent, "code_execution_config") and agent.code_execution_config is not False,
                        "teachable": agent_type == "teachable",
                        "tools_count": len(tools)
                    }
                }
            }
        except Exception as e:
            return {"error": f"Failed to create agent: {str(e)}"}
  • Dataclass defining the input schema/configuration for agent creation with fields matching the expected arguments in create_agent handler.
    class AgentConfig:
        """Configuration for an AutoGen agent."""
        name: str
        type: str = "assistant"  # 'assistant' or 'user'
        role: str = "assistant"  # For compatibility
        description: str = ""
        system_message: str = ""
        llm_config: Optional[Dict[str, Any]] = None
        code_execution_config: Optional[Dict[str, Any]] = None
    
        def to_autogen_config(self) -> Dict[str, Any]:
            """Convert to AutoGen configuration."""
            config = {
                "name": self.name,
                "human_input_mode": "NEVER",  # MCP handles input
                "max_consecutive_auto_reply": 10,  # Reasonable default
                "system_message": self.system_message or None,
                "llm_config": self.llm_config or {},
                "code_execution_config": self.code_execution_config or False,
            }
    
            # Add type-specific settings
            if self.type == "assistant":
                config.update({
                    "is_termination_msg": lambda x: "TERMINATE" in x.get("content", ""),
                })
            elif self.type == "user":
                config.update({
                    "human_input_mode": "NEVER",
                    "code_execution_config": False,  # User agents don't execute code
                })
    
            return config
  • Tool dispatch/registration logic in handle_tool_call method where 'create_agent' is explicitly checked and routed to the handler.
    async def handle_tool_call(self, tool_name: str, arguments: Dict[str, Any]) -> Dict[str, Any]:
        """Handle tool calls with enhanced AutoGen features."""
        try:
            if tool_name == "create_agent":
                return await self._create_agent(arguments)
            elif tool_name == "create_workflow":
                return await self._create_workflow(arguments)
            elif tool_name == "execute_chat":
                return await self._execute_chat(arguments)
            elif tool_name == "execute_group_chat":
                return await self._execute_group_chat(arguments)
            elif tool_name == "execute_nested_chat":
                return await self._execute_nested_chat(arguments)
            elif tool_name == "execute_swarm":
                return await self._execute_swarm(arguments)
            elif tool_name == "execute_workflow":
                return await self._execute_workflow(arguments)
            elif tool_name == "manage_agent_memory":
                return await self._manage_agent_memory(arguments)
            elif tool_name == "configure_teachability":
                return await self._configure_teachability(arguments)
            elif tool_name == "get_agent_status":
                return await self._get_agent_status(arguments)
            elif tool_name == "get_resource":
                return await self._get_resource(arguments)
            else:
                return {"error": f"Unknown tool: {tool_name}"}
        except Exception as e:
            return {"error": str(e)}
  • Supporting method in AgentManager for creating agents using AgentConfig, similar logic to the main handler.
    def create_agent(self, config: AgentConfig) -> ConversableAgent:
        """Create a new agent."""
        if config.name in self._agents:
            raise ValueError(f"Agent {config.name} already exists")
    
        # Get base configuration
        agent_config = config.to_autogen_config()
    
        # Add default configurations if not provided
        if not agent_config.get("llm_config"):
            agent_config["llm_config"] = self._server_config.get_default_llm_config()
        if not agent_config.get("code_execution_config") and config.type == "assistant":
            agent_config["code_execution_config"] = self._server_config.get_default_code_execution_config()
    
        # Create the appropriate agent type
        if config.type == "assistant":
            agent = autogen.AssistantAgent(
                name=config.name,
                system_message=agent_config.get("system_message", ""),
                llm_config=agent_config.get("llm_config"),
                code_execution_config=agent_config.get("code_execution_config"),
                human_input_mode="NEVER",
                max_consecutive_auto_reply=10,
            )
        elif config.type == "user":
            agent = autogen.UserProxyAgent(
                name=config.name,
                human_input_mode="NEVER",
                max_consecutive_auto_reply=10,
                system_message=agent_config.get("system_message", ""),
                code_execution_config=False,
            )
        else:
            raise ValueError(f"Unknown agent type: {config.type}")
    
        self._agents[config.name] = agent
        return agent
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action ('Create') but doesn't describe what happens after creation (e.g., whether the agent is immediately active, stored, or requires further steps), error conditions, or side effects. For a creation tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded with the core action and resource, making it easy to parse. Every part of the sentence earns its place by conveying essential information concisely.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of creating an agent (a mutation operation with 4 parameters, no output schema, and no annotations), the description is insufficient. It doesn't cover behavioral aspects like what the tool returns, error handling, or how the created agent integrates with other tools (e.g., 'start_streaming_chat'). For a creation tool, more context is needed to guide effective use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 4 parameters with basic descriptions. The description adds no additional meaning about parameters beyond what the schema provides, such as explaining the significance of 'type' or how 'llm_config' should be structured. Baseline 3 is appropriate when the schema handles parameter documentation adequately.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Create') and resource ('new AutoGen agent'), making the purpose immediately understandable. It distinguishes from siblings like 'create_streaming_workflow' by specifying the resource type, though it doesn't explicitly contrast them. The description avoids tautology by not just restating the tool name.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives like 'create_streaming_workflow' or 'execute_workflow'. It doesn't mention prerequisites, dependencies, or scenarios where this tool is preferred. Usage is implied only by the tool name and description, with no explicit context or exclusions provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/DynamicEndpoints/Autogen_MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server