{"record":{"id":"044c7febdfc32a3b","repo":"warpdotdev/warp","slug":"streaming-commands-require-output-format-ndjson","errorCode":null,"errorMessage":"Streaming commands require `--output-format ndjson`","messagePattern":"Streaming commands require `--output-format ndjson`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/src/ai/agent_sdk/ambient.rs","lineNumber":1030,"sourceCode":"struct MessageWatchEvent {\n    sequence: i64,\n    message_id: String,\n    sender_run_id: String,\n    subject: String,\n    body: String,\n    occurred_at: String,\n}\n\nfn format_optional_timestamp(timestamp: Option<&str>) -> &str {\n    timestamp.unwrap_or(\"-\")\n}\n\nfn ensure_stream_output_format(output_format: OutputFormat) -> anyhow::Result<()> {\n    if output_format == OutputFormat::Ndjson {\n        return Ok(());\n    }\n\n    Err(anyhow!(\n        \"Streaming commands require `--output-format ndjson`\"\n    ))\n}\n\nfn stream_retry_backoff(failures: usize) -> Duration {\n    let index = failures\n        .saturating_sub(1)\n        .min(STREAM_RETRY_BACKOFF_STEPS.len() - 1);\n    Duration::from_secs(STREAM_RETRY_BACKOFF_STEPS[index])\n}\n\nfn write_stream_record<T: Serialize>(record: &T) -> anyhow::Result<()> {\n    let mut stdout = std::io::stdout();\n    super::output::write_json_line(record, &mut stdout)?;\n    stdout.flush().context(\"unable to flush stdout\")?;\n    Ok(())\n}\n","sourceCodeStart":1012,"sourceCodeEnd":1048,"githubUrl":"https://github.com/warpdotdev/warp/blob/e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc/app/src/ai/agent_sdk/ambient.rs#L1012-L1048","documentation":"`ensure_stream_output_format` guards streaming agent-sdk subcommands. Streaming output writes one JSON record per event via `write_stream_record`, which only makes sense for NDJSON; any other `--output-format` (text/table/json) is rejected up front with this error instead of producing unparseable mixed output.","triggerScenarios":"Invoking a streaming subcommand (ambient agent stream/watch-style commands that call ensure_stream_output_format) with `--output-format` set to anything other than `ndjson`, or inheriting a non-ndjson default while requesting streaming.","commonSituations":"Copy-pasted command templates that use text output; CI wrappers defaulting to pretty output; scripts written for the non-streaming command reused for the streaming one; shell profiles or aliases that set --output-format globally.","solutions":["Add `--output-format ndjson` to the streaming command","Drop the streaming flag if you want human-readable/table output","If you consume the output programmatically, switch the parser to read line-delimited JSON"],"exampleFix":"# before\nwarp agent tasks stream --output-format text\n# after\nwarp agent tasks stream --output-format ndjson","handlingStrategy":"validation","validationCode":"fn stream_format_ok(fmt: &OutputFormat) -> bool {\n    matches!(fmt, OutputFormat::Ndjson)\n}\n// Reject other formats in wrappers before spawning the CLI, with a message pointing at --output-format ndjson.","typeGuard":"fn is_stream_compatible(fmt: &OutputFormat) -> bool {\n    matches!(fmt, OutputFormat::Ndjson)\n}","tryCatchPattern":null,"preventionTips":["Default streaming wrappers to --output-format ndjson","Parse streaming stdout as line-delimited JSON","Validate format/flag combinations up front in tooling"],"tags":["cli","output-format","streaming","ndjson","validation"],"backgroundTag":null,"analyzedSha":"e72fd7aacbbb2236d9b3be2aad7e7178fe94b4bc","analyzedAt":"2026-08-16T08:27:25.381Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}