Skip to main content
praisonai run --output stream-json emits a per-step NDJSON event stream for CI pipelines, scripts, and observability tools.
The user runs the CLI with stream-json output; each agent step emits a versioned NDJSON line for scripts and CI.

Quick Start

1

Run with stream-json output

Each line of stdout is one JSON event object. The stream ends when the run completes.
2

Filter events with jq

Use jq to watch only the events that matter to your pipeline.
3

Process events in Python


How It Works

Each run wires a StreamEventBridge between the agent’s internal StreamEventEmitter and the OutputController. Every agent action — tool calls, text deltas, errors — becomes an NDJSON line on stdout. Run-level lifecycle events (run.start, agent.message, run.result, run.error) are driven directly by the CLI. Per-step events (tool.*, text.delta, reasoning.delta) come through the StreamEventBridge callback.

Event Schema (schema_version = 1)

Every NDJSON line is a JSON object with event and data keys. Every data object contains schema_version: 1.

Example NDJSON output


Examples per Event Type

Emitted once at the start of every run. Contains the target prompt, model, and framework.
Emitted once per agent invocation, immediately before the agent starts processing.
Emitted each time the agent calls a tool. args contains the tool’s input arguments.
Emitted when a tool returns. ok is true unless the tool reported an error.
Streaming text chunks from the model. reasoning.delta is used when is_reasoning=True.
Emitted once when the run completes successfully. result is the agent’s final output.
Emitted when a run-level, streaming, or transport failure occurs. Also emitted for core error events.

Stability and Versioning

Every event’s data object includes schema_version: 1. This version is bumped only on backward-incompatible schema changes.
Pin your consumer against schema_version: 1. Future backward-incompatible changes will increment this value so you can detect and handle them gracefully.

When to Use Which Output Mode


Common Patterns

Filter for specific events with jq

Watch only tool calls and the final result:

Detect run.error in CI

Exit with a non-zero code if the run fails:

Build a progress UI fed by text.delta

Concatenate text.delta chunks to show a live streamed response:

Best Practices

Before processing events, verify data.schema_version == 1. This guards your consumer against future breaking changes.
A run.error event means the run failed. Check ok == false and surface the error field to your observability system.
In text, json, silent, and verbose modes the bridge is a no-op — zero per-step callback overhead. Only enable stream-json when a downstream consumer actually reads the events.
Concatenating text.delta chunks is useful for live display, but run.result.data.result is the single authoritative final output string. Prefer it when you only need the end result.

CLI Run

CLI run reference and output modes

CLI Backend Protocol

Backend protocol for custom CLI integrations