Superseded runtime guide: use SSOT ompfuse. The local
langfuse.tsremains a gated fallback only; do not enable both exporters.
Historical snapshot
The former standalone exporter is preserved only for incident comparison. Current credentials and setup belong to ompfuse in SSOT; it finalizes token usage on message_end and tracks subagents on the same trace tree.
๐๏ธ Architecture
graph TB subgraph OMP["OMP Runtime (Bun)"] subgraph Ext["langfuse.ts extension"] Events["Events<br>(pi.on)"] Queue["Queue<br>(batch)"] Post["POST /ingestion<br>(2s / 500 cap)"] Events --> Queue Queue --> Post end end Server[Langfuse Server] Post -->|HTTP| Server style OMP fill:#f9f9f9,stroke:#333,stroke-width:2px style Ext fill:#e1f5fe,stroke:#0288d1,stroke-width:1.5px style Events fill:#fff,stroke:#333 style Queue fill:#fff,stroke:#333 style Post fill:#fff,stroke:#333 style Server fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px
Key design decisions:
- ๐จ Batched โ events queue in memory, flush every 2s or at 500 events
- ๐ Ordered โ flushes chain via promise to preserve event sequence
- ๐ก๏ธ Fail-open โ all handlers wrapped in
safeOn()try-catch +sendBatchtry-catch; errors logged, never crash OMP - โฑ๏ธ 10s timeout โ slow Langfuse server canโt hang your session
- ๐ Graceful shutdown โ final flush is
awaited before process exits - ๐ Type-safe โ all event properties coerced with
String()/Number()before use; no unsafeascasts
๐ What Gets Traced
| OMP Event | โ Langfuse | Data Captured |
|---|---|---|
๐ฌ session_start | Trace omp-session | cwd, model, hostname, tags, userId (profile) |
๐ session_shutdown | Trace update | turn count summary |
๐ turn_start/end | Span turn | duration (ms), context tokens, context % |
๐ง before_provider_request | Generation llm-call | model, provider, prompt input (redacted + 15k truncated) |
๐ง message_end | Generation complete | final output, tokens (in/out), cache stats, cost, latency, stop reason |
๐ง tool_call | Span tool:<name> | input (redacted + truncated) |
๐ง tool_result | Span update | output (redacted + 4k), duration, error level |
๐ค agent_start/end | Span agent:<type> | subagent type, model, nesting hierarchy, duration |
๐ฆ session_compact | Span compaction | summary, tokens before |
โ ๏ธ auto_retry_start | Span auto-retry | reason, attempt (WARNING level) |
๐ ttsr_triggered | Span ttsr-injection | injected rule names |
๐ฏ goal_updated | Trace update | session title โ trace name |
Historical configuration
Legacy environment variables are intentionally not documented here. Configure the active package through ompfuse in SSOT.
๐ท๏ธ Langfuse Dashboard Tips
Filtering traces
- Tag
ompโ always present on every trace - Tag
provider:<name>โ filter by LLM provider (anthropic, google, etc.) - Tag
model:<name>โ filter by model (claude-opus-4, gemini-pro, etc.) - Custom tags via
LANGFUSE_TAGS=prod,gpu-nodeโ tagsprod,gpu-node
Understanding the trace tree
graph TD %% Define Styles classDef session style fill:#1f77b4,stroke:#115588,stroke-width:2px,color:#fff; classDef turn style fill:#aec7e8,stroke:#1f77b4,stroke-width:1.5px,color:#000; classDef leaf style fill:#f7f7f7,stroke:#ccc,stroke-width:1px,color:#333; classDef warning fill:#ffbb78,stroke:#ff7f0e,stroke-dasharray: 5 5,stroke-width:2px,color:#000; classDef system style fill:#c7c7c7,stroke:#7f7f7f,stroke-width:1px,color:#000; %% Nodes Session["omp-session (Trace)<br/><i>1 per OMP session</i>"]:::session Turn1["turn (Span)<br/><i>1 per userโagent exchange</i>"]:::turn Turn2["turn (Span)"]:::turn Compaction["compaction (Span)<br/><i>context window compacted</i>"]:::system AutoRetry["โ ๏ธ auto-retry (Span)<br/><i>WARNING level</i>"]:::warning Ttsr["ttsr-injection (Span)<br/><i>rule injection event</i>"]:::system %% Children of Turn 1 LLM1["llm-call (Generation)<br/><i>model request/response + tokens</i>"]:::leaf Read["tool:read (Span)<br/><i>tool with I/O</i>"]:::leaf Edit["tool:edit (Span)<br/><i>another tool</i>"]:::leaf Bash["tool:bash (Span)<br/><i>...</i>"]:::leaf AgentTask["agent:task (Span)<br/><i>subagent spawn</i>"]:::leaf %% Children of Turn 2 LLM2["llm-call (Generation)"]:::leaf Search["tool:search (Span)"]:::leaf %% Hierarchy Connections Session --> Turn1 Session --> Turn2 Session --> Compaction Session --> AutoRetry Session --> Ttsr Turn1 --> LLM1 Turn1 --> Read Turn1 --> Edit Turn1 --> Bash Turn1 --> AgentTask Turn2 --> LLM2 Turn2 --> Search
Key metadata fields
durationMsโ on generations + tools + turnscontextTokens/contextPctโ on turns (how full is the context window?)cacheRead/cacheWriteโ on generations (prompt cache hits)totalCostโ on generations (if provider reports cost)stopReasonโ on generations (stop,length,toolUse,error)hostnameโ on trace (which machine ran this session)
๐ Security
| Concern | Protection |
|---|---|
| ๐ API keys & credentials | Auto-redacted by regex before sending across all channels (LLM prompts, completions, and tool inputs/outputs). Matches both key-value pairs (api_key, secret, etc.) and raw keys (ghp_, sk-proj-, sk-lf-, sk-ant-, AIzaSy-). |
| ๐ผ๏ธ Base64 images | Stripped entirely โ [base64 image omitted] |
| โ๏ธ Large payloads | Deep-truncated: LLM I/O โ 15k, tool I/O โ 8k/4k, summaries โ 5k (performed after redaction to avoid leaking pattern prefixes) |
| ๐ Auth to Langfuse | Basic Auth header from env vars (never logged) |
| ๐ Batch limit | Langfuseโs 3.5 MB limit respected via truncation + queue cap |
Historical troubleshooting
Diagnose the active exporter with the ompfuse SSOT. The only legacy decision is whether its explicit compatibility gate is enabled; never run both exporters.
๐ฎ Langfuse API Reference (what the extension uses)
| Endpoint | Method | Auth | Purpose |
|---|---|---|---|
/api/public/ingestion | POST | Basic (pk:sk) | Batch event ingestion |
Event types sent
| Type | When |
|---|---|
trace-create | Session start, goal change, session end (upsert) |
generation-create | LLM request start |
generation-update | LLM response received |
span-create | Turn/tool/agent/compaction/retry/ttsr start |
span-update | Turn/tool end |
๐ Changelog
2026-06-20 โ 100% Perfection Refinement, Raw Token Redaction & Robust Telemetry Redaction
Security & Secret Redaction Hardening:
- ๐ Unified & Structural Secret Redaction โ Applied
redactSecrets()consistently to all telemetry vectors (LLM prompt inputs, LLM completion outputs, and tool output text previews) before payload truncation. Implemented JSON-parsing insideredactSecrets()to detect and recursively redact stringified JSON payloads structurally, preventing regex escapes and ensuring robust schema-aware key redaction. - ๐ Raw Token Pattern Detection โ Implemented
RAW_TOKEN_PATTERNto scan and redact raw API keys/tokens (ghp_,github_pat_,sk-lf-,pk-lf-,sk-ant-,sk-proj-,sk-,AIzaSy) across all string payloads, preventing token leakage even without key-value prefix anchors. - ๐งช Dynamic Environment Secrets Collection โ Added code to dynamically scan and harvest secrets from the environment (
process.env) on initialization, filtering for values >= 8 characters. Deduplicated and sorted these needles by length descending to prevent substring redaction collisions. - ๐๏ธ Deep Metadata Redaction & Safety โ Enforced
redactSecrets()across all trace and span metadata blocks (including error messages, environment dumps, model configurations, and process telemetry). Implemented optional chaining and explicit null-pointer guards inside metadata mapping and array filters, eliminating potential runtime TypeError crashes on malformed payload inputs.
Subagent Nesting & Out-of-Scope Architecture:
- ๐ธ๏ธ OTel-based Subagent Nesting Path โ Identified that OMP runs subagents in-process sharing global process state (rather than isolated OS child processes). Thus, ad-hoc
process.envmutations for trace propagation bleed and race on concurrent executions. Consequently, subagent span nesting has been declared out-of-scope for this event-based extension. Users requiring recursive multi-agent tracing should configure OMPโs native OpenTelemetry (OTel) OTLP exporter to Langfuseโs OTLP endpoint for correct, race-free trace hierarchies.
Tool Output Preview Hardening:
- ๐ง Support for Raw String & Custom Tool Outputs โ Expanded the
tool_resultevent handler to support raw string content and fallback stringification of non-string and non-array custom tool results (objects, numeric stats, booleans), ensuring custom tool outputs are properly captured and redacted in Langfuse.
2026-06-11 โ Architectural Improvements, Subagent Nesting & UI Configs
Subagent Nesting & Developer Profiles:
- ๐ค Subagent Span Closing โ Added
agent_endhook listener to cleanly close subagent execution spans. ImplementedactiveAgentsstack to track nested subagent calls (e.g.taskcallingplan) to correctly reconstruct parent-child execution graphs. - ๐ค Developer Profiles (
userId) โ Added OS user/username metadata capture (process.env.USER) asuserIdto traces, enabling trace filtering by developer profile.
Bug Fixes & Config Enhancements:
- ๐
trace-updaterejected by Langfuse API โ The Ingestion API does not supporttrace-updateevents, returning HTTP 400. Corrected totrace-createevents which Langfuse handles as upserts (updates/inserts) on existingidmatches. - ๐
[object Object]tags & model names โ Whenctx.modelorevent.modelis an object at runtime,String(model)coercion produced"model:[object Object]". Added robust object-to-string extraction of the modelidornamefield. - ๐ก๏ธ JSON secrets redaction bypass โ Tool input secrets in JSON/object keys (like
{ api_key: "value" }) bypassed the regex-basedredactSecrets()due to missing separator matches on object keys. AddedKEY_REDACT_PATTERNto correctly match and redact secret fields in object schemas. - โ๏ธ
LANGFUSE_UI_INDICATORโ Introduced a dedicated env toggle to control the TUI status line tracing indicator, decoupled from verbose debug logging.
2026-06-10 โ Robustness Hardening
Bug Fix:
- ๐
model.split is not a functionโctx.model/event.modelcan be a non-string truthy value at runtime (object, number). Fixed by coercing withString()inbuildTags()(line 237),before_provider_request(line 362โ363), andafter_provider_response(line 414).
Hardening:
- ๐ก๏ธ Fail-open handlers โ all 13 event handlers now wrapped via
safeOn()with try-catch; a thrown error in any handler is logged and swallowed, never crashes OMP. - ๐ก๏ธ
sendBatchtry-catch โJSON.stringifyfailures and uncaughtfetcherrors now caught insidesendBatch(), preventing chain breakage. - ๐ข Token coercion โ
usage.input/output/cacheRead/cacheWritenow coerced viaNumber() || 0to handle string or undefined values. - โฑ๏ธ Consistent timestamps โ
agent_starthandler now capturesiso()once and reuses for bothtimestampandstartTime(was callingiso()twice, producing skewed values). - ๐ท๏ธ Agent name coercion โ
agent_startspan nameev.agentTypecoerced viaString()to prevent[object Object]tags. - ๐
buildTagssignature โ parameter types widened fromstringtounknownto match actual runtime event shapes.
๐งฉ Langfuse Agent Skills (langfuse/skills)
Repo: github.com/langfuse/skills โ MIT ยท 160+ โญ
Official Agent Skills that teach AI coding assistants (Claude Code, Cursor, etc.) how to work with Langfuse. Separate from the OMP extension above โ these are agent-side skills for instrumentation, prompt management, and data access.
Available Skills
| Skill | Description |
|---|---|
langfuse | Query/manage traces, prompts, datasets, scores via API; documentation lookup; best-practice workflows |
Installation
# Cursor Plugin
/add-plugin langfuse
# Skills CLI (no install required)
npx skills add langfuse/skills --skill "langfuse"
# Manual symlink
git clone https://github.com/langfuse/skills.git /path/to/langfuse-skills
ln -s /path/to/langfuse-skills/skills/langfuse /path/to/skills-directory/langfuseCore Capabilities
- CLI Data Access โ
npx langfuse-cli api __schemato discover resources;list/getany API entity (traces, prompts, datasets, scores, sessions) - Documentation Access โ
langfuse.com/llms.txt(full page index), append.mdto any page path, or search via/api/search-docs?query=... - Use-case References โ built-in guides for: instrumentation, prompt migration, user feedback capture, SDK upgrades, judge calibration, error analysis, CI/CD experiment gates
Prerequisites
These credentials configure Langfuse skills and the active ompfuse package:
export LANGFUSE_PUBLIC_KEY=pk-lf-...
export LANGFUSE_SECRET_KEY=sk-lf-...
export LANGFUSE_BASE_URL=https://cloud.langfuse.com # or us.cloud.langfuse.com / self-hostedAuto-Allowed Tools
The skill auto-grants these (read-only, Langfuse-scoped):
WebFetch(domain:langfuse.com)Bash(npx langfuse-cli api __schema/list/get/--help ...)
Plugin Manifests
Ships as plugins to two marketplaces (.claude-plugin/plugin.json + .cursor-plugin/plugin.json), versioned with semver and kept in lockstep.