DeepSeek Harness plugin

dsh-plugin-langfuse

Langfuse observability for DeepSeek Harness: exports session logs as OpenTelemetry traces (GenAI semantic conventions) to Langfuse's OTLP endpoint

Jump to install

Source facts

Repository
linyp/dsh-plugin-langfuse
Latest update
Aug 21, 2026
Category
Memory
GitHub stars
11
Format
plugin
Catalog evidence
Upstream dsh.bundle evidence
Evidence path
package.json#dsh.bundle
Checked against
0.1.0-rc.8
Upstream check date
2026-08-20

This evidence comes from the upstream catalog. This site has not installed, run, or security-reviewed the plugin.

Install

Start with a prompt that asks an agent to review the GitHub repository and source. Switch to the command if you want to install it yourself.

Copy this prompt into DSH, Codex, or another agent and ask it to review the GitHub repository and source first.

Do not install or run any commands yet. Read this plugin's GitHub repository, README, and relevant source code. Then answer the questions below clearly and directly so I can decide whether it fits my needs:

1. What is this plugin, and what problem does it solve?
2. Who is it for, and what are its typical use cases?
3. How is it used after installation? Include one minimal example.
4. What known limitations or privacy, security, compatibility, or maintenance risks does it have?
5. Give a clear recommendation: recommend, conditionally recommend, or do not recommend, with reasons.

Distinguish statements documented by the repository, inferences from source code, and unknowns. If evidence is insufficient, say so explicitly. Do not guess or simply repeat the README.

GitHub: https://github.com/linyp/dsh-plugin-langfuse
Plugin: dsh-plugin-langfuse
Author: linyp

Check the source files

Read the README and other files from this plugin directory before installing.

File explorer4 files
README.mdSource · read only
README language

dsh-plugin-langfuse

English | 中文

Langfuse observability for DeepSeek Harness (dsh): exports each turn as an OpenTelemetry trace — model step → generation, tool call → tool span — groups turns by session, records canonical feedback as Langfuse Scores, and preserves fork/subagent lineage.

This is a community plugin (dsh-plugin topic), not part of the official repository. It implements the harness's public telemetry seam (@deepseek-ai/dsh-session-telemetry) as an alternative backend to the official OTLP-logs exporter.

Install

The commands below assume the installed dsh CLI. Running the official harness from a source checkout instead? Run each of them as pnpm dsh … from the checkout root (after its pnpm run build) — same commands, same web profile.

As a profile bundle (the package ships a cordis.patch.yml patch layer):

dsh plugin --profile web add dsh-plugin-langfuse
export LANGFUSE_PUBLIC_KEY=pk-lf-…
export LANGFUSE_SECRET_KEY=sk-lf-…
# optional, defaults to https://cloud.langfuse.com (EU region); note the plugin
# reads LANGFUSE_HOST, not the Langfuse SDK's LANGFUSE_BASE_URL
export LANGFUSE_HOST=https://us.cloud.langfuse.com
dsh web                        # alias for: dsh --profile web

The bundled patch disables the base profile's session-telemetry-otel row (the telemetry seam accepts exactly one backend per context; a duplicate load throws) and mounts this backend in FULL mode when a Langfuse key is present, DISABLED otherwise. It also enables feedback Scores when both project keys are present. LANGFUSE_TELEMETRY_MODE=FEEDBACK_ONLY narrows sharing to feedback-gated release.

Both the bundle layer and the env vars are read at boot: an already-running instance must be restarted after installing, from a shell that has the variables set. dsh --profile web --dump-config shows the composed result without booting — a # == dsh-plugin-langfuse layer that patches the base telemetry row and adds session-telemetry-langfuse with its env-driven mode. After the next turn, traces appear in the Langfuse console of the region LANGFUSE_HOST points at — keys are region-scoped, so a US project shows nothing on the EU console. dsh plugin --profile web remove dsh-plugin-langfuse removes both the dependency and the layer.

Or as an explicit cordis.yml row:

- id: session-telemetry-langfuse
  name: dsh-plugin-langfuse
  config:
    mode: FULL                 # FULL | FEEDBACK_ONLY | DISABLED (default)
    exporter:                  # passed verbatim to the SDK's OTLP/HTTP trace exporter
      url: https://cloud.langfuse.com/api/public/otel/v1/traces
    auth:
      publicKey: !!js process.env.LANGFUSE_PUBLIC_KEY
      secretKey: !!js process.env.LANGFUSE_SECRET_KEY
    feedbackScores:             # optional; disabled by default for explicit rows
      enabled: true
      url: https://cloud.langfuse.com/api/public/scores
      maxQueueSize: 256
      requestTimeoutMillis: 3000
    content:                    # optional privacy/content controls
      turnInputMode: user       # none | user | user-and-context
      cwdMode: omit             # omit | basename | full
      toolMetaAllowlist: []     # exact top-level tool-result meta keys
    metadata:                   # optional static Langfuse grouping
      environment: production
      tags: [dsh]
    health:
      warningIntervalMillis: 60000
      maxErrorChars: 1000
    processor: {}              # optional; passed verbatim to BatchSpanProcessor
    shutdownTimeoutMillis: 3000

