agentskit.js

@agentskit/observability-langfuse — for agents

Langfuse tracing adapter — plan / tool / model / HITL spans with token, cost, latency capture and parent linking across multi-agent topologies.

#Install

npm install @agentskit/observability-langfuse langfuse

langfuse is loaded lazily and is a peer install.

#Primary exports

  • langfuse(config?) — returns an Observer that emits one Langfuse trace per agent run with nested span / generation objects per AgentsKit event.

#Config

FieldDefaultNotes
publicKeyLANGFUSE_PUBLIC_KEYRequired (env or arg).
secretKeyLANGFUSE_SECRET_KEYRequired (env or arg).
baseUrlLANGFUSE_HOST or https://cloud.langfuse.comSelf-hosted or EU/US cloud.
release / environmentLANGFUSE_RELEASE / LANGFUSE_ENVIRONMENTFree-form metadata.
sessionId / userId / tagsAttached to the trace.
flushAt / flushInterval15 / 1000Forwarded to the Langfuse SDK.

#Span model

AgentsKit eventLangfuse objectNotes
agent:stepspanTop-level loop step (plan / act / observe).
llm:start / llm:endgenerationModel, input message count, output content (truncated), token usage.
tool:start / tool:endspanTool name, args, result snapshot, duration.
memory:load / memory:savespanMessage count.
errorannotates current spanSets level: 'ERROR' and statusMessage.

#Minimal example

import { createRuntime } from '@agentskit/runtime'
import { langfuse } from '@agentskit/observability-langfuse'

const runtime = createRuntime({
  adapter,
  observers: [
    langfuse({
      publicKey: process.env.LANGFUSE_PUBLIC_KEY!,
      secretKey: process.env.LANGFUSE_SECRET_KEY!,
      sessionId: 'demo-session',
      tags: ['agentskit', 'showcase'],
    }),
  ],
})

#Source

Explore nearby

✎ Edit this page on GitHub·Found a problem? Open an issue →·How to contribute →

On this page