get_user_sessions
Fetch user sessions from Langfuse within a time range by providing user ID and age (minutes). Optionally include observations and select output mode: compact summary, full JSON string, or file.
Instructions
Get sessions for a user within a time range.
Args:
ctx: Context object containing lifespan context with Langfuse client
user_id: The ID of the user to retrieve sessions for (unique identifier string)
age: Minutes ago to start looking (e.g., 1440 for 24 hours)
include_observations: If True, fetch and include the full observation objects instead of just IDs.
Use this 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:
Based on output_mode:
- compact: List of summarized session objects
- full_json_string: String containing the full JSON response
- full_json_file: List of summarized session objects with file save info
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 |
|---|---|---|---|
| age | Yes | Minutes ago to start looking (e.g., 1440 for 24 hours) | |
| user_id | Yes | The ID of the user to retrieve sessions for | |
| 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 instead of just IDs. Use this 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 |