Config

FieldMeaning
modeFULL exports every session live; FEEDBACK_ONLY replays and exports the canonical session log only when the user records feedback; DISABLED (default) constructs nothing and nothing leaves the process. The vocabulary and consent semantics are the seam's, identical to the official backend.
exporterThe complete OTLPExporterNodeConfigBase object, passed to the OTLP/HTTP trace exporter. url is required outside DISABLED and must be the full traces path (…/api/public/otel/v1/traces). The plugin defaults an x-langfuse-ingestion-version: 4 header — without it new spans do not land on Langfuse's v4 data model in real time. An explicit entry (any casing) wins, whether supplied in a plain exporter.headers object or returned by a HeadersFactory.
authLangfuse project key pair, turned into the endpoint's Basic-auth header. Mutually exclusive with an explicit exporter.headers authorization; uploading modes require exactly one of the two.
correlationHost-identity correlation: userId/sessionId stamped as langfuse.user.id/langfuse.session.id on every exported span so an embedding host's traces and this plugin's group under one Langfuse user/session. See [Correlating with an embedding host](#correlating-with-an-embedding-host).
feedbackScoresOptional session-level TEXT Score export for canonical feedback/record events. enabled defaults to false; url must be the full …/api/public/scores path. maxQueueSize defaults to 256 and requestTimeoutMillis to 3000. The bounded in-memory queue is failure-isolated from tracing and drains best-effort on shutdown. The bundled profile enables it when both project keys exist.
contentExport-content policy. turnInputMode defaults to user (aggregate human messages only); user-and-context also includes plugin-injected context and none omits root input. cwdMode defaults to omit; basename exports only the final directory and full exports the full path. toolMetaAllowlist defaults empty and admits only named top-level tool/result.meta keys.
metadataOptional static Langfuse environment and tags, propagated to every observation for v4 querying. Environment follows Langfuse's lowercase a-z0-9-_ format, must not start with langfuse, and is at most 40 characters; at most 50 tags of at most 200 characters each are accepted.
healthDelivery diagnostics. warningIntervalMillis defaults to 60000 and rate-limits continuing failure warnings (0 suppresses repeats after the first warning); maxErrorChars defaults to 1000 after credential/URL sanitization. These settings do not add retries or change SDK buffering.
processorPassed verbatim to BatchSpanProcessor (scheduledDelayMillis, maxQueueSize, maxExportBatchSize, …); batching, retry, and loss policy are the SDK's documented behavior.
maxAttributeCharsSerialized-payload ceiling per span attribute (default 32768); longer payloads are clipped with an …[clipped] marker while the canonical session log keeps the full bytes.
shutdownTimeoutMillisPlugin-owned outer deadline on the SDK's shutdown drain (default 3000).

Misconfiguration fails loud at plugin load: a missing/malformed/non-http(s) exporter URL, missing credentials, ambiguous double auth, a non-positive maxExportBatchSize (the SDK would hang on shutdown), invalid correlation/content/metadata/health settings, an enabled Score sink without a valid URL/queue/timeout, or an unknown mode all throw before any transport is constructed.

Delivery status

LangfuseSessionTelemetryBackend.status() returns a synchronous detached snapshot with overall and per-channel state, trace batch/span success and failure counts, consecutive failures, recent timestamps, sanitized last error, and Score queued/delivered/dropped/skipped/failed counts. States are disabled, starting, healthy, degraded, and stopped; Score remains an independent channel. The OTel SDK does not expose BatchSpanProcessor queue depth, so traces.queuedBySdk is explicitly unknown. First failure, rate-limited continuing failure, and recovery are also logged without Authorization or Langfuse keys.

In a standard interactive Harness profile, inspect the same snapshot without leaving the conversation UI:

/langfuse status
/langfuse status --json

The first form is a compact human-readable report; --json returns a stable envelope containing the plugin version, session-sharing policy, and the complete status() snapshot. The command is local-only: it does not contact Langfuse, retry delivery, inspect credentials, or force an SDK flush. It is available whenever the Harness commands service is composed (including the standard web profile); telemetry-only/headless compositions without that optional service continue to load the backend without registering the command. starting means no trace export batch has completed yet, not that the command is probing the endpoint. Even DISABLED mode registers the command when possible, so /langfuse status can confirm that nothing is being shared.

Correlating with an embedding host

A host application that embeds the dsh runtime and already emits its own traces into the same Langfuse project can steer this plugin's identity so both views group under one Langfuse user/session — the host typically injects its ids as env vars when spawning the runtime:

config:
  correlation:
    userId: !!js process.env.HOST_USER_ID
    sessionId: !!js process.env.HOST_SESSION_ID
  • The resolved langfuse.session.id/langfuse.user.id ride every exported span — turn, generation, tool, and compaction — because Langfuse's v4 query model filters and aggregates per observation, not only per trace (propagation contract).
  • sessionId defaults to the dsh session id, and the original dsh session id stays on each logical root as dsh.session.id — the pointer back into $DSH_HOME/sessions for local diagnosis.
  • Per-turn dynamic override: a turn/start record carrying langfuse.user.id/langfuse.session.id attributes overrides the static config for that turn — a deployment injects them through a session-telemetry/record waterfall listener. The snapshot is locked at turn/start; identity attributes on later records are ignored. Precedence: record attributes > correlation config > dsh session id.
  • A dynamic mapping must be deterministic and rebuildable from the dsh session id, and must survive for as long as the session can still trigger a FEEDBACK_ONLY replay — otherwise the replayed tree exports under a different identity than live capture would have.
  • Static correlation values bypass the redaction waterfall: the waterfall transforms records, and these values never transit one.
  • Delivery semantics are unchanged: correlation is identity, not dedup — duplicates remain possible (see decision 5).

What appears in Langfuse

dsh session eventLangfuse concept
session (session.id)session (langfuse.session.id on every exported observation/span)
turn/start / turn/endtrace root observation (root span; error end reasons set span status ERROR)
step/start / step/end + request/header + request/context + assistant/messagegeneration — model, provider, safe request parameters/context window, output, canonical gen_ai.usage.* tokens (input/output/cache-read/cache-creation/reasoning); the latest assistant message also becomes the root observation's overall output. Interrupted partial output is retained and marks both observations with dsh.assistant.interrupted=true without classifying the interruption as an error
llm/retry / llm/retry-startedstructured scheduled/started events on the existing generation, including retry id/attempt/policy/delay and clipped failure details; no synthetic generation is created because the current Harness event contract provides no per-attempt usage lifecycle
first assistant/chunk of a steplangfuse.observation.completion_start_time (time-to-first-token)
tool/call + tool/resulttool span (arguments as input, the full result content array as output, structured error name/code/outcome, isError → status ERROR; private meta is omitted unless allowlisted)
approval/asked + approval/decidedtimed internal approval span under the corresponding tool when callId resolves, otherwise under the current generation/turn; incomplete approvals are force-closed as ERROR
user/messageaggregate root observation input according to content.turnInputMode; deprecated trace input is retained for legacy evaluator compatibility
session/title / subagent/descriptor / agent-preset/selectedsession semantic state used to set langfuse.trace.name and safe browsing metadata on current/future observations without changing stable span names or IDs
session/end-seedcloses compactions inherited without a matching end at the seed boundary and marks them incomplete/ERROR
feedback/recordsession-level dsh_user_feedback TEXT Score when feedbackScores.enabled; only the post-waterfall canonical text is eligible
forked child sessionindependent child turn trace plus queryable parent/seed metadata; an OTel Link points to the completed parent turn when its in-process context is retained
agent-error ops recordagent-error span event + status ERROR on the open turn
compaction/start + compaction/summary + compaction/endone generation spanning the whole compaction transaction; child of its owning turn when available, otherwise a stable standalone trace; includes provider/model/usage and shadowed range/count/token statistics
compaction/prunepoint-in-time span event with the pruned range/count/token statistics
every other event type (todo, plan, hooks, plugin events)point-in-time span event on the open turn

Token accounting follows the OpenTelemetry GenAI inclusive-total contract. DSH reports mutually exclusive input buckets (inputTokens is uncached input), so the exported gen_ai.usage.input_tokens is reconstructed as inputTokens + cacheReadTokens + cacheWriteTokens; cache read/write and reasoning remain canonical detail attributes. Langfuse can then normalize them into mutually exclusive usage buckets exactly once.

Architecture decisions

1. A telemetry-seam backend, not agent-loop or LLM-layer instrumentation

The harness's rule is model-visible ⟺ logged: everything that reaches a model request is reconstructable from the canonical session log, and new behavior lands as a plugin on documented extension points, never as agent-loop changes. The telemetry seam (@deepseek-ai/dsh-session-telemetry) is exactly the extension point built for handing session records to a reporting SDK. Implementing its SessionTelemetryBackend buys, for free and with guaranteed consistency:

  • capture of everything model-visible — including subagent, workflow, compaction, and plugin events this package has never heard of;
  • the session-telemetry/record redaction waterfall (deployment-owned scrub rules apply to the exported copy; the canonical log is never rewritten);
  • FEEDBACK_ONLY consent semantics (nothing leaves until the user records feedback, and only the committed canonical event is consent);
  • the handoff cursor, adoption sweeps, and teardown draining.

Instrumenting the LLM adapter or agent loop directly would duplicate all of that, drift from the log, and break the moment the loop changes.

2. Plain OTel traces SDK, not the Langfuse SDK — because of a signal-type mismatch

The official session-telemetry-otel backend cannot feed Langfuse: it exports OTLP logs, and Langfuse's OTLP endpoint (/api/public/otel) accepts traces only, over OTLP/HTTP (JSON or protobuf; no gRPC), with Basic auth. That mismatch — not a missing URL — is why this plugin exists.

The trace pipeline is the plain OTel traces SDK (BasicTracerProviderBatchSpanProcessorOTLPTraceExporter), the same SDK family and configuration surface as the official backend, with attributes following the OTel GenAI semantic conventions plus Langfuse's documented langfuse.* property mapping. Feedback Scores use a small native-HTTP transport instead of a second tracing SDK so the plugin can reuse its async/custom auth contract and keep trace versus Score failures isolated. The Langfuse SDK can replace that internal transport later without changing the telemetry seam or public configuration.

3. A folding projection, because the seam hands over a flat stream and Langfuse needs a tree

The seam's records mirror session-log events one-to-one; Langfuse needs trace → observation hierarchy. SessionSpanFolder is a state machine keyed by (session.id, turn, step, compactionId) that folds records into open OTel spans. Its contract-critical choices:

  • Timestamps always come from the record's time, never the wall clock, so live capture and FEEDBACK_ONLY canonical-log replay produce identical trees (span start/end times are explicit — the OTel API supports historical stamps).
  • seq gaps are routine, never a loss signal: the seam ships only the first assistant/chunk per step (the stream-started signal; its time is the first-token time). The folder relies on this instead of counting.
  • Severity is the seam's pre-mapped value; the folder maps error onto span status and never re-derives event semantics.
  • Tool spans are children of their step's generation span: the harness defines a step as one model request plus the tools it callstool/call and tool/result land inside the step's boundaries — so the generation span temporally contains its tool executions. A call whose step is no longer open (crash-window replay) falls back to the turn span.
  • Overall turn input/output live on the root observation for Langfuse v4: user/message supplies its input, and each completed assistant message replaces its output so the final message remains at turn end. Deprecated langfuse.trace.input/output aliases are emitted only for legacy trace-level evaluator compatibility.
  • Unknown event types land as span events on the open turn — the event vocabulary is merge-extensible, and dropping unknown types would silently thin the timeline.
  • Compaction is one transaction Generation from compaction/start through compaction/end. Its duration deliberately includes orchestration around the provider call and is not labeled as pure model latency. compaction/summary enriches the span with the compacted summary, provider/model/usage, and aggregate shadow statistics; provider rawOutput and the full shadowedSeqs list are never exported. The paired replacement user/message (source.plugin=compact) remains model-visible context but never overwrites the turn's human input. A missing owner becomes a stable standalone trace, while missing/malformed lifecycle records degrade to point events or an ERROR span rather than fabricated timing.
  • Force-end sweeps close still-open spans (marked dsh.force_ended) on a next turn/start with an open predecessor, on the session's ops shutdown record, and on backend shutdown — teardown never abandons started spans inside the SDK queue.

4. Stable identity, feedback Scores, and fork lineage

  • Versioned SHA-256 identities derived from (dsh session id, turn) and (dsh session id, compaction id) supply stable 32-hex Trace IDs across live export and FEEDBACK_ONLY replay. A valid W3C traceparent still wins for distributed tracing; the deterministic ID remains queryable metadata.
  • Canonical feedback becomes a session-level dsh_user_feedback TEXT Score through a bounded single-worker queue. It uses a deterministic Score ID, retries transient failures with the same ID, and never blocks or fails the agent loop. Because the source event has no rating or target turn, the plugin deliberately does not invent one.
  • Every child turn carries direct parent session, seed boundary, and resolved parent Trace ID metadata. If the com