Understanding Agent Tools
Tools extend agent capabilities by enabling them to retrieve knowledge, execute code, call external APIs, and interact with enterprise systems. This guide explains tool concepts and how to use them effectively.What Are Tools?
Tools are capabilities that agents can invoke during execution to:- Retrieve knowledge from documents, databases, and APIs
- Execute code in sandboxed environments
- Call functions defined by your application
- Search data using Azure AI Search or Bing
- Integrate systems via Azure Functions or Logic Apps
Built-In Tools
Microsoft Foundry provides several built-in tools that work out of the box:Code Interpreter
Capability: Execute Python code in a sandboxed environment Use cases:- Mathematical calculations and data analysis
- Generate charts and visualizations
- Process CSV and data files
- Perform iterative problem-solving
- Automatic retry on code failures
- Support for popular Python libraries
- File upload and download
- Session persistence (1 hour default, 30 min idle timeout)
File Search
Capability: Retrieve information from uploaded documents Use cases:- Knowledge base queries
- Document Q&A
- Product information retrieval
- Internal documentation search
- Automatically parses and chunks documents
- Generates and stores embeddings
- Performs hybrid (vector + keyword) search
- Reranks results for relevance
- Injects top results into context
- Documents: PDF, DOCX, TXT, MD
- Code: PY, JS, JAVA, CPP, etc.
- Data: CSV, JSON, XML
- Images: JPG, PNG, GIF (with vision models)
Azure AI Search
Capability: Search custom indexes with full control Use cases:- Enterprise knowledge bases
- Custom vector search
- Semantic search
- Hybrid search strategies
- Vector search: Semantic similarity
- Keyword search: Exact matches
- Hybrid search: Combined vector + keyword
- Semantic search: AI-enhanced ranking
Custom Tools
Function Calling
Capability: Define custom functions for agents to call Use cases:- Call internal APIs
- Query databases
- Trigger workflows
- Integrate business logic
- Provide clear function descriptions
- Define parameter schemas explicitly
- Validate function inputs
- Handle errors gracefully
- Return structured JSON
Azure Functions
Capability: Execute code in Azure Functions Use cases:- Long-running operations
- Complex business logic
- Database operations
- Third-party API integrations
- Queue-based
- HTTP-based
- MCP Server
Asynchronous processing via Azure Queue Storage:
Tool Design Patterns
Sequential Tool Use
Agent calls tools one after another:Parallel Tool Use
Agent calls multiple tools simultaneously:Conditional Tool Use
Agent decides which tool to use based on context:Hierarchical Tool Use
Tools that call other tools:Tool Execution Flow
1
Agent Determines Tool Need
Model analyzes user request and identifies required tools
2
Run Status Changes
Run status changes to
requires_action with tool call details3
Application Executes Tool
Your code executes the actual function or API call
4
Submit Tool Outputs
Application submits results back to the agent
5
Agent Processes Results
Model incorporates tool outputs into response
6
Generate Response
Agent returns final answer to user
Tool Considerations
Performance
- Latency: Tool calls add execution time
- Timeouts: Runs expire after 10 minutes
- Retries: Implement retry logic for failures
- Caching: Cache frequently accessed data
Security
- Authentication: Use managed identities
- Authorization: Implement proper access controls
- Input validation: Sanitize all inputs
- Output filtering: Apply content safety checks
Cost
- Token usage: Tool outputs consume context tokens
- API calls: External API costs
- Storage: File storage for Code Interpreter and File Search
- Compute: Azure Functions execution time
Reliability
- Error handling: Graceful failure modes
- Fallbacks: Alternative approaches when tools fail
- Monitoring: Track tool invocation success rates
- Logging: Comprehensive execution logs
Tool Best Practices
Write Clear Tool Descriptions
Write Clear Tool Descriptions
The model uses your tool descriptions to decide when to call them:
Define Clear Parameters
Define Clear Parameters
Use JSON Schema to define expected inputs:
Return Structured Data
Return Structured Data
Return JSON for better model understanding:
Handle Errors Gracefully
Handle Errors Gracefully
Provide helpful error messages:
Next Steps
Code Interpreter
Execute Python code in agents
File Search
Retrieve knowledge from documents
Function Calling
Define custom agent tools
Azure AI Search
Search custom indexes