traces:write. The native reference includes request fields, examples, responses, and errors.| Field | Contract |
version | 1 for session events or 2 for swarm events. |
session | Required; UUID. Reuse it for subsequent batches in the same session. |
segment | Required; coding, managed, or business. Cannot change within a session. |
title | Optional; up to 4,096 UTF-8 bytes, without NUL. Whitespace is trimmed. A nonempty title updates the session title. |
events | Required; 1–256 events. |
id, task, attempt, at, and observation. Identifiers contain 1–128 characters from a-z, A-Z, 0-9, ., _, :, @, /, and -. at is an RFC 3339 timestamp, with optional fractional seconds, normalized to UTC on ingestion. Unknown batch, event, and observation fields are rejected.409.context to {userId, conversationId}. These are application identifiers, scoped to a workspace project; each accepts 1–256 UTF-8 bytes without control characters. Keep the technical session UUID separate. Reuse the same context across turns, retries, subagents and asynchronous follow-ups, including when they use different technical sessions. A conversation can include several customer users. Events without identity remain anonymous.createVercelAITrace options. For example, an application boundary can record a response and then submit feedback to an existing boolean rubric:import { Effect } from 'effect'; import { createAgentTraceHook, recordQualityScore } from '@halfspan/sdk'; const project = process.env.HALFSPAN_PROJECT_ID!; const context = { userId: 'customer-42', conversationId: 'support-2026-42' }; const emit = createAgentTraceHook({ apiUrl: process.env.HALFSPAN_URL!, ingestToken: process.env.HALFSPAN_API_KEY!, projectId: project, }); await emit({ session: '30000000-0000-4000-8000-000000000001', segment: 'managed', task: 'support', attempt: '1', id: 'answer-1', at: new Date(), context, kind: 'agent_response', text: 'Your reviewed response', }); await Effect.runPromise(recordQualityScore({ baseUrl: process.env.HALFSPAN_URL!, apiKey: process.env.HALFSPAN_API_KEY!, project, }, { definitionId: process.env.HALFSPAN_FEEDBACK_RUBRIC_ID!, definitionVersion: 1, target: { conversationId: context.conversationId }, value: true, source: 'runtime', evaluatorId: 'support-feedback-v1', idempotencyKey: 'feedback-support-2026-42-1', expectedVersion: 0, }));
GET /api/v1/observability/agent-sessions/{session}/customer-context?workspaceProject={project}. Omitted content and unpriced usage remain explicit. Conversation snapshots have an explicit cutoff; later arrivals remain in the live conversation and require a new snapshot. Source unsharing, expiry and forgetting revoke derived evidence access.Prefer: respond-async to POST /v1/agent-events or POST /v1/agent-lifecycle-events. HTTP 202 means that the replicated stream accepted the validated batch. The JSON body contains a receipt UUID and the Location header gives its status URL.GET /v1/agent-event-receipts/{receipt} with the same publishing identity. A completed lookup returns HTTP 200 with receipt, the batch's terminal status, and its result. A batch with conflicting event content has terminal status 409. A 404 lookup can mean the batch is still pending, the receipt has expired, or the publishing identity differs. Back off between polls. Completed receipts are retained for 30 days by the retention job. Wait for terminal success before uploading dependent artifacts or retiring a producer outbox entry. On HTTP 503 or a lost response, retry with the original event IDs and payload.swarm with a UUID id, project and environment. Optional fields are title (up to 512 UTF-8 bytes) and budget_usd_micros. Each event includes coordination with agent, producer and a nonnegative integer sequence. Keep that sequence unique within the producer's swarm. Optional links reference up to 32 predecessor events by kind, session and event. Set wait_for_end on a link when the consumer had to wait for the predecessor to finish. Agent instances can share from separate sessions while sharing the swarm UUID. Older sharers may use mission as the envelope field. Supplying both fields is rejected. The lifecycle kinds swarm_started and swarm_outcome share event identity and semantics with their original mission_started and mission_outcome spellings.end_at in coordination. To link to a distributed trace, include both trace_id (32 hexadecimal digits) and span_id (16 hexadecimal digits). Swarm events support session observations and coordination evidence such as artifact_produced, artifact_consumed, handoff_sent, handoff_received and swarm_outcome. See SDK swarm propagation for a complete example.HALFSPAN_MISSION_EVENTS_PER_MINUTE to bound swarm ingestion for each tenant. The default is 600,000 events per minute. Retain unconfirmed events in the producer outbox and retry after backpressure.artifact_produced requires artifact, version and a lowercase SHA-256 digest. An optional object_ref carries an opaque object identifier scoped by the sharer. Its optional capture is references, redacted or omitted. Only an explicitly redacted artifact can include a text preview, limited to 2,048 UTF-8 bytes. Redact it before export. The API also scrubs common credential strings in previews during ingest.capture: "redacted", then send POST /v1/agent-artifacts?session=SESSION_UUID&event=EVENT_ID with the same sharer credential. Send a JSON object containing capture set to "redacted" and content set to the standard base64 encoding of up to 128 KiB. The server checks the SHA-256 digest against the event and rejects recognizable credentials. A successful response includes digest and bytes. Retrying the same upload is safe. Managed content requires a configured object archive. The authenticated dashboard accepts the same request at /api/v1/observability/agent-artifacts.GET /api/v1/observability/swarms/SWARM_UUID/artifact?session=SESSION_UUID&event=EVENT_ID returns the retained content in standard base64 with its digest and byte count. Machine readers use a key with traces:read. SDK upload and verified read examplehandoff_sent, handoff_received and handoff_consumed require a correlation ID, sender and recipient. Use the optional context to identify a context manifest. Each sharer can declare its own capture policy for the handoff and attach a redacted body.observation:| Kind | Fields after kind |
span | span, tool: identifiers; parent: "root", "unknown", or {"span":"parent-id"}. Omitted parent becomes "unknown". |
usage | input_tokens, output_tokens: nonnegative integers; usd_micros: nonnegative integer or null (also nullable when omitted). Cost is in millionths of a US dollar. |
application_log | code: identifier; severity: info, warning, or error. Optional fields include capture, body, severity_number (0–24), severity_text (up to 64 ASCII characters) and route (an instrumented route template, up to 256 characters). |
user_prompt, agent_response | text: nonblank string, up to 32,768 UTF-8 bytes, without NUL. |
reasoning_summary | text: nonblank string, up to 4,096 UTF-8 bytes, without NUL. |
context | key: repository, worktree, model, harness, instructions, ci, or owner; value: identifier. |
retry | previous_attempt: identifier. |
tool_receipt | operation, reference: identifiers; state: pending, settled, or failed. |
outcome | result: failed, or the segment's success value below; receipt: identifier. |
attempt_started, approval_waiting, compaction | No additional fields. |
capture accepts references, omitted or redacted. Only an event with capture: "redacted" can include body, a string of up to 4,096 UTF-8 bytes without NUL. Redact the message before sending it. Ingestion also scrubs recognizable credentials before committing the event. Leaving out the policy records no capture decision.required_checks_passed for coding, customer_resolved for managed, and deliverable_accepted for business. See code attribution for the code_attribution observation.POST /api/v1/observability/agent-sessions and POST /api/v1/cli/agent-events, with traces:write. The CLI route additionally supports resharing.POST /v1/traces, POST /v1/logs, and POST /v1/metrics accept OTLP JSON or protobuf and optional gzip compression. Use a bearer key with traces:write. Each request is limited to 262,144 bytes before and after decompression. Successful exports return HTTP 200 with an empty export response in the request encoding. Failures return a google.rpc.Status message. A configured native gRPC listener accepts the corresponding Collector Export services with the same bearer credential."source":"metrics" to inspect metric data directly.halfspan.otlp.v1. A resource may specify halfspan.session.id (UUID), halfspan.segment, halfspan.task.id and halfspan.attempt.id as string attributes. When a session ID is absent, the importer derives a stable session UUID from the record's trace ID. The default segment is managed; missing task and attempt IDs are unknown.halfspan.producer.sequence to each span or log record. Use the same source IDs and sequence on retry. A single record can produce separate tool, usage and span observations. The importer namespaces their producer IDs by observation kind to preserve the original sequence. An imported swarm record carries its source event ID or trace/span pair in coordination.source_id.| Resource attribute | Value |
halfspan.swarm.id | Swarm UUID (older sharers can supply halfspan.mission.id instead) |
halfspan.project, halfspan.environment | Project and environment identifiers |
halfspan.agent.id, halfspan.producer.id | Running agent and source stream identifiers |
traceId, a nonzero 16-digit hexadecimal spanId, and startTimeUnixNano. Instrumented tool spans can supply gen_ai.tool.name. Model spans can supply both gen_ai.usage.input_tokens and gen_ai.usage.output_tokens, with an optional halfspan.cost.usd_micros. The importer preserves available end times, parent span IDs and up to 32 OTLP span links. Use swarm coordination events to record actual delegation, message delivery and artifact consumption. A corrected link identifies the replaced record. Its replacement must carry the same kind, producer and task and a higher producer sequence. Both records remain available for review.timeUnixNano and a session or trace ID. Set string attributes halfspan.event.id and halfspan.log.code for a stable source event identity and a searchable code. Without an event ID, the importer hashes the record. The default code is otel.log. Severity numbers from 13 through 16 map to warning, and 17 or higher maps to error. Other values map to info. By default the importer retains the code and coarse severity and omits the body.halfspan.log.capture on a resource to choose a default capture policy or on a log record to override it. With an explicit policy, ingestion preserves the OTLP severityNumber (0–24), severityText and http.route when supplied. Supply a route template such as /reviews/{id}. For redacted, send the already-redacted text in body.stringValue. An absent or nontext body records capture: "omitted". The references and omitted policies retain metadata only.