Skip to main content
A tool call is a single tool invocation inside a trace. Record it with trace.recordTool() / trace.record_tool() after the tool returns.

Record a tool call

If the tool belongs under a measured parent span, record it as a child of that span:
If the helper only has IDs, attach the tool from the client. This detached helper API is TypeScript-specific:
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.

Show a tool call as an assistant message

When a successful tool sends text directly to the user, set userFacingMessage / user_facing_message to the exact text they received. Lemma displays it as an assistant message while preserving complete input and output in the span detail.
Lemma does not inspect your tool’s input schema. Omit this field for internal tools or unsuccessful sends; their existing rendering remains unchanged.

Measure a live tool call

Use startTool() / start_tool() when you want a handle before the tool finishes. End it only after the tool returns or fails.

What the SDK records

See Native contract props and Client fields vs ingest normalization.

Record failures

Capture arguments and results only when safe. Redact secrets, credentials, and sensitive user data before passing them to traced tools.

Next steps

Spans

Trace retrieval, ranking, and app logic.

Threads & context

Group conversations and attach users.