Skip to main content

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
Tools transform agents from conversational interfaces into action-taking systems.

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
Example:
Features:
  • Automatic retry on code failures
  • Support for popular Python libraries
  • File upload and download
  • Session persistence (1 hour default, 30 min idle timeout)
Code Interpreter has additional charges beyond token-based fees. Each concurrent session is billed separately.
Capability: Retrieve information from uploaded documents Use cases:
  • Knowledge base queries
  • Document Q&A
  • Product information retrieval
  • Internal documentation search
Example:
How it works:
  1. Automatically parses and chunks documents
  2. Generates and stores embeddings
  3. Performs hybrid (vector + keyword) search
  4. Reranks results for relevance
  5. Injects top results into context
Supported formats:
  • Documents: PDF, DOCX, TXT, MD
  • Code: PY, JS, JAVA, CPP, etc.
  • Data: CSV, JSON, XML
  • Images: JPG, PNG, GIF (with vision models)
Capability: Search custom indexes with full control Use cases:
  • Enterprise knowledge bases
  • Custom vector search
  • Semantic search
  • Hybrid search strategies
Example:
Search types:
  • 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
Example:
Best practices:
  • 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
Integration methods:
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 details
3

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

The model uses your tool descriptions to decide when to call them:
Use JSON Schema to define expected inputs:
Return JSON for better model understanding:
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