experimental_telemetry. Those spans carry the exact attributes Lemma reads, so once you point Langfuse at Lemma and wrap each agent run in one root span, you get a complete nested trace: a root with input/output, generations for every model call, and tool spans for every tool.
One agent execution = one trace. Wrap a full multi-step run in a single root span so every model and tool call nests under it. See the trace contract.
experimental_telemetry.
Recipe
Register the Langfuse → Lemma exporter
Register the exporter once, before any agent or model runs. This is the same setup used across the docs — see Setup.Set the environment variables. Lemma-only export needs no
LANGFUSE_* credentials.Enable AI SDK telemetry
Turn on By semantic convention, use
experimental_telemetry for every generateText / streamText / generateObject call. The AI SDK natively emits the model, token-usage, and tool-call attributes Lemma reads. Set gen_ai.agent.name so traces group by workflow.snake_case, CamelCase, or kebab-case for gen_ai.agent.name (for example support_agent, SupportAgent, or support-agent).Wrap the whole run in one root span
A multi-step agent makes several model and tool calls. Wrap the entire run in a single root span so all of them nest under one trace instead of arriving as separate traces.The AI SDK spans created inside the callback automatically become children of the root, producing one nested trace:
Verify in Lemma
Open the Lemma dashboard → Traces and confirm:- One trace per run — a single multi-step execution is one trace, not one per model call.
- Root has input and output — the root span shows the user message and the final response.
- Generations are nested — each model call appears as a child generation with model and token usage.
- Tools are nested — each tool invocation appears as a child tool span with arguments and result.
Next steps
Trace contract
The exact shape Lemma reads.
Setup
Wire the Langfuse → Lemma exporter.
Threads and sessions
Group multi-turn conversations with a thread id.
Good vs bad traces
What issue detection looks for, per shape.