this, so you can chain calls:
Required
Initialize run
.runId property you can use to retrieve its ID (auto-generated or custom):
Set prompt
The prompt is required before calling.end().
End run
End the run and export it. A run must have a prompt set before calling.end(). The run cannot be modified after calling .end().
Optional run data
Set response
Mark run as failed
Sets the status code to error and exports the payload. The run cannot be modified after calling.error(). Unlike .end(), calling .error() does not require a prompt to be set. Any un-ended children (steps, tool calls) are automatically ended with error status.
Add custom metadata
Custom metadata allows you to add additional properties to your agent runs. This is particularly useful for tying agent runs to your own specific business logic, letting you filter and analyze agent runs by user, organization, feature, or some other dimension.Identifying the agent
If your product ships more than one named agent, set the reservedtcc.agent metadata key to scope the run to a specific agent. The dashboard’s top-level agent selector, per-agent patterns and recaps, and the agent filter on the REST API and MCP tools all read from this key.
Agent names that collide with reserved dashboard routes (for example
runs, sessions, patterns, recaps, overview, search, failures, feedback, tools, topics, views, settings, mcp-and-api) are dropped.Identifying users and organizations
Attach the end user and their organization to a run as first-class identity using the reservedtcc.userId, tcc.userName, tcc.orgId, and tcc.orgName metadata keys. This is not the same as adding a userId field to custom metadata — these keys promote user and org identity to dedicated dashboard filters and unlock native user/org search, per-user views, and per-org analytics. See User and organization identity for the full concept.
Set these whenever you have a stable identifier for the end user or their organization in your product.
tcc.userName and tcc.orgName require the corresponding ID (tcc.userId / tcc.orgId) to also be set. Names without IDs are dropped.Add user feedback
User feedback allows you to collect score (thumbs up & thumbs down) and text feedback (up to 2000 characters) from end users on your agent runs. This is useful for tracking user satisfaction, identifying problematic responses, and filtering agent runs in the dashboard to focus on positive or negative feedback. Bothscore and text are optional individually, but each request must include at least one of them.
score is the thumbs rating. Use only "thumbs_up" or "thumbs_down".
text is written feedback from your user, up to 2000 characters.
Use the
submitFeedback function with a run ID:
Track agent sessions
Agent sessions represent multiple agent runs that are grouped together. The most common use case is tracking entire conversations between a human user and an AI agent in chatbot interfaces. Agent sessions can be tracked by passing asessionId when creating a run:
sessionId should be a unique string identifier. We recommend using a UUID.
Agent sessions are automatically indexed and can be filtered directly in the dashboard.
Factory pattern
If you have all run data available upfront (post-hoc logging, batch imports, replaying from logs), use thesendRun function:
