The Cursor Agent CLI provides multiple output formats with the --output-format option when combined with --print. These formats include structured formats for programmatic use (json, stream-json) and a simplified text format for human-readable progress tracking.
The default --output-format is stream-json. This option is only valid when printing (--print) or when print mode is inferred (non-TTY stdout or piped stdin).

JSON format

The json output format emits a single JSON object (followed by a newline) when the run completes successfully. Deltas and tool events are not emitted; text is aggregated into the final result. On failure, the process exits with a non-zero code and writes an error message to stderr. No well-formed JSON object is emitted in failure cases.

Success response

When successful, the CLI outputs a JSON object with the following structure:
{
  "type": "result",
  "subtype": "success",
  "is_error": false,
  "duration_ms": 1234,
  "duration_api_ms": 1234,
  "result": "<full assistant text>",
  "session_id": "<uuid>",
  "request_id": "<optional request id>"
}
FieldDescription
typeAlways "result" for terminal results
subtypeAlways "success" for successful completions
is_errorAlways false for successful responses
duration_msTotal execution time in milliseconds
duration_api_msAPI request time in milliseconds (currently equal to duration_ms)
resultComplete assistant response text (concatenation of all text deltas)
session_idUnique session identifier
request_idOptional request identifier (may be omitted)

Stream JSON format

The stream-json output format emits newline-delimited JSON (NDJSON). Each line contains a single JSON object representing a real-time event during execution. The stream ends with a terminal result event on success. On failure, the process exits with a non-zero code and the stream may end early without a terminal event; an error message is written to stderr.

Event types

System initialization

Emitted once at the beginning of each session:
{
  "type": "system",
  "subtype": "init",
  "apiKeySource": "env|flag|login",
  "cwd": "/absolute/path",
  "session_id": "<uuid>",
  "model": "<model display name>",
  "permissionMode": "default"
}
Future fields like tools and mcp_servers may be added to this event.

User message

Contains the user’s input prompt:
{
  "type": "user",
  "message": {
    "role": "user",
    "content": [{ "type": "text", "text": "<prompt>" }]
  },
  "session_id": "<uuid>"
}

Assistant text delta

Emitted multiple times as the assistant generates its response. These events contain incremental text chunks:
{
  "type": "assistant",
  "message": {
    "role": "assistant",
    "content": [{ "type": "text", "text": "<delta chunk>" }]
  },
  "session_id": "<uuid>"
}
Concatenate all message.content[].text values in order to reconstruct the complete assistant response.

Tool call events

Tool calls are tracked with start and completion events: Tool call started:
{
  "type": "tool_call",
  "subtype": "started",
  "call_id": "<string id>",
  "tool_call": "<json>",
  "session_id": "<uuid>"
}
Tool call completed:
{
  "type": "tool_call",
  "subtype": "completed",
  "call_id": "<string id>",
  "tool_call": "<json>",
  "session_id": "<uuid>"
}

Terminal result

The final event emitted on successful completion:
{
  "type": "result",
  "subtype": "success",
  "duration_ms": 1234,
  "duration_api_ms": 1234,
  "is_error": false,
  "result": "<full assistant text>",
  "session_id": "<uuid>",
  "request_id": "<optional request id>"
}

Example sequence

Here’s a representative NDJSON sequence showing the typical flow of events:
{"type":"system","subtype":"init","apiKeySource":"login","cwd":"/path","session_id":"...","model":"Claude <ver>","permissionMode":"default"}
{"type":"user","message":{"role":"user","content":[{"type":"text","text":"Explain X"}]},"session_id":"..."}
{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"Sure, "}]},"session_id":"..."}
{"type":"assistant","message":{"role":"assistant","content":[{"type":"text","text":"here are the details..."}]},"session_id":"..."}
{"type":"tool_call","subtype":"started","call_id":"abc","tool_call":{...},"session_id":"..."}
{"type":"tool_call","subtype":"completed","call_id":"abc","tool_call":{...},"session_id":"..."}
{"type":"result","subtype":"success","duration_ms":1234,"duration_api_ms":1234,"is_error":false,"result":"Sure, here are the details...","session_id":"...","request_id":"..."}

Text format

The text output format provides a simplified, human-readable stream of agent actions. Instead of detailed JSON events, it outputs concise text descriptions of what the agent is doing in real-time. This format is useful for monitoring agent progress without the overhead of parsing structured data, making it ideal for logging, debugging, or simple progress tracking.

Example output

Read file
Edited file
Ran terminal command
Created new file
Each action appears on a new line as the agent performs it, providing immediate feedback on the agent’s progress through the task.

Implementation notes

  • Each event is emitted as a single line terminated by \n
  • thinking events are suppressed in print mode and will not appear in either output format
  • Field additions may occur over time in a backward-compatible way (consumers should ignore unknown fields)
  • The stream format provides real-time updates, while the JSON format waits for completion before outputting results