When behavior is unclear, first enable Debug mode in the same runtime that serves traffic. It shows whether the SDK is running, which trace it tries to send, how many child spans were included, and whether the ingest request succeeds.
No traces in Lemma
Cause: credentials, project ID, base URL, or outbound network access is wrong. Fix: create oneLemma client with your API key and project ID, then send a tiny test trace.
- TypeScript
- Python
- Confirm
LEMMA_API_KEYandLEMMA_PROJECT_IDcome from the same project. - Confirm your runtime can reach
https://api.uselemma.ai. - Pass
baseUrl/base_urlonly when using a self-hosted or staging endpoint.
LEMMA_DEBUG=true and run the smoke test again. If you do not see SDK logs, the traced code path is not running in that process. If you see an ingest failure, check the status code, credentials, project ID, and baseUrl.
Every span appears as a separate trace
Cause: child work is being recorded outside thelemma.trace() callback, so the SDK cannot attach it to the root trace.
Fix: make lemma.trace() the boundary around the whole agent run, and record tools, generations, and spans inside that callback.
threadId / userId so turns remain connected. If one logical agent execution spans multiple processes, prefer recording the final trace in the coordinator that has the complete input, output, tools, and model calls.
Debug with Debug mode: compare logs from the request handler and any background worker. If the child work runs after the lemma.trace() callback has returned, it will not attach to the active trace. Move the recording into the callback, or pass IDs and use the detached record* helpers from the coordinator.
Tool calls are missing
Cause: provider instrumentation captures model calls but not your application tools, or the tool result is never recorded. Fix: calltrace.recordTool() after each tool completes.
spanCount (span_count in Python) on the sending trace log. If the count does not increase after you add recordTool(...), the tool recording code path is not running or is running outside the trace.
Inputs or outputs are blank
Cause: the trace was created withoutinput, and the callback did not return or set the final output.
Fix: pass input to lemma.trace() and return the final answer. Use trace.output() only when the callback return value is not the user-visible output.
trace sent, then open that trace in Lemma. If root output is still blank, the callback likely returned undefined, streamed the answer elsewhere, or exited before setting trace.output(...).
Model or tokens are missing
Cause: the LLM call is recorded as a generic span, so Lemma has no model name or token usage to read. Fix: record model calls withtrace.recordGeneration().
spanCount (span_count in Python) increases when the model call runs. If it does but the dashboard still lacks model metadata, switch that call site from generic span recording to recordGeneration() / record_generation() and include model and usage.
Agent name is blank
Cause: no stable name is attached to the trace, so traces cannot be grouped or filtered by workflow. Fix: setname on every lemma.trace() call.
name on trace started or sending trace. It should be the stable workflow name you expect, not a generated fallback.
Trace Nesting Is Flat
Cause: long-running subtasks are recorded as sibling observations when they should have their own parent span. Fix: usetrace.startSpan() when a subtask has nested work, then record children from that span handle. In Python, use trace.start_span() to measure the subtask and record child observations on the active trace.
spanCount (span_count in Python) includes both the parent span and the child tool, then inspect the trace in Lemma. If they appear as siblings, record the child from the span handle, for example retrieve.recordTool(...), before ending the parent span.
Serverless traces are delayed or missing
Cause: the request exits before the SDK request finishes, or a background task records work after the trace callback has returned. Fix:await lemma.trace(...) inside the handler and keep trace recording inside the callback. The SDK sends the completed payload before lemma.trace() resolves.
Debug with Debug mode: check whether the ingest log appears before the function returns. If it appears after the response is sent, or never appears, await the trace promise and avoid detached background recording unless you explicitly flush or end the trace handle.
Traces render but there are no issues or incidents
Cause: the trace renders, but it is not in a shape Lemma recognizes for automated issue detection. Fix: match the contract: one root trace, input/output, typed generation children, typed tool children, error states, and thread/user context where available.- Use
lemma.trace()for the root. - Use
trace.recordGeneration()for model calls. - Use
trace.recordTool()for tool calls. - Use
trace.recordSpan()for completed app work ortrace.startSpan()for live app work. - Pass
threadIdanduserIdfor multi-turn analysis.
trace sent with the expected trace name and child spanCount (span_count in Python), then compare the dashboard trace against the contract.