Frequent apply_patch truncation on Amazon Bedrock provider: missing "*** End Patch"

Open 💬 4 comments Opened Jun 4, 2026 by okamototomoyuki

What version of Codex CLI is running?

codex-cli 0.136.0

What subscription do you have?

Amazon Bedrock

Which model were you using?

openai.gpt-5.5

What platform is your computer?

Darwin 25.2.0 arm64 arm

What terminal emulator and version are you using (if applicable)?

Terminal.app

Codex doctor report

What issue are you seeing?

When using Codex through the Amazon Bedrock provider, I frequently encounter the following error during file modifications:

2026-06-04T02:42:22.189481Z ERROR codex_core::tools::router: error=apply_patch verification failed: invalid patch: The last line of the patch must be '*** End Patch'

The issue occurs repeatedly when running codex exec.

The same prompts and repositories work reliably when using the OpenAI provider directly. The problem appears significantly more often when using Amazon Bedrock.

My status output shows:

Model: openai.gpt-5.5
Model provider: Amazon Bedrock - https://bedrock-mantle.us-east-2.api.aws

The error suggests that the generated patch is truncated before the final *** End Patch marker.

What steps can reproduce the bug?

  1. Configure Codex to use Amazon Bedrock.
  2. Use GPT-5.5.
  3. Run codex exec on tasks that modify source files.
  4. After several executions, Codex intermittently fails with:
2026-06-04T02:42:22.189481Z ERROR codex_core::tools::router: error=apply_patch verification failed: invalid patch: The last line of the patch must be '*** End Patch'

Repository size does not appear to be the cause.

Example repository:

6 files
232 KB total size

The failure occurs even on small repositories.

What is the expected behavior?

Codex should either:

  • generate a complete apply_patch block, or
  • detect truncation and retry automatically.

The patch should never be submitted to the apply_patch tool without the required terminating marker.

Additional information

I also noticed that this issue appears much more frequently when using the Amazon Bedrock provider than when using the OpenAI provider directly.

It may be related to:

  • Bedrock Mantle streaming responses
  • tool-call serialization
  • patch truncation during response assembly

I can provide additional logs if needed.

View original on GitHub ↗

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