new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

AI SDK · Providers · all subjects

langfuse/options

9 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Langfuse prompt linking with Prompt Management

Link Langfuse Prompt Management versions to AI SDK model-call observations by fetching a prompt using LangfuseClient.getPrompt(), passing it through runtimeContext.langfusePrompt, and including that key in telemetry.includeRuntimeContext. The prompt is compiled with parameters and used in the generateText call.

Langfuse propagateAttributes for trace context

Use propagateAttributes from @langfuse/tracing to attach Langfuse trace attributes to all observations created inside a callback. Supported attributes include traceName, userId, sessionId, tags (array), and metadata (object). These are passed as the first argument to propagateAttributes, with an async callback as the second argument containing AI SDK calls.

Langfuse telemetry options for generateText

The telemetry option in generateText accepts functionId (string), includeRuntimeContext (object with boolean values for each key to include), recordInputs (boolean, default true), recordOutputs (boolean, default true), and isEnabled (boolean, default true). Set recordInputs or recordOutputs to false to disable tracking of inputs or outputs. Set isEnabled to false to opt out of telemetry for a single call.

Langfuse runtimeContext metadata inclusion

AI SDK v7 excludes runtimeContext from telemetry events by default. To include runtimeContext keys in Langfuse observation metadata, explicitly set each top-level key to true in telemetry.includeRuntimeContext. The special key langfusePrompt in runtimeContext is used for prompt linking and does not appear in metadata.

Langfuse grouping multiple executions with startActiveObservation

Use startActiveObservation from @langfuse/tracing to create an active Langfuse observation and run multiple AI SDK calls inside it. The AI SDK observations become children of the active observation in the trace hierarchy. Pass an observation name string as the first argument and an async callback containing the AI SDK calls as the second argument.

Langfuse propagateAttributes example

Example using propagateAttributes: import propagateAttributes from @langfuse/tracing, then call propagateAttributes with attributes object containing traceName, userId, sessionId, tags array, and metadata object, with a callback calling generateText inside. The generateText call includes telemetry.functionId matching or related to traceName.

Langfuse runtimeContext example

Example using runtimeContext: in generateText, add runtimeContext object with custom keys like route and feature. In telemetry, add includeRuntimeContext object with each key set to true to include those keys in Langfuse observation metadata.

Langfuse prompt linking example

Example prompt linking: create LangfuseClient, fetch prompt using langfuseClient.getPrompt('support-chat/default'), compile it with parameters, pass it to generateText in runtimeContext.langfusePrompt, and include langfusePrompt in telemetry.includeRuntimeContext.

Langfuse startActiveObservation example

Example grouping multiple executions: import startActiveObservation and propagateAttributes from @langfuse/tracing. Call startActiveObservation with observation name and async callback. Inside callback, call propagateAttributes with trace attributes and callback containing multiple generateText calls in a loop. Each call includes telemetry.functionId. After all calls, await sdk.shutdown().

Give your agent this brain