Skip to content

Events ​

Events are the common vocabulary for HPD Agent runtime activity. Local subscriptions, committed hosted SSE, TUI runtimes, bot adapters, middleware, and thread history all use related event types.

This page is family-based. It is not an exhaustive generated schema reference.

Event Envelope ​

Hosted SSE uses envelopes produced by the selected application composition's AgentEventCodec:

json
{
  "version": "1.0",
  "type": "TEXT_DELTA",
  "threadSequenceNumber": 43,
  "text": "hello",
  "messageId": "message-id"
}

The envelope includes injected version and type fields. Built-in type names use SCREAMING_SNAKE_CASE. Payload properties are camelCase and null values are omitted.

Unknown or missing type values cannot be deserialized as known events. HTTP input treats invalid event envelopes as bad requests.

The envelope version is strict. HPD Agent 0.9.7 accepts only "version": "1.0" and rejects missing or unsupported versions.

The event catalog exposes a structural contract digest per discriminator. It covers the serialized property shape independently of effective durability. A runtime reads its catalog as runtime.Composition.Events; a hosted runtime serves it at GET /composition/events, which a client checks before decoding events.

Custom event types must be part of the selected generated application composition and must provide AOT-safe JSON metadata. See Application Composition and Custom Events.

For the practical serialization path, see Serialization And Registration.

Durability ​

Durable events are canonical thread facts. They are appended before live dispatch, survive restart, participate in replay, and contribute to the composition compatibility digest.

LiveOnly events are observable runtime activity. They can be streamed, archived by a host, or sent to telemetry, but cannot enter a thread journal. Diagnostics, retries, progress, execution snapshots, skill read/script mechanics, raw content I/O, and explicit runtime-extension live events use this classification.

The distinction is part of the application contract. A sufficiently important live fact needs its own durable event rather than a blanket promotion of a diagnostic event.

Hosts can select overridable event durability through AgentRuntimeBuilder.WithEventDurability<TEvent>(...), WithEventDurability(discriminator, ...), or WithEventDurabilityPolicy(...). This choice is frozen when the runtime is built and applies to every agent it runs. Recovery-critical events marked as required-durable reject a live-only override.

Text and reasoning delta journaling is coalesced above the session-store abstraction. Custom ISessionStore implementations receive one compact delta plus the message boundary rather than one durable record per provider token.

Channels, Direction, And Canonical Publication ​

Event channel and direction help route and render events. Canonical thread scope and publication determine durability.

Common channel meanings:

ChannelTypical use
Streamingtext and reasoning deltas
Interactivepermission, continuation, clarification, and client-tool request/response flows
Controlthread-run lifecycle and interruption handling
Default or inheritedlifecycle, diagnostic, and framework-specific events that do not explicitly set a channel

Response events for permission, continuation, and clarification use upstream direction.

A thread-scoped projectable event published through IAgentEventPublisher is committed before publication and is replayable by definition. Process-local diagnostics, struct events, and stateless output use separate paths.

Correlation And Projection Fields ​

Events arrive as a stream. Clients can project that stream into transcripts, timelines, workflow views, prompt queues, or trace trees by using correlation fields when they are present.

Common fields:

FieldMeaning
sessionId, threadIdDurable runtime scope when present
threadSequenceNumberAuthoritative positive journal position; zero means uncommitted/stateless
eventFlowIdFlow grouping used by thread history and replay; often a message-turn flow for persisted events
traceIdExecution trace id for a message turn
spanId, parentSpanIdSpan-style hierarchy when present
metadataAgent attribution, including agent name, id, parent id, chain, and depth
messageIdText, reasoning, and tool activity under a message
sourceHPD message source for message/text events, such as UserInput, AssistantOutput, BackgroundNotification, or Steering
visibilityHPD transcript visibility for message/text events: Transcript, Hidden, or Diagnostic
persistenceHPD message persistence policy when present on durable message-start events
callIdTool-call lifecycle grouping
invocationIdOne durable parent-to-subagent delegation; not the child agent or thread identity
permissionId, continuationId, requestIdRequest/response grouping through IRequestCorrelatedEvent.RequestId

