advanced-configuration.mdx 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. ---
  2. title: "Advanced Configuration"
  3. description: "Learn advanced configuration options for your agents in Agency Swarm."
  4. icon: "gears"
  5. ---
  6. All parameters inside the `Agent` class follow the same structure as the OpenAI Agents SDK [`Agent`](https://openai.github.io/openai-agents-python/ref/agent/#agents.agent.Agent). However, there are a few advanced parameters that require more explanation.
  7. ### Parallel Tool Calls
  8. Controls whether tools execute in parallel or sequentially for a given agent.
  9. ```python
  10. from agency_swarm import Agent, ModelSettings
  11. agent = Agent(
  12. name="MyAgent",
  13. instructions="...",
  14. model_settings=ModelSettings(parallel_tool_calls=False),
  15. )
  16. ```
  17. To force sequential execution for a specific tool regardless of that setting, set `one_call_at_a_time = True` in the tool’s `ToolConfig`. See [Advanced Tool Configuration](/core-framework/tools/custom-tools/configuration).
  18. ### File Search
  19. If your `files_folder` ends with `_vs_<vector_store_id>`, Agency Swarm automatically associates files with that Vector Store and adds `FileSearchTool` to the Agent. The `include_search_results` behavior can be toggled via the Agent’s `include_search_results` flag.
  20. ### Web Search Sources
  21. ```python
  22. from agency_swarm import Agent, WebSearchTool
  23. agent = Agent(
  24. name="Researcher",
  25. instructions="Search the web and summarize findings.",
  26. tools=[WebSearchTool()],
  27. include_web_search_sources=True, # default
  28. )
  29. ```
  30. With `include_web_search_sources=True` (default), `WebSearchTool` calls include source URLs.
  31. Set `include_web_search_sources=False` to skip this.
  32. ### Conversation starters cache
  33. Conversation starters are the suggested prompts you see in the chat UI.
  34. When enabled, cache can instantly replay the first reply without calling the LLM.
  35. ```python
  36. from agency_swarm import Agent
  37. agent = Agent(
  38. name="SupportAgent",
  39. instructions="You are helpful.",
  40. model="gpt-5.4-mini",
  41. conversation_starters=["Support: I need help with billing"],
  42. cache_conversation_starters=True,
  43. )
  44. ```
  45. In this example:
  46. - The UI shows the starter prompt “Support: I need help with billing”.
  47. - The FastAPI `/get_metadata` response exposes starters as `conversationStarters`.
  48. - With `cache_conversation_starters=True`, the first plain-text user message can replay a saved reply when it exactly matches a configured starter.
  49. <Info>
  50. Streaming the cached reply includes events for text, tool calls, reasoning, and handoffs.
  51. </Info>
  52. If you change key agent settings (like instructions, tools, or model), the cache for first-turn responses is rebuilt.
  53. Per-run overrides like `additional_instructions`, `context_override`, or `hooks_override` skip replay and call the LLM.
  54. <Note>
  55. Cache files live under `AGENCY_SWARM_CHATS_DIR` (defaults to `.agency_swarm`) in `starter_cache/`.
  56. In production, point `AGENCY_SWARM_CHATS_DIR` at persistent storage to keep instant replies across restarts.
  57. </Note>
  58. See also: [Agent Overview](/core-framework/agents/overview), [FastAPI Integration](/additional-features/fastapi-integration).
  59. ### Output Validation
  60. Use `output_guardrails` on the `Agent` to validate outputs. See the detailed guide: [Guardrails](/additional-features/guardrails/overview).
  61. ### Few‑Shot Examples
  62. You can include few‑shot examples in `instructions` as plain text or pass message history to `get_response` / `get_response_stream`.
  63. ```python
  64. from agency_swarm import Agent
  65. agent = Agent(name="MyAgent", instructions="You are a helpful assistant.")
  66. examples = [
  67. {"role": "user", "content": "Hi!"},
  68. {"role": "assistant", "content": "Hello!"},
  69. ]
  70. new_message = {"role": "user", "content": "Can you help me write a short summary?"}
  71. response = await agent.get_response(examples + [new_message])
  72. ```
  73. See also: [Few‑Shot Examples](/additional-features/few-shot-examples).