X (Twitter) Search Integration for Hermes Agent

Search X (Twitter) posts, profiles, and threads directly from Hermes Agent using Grok.

Data & On-Chainintermediate8 min readVerified Oct 25, 2026

Hermes x_search Tool Reference

Purpose

The x_search tool enables the Hermes agent to search X (Twitter) posts, profiles, and threads via xAI's server-side search. It returns synthesized results with citations, providing a read-only discovery layer for public X content.

When to Use

Use x_search when you need current discussion, reactions, or claims specifically on X. It is ideal for discovering candidate public posts before switching to the xurl skill for exact reads or state-changing actions.

Do NOT use x_search for:

  • Posting, replying, liking, sending DMs, uploading media, deleting content, or proving account state changes.
  • General web pages. Use web_search or web_extract instead.

Prerequisites

Before using x_search, you must have xAI credentials configured. The tool auto-enables when credentials are present. You can disable it manually via hermes tools.

Credential Options

Two credential paths are available:

  • SuperGrok / X Premium+ OAuth token: Add via hermes auth add xai-oauth.
  • xAI API key: Set XAI_API_KEY in ~/.hermes/.env.

If both are configured, the SuperGrok OAuth token is preferred at call time (uses subscription quota). Live Search calls bill against the same xAI key configured for chat if using Portal.

The check_fn runs every time the model's tool list is rebuilt. It returns True only if a bearer token is fetchable, non-empty, and successfully refreshed if expired. Revoked tokens with failed refresh hide the tool from the schema.

Enabling the Tool

The tool auto-enables when xAI credentials (OAuth token or XAI_API_KEY) are present. To disable it explicitly:

  1. Run hermes tools.
  2. Navigate to Search > x_search.
  3. Press space to toggle the tool off.

The picker offers two credential choices: xAI Grok OAuth (SuperGrok/Premium+) or xAI API key. Either choice satisfies gating.

Configuration

Edit ~/.hermes/config.yaml under the x_search: section. The following settings are available:

  • model: The Grok model to use. Default is grok-4.5. Any Grok model with x_search tool access works.
  • reasoning_effort: Optional. Values: low, medium, high, or xhigh. Only supported by models that accept it, such as grok-4.20-multi-agent. Invalid values fail before the API request.
  • timeout_seconds: Default is 180. Minimum is 30.
  • retries: Default is 2. Each retry backs off at 1.5x the attempt seconds, capped at 5 seconds.

Example configuration:

x_search:
  model: grok-4.5
  reasoning_effort: medium
  timeout_seconds: 180
  retries: 2

Parameters

The agent calls x_search with the following parameters. Only query is required.

ParameterMeaningRequired
queryWhat to look up on X.true
allowed_x_handlesOptional list of handles to include exclusively (max 10). Leading @ is stripped.false
excluded_x_handlesOptional list of handles to exclude (max 10). Mutually exclusive with allowed_x_handles.false
from_dateOptional start date in YYYY-MM-DD format.false
to_dateOptional end date in YYYY-MM-DD format.false
enable_image_understandingAsk xAI to analyze images attached to matching posts.false
enable_video_understandingAsk xAI to analyze videos attached to matching posts.false

Parameter Constraints

  • allowed_x_handles and excluded_x_handles are mutually exclusive. You cannot set both in the same call.
  • Each list is limited to 10 handles.
  • from_date and to_date are validated client-side before the HTTP call. Validation rules:
    • Must be YYYY-MM-DD format.
    • from_date must be less than or equal to to_date.
    • from_date must not be later than today UTC.
    • to_date in the future is allowed.
  • Validation failures return a structured error JSON. No HTTP call to xAI is made.

Using the Tool

Procedure

  1. The agent calls x_search with the required query and any optional parameters.
  2. The tool returns a JSON response with the following fields:
    • answer
    • citations
    • inline_citations
    • degraded
    • degraded_reason
    • credential_source
    • model
    • query
    • provider
    • tool
    • success

Handling the Response

  • If degraded is true, treat the answer as unsourced. It comes from model knowledge, not the X index. The degraded_reason field provides context.
  • If degraded is false and no filters were set, a broad unsourced answer is just an answer (not degraded).
  • For state-changing actions (posting, replying, liking, etc.), switch to the xurl skill. Confirm the exact target post via xurl output or X API response before acting. An x_search answer is never evidence that a write happened.

Failure Modes

No xAI Credentials Available

Both auth paths fail. Set XAI_API_KEY in ~/.hermes/.env or run hermes auth add xai-oauth.

x_search Not Enabled for This Model

The configured model lacks x_search tool access. Switch to grok-4.5 or another supported Grok model.

Tool Doesn't Appear in Schema

The toolset is not enabled (check hermes tools) or no xAI credentials are available (check hermes auth status).

Degraded Response with No Citations

Possible causes:

  • Typo in a handle.
  • Date range too narrow.
  • xAI index gap.

Retry with adjusted parameters or use the xurl skill for direct access.

Date Validation Failures

Return a structured error JSON as the tool result. Example:

{"error": "from_date must be YYYY-MM-DD format"}

Invalid reasoning_effort

Fails before the API request. Ensure the value is one of low, medium, high, or xhigh, and that the model supports it.

Constraints and Caveats

  • x_search is read-only. It cannot post, reply, like, DM, upload media, delete, or prove account state changes.
  • An x_search answer is never evidence that a write happened. Must be confirmed by xurl output or X API response.
  • allowed_x_handles and excluded_x_handles are mutually exclusive.
  • Each handle list is limited to 10 handles.
  • Date parameters are validated client-side. Invalid dates return structured error JSON without an HTTP call.
  • degraded: true means filters were set but no citations returned. The answer is unsourced.
  • degraded: false when no filters are set (a broad unsourced answer is just an answer).
  • reasoning_effort is sent as reasoning: {effort: ...}. Invalid values fail before the API request.
  • Both xAI credential paths hit the same endpoint with the same payload. Only the bearer token differs.
  • When both credentials are configured, SuperGrok OAuth wins (uses subscription quota).
  • The check_fn runs every time the model's tool list is rebuilt. Returns True only if the bearer token is fetchable, non-empty, and successfully refreshed if expired. Revoked tokens with failed refresh hide the tool from the schema.

Examples

Example 1: Searching with Handle Filter

User asks: "What are people on X saying about the new Grok image features? Focus on responses from @xai."

The agent calls x_search with:

  • query: "reactions to new Grok image features"
  • allowed_x_handles: ["xai"]

The tool returns a synthesized answer with citations. The agent replies with the answer and references.

Example 2: Transitioning to State-Changing Actions

If the next request is "reply to the best one" or "like that post", the agent switches to the xurl skill. It confirms the exact target post using xurl output or X API response before performing the action.

Retry Behavior

The tool automatically retries on 5xx errors, ReadTimeout, and ConnectionError. Each retry backs off at 1.5x the attempt seconds, capped at 5 seconds. The number of retries is configured via the retries setting in ~/.hermes/config.yaml (default 2).

Mixed Workflows

For workflows that require both discovery and action, use x_search for discovery and the xurl skill for exact reads and state-changing actions. This separation ensures that read-only discovery does not inadvertently trigger writes.

Sources & References

This page was researched from 1 independent source, combined and verified for completeness.

Newsletter

The #1 AI Newsletter

The most important ai updates, guides, and fixes — one weekly email.

No spam, unsubscribe anytime. Privacy policy

Other Hermes Agent integrations