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

Browse and send agent traces

To turn recorded failures into grouped dashboard issues, follow Report and investigate issues. It explains the supported events and which coding-agent failures are captured automatically.
Run span traces to browse local agent sessions and captured Vercel AI SDK sessions across projects. The agent compatibility matrix lists each supported reader, native storage format, and available lifecycle hook. Each row in the browser shows its agent and directory. Use ↑ and ↓ to select a trace, Enter to read it, and Esc to return. Press Tab to switch agents, / to search by title, directory, agent, or session ID, and r to reload. In the timeline, use ↑/↓ or k/j to highlight an entry. Enter folds or unfolds a message or tool group. Select an individual call and press Enter to inspect its recorded input and output. Tab jumps directly to the next call. Shift+Tab or Esc returns to the previous screen.
Manual sharing carries the local session title into the traces table and trace header.
The browser also lists archived sessions and Claude subagents. A History row opens the prompts saved in the agent’s history. Install sqlite3 on your PATH to include SQLite-backed agent stores.
Use span traces --cwd . --json for the current project or span traces --agent opencode for one agent. Piping the list to another command produces plain text.
See the Span CLI reference for all commands, flags, and keyboard shortcuts.
Before sharing, read Privacy and shared data. Content-selection defaults differ between the terminal dialog and span share. Authentication explains personal login and automation credentials.

Share a session

In the browser, select a Codex, Claude Code, or Vercel AI SDK transcript and press s. User prompts, agent replies, and available summaries start on. Press u, a, or s to toggle them before sharing. Review the destination and press Enter to share its reviewed events, or Esc to cancel. After sharing, press c to copy the trace link in terminals that support clipboard access.
Run span login and approve the connection in your browser. Sharing uses your WorkOS user and organization, with no ingest token to configure. Use span auth status to check the connection and span logout to revoke it. Development builds support a local dashboard with just cli login --url DASHBOARD_URL; shared CLI downloads use the production dashboard.
span login span share --list --json span share --session <SESSION_UUID> --json
To share the conversation from a local Codex or Claude Code transcript, run span share --session <uuid> --prompts --agent-responses. Add --reasoning-summaries for available Codex summaries. Full Trace shows the recorded prompts, replies, summaries, tool names and compaction markers. Sharing the same transcript again adds newly selected content to its existing trace.
Use span share --source-path <FILE> to share a specific Claude Code or Codex transcript. With no selector, the CLI uses the current agent session when it can identify it or requires an explicit session ID when several sessions match.
Run span setup skills to install the project-local sharing skill. With span on the agent's PATH, ask Claude Code or Codex to share the current session. Remove the skill with span remove skills.

Capture a coding session

Run span login first. From the project directory, install sharing hooks for session start, prompt submission, and turn completion. The hooks use your saved CLI session to share.
# Send the harness name, tool calls, model identifiers and token counts. span setup hooks # Also send the readable summaries Codex includes in its transcript. span setup hooks --agent codex --reasoning-summaries
Summary sharing runs on the Codex Stop event. Run setup again without the summary flag to return to metadata sharing. Remove the integration with span remove hooks. For a single existing session, use span share --source-path FILE --reasoning-summaries.
Run span setup git in the repository. After a commit, Halfspan writes a Git note and uploads the identified session in the background. It uses the current agent session ID when available or a single recent session in the worktree.
git log --notes=halfspan git push origin refs/notes/halfspan
Run span setup to install agent hooks, skills, and the Git hook together. Run span remove git to remove the Git integration.

Trace a Vercel AI SDK application

Register the Halfspan callback in the server code that calls generateText or streamText. Use the same session UUID for steps that belong together. Set the two ingest variables in the server environment.
import { generateText } from 'ai'; import { createVercelAITrace } from '@halfspan/sdk'; const run = { session: crypto.randomUUID(), segment: 'managed' as const, task: 'invoice', attempt: 'a1' }; const onStepEnd = createVercelAITrace(run, { apiUrl: process.env.HALFSPAN_API_URL!, ingestToken: process.env.HALFSPAN_INGEST_TOKEN!, }); const result = await generateText({ ...options, onStepEnd });
For CLI-assisted setup, run span setup hooks --agent vercel-ai-sdk in the app directory. Import traceVercelRun from the generated .halfspan/vercel-ai-sdk.ts and pass traceVercelRun(run) as the step callback. Use span remove hooks --agent vercel-ai-sdk to remove that generated file.
Set includeResponses: true when creating a Vercel AI trace to record its visible reply text.
Set usagePurposeForStep: step => 'work' when your runtime knows the purpose of each call. Return coordination or compaction for those calls, or undefined when unknown. This attributes the existing provider usage record without creating another charge.
Use your existing model, tools, and prompt for options. AI SDK 6 names the callback onStepFinish. For streaming, consume the stream so the completed-step callback runs. If your app already has a step callback, await both from the same handler. Each completed step records the harness, model identifier when available, tool calls, and reported token totals. In the dashboard, open Traces and select Vercel AI SDK in the agent filter.
Summary capture is opt-in. When the provider is configured to return displayable reasoning summaries, add summaryForStep: step => step.reasoningText to the run options. The default projection excludes prompts, model output, tool arguments, results and reasoning text.
For local capture, pass a batch writer in place of the HTTP destination. This example writes one JSON line per batch to stdout. Send your application's other output to stderr when using the pipe.
const onStepEnd = createVercelAITrace(run, batch => { console.log(JSON.stringify(batch)); });
bun run agent.ts | span hook capture vercel-ai-sdk span traces --agent vercel-ai-sdk
The capture command prints the session UUID after stdin closes. It stores the session under ~/.halfspan/traces/vercel-ai-sdk/ and associates it with the current working directory. To share it later, use span share --agent vercel-ai-sdk --session UUID. Add --reasoning-summaries to include any summaries you captured. Identical events can be replayed using their original IDs and timestamps.

