Using Traces
Traces are an organizing component of a session. They are used to group completions together and provide a way to track the progress of a session. Named traces form the basis of Freeplay’s support for Agents. For a comprehensive guide on building agents with traces, see Agents.| Method Name | Parameters | Description |
|---|---|---|
session.create_trace | input: str - Input to the trace. agent_name: str (optional) - Name of the agent/trace. parent_id: UUID (optional) - Parent trace or completion ID for nesting. kind: str (optional) - Either 'tool' or 'agent'. name: str (optional) - Name of the trace/tool. custom_metadata: dict[str, Any] (optional) - Metadata to associate with the trace. | Generate a TraceInfo object that will be used to group completions |
trace.record_output | output: str - Output of the agent/trace. project_id: str - ID of the project to record to. eval_results: dict[str, Any] (optional) - Code evaluation results. test_run_info: TestRunInfo (optional) | Record the output to a trace |
Adding Tools to Traces
When building agents that use tools, tool calls are recorded as the output of an LLM call by default. You can also add explicit tool spans to provide more data about tool execution, including latency and other metadata. These are recorded as a Trace withkind='tool' and linked to the parent completion using parent_id.
For complete examples and code snippets, see Tool Calls.
Updating a Trace
Trace information can also be updated, similar to a completion. This can be done by using theupdate_trace method. See the below example, note you must have the trace_id and the project_id to properly record:

