fetch_trace
Retrieve a specific trace by ID with full details. Choose compact or full output, and optionally include observations for complete data on model parameters and prompts.
Instructions
Get a single trace by ID with full details.
Args:
ctx: Context object containing lifespan context with Langfuse client
trace_id: The ID of the trace to fetch (unique identifier string)
include_observations: If True, fetch and include the full observation objects. If False, the
observations field group is dropped entirely to avoid expensive per-observation IO.
Use True when you need access to system prompts, model parameters, or other details stored
within observations. Significantly increases response time but provides complete data.
output_mode: Controls the output format and detail level
Returns:
One of the following based on output_mode:
- For 'compact' and 'full_json_file': A response dictionary with the structure:
{
"data": Single trace object,
"metadata": {
"file_path": Path to saved file (only for full_json_file mode),
"file_info": File save details (only for full_json_file mode)
}
}
- For 'full_json_string': A string containing the full JSON response
Usage Tips:
- For quick browsing: use include_observations=False with output_mode="compact"
- For full data but viewable in responses: use include_observations=True with output_mode="compact"
- For complete data dumps: use include_observations=True with output_mode="full_json_file"
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| trace_id | Yes | The ID of the trace to fetch (unique identifier string) | |
| output_mode | No | Controls the output format and action. 'compact' (default): Returns a summarized JSON object optimized for direct agent consumption. 'full_json_string': Returns the complete, raw JSON data serialized as a string. 'full_json_file': Returns a summarized JSON object AND saves the complete data to a file. | compact |
| include_observations | No | If True, fetch and include the full observation objects. If False, the observations field group is dropped entirely to avoid the expensive per-observation IO that dominates large-trace payloads. Use True when you need access to system prompts, model parameters, or other details stored within observations. Significantly increases response time but provides complete data. Pairs well with output_mode='full_json_file' for complete dumps. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |