Agent-readable docs index: /llms.txt. Full docs in one file: /llms-full.txt. Download /docs.zip to grep all markdown files locally.

Agent services and signals

Instrument the server-side runtime that runs your agent. Use one session UUID per run and stable event IDs when replaying a failed upload. The overview links each event and signal back to its source trace.

Start with metadata

The examples on this page send event codes, identifiers, timestamps, and statuses. They exclude prompts, agent replies, reasoning text, tool arguments, and results. Keep confidential content out of identifiers and event codes as well.
The activity API returns an explicit metadata projection. Recorded text events appear by type, without their text. Searches cover metadata rather than message content. Workspace reads use organization-scoped authorization and database row-level security.
Text capture is a separate, explicit choice in the SDK and CLI. Metadata-only capture is data minimization; it does not make a claim of end-to-end encryption.

Emit service events

bun add @halfspan/sdk
Write event batches as NDJSON from your server process. Give each run its own session UUID. Reuse the run's session, task, and attempt across related events.
import { agentTraceBatch, type AgentTraceEvent } from '@halfspan/sdk'; const run = { session: crypto.randomUUID(), segment: 'managed' as const, task: 'task-id', attempt: 'a1', }; const emit = (event: AgentTraceEvent) => process.stdout.write(JSON.stringify(agentTraceBatch(event)) + '\n'); emit({ ...run, id: crypto.randomUUID(), at: new Date(), kind: 'application_log', code: 'agent.task.started', severity: 'info', });
The log projection accepts a code and a severity of info, warning, or error. It does not forward a freeform log message. Write other application output to stderr to keep stdout suitable for the sidecar.

Forward through Span

span login bun run agent.ts | span hook ingest
The sidecar uses your saved CLI session and shares as your WorkOS user in the connected organization. No manually configured ingest token is needed for this path. CLI sessions expire after 30 days; use span auth status to check the connection.
For unattended deployments, use createAgentTraceHook({ apiUrl, ingestToken }) with a workspace service credential in the server environment. The same events can be passed to that callback instead of writing NDJSON. See the CLI reference for credential configuration and SDK harness integration for direct HTTP ingestion.

Report signals

Monitoring shows event volume and operational signals for the selected period. Signals separates explicit feedback from inferred behavior assessments, with polarity trends, feedback dimensions (including intent match), signal definitions, and evaluator availability. Expand exact counts beneath a chart to inspect its UTC buckets. Use the evidence filters and Inspect signal to review linked source events and annotations.
Trend totals cover the full selected period, independently of the latest 100 matching evidence events. Dimension and evaluator breakdowns show up to 200 groups and identify partial coverage when truncated. Counts describe recorded events, including repeated feedback on the same target. Missing assessments remain unknown; feedback polarity does not establish emotional state or task success.
Supported failures, retries, and negative feedback also create grouped entries on the Issues page. Follow Report and investigate issues for a complete failure example, grouping rules, severity review, and coding-agent capture limits.
SignalEvent
Tool Failurestool_receipt with state: 'failed'
Application Errorsapplication_log with severity: 'error'
Failed Outcomesoutcome with result: 'failed'
Retriesretry
Human Approvalsapproval_waiting
Reported Outcomesoutcome with required_checks_passed for coding agents or customer_resolved for managed agents
Emit a failure when the tool reports it, with a reference that identifies the call. Report a positive outcome only after the corresponding result is confirmed.
emit({ ...run, id: crypto.randomUUID(), at: new Date(), kind: 'tool_receipt', operation: 'lookup', reference: 'call-id', state: 'failed', }); emit({ ...run, id: crypto.randomUUID(), at: new Date(), kind: 'outcome', result: 'customer_resolved', receipt: 'resolution-receipt-id', }); emit({ ...run, id: crypto.randomUUID(), at: new Date(), kind: 'retry', previousAttempt: 'a0', }); emit({ ...run, id: crypto.randomUUID(), at: new Date(), kind: 'approval_waiting', });
Use required_checks_passed with segment: 'coding', customer_resolved with segment: 'managed', and deliverable_accepted with segment: 'business'. A failed result is valid in every segment. A signal match counts an event, not a unique issue or user.
For behavior that requires reading private content, classify it inside your own agent runtime and emit an appropriate non-sensitive event code. The built-in signals above use structured fields; they do not run a semantic classifier over your conversations. Trace triage labels are generated automatically when an unfiltered trace is opened and the classifier is configured.

Token usage and spend

Open Home → Activity → Token usage and choose a reporting period. The organization total covers usage events in retained workspace traces. Members can see their own shared usage. Owners and admins can also see each trace sharer and usage without a sharer.
Send inputTokens and outputTokens on an SDK usage event. When the provider supplies a cost, include usdMicros in millionths of a US dollar. For a Vercel AI SDK integration, costMicrosForStep(step) can return the reported cost for that step. Omit the cost when it is unavailable. Token counts still appear, and the dashboard shows how many records contributed to a partial spend total.
OTLP span spend has three provenance values. provider_reported preserves the supplied halfspan.cost.usd_micros. estimated_catalog applies the recorded catalog version to text input, cached input, and output tokens with a single rounding step to microdollars. unknown leaves spend empty. The 2026-11-29 catalog covers the published standard text-token rates for GPT-4o mini, GPT-4.1 mini, GPT-4.1, and GPT-5 mini.

Attribute query and prompt signals