Do not require every event to have every field. For example, some tool events carry traceId and callId without explicit span fields. Use the most specific available id for the projection you are building. See Event Streams And Hierarchies and Render An Event Stream.

Canonical Event Parity ​

Hosted live delivery and durable replay decode to the same event value from the selected composition. SSE adds id, event, and heartbeat framing; it does not define a second event schema. Stable agent attribution required for projection must be canonical data. Volatile delivery information belongs outside the event payload.

Event Families ​

FamilyExamplesPrimary channelThread persistence
InputUserMessagesInputEvent; hosted routes also accept command bodies and interruption requestsupstream/controlcommand plane
Thread executionThreadExecutionStartedEvent, ThreadExecutionFinishedEventcontrolcanonical in thread scope
Subagent delegationSubAgentInvocationStartedEvent, SubAgentInvocationCompletedEvent, SubAgentInvocationFailedEvent, SubAgentInvocationCancelledEventcontrolcanonical in the parent thread; identifies the durable child scope
Message turn lifecycleMessageTurnStartedEvent, MessageTurnFinishedEvent, MessageTurnErrorEventdefault/controlcanonical in thread scope; client setup failures include structured ClientSetup details
Agent turn lifecycleAgentTurnStartedEvent, AgentTurnFinishedEventdefaultstarted is live-only by default; finished is durable and canonical in thread scope
Text streamingTextMessageStartEvent, TextDeltaEvent, TextMessageEndEventstreamingcanonical in thread scope
Reasoning streamingReasoningMessageStartEvent, ReasoningDeltaEvent, ReasoningMessageEndEventstreamingcanonical in thread scope
Tool callsToolCallStartEvent, ToolCallArgsEvent, ToolCallResultEvent, ToolCallEndEventdefault/streamingcanonical in thread scope
Workflow executionWorkflowStartedEvent, WorkflowAgentStartedEvent, WorkflowEdgeTraversedEvent, WorkflowCompletedEventdefault/diagnosticfollows the workflow publication scope
Agent operationsAgentOperationRegisteredEvent, AgentOperationTransitionedEvent, operation notification eventscontrol/defaultcanonical in thread scope
Interactive middlewarerequest events implementing IAgentRequestEvent<TResponse> and response events implementing IAgentResponseEventinteractivecanonical in thread scope; answerable requests also appear in runtime state
Retry and error policyFunctionRetryEvent, ModelCallRetryEvent, middleware error eventsdiagnostic/defaultfollows publication scope
Compaction observabilityCompactionEventdefault/diagnosticfollows publication scope
Thread-history compactionThreadHistoryCompactionCheckpointEventthread historycanonical checkpoint appended to the journal
Content and referencesupload/reference eventsdefault/diagnosticevent publication and content storage are separate policies
Audio transcriptsUserAudioTranscriptDeltaEvent, UserAudioTranscriptCompletedEvent, UserAudioTranscriptFailedEventstreaming/defaultfollows publication scope; raw audio uses content/audio storage policy
Assistant audio outputassistant audio output, stream, artifact, failure, and playback eventsdefault/diagnosticfollows publication scope
Struct eventsAgentStructEvent samples on StructEventHub routesprocess-local/exportprocess-local sample rail
Planning, schema, structured outputframework diagnostics and state changesdefault/diagnosticfollows publication scope

CompactionEvent reports Started, Skipped, Failed, or Completed, plus its automatic, explicit, or fork origin. The successful semantic change is carried by the checkpoint event.

Agent Operations And Notifications ​

AgentOperation is the unified lifecycle for provider background responses, background tool and subagent invocations, multi-agent workflows, remote MCP tasks, and client-owned background work.

EventMeaning
AgentOperationRegisteredEventThe complete initial operation snapshot was committed.
AgentOperationTransitionedEventA version-checked provider or observation transition was committed.
AgentOperationNotificationQueuedEventA selected transition was queued as hidden model context.
AgentOperationNotificationDeliveredEventQueued operation context reached a model turn.
AgentOperationNotificationSuppressedEventPolicy, deduplication, or integrity checks suppressed delivery.
AgentOperationTombstonedEventRetention compacted a terminal operation snapshot into a lightweight tombstone.

