
Ag2 Use Builtin Tools
- 34 installs
- 8 repo stars
- Updated July 27, 2026
- ag2ai/ag2-skills
ag2-use-builtin-tools is a Claude Code skill that wires AG2 beta's shipped provider-native and local tools into an Agent instead of writing custom Python.
About
This skill shows how to wire AG2 beta's shipped tools into an Agent rather than writing custom Python. It covers provider-native server-side tools such as web search, web fetch, code execution, MCP server integration, and image generation, plus locally executed toolkits like FilesystemToolkit, DuckDuckGo, Exa, and Tavily search. A developer uses it to add ready-made capabilities to an agent and to check per-tool provider support before wiring.
- Wire AG2 beta's shipped tools into an Agent instead of writing custom Python
- Covers provider-native tools (web search, web fetch, code execution, MCP, image generation) and local toolkits (filesyst
- Includes a per-tool provider-support matrix and version-pinning guidance
Ag2 Use Builtin Tools by the numbers
- 34 all-time installs (skills.sh)
- Ranked #8,855 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 1, 2026 (Skillselion catalog sync)
ag2-use-builtin-tools capabilities & compatibility
Free skill; some tools need provider or third-party API keys (e.g. EXA_API_KEY, TAVILY_API_KEY) plus an LLM key.
- Capabilities
- tool integration · web search · code execution · mcp integration · filesystem access
- Use cases
- web search · web scraping · image generation
- Pricing
- Bring your own API key
What ag2-use-builtin-tools says it does
Wire AG2 beta's shipped tools into an `Agent` — both provider-native server-side tools (web search, web fetch, code execution, MCP, image generation, memory) and locally-executed common toolkits
`base_path` is enforced — `../../etc/passwd` raises `PermissionError`.
npx skills add https://github.com/ag2ai/ag2-skills --skill ag2-use-builtin-toolsAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 34 |
|---|---|
| repo stars | ★ 8 |
| Last updated | July 27, 2026 |
| Repository | ag2ai/ag2-skills ↗ |
What it does
Add AG2 beta's built-in web-search, code-execution, MCP, filesystem, or third-party search tools to an Agent.
Who is it for?
Developers adding ready-made web-search, code-execution, MCP, filesystem, or third-party search capabilities to an AG2 agent.
Skip if: Shell commands (use ag2-shell-tool) or custom Python tools (use ag2-add-custom-tool).
When should I use this skill?
The user wants a capability AG2 already ships rather than writing custom Python.
What you get
The agent gains built-in tools like web search, code execution, MCP, and filesystem access with correct provider pinning.
- AG2 Agent wired with built-in provider-native and local tools
By the numbers
- references/builtin_tools_matrix.md documents per-tool provider support
Files
Use AG2 beta's built-in tools
When to use
Reach for this skill when the user wants to add a capability that AG2 already ships. Two families:
1. Provider-native tools (autogen.beta.tools — WebSearchTool, CodeExecutionTool, etc.) — executed server-side by Anthropic / OpenAI / Gemini. No Python implementation on your side. 2. Common toolkits (autogen.beta.tools — FilesystemToolkit, DuckDuckSearchTool, TavilySearchTool, SkillsToolkit; plus ExaToolkit from autogen.beta.extensions.tools.search) — regular Python that runs in your process and works with every provider.
For shell commands, use ag2-shell-tool (it's important enough to live in its own skill). For custom Python tools, use ag2-add-custom-tool.
60-second recipes
Web search (provider-native)
from autogen.beta import Agent
from autogen.beta.config import AnthropicConfig
from autogen.beta.tools import WebSearchTool, UserLocation
agent = Agent(
"researcher",
config=AnthropicConfig(model="claude-sonnet-4-6"),
tools=[
WebSearchTool(
max_uses=5,
user_location=UserLocation(country="US"),
allowed_domains=["github.com", "pypi.org"],
blocked_domains=["pinterest.com"],
),
],
)Web fetch (Anthropic / Gemini only)
from autogen.beta.tools import WebFetchTool
tools = [WebFetchTool(max_uses=3, max_content_tokens=50000, citations=True)]Code execution
from autogen.beta.tools import CodeExecutionTool
agent = Agent("analyst", config=config, tools=[CodeExecutionTool()])MCP server integration
from autogen.beta.tools import MCPServerTool
tools = [
MCPServerTool(
server_url="https://mcp.example.com/sse",
server_label="my-tools",
allowed_tools=["search", "summarize"],
),
]Image generation (OpenAI Responses only)
from autogen.beta.config import OpenAIResponsesConfig
from autogen.beta.tools import ImageGenerationTool
agent = Agent(
"designer",
config=OpenAIResponsesConfig(model="gpt-4.1"),
tools=[ImageGenerationTool(quality="high", size="1024x1024", output_format="png")],
)
reply = await agent.ask("Generate a logo for a coffee shop.")
images = reply.files # list[BinaryResult]Filesystem (sandboxed, any provider)
from autogen.beta.tools import FilesystemToolkit
fs = FilesystemToolkit(base_path="/tmp/workspace")
agent = Agent("worker", config=config, tools=[fs])base_path is enforced — ../../etc/passwd raises PermissionError. Use read_only=True to expose only read_file and find_files. For ephemeral workspaces use tempfile.TemporaryDirectory() rather than hardcoding /tmp.
Web search via DuckDuckGo (no API key)
from autogen.beta.tools import DuckDuckSearchTool
# requires: pip install ag2[ddgs]
tools = [DuckDuckSearchTool(max_results=10, region="us-en", safesearch="moderate")]Exa neural search
import os
from autogen.beta.extensions.tools.search import ExaToolkit
# requires: pip install "exa-py>=2.12.1,<3" (no ag2[exa] extra — install the package directly)
tools = [ExaToolkit(api_key=os.environ["EXA_API_KEY"])]Each tool is exposed as a factory method (exa.search(), exa.find_similar(), exa.get_contents(), exa.answer()) so you can pass only what you need with per-call config.
Tavily search
import os
from autogen.beta.tools import TavilySearchTool
# requires: pip install ag2[tavily]
tools = [TavilySearchTool(
api_key=os.environ["TAVILY_API_KEY"],
search_depth="advanced",
include_answer=True,
)]Going deeper
- Per-tool provider support, every parameter, version pinning —
references/builtin_tools_matrix.md. - Source docs —
website/docs/beta/tools/builtin_tools.mdx(provider-native),website/docs/beta/tools/common_toolkits.mdx(common toolkits — also coversSkillsToolkitandSkillSearchToolkit). - Toolkits authoring —
website/docs/beta/tools/toolkits.mdx.
Common pitfalls
- Mismatch between tool and provider —
WebFetchToolraises with OpenAI;MemoryToolis Anthropic-only;ImageGenerationToolis OpenAI Responses only. Checkreferences/builtin_tools_matrix.mdfirst. - Anthropic tool versions default to older revisions — pin
version="web_search_20260209"etc. when you need dynamic filtering on Opus 4.6 / Sonnet 4.6. - `FilesystemToolkit` paths are sandboxed — by design. Don't try to bypass the path-traversal guard; choose a wider
base_pathinstead. - Toolkits and individual tools mix freely —
tools=[fs, exa, my_custom_tool]is fine. - Optional dependency missing —
DuckDuckSearchTool(ag2[ddgs]) andTavilySearchTool(ag2[tavily]) need theirag2[<extra>]install;ExaToolkitis a beta extension with no `ag2` extra — install its package directly (pip install "exa-py>=2.12.1,<3"). Without the dependency you get a clearImportErrorfrom the config-fallback layer, not a confusing crash. Install before delivering the code. If you cannot run commands, state the exactpip installcommand.
Built-in tools — provider matrix and per-tool parameters
Provider-native tools (server-side execution)
| Tool | Anthropic | OpenAI | Gemini |
|---|---|---|---|
CodeExecutionTool | ✓ | ✓ | ✓ |
WebSearchTool | ✓ | ✓ | ✓ |
WebFetchTool | ✓ | ✗ | ✓ |
ShellTool | ✗ | ✓ (Responses) | ✗ |
MCPServerTool | ✓ | ✓ | ✗ |
ImageGenerationTool | ✗ | ✓ | ✗ |
MemoryTool | ✓ | ✗ | ✗ |
Unsupported combinations raise UnsupportedToolError at request time.
WebSearchTool parameters
| Parameter | Anthropic | OpenAI | Gemini |
|---|---|---|---|
max_uses | ✓ | ✓ | ✗ |
user_location | ✓ | ✓ | ✗ |
search_context_size | ✗ | ✓ | ✗ |
allowed_domains | ✓ | ✓ | ✗ |
blocked_domains | ✓ | ✗ | ✓ |
Unsupported parameters are silently ignored.
WebFetchTool parameters (Anthropic / Gemini only)
| Parameter | Anthropic | Gemini |
|---|---|---|
max_uses | ✓ | ✗ |
allowed_domains | ✓ | ✗ |
blocked_domains | ✓ | ✗ |
citations | ✓ | ✗ |
max_content_tokens | ✓ | ✗ |
MCPServerTool parameters
| Parameter | Anthropic | OpenAI |
|---|---|---|
server_url | ✓ | ✓ |
server_label | ✓ | ✓ |
authorization_token | ✓ | ✗ |
description | ✓ | ✗ |
allowed_tools | ✓ | ✓ |
blocked_tools | ✓ | ✗ |
headers | ✗ | ✓ |
ImageGenerationTool parameters (OpenAI Responses only)
| Parameter | Description |
|---|---|
quality | "low", "medium", "high", "auto" |
size | e.g. "1024x1024", "1536x1024", "auto" |
background | "transparent", "opaque", "auto" |
output_format | "png", "jpeg", "webp" |
output_compression | 0–100, jpeg/webp only |
partial_images | 1–3, partial-stream count |
Generated images surface on reply.files: list[BinaryResult].
Anthropic tool versions
Newer Anthropic tool revisions support dynamic filtering (the model writes code to filter results before they reach context) but require Opus 4.6 / Sonnet 4.6.
from autogen.beta.tools import WebFetchTool, WebSearchTool
tools = [
WebSearchTool(version="web_search_20260209"), # default: web_search_20250305
WebFetchTool(version="web_fetch_20260209"), # default: web_fetch_20250910
]Default versions are compatible with all Claude models including Haiku.
Common toolkits (local execution, all providers)
FilesystemToolkit
| Tool | Description |
|---|---|
read_file | Read a file |
write_file | Create / overwrite (auto-creates parent dirs) |
update_file | Replace first occurrence of a string |
delete_file | Delete a file |
find_files | Glob search (supports **) |
Constructor:
FilesystemToolkit(base_path="/tmp/workspace", read_only=False)base_path is enforced — escape attempts raise PermissionError. Individual tools available as fs.read_file(), fs.find_files(), etc.
DuckDuckSearchTool
DuckDuckSearchTool(
max_results=5, # default
region="us-en", # default
safesearch="moderate", # "on" | "moderate" | "off"
)All parameters accept Variable(...) for deferred resolution.
ExaToolkit
Import from autogen.beta.extensions.tools.search (beta extension, not autogen.beta.tools).
| Tool factory | Description |
|---|---|
toolkit.search(...) | Neural web search with filters |
toolkit.find_similar(...) | Find pages similar to a URL |
toolkit.get_contents(...) | Fetch full text |
toolkit.answer(...) | LLM answer with citations |
Constructor:
ExaToolkit(api_key=..., num_results=10, max_characters=2000)Per-call factory params include search_type, category, include_domains, exclude_domains, start_published_date, end_published_date, use_autoprompt, livecrawl. All accept Variable.
TavilySearchTool
TavilySearchTool(
api_key=...,
max_results=5,
search_depth="advanced", # "basic" | "advanced" | "fast" | "ultra-fast"
topic="news", # "general" | "news" | "finance"
include_answer=True,
include_raw_content=True,
include_images=True,
time_range="week", # "day" | "week" | "month" | "year"
include_domains=[...],
exclude_domains=[...],
)SkillsToolkit / SkillSearchToolkit
Discovers and runs skills following the agentskills.io convention. By default reads from .agents/skills/ in the current working directory.
from autogen.beta.tools import SkillsToolkit
from autogen.beta.tools.skills import LocalRuntime
skills = SkillsToolkit() # uses .agents/skills/
skills = SkillsToolkit(runtime="./my-skills") # custom dir
skills = SkillsToolkit(runtime=LocalRuntime("./my-skills", extra_paths=["./shared-skills"]))Three-step progressive disclosure: list_skills (catalog) → load_skill (full SKILL.md) → run_skill_script (execute a script).
SkillSearchToolkit adds search_skills, install_skill, remove_skill against the skills.sh registry. Set GITHUB_TOKEN (env or SkillsClientConfig) to lift the GitHub API rate limit from 60 → 5000 requests/hour.
Required extras
| Tool | pip install |
|---|---|
DuckDuckSearchTool | ag2[ddgs] |
ExaToolkit | "exa-py>=2.12.1,<3" (no ag2 extra — beta extension) |
TavilySearchTool | ag2[tavily] |
| Provider-native tools | the provider's own extra (ag2[anthropic], ag2[openai], ag2[gemini]) |
Related skills
FAQ
What tool families does AG2 ship?
Provider-native tools executed server-side (web search, web fetch, code execution, MCP, image generation, memory) and local common toolkits that run in your process (filesystem, DuckDuckGo, Exa, Tavily, skills).
Why does my WebFetchTool fail on OpenAI?
WebFetchTool is Anthropic/Gemini only, MemoryTool is Anthropic-only, and ImageGenerationTool is OpenAI Responses only; check the built-in tools matrix before wiring a tool to a provider.