Comma Agents
@comma-agents/daemonProtocol

Strategy Observation

Per-step execution events — step lifecycle, agent output, and streaming.

During strategy execution, the daemon emits fine-grained events for each step. These are broadcast to all clients subscribed to the run.

Step Lifecycle

Event: step_started

Sent when a flow step begins execution.

{
  "type": "step_started",
  "runId": "run_abc123",
  "stepName": "analyzer",
  "message": "Review this function: function add(a, b) { return a + b; }",
  "ts": "2025-01-15T10:30:01.000Z"
}
FieldTypeDescription
type"step_started"Message type discriminator
runIdstringThe run this step belongs to
stepNamestringName of the step (agent or nested flow)
messagestringThe input message being passed to this step
requestIdstring?Echoed from the originating start_run
tsstringISO-8601 timestamp

Event: step_completed

Sent when a flow step finishes execution.

{
  "type": "step_completed",
  "runId": "run_abc123",
  "stepName": "analyzer",
  "result": {
    "text": "Found 3 issues: ...",
    "usage": { "promptTokens": 50, "completionTokens": 30 },
    "finishReason": "stop"
  },
  "ts": "2025-01-15T10:30:02.000Z"
}
FieldTypeDescription
type"step_completed"Message type discriminator
runIdstringThe run this step belongs to
stepNamestringName of the step that completed
resultAgentCallResultWireThe step's result (text, usage, finish reason)
requestIdstring?Echoed from the originating start_run
tsstringISO-8601 timestamp

Agent Output

Event: agent_output

Sent when an agent produces its final output. This is the non-streaming counterpart — one event per agent call with the complete text.

{
  "type": "agent_output",
  "runId": "run_abc123",
  "agentName": "analyzer",
  "text": "Found 3 issues: ...",
  "usage": { "promptTokens": 50, "completionTokens": 30 },
  "ts": "2025-01-15T10:30:02.000Z"
}
FieldTypeDescription
type"agent_output"Message type discriminator
runIdstringThe run this output belongs to
agentNamestringName of the agent that produced the output
textstringThe agent's final text response
usageUsageToken usage for this agent call
requestIdstring?Echoed from the originating start_run
tsstringISO-8601 timestamp

Agent Streaming

Event: agent_streaming

Sent for each streaming event as an agent generates output. The event field is a discriminated union on type.

{
  "type": "agent_streaming",
  "runId": "run_abc123",
  "agentName": "analyzer",
  "event": { "type": "text", "text": "Found " },
  "ts": "2025-01-15T10:30:01.500Z"
}
FieldTypeDescription
type"agent_streaming"Message type discriminator
runIdstringThe run this stream belongs to
agentNamestringName of the streaming agent
eventAgentStreamEventWireThe stream event
requestIdstring?Echoed from the originating start_run
tsstringISO-8601 timestamp

Stream Event Types

The event field contains one of these discriminated variants:

text

A chunk of generated text.

{ "type": "text", "text": "Found 3 issues" }
FieldTypeDescription
type"text"Event discriminator
textstringThe text chunk

tool-call

The agent is invoking a tool.

{ "type": "tool-call", "toolName": "read_file", "args": "{\"path\":\"/src/index.ts\"}" }
FieldTypeDescription
type"tool-call"Event discriminator
toolNamestringName of the tool being called
argsstringJSON-encoded tool arguments

tool-result

A tool returned its result.

{ "type": "tool-result", "toolName": "read_file", "output": "import { createAgent } from ..." }
FieldTypeDescription
type"tool-result"Event discriminator
toolNamestringName of the tool that returned
outputstringThe tool's output

step-start

A new model step has begun within a multi-step agent call (e.g., after a tool result triggers another model call).

{ "type": "step-start" }
FieldTypeDescription
type"step-start"Event discriminator

done

The agent has finished generating. Contains the complete result.

{
  "type": "done",
  "result": {
    "text": "Found 3 issues: ...",
    "usage": { "promptTokens": 50, "completionTokens": 30 },
    "finishReason": "stop"
  }
}
FieldTypeDescription
type"done"Event discriminator
resultAgentCallResultWireThe complete agent result

On this page