Session becomes unusable: Invalid input[N].id = fc_... (expected ctc) when replaying history

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

What version of the Codex App are you using (From “About Codex” dialog)?

26.818.32112

What subscription do you have?

use openai api

What platform is your computer?

Microsoft Windows NT 10.0.22635.0 x64

What issue are you seeing?

Using OpenAI API to access Codex ++, the dialogue will now report this error every once in a while, resulting in the whole dialogue not being able to be used normally.

A new dialogue must be opened, but this error will also occur after a while in the new dialogue, which will make it impossible to use normally.

error example:
Invalid 'input[107].id': 'fc_08d2f9b0333b7690016a88ed74f82c87d0aa6bf2edc704ebc0'. Expected an ID that begins with 'ctc'. [trace_id=76843951e11a52345eaa4b2aba010e12]

<img width="779" height="94" alt="Image" src="https://github.com/user-attachments/assets/053ab607-3291-4110-9e69-d4a86aa21215" />

What steps can reproduce the bug?

This error occurs frequently in long sessions, but it can take a long time to open a new session.
Once this error occurs, it cannot continue and a new session must be opened.

What is the expected behavior?

_No response_

Additional information

_No response_

View original on GitHub ↗

6 Comments

github-actions[bot] contributor · 6 days ago

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

  • #39125
  • #38855

Powered by Codex Action

zzr005119 · 6 days ago

我也遇见了同样的问题,而且发现它常发生在上下文自动压缩后,而且同一个会话在input后面的id一样,不同会话不一样。请官方尽快解决,已经严重影响到大型工程的完成
Invalid 'input[19].id': 'fc_0fd5308a94266ded016a896f6797d487d0a3ef0902829fe54c'. Expected an ID that begins with 'ctc'.

<img width="945" height="190" alt="Image" src="https://github.com/user-attachments/assets/9e66dd4f-d131-4be7-8e31-c381fa166850" />

jhkzw521-ui · 5 days ago

me tooooooo!

lucaslynn · 5 days ago

错误的原因是rollout文件中出现了类似这样的记录:

  {
    "type": "custom_tool_call",
    "id": "fc_0839aaebfb85d070016a895d57152087d286a0857bcffba1fa",
    "call_id": "call_dnAQC4K7pElm7QnJZRY6iRey",
    "name": "exec"
  }

但 Responses API 的 ID 规则是:

  function_call          -> fc_
  function_call_output   -> fco_
  custom_tool_call       -> ctc_
  custom_tool_call_output-> ctco_

因此,custom_tool_call 搭配 fc_ 是非法组合,API 才会报:

  Expected an ID that begins with 'ctc'`

错误发生的源头,是 Responses API 返回了错误的 ID,但是 Codex 未检查 ID 前缀是否和 item 类型匹配,并将错误的 item 写入了 rollout,当恢复会话时再次发送该历史 item,Responses API 拒绝请求。

当前源码中的缺陷在于:

  • codex-rs/codex-api/src/sse/responses.rs 解析 output_item.done 时保留了服务端 ID,但没有做类型校验;
  • codex-rs/core/src/client.rs 的 prepare_response_items_for_request() 只检查“是否存在任意前缀”;- fc_... 会通过这个检查,因为它确实有前缀;
  • codex-rs/protocol/src/models.rs 虽然已经定义 CustomToolCall 应使用 ctc,但该规则没有用于出站校验。
zzr005119 · 2 days ago

我想知道如何解决这个问题,因为我用的ccswitch

BingLi37 · 1 day ago

我开源了修复codex会话id与服务器id不匹配导致的报错工具:
https://github.com/BingLi37/codex-fix
!image.avif