overview.mdx 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. ---
  2. title: "Overview"
  3. description: "Understanding Agents in Agency Swarm."
  4. icon: "globe"
  5. ---
  6. Agents are the core building blocks of the Agency Swarm framework. Each agent is specialized for a specific role and is designed to perform a specific set of processes within an agency.
  7. ## Key Characteristics of Agents
  8. <CardGroup cols={3}>
  9. <Card
  10. title="Autonomous"
  11. icon="robot"
  12. >
  13. Agents can decide the next best action to achieve a goal autonomously within the guardrails.
  14. </Card>
  15. <Card
  16. title="Perceptual"
  17. icon="eye"
  18. >
  19. Agents sense the environment, interpret observations, and self-correct based on feedback.
  20. </Card>
  21. <Card
  22. title="Proactive"
  23. icon="lightbulb"
  24. >
  25. Agents can take initiative (monitor, plan, act) and surprise you with the results, or escalate when needed.
  26. </Card>
  27. </CardGroup>
  28. ## Defining AI agents
  29. <Callout type="info" icon="robot" title="What is an AI Agent?">
  30. **An AI agent is an autonomous, goal-driven system that perceives its environment, dynamically uses tools and APIs to take actions, adapts proactively within guardrails, and can collaborate with other agents or humans.**
  31. </Callout>
  32. Now, let's breakdown this definition:
  33. - **Autonomous** - Agents define their own execution flow independently without hardcoded logic, unlike traditional workflows
  34. - **Goal-driven** - Agents are focused on outcomes, rather than on invididual steps
  35. - **Perceives environment** - Agents observe the real-world and use the feedback to validate its own actions (e.g., a coding agent testing its code)
  36. - **Dynamic tool use** - Agents generate value through actions rather than just responses (most critical characteristic)
  37. - **Adapts within guardrails** - Agents balance autonomy with safety constraints for enterprise reliability
  38. - **Collaboration** - Agents can work seamlessly with other agents or humans in multi-agent systems
  39. ## Agent Parameters
  40. In agency swarm, to create an agent, you need to instantiate the `Agent` class.
  41. <Tabs>
  42. <Tab title="Core Parameters">
  43. | Name | Parameter | Description |
  44. |------|-----------|-------------|
  45. | Name *(required)* | `name` | The name of the agent. |
  46. | Instructions *(optional)* | `instructions` | The instructions for the agent. Will be used as the "system prompt" when this agent is invoked. Can be a string or a function that dynamically generates instructions. Default: `None` |
  47. | Description *(optional)* | `description` | A description of the agent's role or purpose, used to convey agent's role to other agents. Default: `None` |
  48. | Model *(optional)* | `model` | The model implementation to use when invoking the LLM. If not provided, uses agents SDK default model. Current default model can be [found here](https://openai.github.io/openai-agents-python/models). Default: `None` |
  49. | Model Settings *(optional)* | `model_settings` | Configures model-specific tuning parameters (e.g. temperature, top_p). See [ModelSettings documentation](https://openai.github.io/openai-agents-python/ref/model_settings/) for details. Default: SDK defaults with Agency Swarm applying `truncation="auto"` when unset. |
  50. | Tools *(optional)* | `tools` | A list of tools that the agent can use. Default: `[]` |
  51. | Tools Folder *(optional)* | `tools_folder` | Path to a directory containing tool definitions. Tools are automatically discovered and loaded from this directory. Supports both BaseTool subclasses and modern FunctionTool instances. Default: `None` |
  52. | Files Folder *(optional)* | `files_folder` | Path to a local folder for managing files associated with this agent. If the folder name follows the pattern `*_vs_<vector_store_id>`, files uploaded via `upload_file` will also be added to the specified OpenAI Vector Store, and a `FileSearchTool` will be automatically added. Default: `None` |
  53. | MCP Servers *(optional)* | `mcp_servers` | A list of Model Context Protocol servers that the agent can use. Every time the agent runs, it will include tools from these servers in the list of available tools. Default: `[]` |
  54. | Input Guardrails *(optional)* | `input_guardrails` | A list of checks that run in parallel to the agent's execution, before generating a response. Default: `[]` |
  55. | Output Guardrails *(optional)* | `output_guardrails` | A list of checks that run on the final output of the agent, after generating a response. Default: `[]` |
  56. | Output Type *(optional)* | `output_type` | The type of the output object. If not provided, the output will be `str`. In most cases, you should pass a regular Python type (e.g. a dataclass, Pydantic model, TypedDict, etc). Default: `None` |
  57. </Tab>
  58. <Tab title="Additional Parameters">
  59. | Name | Parameter | Description |
  60. |------|-----------|-------------|
  61. | MCP Config *(optional)* | `mcp_config` | Configuration for MCP servers. Default: `MCPConfig()` |
  62. | API headers *(optional)*<br/>API params *(optional)*| `api_headers`<br/><br/>`api_params` | Additional parameters to include into tools converted from OpenAPI schemas. Default: `None` |
  63. | Schemas Folder *(optional)* | `schemas_folder` | Path to a directory containing openapi schema files in .json format. Schemas are automatically converted into FunctionTools. Default: `None` |
  64. | Validation Attempts *(optional)* | `validation_attempts` | Number of retries when an output guardrail trips. Default: `1` |
  65. | Raise Input Guardrail Error *(optional)* | `raise_input_guardrail_error` | If set to `True`, input guardrail errors raise an exception. If set to `False`, the guardrail message is returned as the agent's response. Default: `False` |
  66. | Handoff Reminder *(optional)* | `handoff_reminder` | Replaces the default handoff reminder system message with a given string. Default: "Transfer completed. You are [recipient_agent_name]. Please continue the task." |
  67. | Include Search Results *(optional)* | `include_search_results` | Include search results in FileSearchTool output for citation extraction. Default: `False` |
  68. | Include Web Search Sources *(optional)* | `include_web_search_sources` | Include source URLs from WebSearchTool calls. Default: `True` |
  69. | Conversation Starters *(optional)* | `conversation_starters` | List of short user prompts for UIs. Each starter must be a non-empty string. Default: `None` |
  70. | Quick Replies *(optional)* | `quick_replies` | First-turn user phrases used for cached responses. These phrases are not shown as `conversation_starters` in the UI. Each value must be a non-empty string. Default: `None`. |
  71. | Starter Cache *(optional)* | `cache_conversation_starters` | Enables caching for `conversation_starters`. When `True`, a first-turn message that matches a `conversation_starter` can return a cached response instead of calling the model. This setting does not affect `quick_replies`. See [Advanced Configuration](/core-framework/agents/advanced-configuration#conversation-starters-cache). Default: `False`. |
  72. </Tab>
  73. </Tabs>
  74. <Note>
  75. To see a full list of agent parameters, refer to [OpenAI documentation]( https://openai.github.io/openai-agents-python/ref/agent/#agents.agent.Agent).
  76. Please note that agent handoff parameters are not supported. To enable handoffs, use `communication_flows` with the `Handoff` tool class as [shown here](/additional-features/custom-communication-flows/overview)
  77. </Note>
  78. <Warning>
  79. To start receiving reasoning events for reasoning models, you need to explicitly specify `reasoning` parameter inside `ModelSettings`
  80. </Warning>
  81. ## Agent Template
  82. Create a new agent by instantiating the Agent class:
  83. ```python
  84. from agency_swarm import Agent, ModelSettings, Reasoning
  85. example_agent = Agent(
  86. name="agent_name",
  87. description="agent_description",
  88. model="gpt-5.4-mini",
  89. instructions="./instructions.md",
  90. files_folder="./files",
  91. tools_folder="./tools",
  92. tools=[],
  93. model_settings=ModelSettings(
  94. reasoning=Reasoning(effort="medium"),
  95. ),
  96. )
  97. ```
  98. You can adjust the parameters to fit the agent to your use case.