[BUG] --json-schema flag hangs/produces zero output under Bedrock

Resolved 💬 2 comments Opened Jun 3, 2026 by adam-swenson-ews Closed Jul 8, 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?

Bug Report: --json-schema flag hangs/produces zero output under Bedrock

CLI build: Claude Code 2.1.161
Backend: Amazon Bedrock (CLAUDE_CODE_USE_BEDROCK=1)
Region: us-east-1
Models: us.anthropic.claude-opus-4-8 (lead), us.anthropic.claude-sonnet-4-6 (subagents)
Mode: Headless (claude -p), --output-format json, --permission-mode dontAsk
Severity: Blocker — flag is unusable in Bedrock mode; affects every scan in our pipeline.

---

Summary

The --json-schema <path> flag, while documented in 2.1.161, does not function under Bedrock. Depending on the schema, the CLI either hangs indefinitely until the caller's timeout fires, or exits immediately with zero bytes on stdout. Removing the flag (with no other changes) restores normal behavior.

Actual behavior

| # | Invocation | Result |
|---|---|---|
| 1 | trivial prompt, no flags | ✅ exits in ~5s with valid output |
| 2 | trivial + --add-dir (real repo on EFS) | ✅ exits in ~19s with valid output |
| 3 | trivial + --add-dir + --json-schema <real findings schema> | ❌ hangs to timeout, 0 bytes on stdout/stderr |
| 4 | trivial + --json-schema <real findings schema> (no --add-dir) | ❌ hangs to timeout, 0 bytes on stdout/stderr |
| 5 | identical prompt to row 3, --json-schema removed | ✅ exits in ~2s with valid output |

A second variant tested with a minimal schema (single string field) exited instantly with zero bytes rather than hanging — suggesting the structured-output validator returns nothing when validation fails on the first/empty response, while a larger schema causes the loop to never produce a final message at all.

What Should Happen?

Expected behavior

claude -p ... --output-format json --json-schema <findings.schema.json> should return a JSON envelope whose result field is a string conforming to the supplied draft-07 schema, exiting with code 0.

Error Messages/Logs

`claude -p ... --output-format json --json-schema <findings.schema.json>` should return a JSON envelope whose `result` field is a string conforming to the supplied draft-07 schema, exiting with code 0.

trivial + `--add-dir` + `--json-schema <real findings schema>` | ❌ hangs to timeout, 0 bytes on stdout/stderr |
trivial + `--json-schema <real findings schema>` (no `--add-dir`) | ❌ hangs to timeout, 0 bytes on stdout/stderr |

Steps to Reproduce

  1. Bedrock-mode env: CLAUDE_CODE_USE_BEDROCK=1, AWS_REGION=us-east-1, ANTHROPIC_DEFAULT_OPUS_MODEL=us.anthropic.claude-opus-4-8.
  2. Save any draft-07 JSON Schema to findings_schema.json (ours describes a fixed-shape object with a findings[] array; <2 KB).
  3. Run:

``
claude -p "Return a tiny valid object." \
--output-format json \
--permission-mode dontAsk \
--json-schema ./findings_schema.json
``

  1. Observe: process never produces output; must be killed.
  2. Re-run with the --json-schema line removed → exits cleanly in seconds.

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

Claude Code 2.1.161

Platform

AWS Bedrock

Operating System

Other Linux

Terminal/Shell

Other

Additional Information

Notes / hypotheses

  • Failure is independent of repo content, prompt content, and --add-dir — schema-only invocations also fail (row 4).
  • Failure mode (hang vs instant 0-byte exit) appears correlated with schema size/complexity, suggesting the issue is in the structured-output enforcement loop rather than schema parsing.
  • We did not test against the first-party Anthropic API; cannot confirm whether this is Bedrock-specific or general to 2.1.161.

Asks

  1. Confirm whether --json-schema is supported under Bedrock in 2.1.161, and if not, document the gap.
  2. If it is supposed to work, a fix or guidance on a feature flag / config that re-enables it.
  3. Ideally, surface a non-zero exit code + stderr message when the structured-output path fails, instead of silent hang / silent 0-byte exit.

View original on GitHub ↗

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