codex - 💡(How to fix) Fix Blocking stop hook continuation can fail with invalid local message id [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#20783Fetched 2026-05-03 04:45:32
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×3unlabeled ×1

Error Message

"error": {

Root Cause

A stop hook with decision: "block" is supposed to inject a continuation prompt, for example telling Codex to fix failing lint/type/test checks before stopping.

In this failure mode, the stop hook successfully blocks and emits the continuation prompt, but the next Responses API request rejects the conversation input. That makes the hook mechanism counterproductive: it prevents Codex from continuing to fix the problem.

Code Example

{
  "error": {
    "message": "Invalid 'input[118].id': 'c047686e-8eaf-4c21-9eba-e25d3122d898'. Expected an ID that begins with 'msg'.",
    "type": "invalid_request_error",
    "param": "input[118].id",
    "code": "invalid_value"
  }
}
RAW_BUFFERClick to expand / collapse

Bug

A blocking stop hook can break the Codex turn instead of prompting Codex to fix the blocked condition.

Observed failure:

{
  "error": {
    "message": "Invalid 'input[118].id': 'c047686e-8eaf-4c21-9eba-e25d3122d898'. Expected an ID that begins with 'msg'.",
    "type": "invalid_request_error",
    "param": "input[118].id",
    "code": "invalid_value"
  }
}

Why this matters

A stop hook with decision: "block" is supposed to inject a continuation prompt, for example telling Codex to fix failing lint/type/test checks before stopping.

In this failure mode, the stop hook successfully blocks and emits the continuation prompt, but the next Responses API request rejects the conversation input. That makes the hook mechanism counterproductive: it prevents Codex from continuing to fix the problem.

Expected behavior

When a stop hook blocks, Codex should append the hook continuation prompt and continue the turn normally.

Actual behavior

Codex sends a locally generated UUID as input[].id for a message item. The Responses API rejects it because message ids must be server-generated msg... ids.

Root-cause hypothesis

build_hook_prompt_message creates a user message with a local UUID. Later, attach_item_ids reattaches hidden item ids into the serialized Responses API request body.

That path appears to treat local message UUIDs the same as server-generated message ids, so a local UUID is sent as a wire message.id.

Reference fix

I prepared a minimal fix in a fork.

Reference commit: https://github.com/shawnsw/codex/commit/15286e639ad4f11771ddf1393b565f503c0aafc7

Approach:

  • only reattach message.id when it looks like a server-generated msg... id
  • continue preserving ids for other Responses API output item types
  • add regression coverage for local UUIDs and server message ids

extent analysis

TL;DR

The issue can be fixed by modifying the attach_item_ids function to only reattach message.id when it looks like a server-generated msg... id.

Guidance

  • Review the build_hook_prompt_message function to ensure it correctly handles local message UUIDs and server-generated message ids.
  • Update the attach_item_ids function to check if the message.id starts with 'msg' before reattaching it to the Responses API request body.
  • Verify that the fix does not break other functionality, such as preserving ids for other Responses API output item types.
  • Consider adding regression tests to cover local UUIDs and server message ids.

Example

// Example of a server-generated message id
{
  "id": "msg1234567890"
}

// Example of a local message UUID
{
  "id": "c047686e-8eaf-4c21-9eba-e25d3122d898"
}

Notes

The provided reference fix in the fork can be used as a starting point, but it's essential to review and test the changes thoroughly to ensure they do not introduce new issues.

Recommendation

Apply the workaround by updating the attach_item_ids function to correctly handle local message UUIDs and server-generated message ids, as this will fix the issue without requiring a version upgrade.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

When a stop hook blocks, Codex should append the hook continuation prompt and continue the turn normally.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix Blocking stop hook continuation can fail with invalid local message id [1 participants]