Agents in AG2 leverage tools to extend their functionality, allowing them to interact with external systems, fetch real-time data, and execute complex tasks beyond the scope of a language modelβs internal knowledge. This enables a structured approach where agents decide which tool to use and then execute it accordingly.Documentation Index
Fetch the complete documentation index at: https://private-04b27de1.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
How Tool Usage Works in AG2
In AG2, tool execution follows a two-step process:- Selection: An agent (driven by its LLM) decides which tool is appropriate based on the given task.
- Execution: A separate executor agent invokes the tool and returns the results.
register_for_llm to make the tool available for LLM-driven selection and register_for_execution to allow the agent to execute the tool directly when needed.
π Explore the Walk-through
Secure Tool Usage with Secrets
When tools require sensitive information like API keys or credentials, AG2 employs dependency injection to keep such data secure. This method ensures that private information is not exposed to the LLM while still allowing seamless execution of agent tasks. Some key benefits include:- Enhanced Security: Keeps secrets out of LLM interactions and telemetry.
- Simplified Development: Securely passes credentials without hardcoding them.
- Flexible Integration: Allows agents to access necessary credentials while maintaining security.
Interoperability with External Frameworks
AG2 supports interoperability with popular LLM tool frameworks, making it easier to integrate a wide range of tools:- LangChain: Provides numerous pre-built tools for API calls, web scraping, and more.
- CrewAI: Offers specialized tools for web scraping, search, and automation.
- PydanticAI: Supports structured data handling and dependency injection for context-driven tool execution.