exploring-llm-traces
Skill này làm gì
Skill này đọc các trace AI, tức là những bản ghi từng bước về những gì một agent AI đã làm, và giải thích điều gì sai hoặc đúng. Nó dành cho lập trình viên và nhóm sản phẩm đang gỡ lỗi agent hoặc chatbot AI.
Khi nào nên dùng
- ✓Khi bạn dán một liên kết trace hoặc phiên và muốn biết AI đã làm gì.
- ✓Khi bạn muốn kiểm tra xem một agent có dùng công cụ hoặc ngữ cảnh đúng cách không.
- ✓Khi bạn muốn xem một lần chạy agent tốn bao nhiêu token và bao nhiêu chi phí.
Liên kết skill
https://github.com/PostHog/posthog/blob/master/products/ai_observability/skills/exploring-llm-traces/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Đây là liên kết trace từ agent của chúng tôi. Hãy cho tôi biết điều gì sai và agent có dùng công cụ tìm kiếm đúng cách không.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill tìm trace từ liên kết hoặc ID, rồi đi qua cây các bước của nó, chẳng hạn các lần gọi mô hình và lệnh gọi công cụ. Sau đó, skill giải thích các quyết định, đầu vào và đầu ra, cùng chi phí bằng ngôn ngữ đơn giản.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
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
| Tool | Purpose |
|---|---|
posthog:query-llm-traces-list |
Search and list traces; can return large multi-trace payloads |
posthog:query-llm-trace |
Get a single trace by ID with full event tree |
posthog:read-data-schema |
Discover custom event/person properties before filtering |
posthog:execute-sql |
Ad-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 or session from a URL
Step 1 — Classify the URL
First inspect the path. Do not treat every UUID-looking value as a trace ID.
/ai-observability/traces/<trace_id>or legacy/llm-analytics/traces/<trace_id>//llm-observability/traces/<trace_id>is a single trace. Fetch it withposthog:query-llm-trace./ai-observability/sessions/<session_id>or legacy/llm-analytics/sessions/<session_id>is an AI session, not a trace. Fetch traces withposthog:query-llm-traces-listfiltered by event property$ai_session_id.
Preserve date_from / date_to query parameters from the URL when present.
If none are present but the URL has a timestamp query parameter, use that timestamp as the anchor and query an absolute window around it, for example timestamp - 36h to timestamp + 36h.
This handles exact session links whose UI timestamp may be offset from the stored event timestamps while keeping the query bounded.
If the URL has neither explicit dates nor timestamp, use a safe default like {"date_from": "-7d"}.
For exact trace and session URLs, skip schema discovery for the standard $ai_* fields used below. These are AI observability built-ins, not project-specific custom properties.
Step 2 — Browse trace summaries
Explicitly set detail: "summary" when browsing traces.
This returns event metadata and leaves the conversation content out,
so browsing does not spend context on prompts and outputs.
Omitting detail still returns full detail for compatibility with existing callers.
For a trace URL, call posthog:query-llm-trace with:
{
"traceId": "<trace_id>",
"detail": "summary",
"dateRange": { "date_from": "-7d" }
}
For a session URL, call posthog:query-llm-traces-list with:
{
"detail": "summary",
"dateRange": { "date_from": "<timestamp_minus_36h>", "date_to": "<timestamp_plus_36h>" },
"filterTestAccounts": false,
"limit": 20,
"properties": [{ "type": "event", "key": "$ai_session_id", "value": ["<session_id>"], "operator": "exact" }]
}
Use the URL's date_from / date_to values in the session query if present.
If the URL only has timestamp, calculate the absolute date range from that timestamp instead of using a relative range like -1h.
Set filterTestAccounts: false for an exact URL so the requested trace is not hidden by account filters.
The result contains trace and event metadata only.
Prompts, outputs, span states, $ai_error and $ai_feedback_text are left out,
and their names are listed in _summaryOmittedKeys beside the property bag.
A trace with _detail: { "mode": "summary" } carries no conversation content at all.
Read the content with detail: "full".
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 _posthogUrl— always include this in your response so the user can click through to the UI
Step 3 — Read the content needed for the investigation
Once you have selected a trace, request posthog:query-llm-trace with detail: "full" before inspecting
exact tool
Câu hỏi thường gặp
Trace là gì?
Trace là bản ghi đầy đủ của một tương tác AI, từ lần chạy agent cấp cao nhất xuống từng lần gọi mô hình bên trong.
Skill có đọc được toàn bộ một phiên không?
Có. Skill có thể mở một liên kết phiên và xem các trace bên trong.
Skill có thay đổi gì trong ứng dụng của tôi không?
Không. Skill chỉ đọc dữ liệu trace mà PostHog đã ghi lại.
Chi tiết
Mô tả gốc của tác giả
Debug and inspect LLM/AI agent traces using PostHog's MCP tools. Use when the user pastes a trace or session URL (e.g. /ai-observability/traces/<id> or /ai-observability/sessions/<id>), asks to debug a trace, figure out what went wrong, check if an agent used a tool correctly, verify context/files were surfaced, inspect subagent behavior, investigate LLM decisions, or analyze token usage and costs. Also use when raw SQL/HogQL against `events.properties.$ai_input` / `$ai_output_choices` returns empty — message content lives only on the dedicated `posthog.ai_events` table.
repo: PostHog/posthog
Độ phổ biến
- Sao GitHub
- 41k
- Vị trí xếp hạng
- #6833
- Giấy phép
- —
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
depot-ci
41kGiúp agent của bạn thiết lập và chạy quy trình Depot CI, một lựa chọn thay thế GitHub Actions, gồm chuyển các quy trình hiện có và đọc nhật ký chạy.
depot-container-builds
41kGiúp agent của bạn build image Docker trên các builder từ xa của Depot, gồm image đa nền tảng, đẩy lên registry và sửa lỗi build.
depot-github-runners
41kGiúp agent của bạn chuyển các job GitHub Actions sang runner do Depot quản lý, chọn kích thước và nhãn runner, và xử lý lỗi thiết lập runner.
editing-agents-md
41kGiúp agent của bạn quyết định một quy tắc nên nằm trong file AGENTS.md hay CLAUDE.md, và viết sao cho quy tắc được tuân thủ mà file không bị phình to.
Skill tương tự
add-model-provider
394kGiúp agent của bạn kết nối nhà cung cấp mô hình AI mới với OpenClaw bằng lệnh an toàn, giữ API key khỏi văn bản thuần và chạy thử.
acp-router
394kGiúp agent của bạn gửi một tác vụ đến trợ lý lập trình như Claude Code hoặc Cursor qua OpenClaw, để công việc chạy ngay trong công cụ đó.
browser-automation
394kHướng dẫn agent của bạn điều khiển trang web từng bước, gồm đăng nhập, tab và cách khôi phục khi trang ngừng phản hồi.