Documentation Index
Fetch the complete documentation index at: https://mintlify.com/The-Context-Company/observatory/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Therun() function creates a new run to track the execution of your AI agent. A run represents a single interaction or task execution, containing the prompt, response, metadata, and child steps or tool calls.
Function Signature
Parameters
Unique identifier for this run. If not provided, a UUID will be automatically generated.
Session identifier to group multiple runs together (e.g., a conversation thread).
Whether this run is part of a conversational flow. Set to
True for chat-based interactions.Observatory API key. If not provided, uses the
TCC_API_KEY environment variable.Custom Observatory endpoint URL. If not provided, uses the
TCC_URL environment variable or defaults to production.Returns
Returns aRun object with the following methods:
prompt()
Set the prompt for the run:The user’s input or query
System instructions or context
response()
Set the final response:The agent’s final response text
status()
Set the status code and optional message:Status code:
0 = success, 1 = partial success, 2 = errorHuman-readable status message
metadata()
Attach custom metadata:Dictionary of metadata key-value pairs
Additional metadata as keyword arguments
step()
Create a child step:tool_call()
Create a child tool call:feedback()
Submit user feedback for this run:Thumbs up or thumbs down rating
Textual feedback (max 2000 characters)
end()
Finalize and send the run data:error()
Mark the run as failed and send immediately:Error message describing what went wrong
Properties
run_id
Get the run identifier:Usage Examples
Basic Usage
Conversational Agent
With Metadata
With Steps and Tool Calls
Error Handling
Custom Status Codes
Best Practices
-
Always call end(): Ensure
r.end()orr.error()is called to send the run data to Observatory. -
Set prompt before ending: The prompt is required before calling
r.end(). -
Use session_id for conversations: Group related runs together using the same
session_id. - Add meaningful metadata: Attach user IDs, request IDs, or other context to help with debugging and analysis.
-
Handle errors gracefully: Use
r.error()to capture and report failures.
See Also
- step() - Track LLM calls within a run
- tool_call() - Track tool invocations
- submit_feedback() - Submit user feedback
