thread_id / user_id, typed nested generations/tools/spans, and real
wall-clock timing. Standalone LLM/tool/retriever callbacks finalize their own
owned trace. Missing-parent events never overwrite concurrent trace state.
You do not need to wrap LangChain calls in lemma.trace(). Pass the callback
handler through LangChain’s callbacks option, then flush() to send the
trace.
TypeScript
Install LangChain and the Lemma SDK:langChain() as a callback handler:
Python
Install the optional extra:langchain() as a callback handler:
What Lemma records
Promote identity from configurable metadata/tag keys (
threadIdKey /
thread_id_key, userIdKey / user_id_key). Defaults also check
conversation_id, session_id, and resourceId.
Prompts, tool inputs, outputs, model output text, and error messages are always
recorded. Redact secrets and sensitive user data before they reach the chain.