Agent skill

Langfuse and LLM Gateway Logs

by KonghaYao in KonghaYao/peri

Queries Langfuse traces, prompts, datasets and sessions, and analyzes local LLM gateway logs for requests, context growth, token use and cache hits.

Apache-2.0Auto-check: notesAI & LLM Engineering

SKILL.md written in Chinese; this summary is our English description.

Install Langfuse and LLM Gateway Logs

skills CLI
$ npx skills add KonghaYao/peri --skill langfuse -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install KonghaYao/peri langfuse --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/KonghaYao/peri.git skills-src && mkdir -p .claude/skills && cp -r skills-src/.claude/skills/langfuse .claude/skills/langfuse && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
langfuse
GitHub stars
223
Token cost
~4.3k tokens
SKILL.md length
1,192 words
Files
23 (incl. scripts, references)
Skills in repo
19
Repo updated
First seen
Licence
Apache-2.0

At a glance

Queries Langfuse traces, prompts, datasets and sessions, and analyzes local LLM gateway logs for requests, context growth, token use and cache hits.

  • Works in 7 steps: Langfuse API via CLI → Data Retrieval Tools (脚本工具集) → Query Recipes(常见数据获取场景) → …
  • Inspecting a Langfuse trace or session to find where a run went wrong
  • SKILL.md covers 数据来源与分析方式, 1. Langfuse API via CLI, 2. Data Retrieval Tools (脚本工具集) and 3. Query Recipes(常见数据获取场景), plus 2 more sections
  • Runs TypeScript and JavaScript scripts from its folder; calls bun, bunx and curl; reaches langfuse.com and cloud.langfuse.com; needs LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY

What it does

Two data sources are handled. Langfuse traces, observations, sessions, prompts, datasets and scores are reached through langfuse-cli (run with bunx) and TypeScript scripts, while local llm-gateway request.json and stream.log files are analyzed with scripts such as llm-log-query.mjs and context-growth.mjs. The local route needs no Langfuse credentials or network, and the two sources are not treated as interchangeable.

The Langfuse route needs LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY and LANGFUSE_HOST in a .env file, and the agent asks you to add them there rather than paste keys in chat. A preflight checks that the host returns JSON, discovers the installed CLI schema, fetches every page of list results (the public API limit is 100 per page) and records which fields were requested, reporting uninspected fields as not inspected instead of missing. An auth, schema or truncation failure stops diagnosis.

Raw gateway logs can hold credentials and private content, so the skill shows summaries first and confirms redaction before drilling into bodies or headers. Other scripts cover trace messages, prompt breakdown, session analysis and a daily report, and reference files cover error analysis, instrumentation, judge calibration, prompt migration, SDK upgrades and feedback. The SKILL.md mixes Chinese and English.

When your agent uses it

  • Inspecting a Langfuse trace or session to find where a run went wrong
  • Comparing requests and context growth in local LLM gateway logs
  • Checking token usage and prompt cache hit rates
  • Looking up Langfuse SDK usage or API resources

Example prompts

  • “List the latest Langfuse traces for this project and find the ones with errors.”
  • “Analyze the gateway logs in logs/session-a and show how the context grows across requests.”
  • “Why is our cache hit rate low? Break down the prompt in the last few requests.”
  • “Create a daily report from Langfuse for yesterday's sessions.”

