Skip to content

Summary generation fails: cannot unmarshal array from Claude Code 2.x JSON output #750

@bboutayeb

Description

@bboutayeb

What happened?

entire explain --checkpoint <id> --generate fails with a JSON parsing error. Entire expects a single JSON object from Claude CLI but Claude Code 2.x returns a JSON array when invoked with --output-format json.

$ entire explain --checkpoint 336b6c705d35 --generate
2026/03/22 00:32:21 INFO generating checkpoint summary
failed to generate summary: failed to generate summary: failed to parse claude CLI response: json: cannot unmarshal array into Go value of type summarize.claudeCLIResponse

The root cause: Claude Code 2.x --print --output-format json returns an array of objects ([{type:"system",...}, {type:"assistant",...}, {type:"result",...}]) instead of a single object. The Go struct summarize.claudeCLIResponse tries to unmarshal this array as a single object, which fails.

Auto-summarization on commit (strategy_options.summarize.enabled: true in .entire/settings.json) is also silently broken for the same reason — summaries are never generated.

Steps to reproduce

  1. Have Claude Code 2.x installed
  2. Enable summarize in .entire/settings.json:
    { "enabled": true, "strategy_options": { "summarize": { "enabled": true } } }
  3. Make a commit (checkpoint is created without summary)
  4. Run entire explain --checkpoint <id> --generate
  5. Error: failed to parse claude CLI response: json: cannot unmarshal array into Go value of type summarize.claudeCLIResponse

You can verify the format change by running:

echo "hello" | claude --print --output-format json --max-turns 1
# Returns: [{...}, {...}, {...}]  ← array, not object

Entire CLI version

Entire CLI 0.5.1 (d46fdc2), Go version: go1.26.1, OS/Arch: linux/amd64

OS and architecture

Linux 6.6.87.2-microsoft-standard-WSL2 x86_64 (WSL2)

Agent

Claude Code 2.1.81

Terminal

Bash (WSL2)

Logs / debug output

$ entire explain --checkpoint 336b6c705d35 --generate
2026/03/22 00:32:21 INFO generating checkpoint summary
failed to generate summary: failed to generate summary: failed to parse claude CLI response: json: cannot unmarshal array into Go value of type summarize.claudeCLIResponse

Additional context

  • Related to Explain command: failed to generate summary #334 (same explain --generate command, different error)
  • The fix would likely involve parsing the JSON array and extracting the result object (last element with type: "result") instead of trying to unmarshal the entire response as a single object
  • Git version: 2.47.2, shell: bash

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions