Token导航 LogoToken导航TokenDH.com
研究检索external-servicegithub未标认证来源可访问许可证需确认审计异常

exploring-llm-tracesexploring LLM traces 搜索

Agent Skill

exploring-llm-traces 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

679

周安装

28

GitHub Stars

31

下载量

222
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:exploring-llm-traces(exploring LLM traces 搜索)
来源仓库:https://github.com/posthog/skills
仓库路径:skills/exploring-llm-traces
安装命令:
npx skills add https://github.com/posthog/skills --skill exploring-llm-traces
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/posthog/skills --skill exploring-llm-traces

简介

exploring-llm-traces 查询 AI 交互 trace 树形事件结构。

  • 支持按 span 层级钻取单个 API 调用详情与 token 消耗。
  • 适用于性能瓶颈分析与 RAG 流程完整性验证。
  • trace 数据保留周期有限,建议及时导出关键案例存档。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Exploring LLM traces with MCP tools

PostHog captures LLM/AI agent activity as traces. Each trace is a tree of events representing a single AI interaction — from the top-level agent invocation down to individual LLM API calls.

Available tools

ToolPurpose
posthog:query-llm-traces-listSearch and list traces (compact — no large content)
posthog:query-llm-traceGet a single trace by ID with full event tree
posthog:execute-sqlAd-hoc SQL for complex trace analysis

Event hierarchy

See the event reference for the full schema.

$ai_trace (top-level container)
  └── $ai_span (logical groupings, e.g. "RAG retrieval", "tool execution")
        ├── $ai_generation (individual LLM API call)
        └── $ai_embedding (embedding creation)

Events are linked via $ai_parent_id → parent's $ai_span_id or $ai_trace_id.

Workflow: debug a trace from a URL

Step 1 — Fetch the trace

posthog:query-llm-trace
{
  "traceId": "<trace_id>",
  "dateRange": {"date_from": "-7d"}
}

The result contains the full event tree with all properties. The response may be large — when it exceeds the inline limit, Claude Code auto-persists it to a file.

From the result you get:

  • Every event with its type ($ai_span, $ai_generation, etc.)
  • Span names ($ai_span_name) — these are the tool/step names
  • Latency, error flags, models used
  • Parent-child relationships via $ai_parent_id
  • _posthogUrlalways include this in your response so the user can click through to the UI

Step 2 — Parse large results with scripts

When the result is persisted to a file (large traces with full $ai_input/$ai_output_choices), use the parsing scripts to explore it.

Start with the summary to get the full picture, then drill into specifics:

# 1. Overview: metadata, tool calls, final output, errors
python3 scripts/print_summary.py /path/to/persisted-file.json

# 2. Timeline: chronological event list with truncated I/O
python3 scripts/print_timeline.py /path/to/persisted-file.json

# 3. Drill into a specific span's full input/output
SPAN="tool_name" python3 scripts/extract_span.py /path/to/persisted-file.json

# 4. Full conversation with thinking blocks and tool calls
python3 scripts/extract_conversation.py /path/to/persisted-file.json

# 5. Search for a keyword across all properties
SEARCH="keyword" python3 scripts/search_traces.py /path/to/persisted-file.json

All scripts support MAX_LEN=N env var to control truncation (0 = unlimited).

Investigation patterns

"Did the agent use the tool correctly?"

  1. Find the $ai_span for the tool call (look at $ai_span_name)
  2. Check $ai_input_state — what arguments were passed to the tool?
  3. Check $ai_output_state — what did the tool return?
  4. Check $ai_is_error — did the tool call fail?

"Was the context correct?" / "Were the right files surfaced?"

  1. Find the $ai_generation event where the LLM made the decision
  2. Check $ai_input — this is the full message history the LLM saw
  3. Look at preceding $ai_span events for retrieval/search steps
  4. Check their $ai_output_state — what content was retrieved and fed to the LLM?

"Did the subagent work?"

  1. In the structural overview, find spans that are children of other spans (via $ai_parent_id)
  2. The parent span is the orchestrator; child spans are subagent steps
  3. Check each child's $ai_output_state and $ai_is_error
  4. If a child span contains $ai_generation events, those are the subagent's LLM calls

"Why did the LLM say X?"

  1. Use search_traces.py to find where the text appears: SEARCH="the text" python3 scripts/search_traces.py FILE
  2. This shows which event and property path contains it
  3. Check the $ai_input of that generation to see what the LLM was told before it said X

Constructing UI links

The trace tools return _posthogUrl — always surface this to the user.

You can also construct links manually:

  • Trace detail: https://app.posthog.com/llm-observability/traces/<trace_id>?timestamp=<url_encoded_timestamp>&event=<optional_event_id>
  • Traces list with filters: returned in _posthogUrl from query-llm-traces-list

The timestamp query param is required — use the createdAt of the earliest event in the trace, URL-encoded (e.g. timestamp=2026-04-01T19%3A39%3A20Z).

When presenting findings, always include the relevant PostHog URL so the user can verify.

Finding traces

Use posthog:query-llm-traces-list to search and filter traces.

CRITICAL: Never assume event names, property names, or property values from training data. Every project instruments different custom properties. Always call posthog:read-data-schema first to discover what properties and values actually exist in the project's data before constructing filters.

Discovering the schema first

