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.sqlite3 on your PATH to include SQLite-backed agent stores.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.span share. Authentication explains personal login and automation credentials.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.123span login span share --list --json span share --session <SESSION_UUID> --json
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.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.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.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.12345# 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
span remove hooks. For a single existing session, use span share --source-path FILE --reasoning-summaries.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.12git log --notes=halfspan git push origin refs/notes/halfspan
span setup to install agent hooks, skills, and the Git hook together. Run span remove git to remove the Git integration.generateText or streamText. Use the same session UUID for steps that belong together. Set the two ingest variables in the server environment.123456789import { 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 });
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.includeResponses: true when creating a Vercel AI trace to record its visible reply text.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.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.summaryForStep: step => step.reasoningText to the run options. The default projection excludes prompts, model output, tool arguments, results and reasoning text.123const onStepEnd = createVercelAITrace(run, batch => { console.log(JSON.stringify(batch)); });
12bun run agent.ts | span hook capture vercel-ai-sdk span traces --agent vercel-ai-sdk
~/.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.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.', });
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', });
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.1234567891011import { 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, });
capture: 'omitted' or capture: 'references' when sharing identifiers only.12345678import { 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);
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.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.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.1234await record({ id: 'loss-1', sequence: 2, at: new Date('2026-11-25T15:00:02Z'), kind: 'coverage_loss', reason: 'queue_overflow', count: 3, });
123456await 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.', });
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.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.Mission SDK helpers and the mission wire field continue to work.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.123456import { sendAgentTraceRecord, type AgentTraceRecord } from '@halfspan/sdk'; await sendAgentTraceRecord({ apiUrl: process.env.HALFSPAN_API_URL!, ingestToken: process.env.HALFSPAN_INGEST_TOKEN!, }, record as AgentTraceRecord);
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.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.1span hook ingest < batches.ndjson