Set TCC environment variables
.env
Instrument OpenClaw
- Plugin install
- Manual registration
The fastest way to get started. Install the plugin and configure it in your That’s it! The plugin hooks into the agent runtime and starts sending traces to The Context Company. All LLM calls, tool executions, and agent lifecycle events are automatically captured.
openclaw.json.Step 1: Install the plugin
Step 2: Configure the plugin
Add the plugin to youropenclaw.json:openclaw.json
Step 3: Restart the gateway
Adding 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.- Plugin config
- Manual registration
Set static metadata in your
openclaw.json to attach the same metadata to every run:openclaw.json
The
tcc.* namespace is reserved. Only the reserved TCC metadata keys (tcc.runId, tcc.sessionId, tcc.conversational, tcc.agent, tcc.userId, tcc.userName, tcc.orgId, tcc.orgName) are recognized; any other tcc.* keys are ignored. None of them appear in your custom metadata.The plugin auto-mints a per-run tcc.runId and stamps it on every payload. Do not set tcc.runId in metadata. Use the runId config (consumed once) or override per run via the onRunStart callback.Adding 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.Step 1: Capture the run ID
The plugin auto-generates a unique run ID (UUID) for every agent turn. Use theonRunEnd callback to capture it:
extensions/tcc-observability/index.ts
Step 2: Submit feedback
When the user provides feedback, submit it using thesubmitFeedback function.
Both score 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.
Tracking 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. By default, the plugin automatically uses OpenClaw’sctx.sessionKey as the session ID, which is already scoped per conversation thread. This means sessions are tracked automatically for channel-based setups (e.g. Slack threads).
To override this default, use manual registration and derive the session ID from the run context:
extensions/tcc-observability/index.ts
onRunStart callback:
extensions/tcc-observability/index.ts
sessionId should be a unique identifier for the agent session. This can be any string, but it’s generally recommended to use a UUID.
Agent sessions are automatically indexed and can be filtered directly in the dashboard.
Marking runs as conversational
A conversational run is an agent run that was initiated by a user. Marking a run as conversational tells The Context Company that this run involves direct user interaction. This is important because conversational runs are the only runs monitored for user insights, such as user confusion, frustration, or any other custom insights you want to track. Runs that are not marked as conversational (e.g. background jobs, cron tasks, or internal automations) are excluded from user insight analysis. Mark a run as conversational by settingtcc.conversational to "true" in metadata:
- Plugin config
- Manual registration
openclaw.json
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.
- Plugin config
- Per-run via onRunStart
openclaw.json
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.
- Plugin config
- Per-run via onRunStart
openclaw.json
tcc.userName and tcc.orgName require the corresponding ID (tcc.userId / tcc.orgId) to also be set. Names without IDs are dropped.Lifecycle callbacks
TheonRunStart and onRunEnd callbacks give you fine-grained control over each agent run. These are only available with manual registration.
onRunStart
Called at the start of each agent run, before any LLM calls. Use it to set per-run metadata, override the run ID, or customize the session ID.
extensions/tcc-observability/index.ts
onRunEnd
Called when an agent run completes. Use it to capture the run ID for feedback, log results, or trigger downstream actions.
extensions/tcc-observability/index.ts
Configuration
| Option | Environment variable | Default | Description |
|---|---|---|---|
apiKey | TCC_API_KEY | — | Your Context Company API key |
debug | TCC_DEBUG | false | Enable debug logging |
sessionId | — | ctx.sessionKey | Session ID for grouping runs |
metadata | — | {} | Key-value metadata attached to every run |
runId | — | Auto-generated UUID | Explicit run ID (first run only) |
onRunStart | — | — | Callback at run start (manual registration only) |
onRunEnd | — | — | Callback at run end (manual registration only) |
Debug mode
You can enable debug mode to log hook events and transport details to the console.- Plugin config
- Manual registration
- Environment variable
openclaw.json