Before filtering traces, discover what's available:

  1. Confirm AI events exist — call posthog:read-data-schema with kind: "events" and look for $ai_* events
  2. Find filterable properties — call posthog:read-data-schema with kind: "event_properties" and event_name: "$ai_generation" (or another AI event) to see what properties are captured
  3. Get actual values — call posthog:read-data-schema with kind: "event_property_values", event_name: "$ai_generation", and property_name: "$ai_model" to see real model names in use

Only then construct the query-llm-traces-list call with property filters.

This is especially important for custom properties like project_id, conversation_id, user_tier, etc. — these vary per project and cannot be guessed.

Do not confirm $ai_* properties, but confirm any other like email of a person.

By filters

posthog:query-llm-traces-list
{
  "dateRange": {"date_from": "-1h"},
  "filterTestAccounts": true,
  "limit": 20,
  "properties": [
    {"type": "event", "key": "$ai_model", "value": "gpt-4o", "operator": "exact"}
  ]
}

Multiple filters are AND-ed together:

posthog:query-llm-traces-list
{
  "dateRange": {"date_from": "-1h"},
  "filterTestAccounts": true,
  "properties": [
    {"type": "event", "key": "$ai_provider", "value": "anthropic", "operator": "exact"},
    {"type": "event", "key": "$ai_is_error", "value": ["true"], "operator": "exact"}
  ]
}

You can also filter by person properties (discover them via read-data-schema with kind: "entity_properties" and entity: "person"):

posthog:query-llm-traces-list
{
  "dateRange": {"date_from": "-1h"},
  "filterTestAccounts": true,
  "properties": [
    {"type": "person", "key": "email", "value": "@company.com", "operator": "icontains"}
  ]
}

By external identifiers

Customers often store their own IDs as event or person properties. Use posthog:read-data-schema to discover what custom properties exist, then filter:

  1. Call posthog:read-data-schema with kind: "event_properties" and event_name: "$ai_trace" to find custom properties
  2. Review the returned properties and their sample values
  3. Construct the filter using the discovered property key and a known value
posthog:query-llm-traces-list
{
  "dateRange": {"date_from": "-7d"},
  "properties": [
    {"type": "event", "key": "project_id", "value": "proj_abc123", "operator": "exact"}
  ]
}

By SQL (for full-text search or custom aggregations)

Use SQL when you need something query-llm-traces-list can't express — typically full-text search across message content or custom aggregations.

SELECT
    properties.$ai_trace_id AS trace_id,
    properties.$ai_model AS model,
    timestamp
FROM events
WHERE
    event = '$ai_generation'
    AND timestamp >= now() - INTERVAL 1 HOUR
    AND properties.$ai_input ILIKE '%search term%'
ORDER BY timestamp DESC
LIMIT 20

For more complex SQL patterns, read these references:

Parsing large trace results

Trace tool results are JSON. When too large to read inline, Claude Code persists them to a file.

Persisted file format

[{ "type": "text", "text": "{\"results\": [...], \"_posthogUrl\": \"...\"}" }]

Trace JSON structure

results (array for list, object for single trace)
  ├── id, traceName, createdAt, totalLatency, totalCost
  ├── inputState, outputState (trace-level state)
  └── events[]
        ├── event ($ai_span | $ai_generation | $ai_embedding | $ai_metric | $ai_feedback)
        ├── id, createdAt
        └── properties
              ├── $ai_span_name, $ai_latency, $ai_is_error
              ├── $ai_input_state, $ai_output_state (span tool I/O)
              ├── $ai_input, $ai_output_choices (generation messages)
              ├── $ai_model, $ai_provider
              └── $ai_input_tokens, $ai_output_tokens, $ai_total_cost_usd

Available scripts

ScriptPurposeUsage
print_summary.pyTrace metadata, tool calls, errors, and final LLM outputpython3 scripts/print_summary.py FILE
print_timeline.pyChronological event timeline with I/O summariespython3 scripts/print_timeline.py FILE
extract_span.pyFull input/output of a specific span by nameSPAN="name" python3 scripts/extract_span.py FILE
extract_conversation.pyLLM messages with thinking blocks and tool callspython3 scripts/extract_conversation.py FILE
search_traces.pyFind a keyword across all event propertiesSEARCH="keyword" python3 scripts/search_traces.py FILE
show_structure.pyShow JSON keys and types without values`cat blob.json \python3 scripts/show_structure.py`

Tips

  • Always set dateRange — queries without a time range are slow. Use narrow windows (-30m, -1h) for broad listing queries; wider windows (-7d, -30d) are fine for narrow queries filtered by trace ID or specific property values
  • Always include the _posthogUrl in your response so the user can click through
  • $ai_input_state / $ai_output_state on spans contain tool call inputs and outputs
  • $ai_input / $ai_output_choices on generations contain the full LLM conversation — can be megabytes; when the result is persisted to a file, use the parsing scripts
  • Use filterTestAccounts: true to exclude internal/test traffic when searching
  • $ai_trace events are NOT in the events array — their data is surfaced via trace-level inputState, outputState, and traceName

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.95%
按下载量换算80

Claude

31.98%
按下载量换算71

Cursor

17.24%
按下载量换算38

Gemini CLI

9.71%
按下载量换算22

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

未通过

权限和风险

external-service

该 Skill 可能调用第三方服务、云服务或外部模型 API,使用前需要确认账号、额度、数据发送范围和服务条款。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills