trace.recordTool() / trace.record_tool() after the tool returns.
Record a tool call
- TypeScript
- Python
- TypeScript
- Python
traceId is required for detached tools. When the tool belongs under a span, parentSpanId is required; missing IDs warn and no-op.
Pass durationMs when you already measured the tool call. If you omit it, Lemma splits the parent span’s remaining unclaimed duration equally across siblings that also omitted duration.
Measure a live tool call
UsestartTool() / start_tool() when you want a handle before the tool finishes. End it only after the tool returns or fails.
- TypeScript
- Python
What the SDK records
| Field | Attribute keys |
|---|---|
| Tool kind | Lemma tool marker |
| Tool name | Span name and tool.name |
| Arguments | input.value, ai.toolCall.args |
| Result | output.value, ai.toolCall.result |
| Contract props | Native props such as toolDescription and toolParameters; raw attributes for escape-hatch keys |
Record failures
- TypeScript
- Python
Next steps
Spans
Trace retrieval, ranking, and app logic.
Threads & context
Group conversations and attach users.