Benefits of Using an Agency
Utilizing an Agency consisting of multiple agents offers several benefits:Fewer Hallucinations
Agents within an agency can supervise each other, reducing mistakes and handling unexpected scenarios more effectively.
Complex Tasks
Adding more agents allows for longer sequences of actions, enabling the completion of more complex tasks before delivering results to the user.
Scalability
Agencies allow you to scale your solutions seamlessly by adding more agents, as the complexity of your system grows.
Agent instances based on a defined structure. It provides enhanced thread management, persistence hooks, and improved communication patterns between agents.
Agency Parameters
Overview of parameters in the newAgency class:
| Name | Parameter | Description |
|---|---|---|
| Entry Points | *entry_points_args | Positional arguments representing Agent instances that serve as entry points for external interaction. These agents can be directly messaged by users. |
| Communication Flows (optional) | communication_flows | List of (sender, receiver) tuples defining allowed agent-to-agent message paths. Example: [(ceo, dev), (ceo, va)]. Default: None |
| Name (optional) | name | A name for the agency instance. Default: None |
| Shared Instructions (optional) | shared_instructions | Instructions prepended to all agents’ system prompts in a string format or a path to markdown file. Default: None |
| Send Message Tool Class (optional) | send_message_tool_class | Fallback SendMessage tool class when a communication_flows entry does not specify its own tool. Prefer configuring SendMessage variants directly through communication_flows. Default: None |
| Load Threads Callback (optional) | load_threads_callback | A callable to load conversation threads for persistence. Default: None |
| Save Threads Callback (optional) | save_threads_callback | A callable to save conversation threads for persistence. Default: None |
| User Context (optional) | user_context | Initial shared context accessible to all agents during runs. Default: None |