Learn how to control the capture and structure of input and output data for traces and spans with the LangWatch Python SDK.
@langwatch.trace()
or @langwatch.span()
as decorators on functions, the SDK attempts to automatically capture:
capture_input
and capture_output
boolean parameters.
@langwatch.trace()
and @langwatch.span()
for more details on capture_input
and capture_output
parameters.input
and output
parameters when initiating a trace or span, or by using the update()
method on the respective objects.
This is useful for:
ChatMessage
objects).@langwatch.trace()
or @langwatch.span()
(either as decorators or context managers), you can pass input
and output
arguments.
input
or output
directly, it overrides what might have been automatically captured for that field.
update()
method. This is particularly useful when the input/output data is determined or refined during the operation.
update()
method on LangWatchTrace
and LangWatchSpan
objects is versatile. See the reference for LangWatchTrace
methods and LangWatchSpan
methods.ChatMessage
objects: The standard way to represent conversations for LLM interactions. This ensures proper display and analysis in the LangWatch UI.ChatMessage
objects.
ChatMessage
, ToolCall
, and other related types, please refer to the Core Data Types section in the API Reference.capture_input=False
, capture_output=False
) and explicitly set sanitized versions using input
/output
parameters or update()
.input=None
or output=None
via the update()
method to remove previously captured (or auto-captured) data if it’s no longer relevant or was captured in error.ChatMessage
for conversations), you can ensure that your traces provide clear, relevant, and secure insights into your LLM application’s behavior.