Skip to main content

JSON Event Stream Mode

Outputs all session events as JSON lines to stdout. Useful for integrating Atomic into other tools or custom UIs.

Event Types

Events are defined in AgentSessionEvent:
queue_update emits the full pending steering and follow-up queues whenever they change. session_info_changed, model_changed, thinking_level_changed, and context_window_changed report interactive session metadata changes. context_window_changed carries the active token budget after AgentSession.setContextWindow() or branch navigation replay applies a branch-scoped context_window_change; branch replay does not add another session journal entry or write settings. compaction_start and compaction_end cover manual and automatic verbatim line compaction: the model emits deleted ranges and Atomic mechanically reconstructs retained text. For automatic compaction, compaction_end.willRetry === true means the agent is retrying the interrupted turn after compaction; AgentSession.prompt() waits for that continuation before resolving. This includes overflow recovery and live threshold compaction for retry-worthy interrupted work such as output-token truncation or OpenAI Responses output-budget underflow errors. Generic provider invalid_request_body failures still compact with willRetry: false when threshold compaction is warranted. If the same-model compact-and-retry overflow path is exhausted, compaction_end includes unresolvedOverflow: true plus an errorMessage so orchestration layers can fall back to another model instead of treating the prompt as successful. Compaction planning and branch summaries reuse the configured retry policy for transient provider failures. Their summarization_retry_* events expose scheduling, each restarted request (including whether it belongs to branch summarization or a compaction reason), and retry-loop completion to JSON, RPC, SDK, and interactive consumers. Base events come from AgentEvent in @earendil-works/pi-agent-core (installed as an Atomic dependency):

Message Types

Base messages come from @earendil-works/pi-ai (installed as an Atomic dependency):
  • UserMessage
  • AssistantMessage
  • ToolResultMessage
Extended messages from packages/coding-agent/src/core/messages.ts:
  • BashExecutionMessage
  • CustomMessage
  • BranchSummaryMessage

Output Format

Each line is a JSON object. The first line is the session header:
Followed by events as they occur:

Example