Record one query event for each user intent and one response event for each assessed reply. Their wire query and response identifiers equal their event IDs. Link follow-up queries with parentQueryId only when they continue the same task. Record the prompt version used at execution time; changing a template later does not change past exposures.
await onTrace({ ...run, id: 'query-1', at: new Date(), kind: 'query', parentQueryId: null, }); await onTrace({ ...run, id: 'exposure-1', at: new Date(), kind: 'prompt_exposure', queryId: 'query-1', promptId: 'support-answer', promptVersion: 'v2', }); await onTrace({ ...run, id: 'response-1', at: new Date(), kind: 'response', queryId: 'query-1', }); await onTrace({ ...run, id: 'feedback-1', at: new Date(), kind: 'user_feedback', targetEventId: 'response-1', dimension: 'helpfulness', value: 'negative', reasonCode: 'instruction_missed', });
These events carry metadata, not message text. Send referenced events before their dependents, or include them in the same batch. Targets must belong to the same session and task. Reuse the original IDs and timestamps when retrying; changed contents under an existing ID are rejected.
Feedback records what your integration reports. Authenticate the feedback source in your application before forwarding it. A workspace ingest credential does not prove that an end user authored a rating.
Explicit feedback supports helpfulness, correctness, and intent_match, with positive, negative, or neutral values. Inferred behavior uses a versioned behavior_signal with an evidence reference and positive, negative, neutral, or unknown assessment. Keep those sources separate from confirmed task outcomes. Silence is not positive feedback, a repeated query may be a new task, and a safe refusal may be the correct result.
Review a match from the trace analysis. Confirming, dismissing, or correcting it appends a review; the original event remains available. Reviews annotate the original signal and do not rewrite raw counts or automatically change control decisions. Positive and negative evidence may coexist. Review feedback separately from outcome receipts and inspect missing classification and price coverage before comparing releases.

Control the next action

A protected request passes through the configured Guardian policy and request-bound permit checks. Inspect its policy decision, permit, dispatch, and observed HTTP response in the proxy trace. An HTTP response is evidence of transport behavior; use an application receipt to establish the business effect.
An authorized operator can cancel a proxy session from its trace. Cancellation revokes future authorization and queued reviews. It does not undo dispatched requests. Reconcile any uncertain dispatch with the destination before starting another run that could repeat the effect.
User ratings and inferred satisfaction do not expand operation permissions or turn a reported outcome into independently verified success. Roll out each protected operation in observation mode first, verify origin isolation and request mappings, then enable enforcement for the verified scope.

Evaluate behavior in your runtime

The SDK exports builtInSignalDefinitions, evaluateSignalsEffect, and signalEvaluationEvents. Presets describe satisfaction, frustration, corrections, instruction adherence, premature completion, and recovery. Supply your evaluator and provider configuration; Halfspan does not infer satisfaction from keywords or missing feedback.
evaluateSignalsEffect accepts explicit content access, evidence with original event IDs, an evaluator version, concurrency of 1–4, and a timeout up to 30 seconds. The evaluator receives an abort signal and must return an assessment, explanation, and references drawn from the supplied evidence. Unsupported content and failed evaluations return an unavailable result. Your runtime owns durable scheduling, retries, provider spend limits, and the decision to share content.
Convert each result with signalEvaluationEvents({ context, evaluation, idForEvidence }) and pass its events to your trace hook. Supply stable IDs per definition, definition version, evaluator version, subject, and evidence reference; reuse the original observation time on replay. Conversion retains evaluator versions, evaluation status, reason codes, and all evidence references in one assessment event. Unavailable and not-applicable results keep an unknown assessment with distinct statuses; they do not count as assessed targets.
The dashboard exposes raw explicit and inferred assessments with their evidence and append-only reviews. Release comparisons describe observed cohorts; they do not establish causality. A later failed outcome removes a task from successful-task counts, and contradictory outcomes at the same timestamp are inconclusive. The historical ever-observed-success count remains separate.

Pause for signal review

An owner or admin can open a proxy trace, select its linked feedback or behavior events, and choose Pause for signal review. The API reads the stored evidence for that exact tenant and session, captures the current observation and epoch, and records the actor with a signed decision snapshot. It never accepts a client-supplied classifier result as a new permission grant.
A pause revokes outstanding permits and fences queued or running reviews. It requires an active session and current observation; stale decisions fail. Recovery requires explicit clarification through the existing agent integration and a new review. Previously dispatched requests retain their receipts and uncertainty.

Label traces for triage

Set TYPESAFE_API_KEY and HALFSPAN_TRACE_LABEL_MODEL on the API server, then restart it. Choose a versioned Jev model ID from your TypeSafe account. Apply the telemetry migration with just db-migrate and grant the runtime role SELECT, INSERT, DELETE on agent_trace_labels (infra/observability/local-role.sql includes the local grant).
Open an unfiltered agent trace to generate labels automatically. The API sends up to the latest 64 recorded events, bounded to 64 KiB, to TypeSafe when no saved evaluation matches the current evidence and classifier configuration. This can include recorded prompts and responses. Reopening the same trace reuses its saved evaluation. A filtered agent or historical view does not generate labels for the whole session.
The triage-v1 taxonomy asks independently about tool failures, provider failures, user corrections, repeated attempts, incomplete work, and recovery. The trace displays labels with probabilities at or above 0.7 and retains every probability under Label details. This display threshold has not been calibrated against your traffic. No label above the threshold does not establish success or absence of a problem.
Each evaluation stores its taxonomy and model version, input digest, source event IDs, coverage, token usage when available, and elapsed provider time. Source IDs identify the input snapshot; they are not model-selected citations supporting individual labels. Later events do not change that snapshot. Only the latest 20 evaluations are shown. Provider errors and malformed responses produce an unavailable evaluation with no labels. Labeling has a 10-second provider timeout, at most four concurrent requests per API process, and no automatic retry.
Labels are observability annotations. They do not create behavior signals, change signal counts, establish outcomes, or drive permissions, pauses, or routing. Removing or unsharing a trace erases its labels and fences results from in-flight classification. Opening an unfiltered trace creates an evaluation when its evidence or classifier configuration has changed.