Hex

From getsentry/junior · View interactive version

Hex is an AI agent skill from the GitHub repository getsentry/junior. Internal data access primitive. Executes a Hex query and returns structured results. Called by core skills — not intended for direct use. Invoke when you need to run a Hex query on behalf of a core skill that has provided a query and pattern. Do not use for Sentry product telemetry, Sentry feature-u

How to use this skill

Skill file

Query Hex (Atomic)

Single responsibility: execute a Hex query via MCP, poll for completion, and return results matched against the caller-provided pattern. Hex Threads take a few minutes to run — this skill owns the full create → poll → extract cycle.

Input

Receive all three from the calling core skill:

Prompt Construction (Critical — Read Before Creating a Thread)

Hex's Threads Agent decides which tables to query and what SQL to run based entirely on your prompt. A vague prompt causes broad table exploration and significantly slower responses. A precise prompt can shave several minutes off query time.

Rules

  1. Batch everything into one prompt. Include every metric and data point the caller needs in a single create_thread call. Do NOT use continue_thread to fetch additional fields — each call re-triggers the full agent pipeline and adds multiple minutes of latency. Treat continue_thread as a last resort only when a genuinely requested data point is absent from the initial response.
  1. Anchor on a specific entity identifier. Always include the primary key or identifier for the entity being queried (e.g. account ID, org slug, user ID, opportunity ID). Never rely on Hex to infer the entity from a name or description alone.
  1. Use exact field and table terminology. Vague terms force Hex to guess. Use the canonical column names, table names, and metric names from the caller's data model. If the caller provides known column names, include them in the prompt.
  1. Specify the time window explicitly. Always state the period: "for the last 28 days", "from [start date] to today", "monthly for the last 6 months".
  1. Request structured output. End every prompt with: "Return results in a structured list or table."
  1. Pass raw SQL when available. When the caller provides a specific SQL query, pass it directly to create_thread — the agent will execute it as-is, which is faster than natural language exploration.

Example: Natural Language Query

"For account ID '12345': return (1) total revenue for the last 90 days, (2) number of active users this month, and (3) any plan or subscription changes in the last 30 days. Return results in a structured list."

Example: Raw SQL Query

"Run this SQL: SELECT id, name, revenue, created_at FROM \my-project.dataset.orders\ WHERE account_id = '12345' AND created_at >= DATE_SUB(CURRENT_DATE(), INTERVAL 90 DAY) ORDER BY created_at DESC"

Steps

  1. Create a Hex thread.

Call create_thread with the fully constructed prompt.

If the call fails (network error, auth error), return immediately with status: "error" and the error message.

  1. Poll for completion.

Call get_thread to check thread status.

```json

{

"status": "timeout",

"value": null,

"source": "Hex",

"raw": "Hex query did not complete after 10 polling attempts."

}

```

  1. Extract the result.

Once the thread reaches IDLE, read the response content. Reason against the returned data using the caller-provided pattern to locate and extract the target value(s).

  1. Use continue_thread only as a last resort.

If a genuinely requested data point is completely absent from the response (not just unlabeled or formatted differently), use continue_thread once to ask for it specifically. Re-extract after. Do not use it to request additional data the caller didn't include in the original query — that is a caller-side error.

  1. Return structured output.

Return one of:

```json

{

"status": "found",

"value": "<extracted value(s) matching the pattern>",

"source": "Hex",

"raw": "<full thread response for debugging>"

}

```

```json

{

"status": "not_found",

"value": null,

"source": "Hex",

"raw": "<full thread response for debugging>"

}

```

Constraints

Guardrails

Auth and error handling

Query safety

Rate limits

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.