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

Open 💬 4 comments Opened Jun 4, 2026 by okamototomoyuki
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

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 ↗

4 Comments

github-actions[bot] contributor · 2 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #26195

Powered by Codex Action

okamototomoyuki · 2 months ago

I am also seeing a similar issue on Windows.
The following error appears intermittently when using Codex:

2026-06-04T04:58:00.719191Z ERROR codex_core::tools::router: error=failed to parse function arguments: EOF while parsing a string at line 1 column 3351
etraut-openai contributor · 2 months ago

If you see this again, please use /feedback and post the session ID here.

okamototomoyuki · 2 months ago

@etraut-openai
I've submitted the feedback report.
The session ID is:
019ea5b5-1aea-7e12-af74-35f667cd9ae5
Could you please investigate this issue?
Thank you.