X Search
The XSearch capability gives your agent search over X (Twitter) posts. It’s a provider-adaptive tool backed by XSearchTool on the native side — see X Search Tool for configuration options.
Unlike Web Search and Web Fetch, there is no default non-xAI fallback: X search is only available natively on xAI models. If your agent is not running on an xAI model, set fallback_subagent_model explicitly to an xAI model that supports XSearchTool, and search requests are delegated to that model as a subagent tool:
from pydantic_ai import Agent
from pydantic_ai.capabilities import XSearch
agent = Agent(
'anthropic:claude-sonnet-4-6',
capabilities=[XSearch(fallback_subagent_model='xai:grok-4.3')],
)
native= can be a factory: a callable taking RunContext that returns XSearchTool or None — XSearchNativeTool is the type the fallback_subagent_model subagent accepts. It resolves on each model request, and again when the subagent runs — so keep it free of one-shot side effects. Both resolutions belong to the same run and carry the same deps, but they do not share a RunContext: the subagent resolves from its own tool call, so tool_call_id and tool_name name that call instead of being None, and messages holds the run so far. Read ctx.deps for configuration that has to match across both. On the subagent, capability-level fields such as include_output override the factory result. See Dynamic Configuration.