[BUG] `claude -p --output-format json` returns empty `result` field despite generating output tokens

Resolved 💬 2 comments Opened Mar 25, 2026 by titouan-souk Closed Mar 25, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

claude -p --output-format json always returns "result":"" in the JSON output, even when the model generates tokens.

What Should Happen?

The result field in the JSON output should contain the model's text response. For example, claude -p
--output-format json "What is 2+2?"
should return "result":"4" (or similar), not "result":"".

Error Messages/Logs

$ claude -p --output-format json "What is 2+2?"

 {"type":"result","subtype":"success","is_error":false,"duration_ms":4047,"num_turns":1,"result":"","stop_reason":"
  end_turn","session_id":"20dde46c-b21a-4475-ac07-6a190b80c4e3","total_cost_usd":0.079,"usage":{"output_tokens":13}}

  # result is "" despite 13 output_tokens
  # stream-json mode confirms the text exists in the assistant message:
  # {"type":"assistant","message":{"content":[{"type":"text","text":"\n\n4"}]}}

Steps to Reproduce

  1. Run: claude -p --output-format json "What is 2+2?"
  2. Observe the JSON output: "result":"" despite "output_tokens":13
  3. Compare with stream mode: claude -p --verbose --output-format stream-json "What is 2+2?"
  4. Stream mode shows the text exists in assistant message content: {"type":"text","text":"\n\n4"}
  5. But the final result event still has "result":""

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.83

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

iTerm2

Additional Information

_No response_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