Connect an SDK harness

Create one callback for your harness and invoke it when a tool call or provider-shared reasoning summary is complete. Await the receipt before acknowledging the event. The harness supplies the session UUID, event ID and original timestamp so that it can replay the same event after an interrupted request.
import { createAgentTraceHook } from '@halfspan/sdk'; const onTrace = createAgentTraceHook({ apiUrl: process.env.HALFSPAN_API_URL!, ingestToken: process.env.HALFSPAN_INGEST_TOKEN!, }); const run = { session: '6b2863cf-ce34-405e-af75-27748912d239', segment: 'managed' as const, task: 'invoice-42', attempt: 'attempt-1', }; await onTrace({ ...run, id: 'lookup-1', at: new Date('2026-11-24T15:00:00Z'), kind: 'span', tool: 'lookup_invoice', parent: 'root', }); await onTrace({ ...run, id: 'summary-1', at: new Date('2026-11-24T15:00:01Z'), kind: 'reasoning_summary', text: 'Checked the invoice status before scheduling a reminder.', });
The summary field accepts up to 4096 UTF-8 bytes. Supply only text the provider or harness makes available for display. Tool events carry the tool name and parent span. Prompts, tool arguments, and encrypted reasoning data stay out of the callback payload.

Follow work across agents

Open Swarms in the dashboard and select the run. Under Agents, select an agent and open a session to read its trace. Messages shows each agent’s mailbox and lets you follow a conversation in both directions. Logs shows all retained events across the swarm. Message and log text appear when the producer includes a redacted body.
Diagnostics explains recorded time, usage purpose, evaluation provenance, and delivery receipts. Understand diagnostic coverage.
Use createSwarmTraceHook for explicit coordination events. Copy the swarm, task and attempt into a queued job. Give each consumer its own session UUID, agent instance and producer ID. Keep the producer sequence, event ID and original timestamp with the event so a restarted worker can replay it.
import { createSwarmTraceHook, parseSwarmContext } from '@halfspan/sdk'; const context = parseSwarmContext({ swarm: { id: 'b387220d-b43b-4273-949a-49c8011ea1b3', project: 'checkout', environment: 'staging', title: 'Review checkout patch', }, session: '12a4c28d-2ab4-4d3c-af0d-10dce86846b7', segment: 'coding', task: 'review', attempt: 'review-1', agent: 'reviewer-1', producer: 'review-worker-1', }); const write = { apiUrl: process.env.HALFSPAN_API_URL!, ingestToken: process.env.HALFSPAN_INGEST_TOKEN!, }; const record = createSwarmTraceHook(write, context); // Persist this event in your local outbox before attempting delivery. const input = { id: 'review-input', sequence: 0, at: new Date('2026-11-25T15:00:00Z'), kind: 'artifact_consumed', artifact: 'patch', version: 'v1', expectedVersion: 'v2', links: [{kind: 'consumed', session: 'd18a94fe-93e7-4e93-a24d-27fe7efeefca', event: 'patch-v1'}], } as const; await record(input); const replay = await record(input); // replay.inserted === 0 await record({ id: 'handoff-context', sequence: 1, at: new Date('2026-11-25T15:00:01Z'), kind: 'context_manifest', manifest: 'review-inputs', capture: 'redacted', });
Supply expectedVersion when a recorded requirement identifies the expected input. A causal link references a predecessor by session and event ID. To retain a replayable envelope locally, call swarmEventBatch(context, event). For artifact versions, the default payload contains the ID, version and lowercase SHA-256 digest. To include a bounded preview, explicitly supply already-redacted text. The SDK never reads the artifact file.
import { createHash } from 'node:crypto'; const patch = 'customer_id=customer-42\nstatus=accepted'; const redacted = patch.replace(/^customer_id=.*/m, 'customer_id=[redacted]'); const content = new TextEncoder().encode(redacted); const digest = createHash('sha256').update(content).digest('hex'); await record({ id: 'patch-v2', sequence: 3, at: new Date('2026-11-25T15:00:03Z'), kind: 'artifact_produced', artifact: 'patch', version: 'v2', digest, capture: 'redacted', preview: redacted, });
Artifact previews accept up to 2,048 UTF-8 bytes. Use capture: 'omitted' or capture: 'references' when sharing identifiers only.
To let a reviewer retrieve the complete redacted version, explicitly upload the bytes after the event commits. Compute the event digest over exactly the redacted bytes you intend to upload. Transferring content requires a configured object store. Each upload accepts up to 128 KiB. Retrying with the same bytes and event reference returns the same digest and byte count.
import { uploadSwarmArtifact, readSwarmArtifact } from '@halfspan/sdk'; const ref = { session: context.session, event: 'patch-v2', digest }; await uploadSwarmArtifact(write, { ...ref, capture: 'redacted', content }); const artifact = await readSwarmArtifact({ apiUrl: write.apiUrl, readToken: process.env.HALFSPAN_READ_KEY!, }, { ...ref, swarm: context.swarm.id }); const reviewText = new TextDecoder().decode(artifact.content);
Use a workspace key with traces:read for retrieval. The SDK verifies the length and digest before returning any bytes. Both calls accept an AbortSignal in their options and use a 10-second HTTP deadline.
Vercel AI SDK. Supply the same swarm and agent to createVercelAITrace with the session, segment, task and attempt. Its completed-step callback records model, usage and tool evidence under that swarm. Use linksForStep(step) to attach known dependencies. Swarm step export has a 10-second deadline. Set exportTimeoutMs to an integer from 1 through 30,000 to change it. A custom sink receives (batch, signal) and should cancel its I/O when the signal aborts.
A failed or timed-out step raises SwarmExportError with unconfirmedEvents, the number of events with no receipt. The destination may have committed them. Retry the original step before recording permanent loss. If your queue actually drops events, record the known count with the next durable export.
await record({ id: 'loss-1', sequence: 2, at: new Date('2026-11-25T15:00:02Z'), kind: 'coverage_loss', reason: 'queue_overflow', count: 3, });
To record an application log, pass a stable code and severity. Add a redacted message if your producer has one. The route is the instrumented route template.
await record({ id: 'review-log', sequence: 4, at: new Date('2026-11-25T15:00:04Z'), kind: 'application_log', code: 'review_ready', severity: 'info', severityText: 'INFO', severityNumber: 9, route: '/reviews/{id}', capture: 'redacted', body: 'The patch passed its review checks.', });
MCP. Build outbound metadata and a send event with mcpSwarmHandoff(sender, {id, at, sequence, recipient, correlation}). Pass the returned meta to client.callTool in _meta and share sent when the call is dispatched. In the registered tool callback, call mcpSwarmReceipt(receiver, extra._meta, {id, at, sequence}) with the authenticated receiver's swarm context. It returns a linked receive event for an instrumented call or undefined for an ordinary call. Send the resulting batch with sendAgentTraceBatch. The dispatching and receiving applications independently choose what to record. To attach a message, add capture: 'redacted' and an already-redacted body to the event on that side. The MCP metadata carries correlation and identity fields only.
For a Vercel tool that dispatches work to an agent, configure sentHandoffForToolCall(step, call). Return the actual recipient and correlation ID for dispatched calls and return undefined for other tools. The callback can include the same capture and body fields. Handoffs and application logs accept up to 4,096 UTF-8 bytes per body. Use capture: 'references' for a referenced message or capture: 'omitted' for deliberately withheld text.
Existing Mission SDK helpers and the mission wire field continue to work.

