Stream the agent's output as it works

print mode & automation

// what it does

--output-format stream-json emits newline-delimited JSON, one line per assistant message plus a terminal result event; a system/init line comes first with the session id and model. Add --stream-partial-output for character-level deltas as they generate. With partial output, only assistant events that have timestamp_ms and no model_call_id carry new text — the others are duplicate flushes to skip.

// shell

$ cursor-agent -p "add tests for utils.ts" --output-format stream-json
$ cursor-agent -p "add tests for utils.ts" --output-format stream-json --stream-partial-output

// gotcha

On failure the stream can end early with no terminal result event, so consumers must handle an abrupt stop and a non-zero exit rather than waiting forever for the final line.

// resources