@halfspan/sdk and create a workspace API key with traces:write. Set HALFSPAN_API_KEY in your server environment, then call the hook when your tool reports a failure:1bun add @halfspan/sdk
import { createAgentTraceHook } from '@halfspan/sdk'; const onTrace = createAgentTraceHook({ apiUrl: 'https://app.halfspan.com', ingestToken: process.env.HALFSPAN_API_KEY!, }); const session = crypto.randomUUID(); // Keep this UUID for the whole run. const failure = { session, segment: 'coding' as const, task: 'verify-change', attempt: '1', id: crypto.randomUUID(), at: new Date(), kind: 'tool_receipt' as const, operation: 'required_checks', reference: 'verification-run-1', state: 'failed' as const, }; await onTrace(failure);
POST /v1/agent-events. After ingestion, this event appears as a Tool failure: required_checks issue. Reuse the original event ID, timestamp, and payload when retrying an upload; assign a new event ID to a new occurrence. Replaying an identical event does not add another occurrence.required_checks for the kind of work and a call-specific reference for its execution. Keep credentials and confidential content out of both fields. See the event ingestion guide for batch limits and the wire format.12span login bun run agent.ts | span hook ingest
agentTraceBatch(event) to produce each line, as shown in Agent services and signals. Keep other application output on stderr.| Recorded event | Required condition | Issue category |
tool_receipt | state: 'failed' | Tool failure |
resume | failed: true | Failed resume |
outcome | result: 'failed' | Failed outcome |
retry | Every recorded retry | Repeated attempt |
application_log | severity: 'error' | Application error |
user_feedback | value: 'negative' | Negative feedback |
previousAttempt and targetEventId; JSON batches use previous_attempt and target_event_id. The SDK examples and event contracts cover required fields for each event.123span login span share --list --json span share --session <SESSION_UUID>
span setup hooks --agent claude-code. Sharing uploads the events the adapter can extract; it does not guarantee that every error in a transcript becomes a structured failure.is_error: true into failed tool receipts. The Codex transcript importer currently records tool calls but does not convert their outputs into failure receipts. A failed command in a shared Codex transcript therefore does not automatically create a tool-failure issue. Send a structured failure from your runtime or CI through the SDK or ingestion endpoint when you need that signal. Enabling prompt, reply, or summary capture does not fill this gap.operation, the application log's code, or the negative feedback's dimension; other categories have no target. Different sessions can contribute occurrences to the same issue.unassigned and unspecified. See swarm envelopes to attach those fields.openssl rand -base64 32. Set HALFSPAN_NOTIFICATION_KEY to the same value on the API and halfspan-api monitor-worker replicas so each can decrypt saved destinations. Run the telemetry migrations and apply the runtime grants in infra/observability/local-role.sql or the hosted role script.OPENROUTER_API_KEY and HALFSPAN_SIGNAL_MODEL on halfspan-api signal-worker. Each workspace has a per-minute call limit, daily evaluation budgets and optional overrides for daily token and spend reservations through HALFSPAN_SIGNAL_DAILY_TOKENS and HALFSPAN_SIGNAL_DAILY_USD_MICROS. The preview shows unavailable results when a provider or quota prevents evaluation.HALFSPAN_SLACK_CLIENT_ID, HALFSPAN_SLACK_CLIENT_SECRET and HALFSPAN_SLACK_REDIRECT_URI on the API and register the matching redirect URI ending in /v1/integrations/slack/oauth/callback in your Slack app.