Import Agent Trace code attribution

Halfspan accepts Agent Trace RFC 0.1.0 records independently of session activity. Send the original JSON record to POST /v1/agent-traces with a workspace ingest token and Content-Type: application/vnd.agent-trace.record+json (or application/json). The record ID identifies its coding session. Replaying the same record is idempotent; use a new ID for a new attribution record.
import { sendAgentTraceRecord, type AgentTraceRecord } from '@halfspan/sdk'; await sendAgentTraceRecord({ apiUrl: process.env.HALFSPAN_API_URL!, ingestToken: process.env.HALFSPAN_INGEST_TOKEN!, }, record as AgentTraceRecord);
The SDK sends the record as a code_attribution event through the existing event ingestion endpoint. agentTraceRecordBatch(record) produces the same envelope for span hook ingest. Attribution preserves file paths, revision information, conversation links, line ranges, contributor overrides, content hashes, and vendor metadata. Line positions refer to the recorded revision. Both 0.1 and 0.1.0 version strings are accepted to accommodate the RFC schema and examples. Records must fit the 256 KiB request limit.

Run a sidecar

Start span hook ingest as a child process with piped stdin and stdout. Write one session or swarm JSON batch followed by a newline for each callback. In TypeScript, JSON.stringify(agentTraceBatch(event)) from @halfspan/sdk produces the same wire format. The sidecar uses your saved CLI login session, or service credentials for unattended ingestion. It sends each complete line immediately and prints its line number, session ID, inserted count and total as a JSON receipt. Closing stdin finishes the process. A file can use the same entry point.
span hook ingest < batches.ndjson
The sidecar stops at the first invalid or unconfirmed batch and reports the line on stderr. Replay from that line with the original IDs, timestamps and contents. The ingest API deduplicates identical events within the session.