Built-in tools: web_search, x_search, and more
On this page
Tools that serve agents
An agent team without tools stays locked inside what the model memorized during training. The whole value of multi-agent work shows up when those agents go find information at the moment you ask the question: parallelization only helps if there are several paths to explore at the same time. Grok gives them five built-in tools, and each agent decides on its own which ones to use.
web_search, the engine behind parallel research
Web search is the dominant tool in multi-agent work, the one you will enable in almost all your requests.
from xai_sdk.tools import web_search
chat = client.chat.create(
model="grok-4.20-multi-agent-0309",
agent_count=4,
tools=[web_search()],
)
What changes here compared with a single model is that each agent runs its own queries. On a question such as “which backup solution should we choose for our server fleet,” one agent will dig into technical specs, another into pricing, and a third into user feedback on specialized forums. With 16 agents, the web coverage is nothing like what a sequential search run by a single model can reach.
x_search, the tool the others don’t have
Search on X, formerly Twitter, is specific to Grok and gives access to posts, discussions, and trends on the platform in real time.
from xai_sdk.tools import web_search, x_search
chat = client.chat.create(
model="grok-4.20-multi-agent-0309",
agent_count=4,
tools=[web_search(), x_search()],
)
Its value comes from a timing gap: when a company announces a product, reactions appear on X within an hour, while in-depth articles take several days. You find the immediate reaction to an announcement, the positions of experts who will never write a full article, trending topics, and technical discussions in developer communities. On a fast-moving topic, the combination of web_search + x_search produces a picture that neither would give on its own.
code_execution, when you need to calculate rather than read
Code execution lets an agent write and run Python to analyze data, perform calculations, or produce visualizations.
from xai_sdk.tools import code_execution
chat = client.chat.create(
model="grok-4.20-multi-agent-0309",
agent_count=4,
tools=[code_execution()],
)
The typical scenario: an agent retrieves a CSV file found during its search, loads it, derives statistics from it, and passes verified numbers to the lead agent rather than an impression from reading. Part of the work thus moves from interpretation to calculation, which matters as soon as the question involves orders of magnitude.
collections_search, your documents in the loop
This tool lets agents query the document collections you have indexed at xAI.
from xai_sdk.tools import collections_search
chat = client.chat.create(
model="grok-4.20-multi-agent-0309",
agent_count=4,
tools=[collections_search()],
)
It is the equivalent of built-in RAG: agents search your own documents alongside the web, which lets you cross-reference internal documentation with market conditions without building the retrieval pipeline yourself.
Remote MCP, a door into your own systems
Remote MCP tools extend agent capabilities with external services you control. If you expose MCP servers, agents use them during their research exactly like native tools: querying an internal database, calling a business API, reaching a document management system. This is the official extension mechanism, and you will see in the next lesson that it is also the answer to an important limitation of multi-agent work.
Making tools work together
The real gain appears when several tools are available at the same time, because the split between agents also becomes a split between sources.
from xai_sdk.tools import web_search, x_search, code_execution
chat = client.chat.create(
model="grok-4.20-multi-agent-0309",
agent_count=16,
tools=[web_search(), x_search(), code_execution()],
include=["verbose_streaming"],
)
chat.append(user(
"Analyze sentiment around NVIDIA's GPU announcements this week: "
"press articles, reactions on X, and summarize the key figures"
))
Some agents then review the press, another group analyzes posts on X, and a third aggregates the numbers through code. Keep the multiplier effect in mind: every tool you open to sixteen agents broadens coverage and increases the bill accordingly. Open what the question needs, not everything by default.
Key takeaways
- Five built-in tools:
web_search,x_search,code_execution,collections_search, Remote MCP - Each agent can use any tool independently of the others
x_searchis exclusive to Grok — real-time access to X posts- Combine tools for more complete research
- More agents + more tools = broader coverage but higher token usage