[BUG] Prompt-based Stop hook cannot response correct JSON

Resolved 💬 10 comments Opened Nov 19, 2025 by elct9620 Closed Apr 14, 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?

Whe adding a Stop hook with Response with JSON: { ... } the Claude Code cannot get correct JSON

⏺ Ran 4 stop hooks
  ⎿  Stop hook error: Schema validation failed: [
    {
      "code": "invalid_type",
      "expected": "boolean",
      "received": "undefined",
      "path": [
        "ok"
      ],
      "message": "Required"
    }
  ]

In the debug log, the Hook response:

2025-11-19T13:55:18.624Z [DEBUG] Stream started - received first chunk
2025-11-19T13:55:19.276Z [DEBUG] Hooks: Model response: {
  "decision": "approve",
  "reason": "User's task of amending the last commit with changes to `.claude/settings.json` is complete. The working tree is clean and no further work is indicated. The conversation shows a straightforward git operation that has been successfully completed."
}
2025-11-19T13:55:19.277Z [DEBUG] Hooks: model response does not conform to expected schema: [
  {
    "code": "invalid_type",
    "expected": "boolean",
    "received": "undefined",
    "path": [
      "ok"
    ],
    "message": "Required"
  }
]

What Should Happen?

The hook should not contain Model response: that Claude Code can parse it.

Error Messages/Logs

2025-11-19T13:55:18.624Z [DEBUG] Stream started - received first chunk
2025-11-19T13:55:19.276Z [DEBUG] Hooks: Model response: {
  "decision": "approve",
  "reason": "User's task of amending the last commit with changes to `.claude/settings.json` is complete. The working tree is clean and no further work is indicated. The conversation shows a straightforward git operation that has been successfully completed."
}
2025-11-19T13:55:19.277Z [DEBUG] Hooks: model response does not conform to expected schema: [
  {
    "code": "invalid_type",
    "expected": "boolean",
    "received": "undefined",
    "path": [
      "ok"
    ],
    "message": "Required"
  }
]
2025-11-19T13:55:19.987Z [DEBUG] Hook output does not start with {, treating as plain text
2025-11-19T13:55:24.129Z [DEBUG] Hook output does not start with {, treating as plain text

Steps to Reproduce

Add the following hook to .claude/settings.json

  "Stop": [
      {
        "hooks": [
          {
            "type": "prompt",
            "prompt": "You are evaluating whether Claude should stop working. Context: $ARGUMENTS\n\nAnalyze the conversation and determine if:\n1. All user-requested tasks are complete\n2. Any errors need to be addressed\n3. Follow-up work is needed\n4. No over-design or over-document\n\nRespond with JSON: {\"decision\": \"approve\" or \"block\", \"reason\": \"your explanation\"}\nDo not include anything else JSON."
          }
        ]
      }
    ]

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.0.46 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Other

Additional Information

_No response_

View original on GitHub ↗

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