Operation snapshots carry the authoritative OperationId, optional provider operation ID, source kind, name, owning agent/session/thread, originating execution, optional function invocation, provider status, observation status, control surface, completion or failure, protected recovery reference, version, and metadata.

When terminal-operation retention compacts a full snapshot, the tombstone preserves the OperationId and provider deduplication keys needed to reject late transitions and duplicate provider deliveries. The compacted operation is no longer part of active operation projections.

AgentOperationNotificationPolicy controls semantic model delivery:

json
{
  "includeInputRequired": true,
  "includeProgress": false,
  "includeTerminal": true,
  "deduplicationKey": null,
  "minimumInterval": "00:00:05"
}

Terminal notifications are delivered optimally during a matching active turn; otherwise HPD queues them as subsequent work. Delivered operation context uses source: "BackgroundNotification" and visibility: "Hidden" and must not be rendered as an assistant transcript row.

Hosted runtime state exposes operations through activeExecution.operations. Execution projections include operation status, control capabilities, handle ID when present, completion summary, artifact references, failure, timestamps, and metadata.

For registration, invocation modes, and hosted projections, see Agent Operations, Background Work, And Notifications.

Struct Events ​

Struct events are a separate process-local surface for realtime samples. HPD Agent-owned samples implement AgentStructEvent, which is an agent-level marker over the lower HPD Events struct-event contract. They do not inherit from AgentEvent, do not use the application composition's AgentEventCodec, and do not appear in hosted SSE or thread history unless a component explicitly converts or summarizes them as an AgentEvent.

Selected struct events can be exported with AgentStructEventSerializer. That serializer uses a separate envelope from hosted AgentEvent streaming and is for diagnostics, local capture, replay tooling, or telemetry export. Serializing a struct event does not make it visible to the TypeScript client or durable thread history.

Use runtime.SubscribeStruct<TEvent>(...) for local observation. Tools that accept FunctionExecutionContext can access context.StructEvents for the same process-local sample lanes. Use this for high-volume diagnostics such as audio playout samples or queue-depth telemetry, not for semantic workflow facts, permissions, or persisted progress.

Assistant Audio Output Events ​

Assistant audio output events use the same envelope as other AgentEvent values. The event payload includes sessionId when the event has a session scope, plus audio-specific identifiers such as outputFlowId, responseId, segmentId, and provider or playback fields.

Source-generated assistant audio output type names include:

TypePurpose
ASSISTANT_AUDIO_OUTPUT_STARTEDAssistant audio output flow started.
ASSISTANT_AUDIO_OUTPUT_STREAM_STARTEDA synthesized audio stream segment started.
ASSISTANT_AUDIO_OUTPUT_CHUNK_READYAn audio chunk is ready.
ASSISTANT_AUDIO_PUSH_TEXT_STREAM_OPENINGPush-text TTS stream is opening.
ASSISTANT_AUDIO_PUSH_TEXT_STREAM_OPENEDPush-text TTS stream opened.
ASSISTANT_AUDIO_PUSH_TEXT_INPUT_SENTText input was sent to a push-text TTS stream.
ASSISTANT_AUDIO_OUTPUT_STREAM_COMPLETEDAn audio stream segment completed.
ASSISTANT_AUDIO_OUTPUT_ARTIFACT_CAPTUREDAudio output was captured as an artifact.
ASSISTANT_AUDIO_OUTPUT_SEGMENT_FAILEDOne audio segment failed.
ASSISTANT_AUDIO_OUTPUT_COMPLETEDAssistant audio output flow completed.
ASSISTANT_AUDIO_OUTPUT_FAILEDAssistant audio output flow failed.
ASSISTANT_AUDIO_PLAYBACK_QUEUEDAudio playback was queued.
ASSISTANT_AUDIO_PLAYBACK_STARTEDAudio playback started.
ASSISTANT_AUDIO_PLAYBACK_PROGRESSAudio playback progress was reported.
ASSISTANT_AUDIO_PLAYBACK_COMPLETEDAudio playback completed.
ASSISTANT_AUDIO_PLAYBACK_INTERRUPTEDAudio playback was interrupted.
ASSISTANT_AUDIO_PLAYBACK_FAILEDAudio playback failed.

Value round-trip tests cover sessionId, output flow, response, segment, chunk, artifact, error, and playback fields for these event families.

UI Rendering Guidance ​

For text output, render TextMessageStartEvent, append TextDeltaEvent, and close the block on TextMessageEndEvent. Do not infer transcript behavior from role alone. role is provider-facing model protocol; visibility and source are HPD-owned rendering policy. A text stream with visibility: "Hidden" is model/runtime context and should not become a visible transcript row. visibility: "Diagnostic" should render as an internal or diagnostic row when the app chooses to show it.

Common visible transcript cases:

SourceVisibilitySuggested rendering
UserInputTranscriptuser message
AssistantOutputTranscriptassistant message
BackgroundNotificationHiddenno transcript row; the model receives this context
RuntimeContextHiddenno transcript row
SteeringHidden or Diagnostichidden runtime input or explicit diagnostic row

For reasoning output, use the same start/delta/end pattern but render it separately from final user-visible text.

For tool calls, use start/args/result/end events to show activity, arguments, and results. Tool events may arrive interleaved with streaming text depending on the model and middleware.

For interactive middleware, render request events and answer with the matching IAgentResponseEvent through the hosted HTTP /responses route or a RespondInputEvent in a local app. Permission, continuation, clarification, and client-tool responses are coordination events, not ordinary output. See Bidirectional Events.

Request-specific event families should define only the domain request and domain response events. Do not add family-specific terminal lifecycle events such as FooApprovedEvent, FooDeniedEvent, FooResolvedEvent, or FooCancelledEvent; use the generic request lifecycle events for request-session state.

For JavaScript and TypeScript apps, use AgentClient to observe canonical thread events from an applied cursor, handle unknown custom events through onAny(...), and send response events back to the hosted runtime. See TypeScript Client Events.

For retry events, be careful with already-rendered partial output. A ModelCallRetryEvent can arrive after partial model content, so UIs may need to clear or mark stale partial text before rendering retry output.

For lifecycle, retry, and failure rendering, see Lifecycle, Retry, And Error Events.

Use thread-execution start/finish events to project historical hosted work. Use authoritative activeExecution runtime state—not replayed lifecycle events or thread-operation-lock conflicts—to decide whether a thread is currently busy or cancellable.

For subagents, project SUBAGENT_INVOCATION_STARTED and its completed, failed, or cancelled terminal event by invocationId. The started event provides childAgentId, childSessionId, and childThreadId, which are the continuation route. The invocation id correlates one delegation and is not a replacement for the child AgentId or thread id.

For compaction, distinguish lifecycle facts from the projection checkpoint. CompactionEvent records start and terminal status. ThreadHistoryCompactionCheckpointEvent records the compaction point and semantic result. Every compaction appends it while preserving source events, and the history projection applies it.

For workflows, render workflow lifecycle, layer, node, edge, and diagnostic events as a timeline or graph projection. Child agent, tool, and permission events may also appear in the same live stream when the workflow or subagent execution bubbles events through a parent coordinator.

For tool progress emitted from inside a function body, see Tool And Function Events.

Publication Summary ​

Thread-scoped projectable AgentEvent values pass through the canonical publisher:

text
identify -> commit -> assign ThreadSequenceNumber -> publish -> replay

The selected composition's codec preserves the concrete event type and canonical payload across in-process subscribers, hosted observation, and replay. Process-local publication keeps ThreadSequenceNumber == 0 and provides no replay guarantee. High-volume AgentStructEvent values use the separate struct-event rail.

See Canonical And Process-Local Events and Canonical Thread Journal.

Built for production .NET agent applications.