A Toolkit groups related tools into a single, reusable unit. Instead of passing individual tools one by one, you can bundle them into a toolkit and pass the whole collection to an agent. This is useful for organizing domain-specific capabilities (e.g., all database tools, all file-system tools) and sharing them across multiple agents.
fromautogen.betaimportAgentfromautogen.beta.toolsimportToolkitdefsearch_orders(query:str)->str:"""Searches the order database."""return"Order #123"defcancel_order(order_id:str)->str:"""Cancels an order by its ID."""returnf"Order {order_id} cancelled."support_tools=Toolkit(search_orders,cancel_order)agent=Agent(name="SupportBot",tools=[support_tools])
A toolkit accepts both plain functions and @tool-decorated functions in its tools list. Plain functions are automatically converted, just like when passing them directly to an agent.
fromautogen.beta.toolsimportToolkitinventory=Toolkit()@inventory.tooldefcheck_stock(item_id:str)->int:"""Returns the current stock count for an item."""return42@inventory.tool(name="reorder_item",description="Places a reorder for a low-stock item.",)defreorder(item_id:str,quantity:int)->str:returnf"Reordered {quantity} of {item_id}."
The toolkit can then be passed to any number of agents:
fromautogen.betaimporttool@tooldefescalate(reason:str)->str:"""Escalates the conversation to a human agent."""return"Escalated."agent=Agent(name="SupportBot",tools=[support_tools,inventory,escalate],)