Requirements

  • bun, to run langfuse-cli and the bundled scripts
  • Langfuse API keys and host in a .env file for the remote route
  • Local gateway log files for the offline route
  • Pre-approved tools (allowed-tools): WebFetch(domain:langfuse.com), Bash(curl *langfuse.com/*), Bash(bunx langfuse-cli api --help *), Bash(bunx langfuse-cli api * --help *), Bash(bunx langfuse-cli api * list *), Bash(bunx langfuse-cli api * get *), Bash(bun .claude/skills/langfuse/scripts/analyze.ts *), Bash(bun .claude/skills/langfuse/scripts/trace-search.ts *), Bash(bun .claude/skills/langfuse/scripts/trace-tree.ts *), Bash(bun .claude/skills/langfuse/scripts/trace-tokens.ts *), Bash(bun .claude/skills/langfuse/scripts/trace-messages.ts *), Bash(bun .claude/skills/langfuse/scripts/prompt-breakdown.ts *), Bash(bun .claude/skills/langfuse/scripts/traces-list.ts *), Bash(bun .claude/skills/langfuse/scripts/session-analyze.ts *), Bash(bun .claude/skills/langfuse/scripts/daily-report.ts *), Bash(bun .claude/skills/langfuse/scripts/llm-log-query.mjs *), Bash(bun .claude/skills/langfuse/scripts/context-growth.mjs *)

Workflow steps

7 steps, taken from the step headings in SKILL.md.

  1. Langfuse API via CLI
  2. Data Retrieval Tools (脚本工具集)
  3. Query Recipes(常见数据获取场景)
  4. Data Retrieval Patterns(按目的选择工具)
  5. Cost Analysis(详细版)
  6. Langfuse Documentation
  7. 上下文 Diff 诊断(对比两次 LLM 调用的完整输入)

What it can do on your machine

Read from SKILL.md and the folder at commit d7ee444. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • WebFetch(domain:langfuse.com)
    • Bash(curl *langfuse.com/*)
    • Bash(bunx langfuse-cli api --help *)
    • Bash(bunx langfuse-cli api * --help *)
    • Bash(bunx langfuse-cli api * list *)
    • Bash(bunx langfuse-cli api * get *)
    • Bash(bun .claude/skills/langfuse/scripts/analyze.ts *)
    • Bash(bun .claude/skills/langfuse/scripts/trace-search.ts *)
    • Bash(bun .claude/skills/langfuse/scripts/trace-tree.ts *)
    • Bash(bun .claude/skills/langfuse/scripts/trace-tokens.ts *)

    …and 7 more on the same allowed-tools line.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 9 files in scripts/ (TypeScript and JavaScript, from the files we listed), which the agent can run.

    Shell commands in SKILL.md call:

    • bun
    • bunx
    • curl
    • jq

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Hosts in commands or code, which the agent is likely to contact:

    • langfuse.com
    • cloud.langfuse.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • LANGFUSE_PUBLIC_KEY
    • LANGFUSE_SECRET_KEY

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Langfuse and LLM Gateway Logs loads about 4.3k tokens when it runs, and up to ~19k if it reads all its reference files. Until then it costs about 53 tokens; SKILL.md has 1,192 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~53
When it runs · the whole SKILL.md, loaded when a task matches
~4.3k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~19k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NoteMentions a .env fileSKILL.md:40
    fuse REST API. Run via bunx (auto-loads `.env`):
  • NoteMentions a .env fileSKILL.md:51
    bunx automatically loads `.env`. Ensure it contains:
  • NoteMentions a .env fileSKILL.md:59
    re missing, ask the user to add them to `.env`. Do not ask to paste keys in chat.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from KonghaYao/peri at commit d7ee444, republished under its Apache-2.0 licence (© KonghaYao). 1,192 words, ~4,308 tokens.

Download SKILL.mdSave it as .claude/skills/langfuse/SKILL.md (or your agent's skills folder). This skill also uses 22 other files; get the full folder from GitHub.
name
langfuse
description
查询或操作 Langfuse traces、prompts、datasets、scores、sessions,查阅 Langfuse 文档与 SDK 用法;也用于分析本地 llm-gateway 请求/响应日志、查看 LLM 请求、追踪 session、对比上下文、排查 token 用量及缓存命中率。根据数据来源选择 Langfuse API 或本地网关日志脚本;本地分析无需 Langfuse 凭据。
allowed-tools
WebFetch(domain:langfuse.com), Bash(curl *langfuse.com/*), Bash(bunx langfuse-cli api --help *), Bash(bunx langfuse-cli api * --help *), Bash(bunx langfuse-cli api * list *), Bash(bunx langfuse-cli api * get *), Bash(bun .claude/skills/langfuse/scripts/analyze.ts *), Bash(bun .claude/skills/langfuse/scripts/trace-search.ts *), Bash(bun .claude/skills/langfuse/scripts/trace-tree.ts *), Bash(bun .claude/skills/langfuse/scripts/trace-tokens.ts *), Bash(bun .claude/skills/langfuse/scripts/trace-messages.ts *), Bash(bun .claude/skills/langfuse/scripts/prompt-breakdown.ts *), Bash(bun .claude/skills/langfuse/scripts/traces-list.ts *), Bash(bun .claude/skills/langfuse/scripts/session-analyze.ts *), Bash(bun .claude/skills/langfuse/scripts/daily-report.ts *), Bash(bun .claude/skills/langfuse/scripts/llm-log-query.mjs *), Bash(bun .claude/skills/langfuse/scripts/context-growth.mjs *)

Langfuse

数据来源与分析方式

数据来源 / 需求使用方式
Langfuse trace、observation、session,或平台 API / 文档下文 Langfuse CLI 与 TypeScript 脚本
本地 llm-gateway 的 request.json、stream.log,请求差异、缓存断点、上下文增长本地网关日志分析,使用 scripts/llm-log-query.mjs 与 scripts/context-growth.mjs
  • 本地日志方式不依赖 Langfuse API、凭据或网络,不执行下文远端凭据预检。
  • 用户只说“分析日志”而未明确来源时,先根据已提供的路径或 trace 信息定位;仍无法确定再询问,不默认查询远端。
  • 两种来源不能默认互相替代。跨来源对照需核实 session、请求标识和时间范围;未采集或未返回的字段标记为未检查。
  • 原始日志可能包含凭据和私密内容,不直接展示 headers、完整请求体或原始响应;先使用摘要,内容下钻前确认已脱敏。

1. Langfuse API via CLI

Use langfuse-cli to interact with the full Langfuse REST API. Run via bunx (auto-loads .env):

bash
bunx langfuse-cli api --help                              # 列出所有 resources
bunx langfuse-cli api <resource> --help                     # List actions for a resource
bunx langfuse-cli api <resource> <action> --help            # Show args for an action
bunx langfuse-cli api <resource> <action> [options]         # Execute
Credentials

bunx automatically loads .env. Ensure it contains:

bash
LANGFUSE_PUBLIC_KEY=pk-lf-...
LANGFUSE_SECRET_KEY=sk-lf-...
LANGFUSE_HOST=https://cloud.langfuse.com  # Required

If credentials are missing, ask the user to add them to .env. Do not ask to paste keys in chat.

CLI Preflight and Query Integrity

Before attributing missing or malformed data to application behavior:

  1. Confirm LANGFUSE_HOST or LANGFUSE_BASE_URL is set, credentials are present, and the selected host returns JSON rather than an HTML fallback. Never print credentials or authorization headers.
  2. Discover the installed CLI schema with bunx langfuse-cli api --help and resource/action --help; resource names vary by CLI version, so do not assume observations-v2s or another historical alias exists.
  3. For list endpoints, inspect pagination metadata and fetch every required page. The public API page limit is 100; a single page is not proof of completeness.
  4. Record the requested field projection. If input/output fields were not requested or returned by the selected endpoint, report them as not inspected, not null or missing.
  5. Stop business-level diagnosis on host/auth/schema failure. A 401, unsupported resource, HTML response, or truncated page set is a query precondition failure, not evidence about the trace producer.
CLI Tips
  • Use --json for machine-readable output
  • Use --curl to preview HTTP request without executing
  • Discover resources/actions with --help; do not hard-code version-specific v2 aliases
  • Prefer the bundled scripts for traces and observations because they implement the current public endpoints and pagination

2. Data Retrieval Tools (脚本工具集)

本节 Langfuse 查询脚本的时间与元数据过滤选项如下;本地网关日志脚本的参数见 本地网关日志分析,不要混用两套参数:

OptionDescriptionExample
--from <ISO>Start timestamp--from 2026-07-01T00:00:00Z
--to <ISO>End timestamp--to 2026-07-31T23:59:59Z
--days <N>Last N days (from now)--days 7
--tag <tag>Filter by tag--tag production
--user <id>Filter by user ID--user user_123
--session <id>Filter by session ID--session sess_abc
--name <str>Filter by trace name--name chat
--limit <N>Max results--limit 50
2a. trace-search — 灵活搜索/过滤/导出
bash
bun .claude/skills/langfuse/scripts/trace-search.ts [选项]

# 示例
bun .claude/skills/langfuse/scripts/trace-search.ts --days 7 --tag production                # 最近 7 天带 production tag 的 trace
bun .claude/skills/langfuse/scripts/trace-search.ts --session sess_abc --csv > session.csv   # 导出 session 为 CSV
bun .claude/skills/langfuse/scripts/trace-search.ts --model claude-sonnet --status error     # 查询特定模型的错误 trace
bun .claude/skills/langfuse/scripts/trace-search.ts --from 2026-07-01T00:00:00Z --summary   # 只看汇总统计
bun .claude/skills/langfuse/scripts/trace-search.ts --days 30 --json > report.json           # 导出 JSON
bun .claude/skills/langfuse/scripts/trace-search.ts --user user_123 --limit 100              # 按用户过滤
bun .claude/skills/langfuse/scripts/trace-search.ts --order latency.desc --limit 10          # 按延迟排序,找最慢的

Output modes: table (default), --csv, --json, --summary (aggregate only), --full (detailed fields).

2b. analyze — 成本/质量综合分析
bash
bun .claude/skills/langfuse/scripts/analyze.ts [N]              # Overview + trace table + flags
bun .claude/skills/langfuse/scripts/analyze.ts --tools [N]      # Tool call analysis
bun .claude/skills/langfuse/scripts/analyze.ts --growth [N]     # Context growth trend
bun .claude/skills/langfuse/scripts/analyze.ts --report [N]     # Full report (all 7 sections)
bun .claude/skills/langfuse/scripts/analyze.ts --trace-id <id>  # Single trace detail

# 支持时间/元数据过滤
bun .claude/skills/langfuse/scripts/analyze.ts 20 --days 7 --user user_123 --report         # 某用户最近 7 天的完整报告
2c. session-analyze — Session 完整分析
bash
bun .claude/skills/langfuse/scripts/session-analyze.ts --session <id> [选项]

# 选项
--limit <N>    最多拉取 trace 数(默认 100)
--detail       显示每个 trace 的逐轮 token 流
--csv          导出 CSV(每个 LLM 调用一行)

# 输出内容
# - Session 总体指标(traces, tokens, cost, time span)
# - Trace 时间线表格
# - 累积 token 增长趋势
# - 工具使用频率统计
# - 异常检测
2d. daily-report — 日报/周报
bash
bun .claude/skills/langfuse/scripts/daily-report.ts [选项]

bun .claude/skills/langfuse/scripts/daily-report.ts                           # 今天的日报
bun .claude/skills/langfuse/scripts/daily-report.ts --days 7                  # 最近 7 天周报
bun .claude/skills/langfuse/scripts/daily-report.ts --days 30 --tag prod      # 按 tag 过滤的月报
bun .claude/skills/langfuse/scripts/daily-report.ts --model claude-sonnet     # 按模型过滤
bun .claude/skills/langfuse/scripts/daily-report.ts --detail                  # 显示所有 trace 详情

# 输出内容
# - Key Metrics(traces, sessions, errors, tokens, cost)
# - By Model 分布
# - Top Users(按输入 token)
# - Top Traces(按输入 token)
# - 异常 trace 列表
2e. 单 trace 深度分析
bash
# Token 流 + 缓存异常
bun .claude/skills/langfuse/scripts/trace-tokens.ts <traceId>
bun .claude/skills/langfuse/scripts/trace-tokens.ts --index 1 --days 7        # 用 --index 从过滤结果中选 trace

# 消息组成 + diff
bun .claude/skills/langfuse/scripts/trace-messages.ts <traceId> [--detail]
bun .claude/skills/langfuse/scripts/trace-messages.ts --index 3 --user user_123

# System prompt 段落拆解
bun .claude/skills/langfuse/scripts/prompt-breakdown.ts <traceId>
bun .claude/skills/langfuse/scripts/prompt-breakdown.ts --index 1 --days 7

# Trace 汇总列表
bun .claude/skills/langfuse/scripts/traces-list.ts [N] [过滤选项]
2f. trace-tree — observation parent/orphan 审计
bash
bun .claude/skills/langfuse/scripts/trace-tree.ts <traceId>

This command fetches all observation pages, prints a metadata-only tree, and exits non-zero when it finds duplicate IDs, missing parent observations, or cycles. A parent equal to the trace ID is a valid root attachment. Use it whenever the diagnosis concerns subagent ownership, generation/tool/batch nesting, or orphan observations; do not infer parent integrity from a flat list.

Production Verification Gate

A unit/mock pass proves only local construction. After changing instrumentation or parent assignment:

  1. Restart the actual producer process and record the new process/session provenance without exposing secrets.
  2. Generate a new real trace after restart; do not reuse pre-fix data as acceptance evidence.
  3. Run trace-tree.ts on that trace and inspect expected generation/tool/batch ownership.
  4. Report code tests and production trace verification separately. If restart, credentials, or a live trace is unavailable, mark production verification blocked rather than complete.

3. Query Recipes(常见数据获取场景)

按时间查询
需求命令
今天所有 tracebun .claude/skills/langfuse/scripts/daily-report.ts 或 bun .claude/skills/langfuse/scripts/trace-search.ts --days 1
本周 tracebun .claude/skills/langfuse/scripts/daily-report.ts --days 7
本月 tracebun .claude/skills/langfuse/scripts/daily-report.ts --days 30
特定时间段bun .claude/skills/langfuse/scripts/trace-search.ts --from ISO --to ISO
上周 vs 本周对比分别跑两次 .claude/skills/langfuse/scripts/daily-report.ts --days 7(注意时间不对齐),或用 --from/--to 精确控制
按用户/会话查询
需求命令
某用户的所有 tracebun .claude/skills/langfuse/scripts/trace-search.ts --user <id> --days 30
某 session 完整分析bun .claude/skills/langfuse/scripts/session-analyze.ts --session <id> --detail
某 session 导出 CSVbun .claude/skills/langfuse/scripts/session-analyze.ts --session <id> --csv
用户日报bun .claude/skills/langfuse/scripts/daily-report.ts --user <id> --days 1
成本排查
需求命令
找最贵的 tracebun .claude/skills/langfuse/scripts/trace-search.ts --order totalTokens --days 7 --limit 10
全量成本报告bun .claude/skills/langfuse/scripts/analyze.ts 50 --days 7 --report
单模型成本bun .claude/skills/langfuse/scripts/daily-report.ts --days 7 --model claude-sonnet
缓存效率低的 tracebun .claude/skills/langfuse/scripts/analyze.ts --days 7 --report(看 Summary & Flags 的缓存异常)
质量排查
需求命令
找所有错误 tracebun .claude/skills/langfuse/scripts/trace-search.ts --status error --days 7
某错误 trace 深挖bun .claude/skills/langfuse/scripts/trace-tokens.ts <traceId> + bun .claude/skills/langfuse/scripts/trace-messages.ts <traceId>
agent loop 检测bun .claude/skills/langfuse/scripts/analyze.ts --days 7 --tools(看 LLM 调用次数)
context 膨胀分析bun .claude/skills/langfuse/scripts/analyze.ts --growth --days 7
模型对比
需求命令
模型用量分布bun .claude/skills/langfuse/scripts/daily-report.ts --days 7(看 By Model 表)
某模型所有 tracebun .claude/skills/langfuse/scripts/trace-search.ts --model <model> --days 7 --csv
调试 Prompt
需求命令
看 system prompt 结构bun .claude/skills/langfuse/scripts/prompt-breakdown.ts --index 1 --days 1
system prompt 是否稳定bun .claude/skills/langfuse/scripts/trace-messages.ts <traceId>(看 System Prompt Stability 段落)
上下文增长来源bun .claude/skills/langfuse/scripts/trace-messages.ts <traceId> --detail(看消息 diff)
Show full SKILL.md (470 more words)Show less

4. Data Retrieval Patterns(按目的选择工具)

日常监控 → daily-report.ts

快速了解系统状态:今天/本周有多少 trace、花了多少钱、有没有异常。每天跑一次即可。

深入问题诊断 → analyze.ts --report

当发现异常(成本飙升、缓存降低、用户反馈质量差)时,对最近 N 条 trace 做全维度扫描。

精准搜索 → trace-search.ts

当你已经知道要找什么(某用户、某 session、某时间段、某模型),直接筛选。支持导出 CSV/JSON 做进一步分析。

单条追踪 → trace-tokens.ts + trace-messages.ts + prompt-breakdown.ts

定位到具体 trace 后,这三件套分别看 token 流、消息变化、prompt 结构,逐轮定位问题。

Session 回溯 → session-analyze.ts

需要完整还原用户的一次会话时使用,看 trace 时间线、token 累积、工具使用演变。

Prompt 工程 → prompt-breakdown.ts + CLI get prompt

先看现有 request 中 system prompt 的段落分布(哪些段落最大),然后用 CLI 管理 Langfuse prompt:

bash
bunx langfuse-cli api prompts list
bunx langfuse-cli api prompts get --name <name>
bunx langfuse-cli api prompts create --name <name> --type chat --prompt '[...]'

5. Cost Analysis(详细版)

Report Sections
#SectionWhat it shows
1OverviewAggregate stats, cache efficiency, output/input ratio
2Per-Trace TableInput/output/cache/latency per trace
3Tool AnalysisFrequency, avg latency, redundancy detection, tool→context growth
4Context GrowthPer-trace token trend (visual bar chart), session accumulation, cross-trace growth rate
5System Prompt OccupancySection breakdown with estimated tokens, system vs conversation ratio
6Most Expensive TracePer-LLM-call detail with delta
7Summary & FlagsAuto-detected issues (low cache, redundant tools, slow calls, etc.)
Red Flags
PatternThresholdRoot Cause
Cache hit rate < 90%Single traceSystem prompt instability, cold start, or structure changing across turns
Effective new tokens > 20KSingle traceTool results or context growing unbounded
Output/Input ratio > 5%Single traceModel over-explaining
Output/Input ratio < 0.1%Single traceMassive input for tiny output — unnecessary context
LLM calls > 10 for simple taskSingle traceAgent looping or retrying
Single LLM call > 60sPer-callModel generating too much for the task
Optimization Checklist

After analysis, evaluate:

  1. System Prompt Weight — >40% of context → trim; largest section → shorten or lazy-load; stale CLAUDE.md TRAPs → archive
  2. Context Accumulation — tool results retained across turns?; micro-compact threshold right?; redundant reads?
  3. Agent Loop Efficiency — redundant tool calls?; sequential reads → batch?; broad exploration → targeted search?
  4. Task Decomposition — complex task → focused sub-tasks?; sub-agents to reduce context pressure?
Reflection Output Format
## Cost Reflection

### Metrics
- Traces analyzed: N
- Total input: X tokens (Y% cache hit)
- Total output: Z tokens
- Avg LLM calls per trace: M

### Findings
1. [Pattern with specific trace example]
2. [Another pattern]

### Recommendations
1. [Actionable optimization] — estimated savings: ~X tokens/trace
2. [Another recommendation]

6. Langfuse Documentation

6a. Documentation Index (llms.txt)
bash
curl -s https://langfuse.com/llms.txt

Returns structured list of every doc page. Use to discover the right page, then fetch it.

6b. Fetch Pages as Markdown

Append .md to any doc path:

bash
curl -s "https://langfuse.com/docs/observability/overview.md"
6c. Search Documentation
bash
curl -s "https://langfuse.com/api/search-docs?query=How+do+I+trace+LangGraph+agents"

Returns matching documents with URLs, titles, and excerpts. Also indexes GitHub Issues/Discussions.

Workflow
  1. Start with llms.txt to orient
  2. Fetch specific pages when identified
  3. Fall back to search when topic is unclear

7. 上下文 Diff 诊断(对比两次 LLM 调用的完整输入)

当不同 trace/session 的 input tokens 存在无法解释的差异时,下载完整 input 做 diff 是最直接的定位手段。

步骤

1. 找到差异 trace 的 generation observation ID

bash
# 列出 session 的所有 trace
bunx langfuse-cli api traces list --session-id <session_id> --json | jq '.body.data[].id'

# 列出 trace 下所有 GENERATION observation
curl -s -u "$LANGFUSE_PUBLIC_KEY:$LANGFUSE_SECRET_KEY" \
  "$LANGFUSE_HOST/api/public/observations?traceId=<trace_id>&limit=100" \
  | jq '[.data[] | select(.type == "GENERATION") | {id, inputTokens: .usageDetails.input}]'

2. 下载完整 input 并保存

bash
curl -s -u "$LANGFUSE_PUBLIC_KEY:$LANGFUSE_SECRET_KEY" \
  "$LANGFUSE_HOST/api/public/observations/<obs_id>" \
  | jq '.input' > /tmp/input_a.json

curl -s -u "$LANGFUSE_PUBLIC_KEY:$LANGFUSE_SECRET_KEY" \
  "$LANGFUSE_HOST/api/public/observations/<obs_id>" \
  | jq '.input' > /tmp/input_b.json

3. Diff

bash
diff /tmp/input_a.json /tmp/input_b.json
典型场景
场景表现Diff 会发现
System prompt 不稳定同模型同会话类型但 input tokens 差异大messages[0].content(system prompt)中某段内容不同
Tools 数组变化input tokens 差异 ~数 Ktools 数组长度或内容不同
Deferred Tools / MCP 描述跨会话缓存命中率为 0%system prompt 中 Deferred Tools 段多了/少了 MCP 工具描述文本
消息历史差异上下文增长异常messages 数组长度不同,某条消息缺失或重复
注意
  • .input 是完整请求体(包含 messages、tools、model 等字段),diff 能精确定位任何差异
  • 如果只需要比 system prompt:jq '.input.messages[0].content' -r
  • 如果只需要比 tools:jq '.input.tools'
  • Generation observation 的 usageDetails 包含 cache_read_input_tokens 和 cache_creation_input_tokens,是缓存诊断的关键数据

Use Case References

  • instrumenting an application: references/instrumentation.md
  • migrating prompts: references/prompt-migration.md
  • user feedback as scores: references/user-feedback.md
  • CLI tips: references/cli.md
  • SDK upgrade: references/sdk-upgrade.md
  • judge calibration: references/judge-calibration.md
  • error analysis: references/error-analysis.md
  • skill feedback: references/skill-feedback.md

© KonghaYao, Apache-2.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 22 other files (scripts, references) in .claude/skills/langfuse of KonghaYao/peri.

  • SKILL.md
  • references/cli.md
  • references/error-analysis.md
  • references/instrumentation.md
  • references/judge-calibration.md
  • references/local-gateway-logs.md
  • references/prompt-migration.md
  • references/sdk-upgrade.md
  • references/skill-feedback.md
  • references/user-feedback.md
  • scripts/analyze.ts
  • scripts/context-growth.mjs
  • scripts/daily-report.ts
  • scripts/lib.test.ts
  • scripts/lib.ts
  • scripts/llm-log-query.mjs
  • scripts/prompt-breakdown.ts
  • scripts/session-analyze.ts
  • scripts/trace-messages.ts
  • … and 4 more

Open the folder on GitHubat commit d7ee444

Compare with similar skills

Langfuse and LLM Gateway Logs next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Langfuse and LLM Gateway Logs compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Langfuse and LLM Gateway Logs this skillKonghaYao/peri223—~4.3kAutomated safety check: NotesApache-2.0
Langfuse Cost Tuningjeremylongshore/tons-of-skills-marketplace2.8k1 repos~2.4kAutomated safety check: PassMIT
AI Observabilityomer-metin/skills-for-antigravity162—~578Automated safety check: PassApache-2.0
Telemetry AnalyzerIBM/ibm-watsonx-orchestrate-adk178—~10kAutomated safety check: NotesMIT
Monitoring Observabilityyonatangross/orchestkit289—~2.2kAutomated safety check: PassMIT
Caveman Workflow LabelerJuliusBrussee/caveman110k1 repos~1.3kAutomated safety check: PassApache-2.0

Similar skills

  • Langfuse Cost Tuning

    jeremylongshore/tons-of-skills-marketplace

    Monitor and optimize LLM costs using Langfuse analytics and dashboards.

    2.8k GitHub starsUsed in 1 repo~2.4k tokens
    AI & LLM EngineeringAuto-check passed
  • AI Observability

    omer-metin/skills-for-antigravity

    Implement comprehensive observability for LLM applications including tracing (Langfuse/Helicone), cost tracking, token optimization, RAG evaluation metrics (RAGAS), hallucination detection, and…

    162 GitHub stars~578 tokensUpdated 8 mo ago
    AI & LLM EngineeringAuto-check passed
  • Telemetry Analyzer

    IBM/ibm-watsonx-orchestrate-adk

    Official

    A skill your agent uses when the user wants to analyze agent telemetry traces to find bugs and get fix recommendations — walks through exporting traces from a local or remote watsonx Orchestrate…

    178 GitHub stars~10k tokensUpdated today
    DevelopmentAuto-check: notes
  • Monitoring Observability

    yonatangross/orchestkit

    Monitoring and observability patterns for Prometheus metrics, Grafana dashboards, Langfuse v4 LLM tracing (astype, scorecurrentspan, shouldexportspan, LangfuseMedia), and drift detection.

    289 GitHub stars~2.2k tokensUpdated today
    DevOps & CloudAuto-check passed
  • Caveman Workflow Labeler

    JuliusBrussee/caveman

    Finds every LLM workflow in a repository, proposes a labeling table and, once you agree, wires labels so Caveman Cloud groups spend per workflow.

    110k GitHub starsUsed in 1 repo~1.3k tokens
    AI & LLM EngineeringAuto-check passed
  • Caveman Evidence Review

    JuliusBrussee/caveman

    Read-only review of Caveman Cloud data to explain where LLM spend goes: cost, score, workflows, traces, latency, errors, routing and verified savings.

    110k GitHub starsUsed in 1 repo~927 tokens
    AI & LLM EngineeringAuto-check passed

More from KonghaYao/peri

All 19 skills in this repo
  • Audits recent agent conversation history and turns repeated failures and successes into testable harness improvement proposals that later audits can check.

    223 GitHub stars~3.5k tokensUpdated today
    Auto-check passed
  • Runs commands, reads and edits files, and copies data on remote machines through a single-file Node script that wraps the system ssh and scp, in Chinese.

    223 GitHub stars~924 tokensUpdated today
    Auto-check: warnings
  • Advisor Consultation

    KonghaYao/peri

    Sends a compact, redacted decision packet to a tool-free Opus advisor subagent when a task has high-risk trade-offs or stalled investigations, then weighs the answer.

    223 GitHub stars~1.3k tokensUpdated today
    Auto-check passed
  • Scheduled Tasks Cron

    KonghaYao/peri

    Registers, lists and removes recurring agent tasks with five-field cron expressions, and sets safety rules so a schedule is created only when the user clearly asks.

    223 GitHub stars~683 tokensUpdated today
    Auto-check passed
  • Verifies and repairs a feature by using the real Peri terminal UI as a user would, looping verify, decide, fix and review until a fresh round shows no blockers.

    223 GitHub stars~2.1k tokensUpdated today
    Auto-check: notes
  • Ultracode

    KonghaYao/peri

    Multi-agent workflow orchestration. An agent skill from KonghaYao/peri.

    223 GitHub stars~2k tokensUpdated today
    Auto-check passed

Works with

Questions about Langfuse and LLM Gateway Logs

What does Langfuse and LLM Gateway Logs do?

Queries Langfuse traces, prompts, datasets and sessions, and analyzes local LLM gateway logs for requests, context growth, token use and cache hits. Two data sources are handled.mjs.

When should I use Langfuse and LLM Gateway Logs?

Langfuse and LLM Gateway Logs fits situations like: inspecting a Langfuse trace or session to find where a run went wrong; comparing requests and context growth in local LLM gateway logs; checking token usage and prompt cache hit rates; looking up Langfuse SDK usage or API resources.

How do I install Langfuse and LLM Gateway Logs in Claude Code?

Run `npx skills add KonghaYao/peri --skill langfuse -a claude-code`. Or copy the skill folder (.claude/skills/langfuse in KonghaYao/peri) into .claude/skills/langfuse in your project. Claude Code loads it when a task matches its description.

How do I install Langfuse and LLM Gateway Logs in Codex?

Run `npx skills add KonghaYao/peri --skill langfuse -a codex`. Or copy the skill folder (.claude/skills/langfuse in KonghaYao/peri) into .agents/skills/langfuse in your project. Codex loads it when a task matches its description.

Can I use Langfuse and LLM Gateway Logs in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add KonghaYao/peri --skill langfuse -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/langfuse, .gemini/skills/langfuse, .github/skills/langfuse and .opencode/skills/langfuse in your project.

What does Langfuse and LLM Gateway Logs need to run?

Going by SKILL.md and its folder, Langfuse and LLM Gateway Logs needs TypeScript and JavaScript for the scripts in its folder, the command-line tools its instructions call (bun, bunx, curl and jq) and credentials named LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY. Our summary lists: bun, to run langfuse-cli and the bundled scripts; Langfuse API keys and host in a .env file for the remote route; Local gateway log files for the offline route. Its frontmatter pre-approves these tools: WebFetch(domain:langfuse.com), Bash(curl *langfuse.com/*), Bash(bunx langfuse-cli api --help *), Bash(bunx langfuse-cli api * --help *), Bash(bunx langfuse-cli api * list *), Bash(bunx langfuse-cli api * get *), Bash(bun .claude/skills/langfuse/scripts/analyze.ts *), Bash(bun .claude/skills/langfuse/scripts/trace-search.ts *), Bash(bun .claude/skills/langfuse/scripts/trace-tree.ts *), Bash(bun .claude/skills/langfuse/scripts/trace-tokens.ts *), Bash(bun .claude/skills/langfuse/scripts/trace-messages.ts *), Bash(bun .claude/skills/langfuse/scripts/prompt-breakdown.ts *), Bash(bun .claude/skills/langfuse/scripts/traces-list.ts *), Bash(bun .claude/skills/langfuse/scripts/session-analyze.ts *), Bash(bun .claude/skills/langfuse/scripts/daily-report.ts *), Bash(bun .claude/skills/langfuse/scripts/llm-log-query.mjs *), Bash(bun .claude/skills/langfuse/scripts/context-growth.mjs *).

Does Langfuse and LLM Gateway Logs access the network?

SKILL.md names 2 domains. In commands or code: langfuse.com and cloud.langfuse.com; the agent is likely to contact these when it follows the instructions. This is read from the text; nothing was executed.

Is Langfuse and LLM Gateway Logs safe to install?

Our automated static check of SKILL.md found notes only (mentions a .env file), nothing it rates as a warning. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Langfuse and LLM Gateway Logs use?

Langfuse and LLM Gateway Logs is published under the Apache-2.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Langfuse and LLM Gateway Logs use?

About 4.3k tokens (SKILL.md is roughly 17k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 15k tokens, read only when the agent opens those files.

What are the alternatives to Langfuse and LLM Gateway Logs?

Skills that share tags, products or a category with Langfuse and LLM Gateway Logs: Langfuse Cost Tuning (jeremylongshore/tons-of-skills-marketplace, 2.8k stars), AI Observability (omer-metin/skills-for-antigravity, 162 stars), Telemetry Analyzer (IBM/ibm-watsonx-orchestrate-adk, 178 stars) and Monitoring Observability (yonatangross/orchestkit, 289 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Langfuse and LLM Gateway Logs?

KonghaYao (a GitHub user) maintains it in KonghaYao/peri, which has 223 GitHub stars. The repository holds 19 skills in this directory. The repository was last updated on October 8, 2026.

Source: KonghaYao/peri on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.