This guide explains how to add web search capabilities to AI Agent Foundry agents.
- ✅ Experience creating and managing agents in AI Agent Foundry
- ✅ TDX CLI installed and authenticated
Web Search Tool is not visible in the console UI. Configuration is only possible via TDX CLI or Treasure Studio.
1. Create Web Search Tool instance (API)
↓
2. Add tool to agent.yml (pull → edit → push)
↓
3. Test functionality# List projects with IDs
tdx llm project list --format json 2>&1 | tail -n +2 | jq -r '.[] | {id, name}'
# Or store in variable
PROJECT_ID="<your-project-id>"cat > web_search_tool.json <<EOF
{
"data": {
"type": "webSearchTools",
"attributes": {
"name": "my_web_search_tool",
"projectId": "$PROJECT_ID",
"modelType": "gpt-5-mini",
"systemPrompt": "You are a focused web search assistant. Answer only with the information requested.",
"searchContextSize": "medium",
"filters": {
"allowed_domains": [
"example.com",
"openai.com"
]
}
}
}
}
EOF
tdx api -X POST --type llm \
-H "Content-Type: application/vnd.api+json" \
-f web_search_tool.json \
/api/web_search_toolsSave the data.id from the response for later direct API calls (for example, GET/PATCH) and verification. The agent.yml example in this guide refers to the tool by name.
# Pull agent configuration
tdx agent pull "Project Name" -yAdd to agents/Project Name/agent-name/agent.yml:
tools:
- type: web_search
target: '@ref(type: "web_search_tool", name: "my_web_search_tool")'
target_function: SEARCH
function_name: search_web
function_description: Search the web for current informationKey points:
targetname must matchattributes.namefrom Step 1function_descriptionguides the LLM's tool selection decisions
tdx agent push "agents/Project Name/" -ytdx chat --agent "Project Name/agent-name" \
--new "What is the latest news about Anthropic?"Success if web search executes and returns current information.
| Parameter | Required | Default | Description |
|---|---|---|---|
name | ✅ | - | Tool name (referenced in @ref) |
projectId | ✅ | - | Project ID |
modelType | ✅ | - | gpt-5-mini |
systemPrompt | ❌ | null | System prompt for web search |
searchContextSize | ❌ | medium | low / medium / high |
userLocation | ❌ | null | Location object for regional optimization |
filters.allowed_domains | Conditional | [] | Allowed domain list (max 20, no https://). If you include filters, you must include allowed_domains; an empty array ([]) is allowed. |
"userLocation": {
"type": "approximate",
"country": "JP",
"city": "Minato",
"region": "Tokyo",
"timezone": "Asia/Tokyo"
}| Field | Required | Description |
|---|---|---|
type | ✅ | web_search (fixed) |
target | ✅ | @ref(type: "web_search_tool", name: "...") |
target_function | ✅ | SEARCH (fixed) |
function_name | ✅ | Function name shown to LLM |
function_description | ✅ | Function description shown to LLM |
To reduce costs:
- modelType: Use
gpt-5-mini - searchContextSize: Use
lowormedium(highis expensive) - allowed_domains: Restrict to trusted domains only
- systemPrompt: Include instructions for concise responses
Update example:
cat > update.json <<EOF
{
"data": {
"type": "webSearchTools",
"attributes": {
"modelType": "gpt-5-mini",
"searchContextSize": "low"
}
}
}
EOF
tdx api -X PATCH --type llm \
-H "Content-Type: application/vnd.api+json" \
-f update.json \
/api/web_search_tools/<TOOL_ID>Cause:
- Web Search Tool feature not enabled for account
- Web Search Tool instance doesn't exist
Solution:
# Verify Web Search Tool exists
tdx api --type llm /api/web_search_tools | jq '.data[] | {id, name, projectId}'
# Contact Support for feature enablementCause:
- Including
https://in domain names - Adding subdomains individually
Solution:
- Specify domain only:
openai.com(nothttps://openai.com) - Subdomains are automatically allowed (no need to add separately)
Cause:
- Using
searchContextSize: high
Solution:
- See "Cost Optimization" section above
Cause:
- Missing
Content-Type: application/vnd.api+jsonheader in API call
Solution:
# Required: include the Content-Type header
tdx api -X POST --type llm \
-H "Content-Type: application/vnd.api+json" \
-f payload.json \
/api/web_search_toolsList all:
tdx api --type llm /api/web_search_toolsGet details:
tdx api --type llm /api/web_search_tools/<TOOL_ID>Update:
tdx api -X PATCH --type llm \
-H "Content-Type: application/vnd.api+json" \
-f update.json \
/api/web_search_tools/<TOOL_ID>Delete:
tdx api -X DELETE --type llm /api/web_search_tools/<TOOL_ID># Check tools attached to agent
tdx api --type llm /api/agents/<AGENT_ID> | jq '.data.attributes.tools'Expected output:
[
{
"toolTargetId": "<WEB_SEARCH_TOOL_ID>",
"targetFunction": "SEARCH",
"functionName": "search_web",
"functionDescription": "Search the web for current information",
"toolTargetType": "WebSearchTool"
}
]Q: How to add to new project/agent?
A: After creating project, create Web Search Tool with new project ID in Step 1. For agent creation, use API with explicit projectId:
cat > agent.json <<EOF
{
"data": {
"type": "agents",
"attributes": {
"name": "new-agent",
"projectId": "$PROJECT_ID",
"systemPrompt": "Your prompt here",
"modelType": "claude-4.5-sonnet"
}
}
}
EOF
tdx api -X POST --type llm \
-H "Content-Type: application/vnd.api+json" \
-f agent.json \
/api/agentsQ: Correct Claude model name format?
A: claude-4.5-sonnet (note hyphens and periods)
Q: Using multiple tools together?
A: Add multiple tool definitions under tools: in agent.yml:
tools:
- type: knowledge_base
target: '@ref(type: "knowledge_base", name: "product-catalog")'
target_function: SEARCH
function_name: search_products
function_description: Search internal product catalog
- type: web_search
target: '@ref(type: "web_search_tool", name: "my_web_search_tool")'
target_function: SEARCH
function_name: search_web
function_description: Search the web for current informationDocument Version: v2.1 Last Updated: 2026-03-16