Repository navigation
Description
Component: Codex desktop app (Windows), package 26.903.9818.0 (ChatGPT.exe 152.0.7977.83), bundled codex-cli 0.153.4
Model provider: custom OpenAI-compatible provider in config.toml with wire_api = "responses" (base_url https://api.deepseek.com/)
Summary
When an automation fires (heartbeat or cron), the app appends a synthetic tool-result item to the target session and posts the session history to the Responses endpoint. The item is a function_call_output for the app tool automation_update, but it carries no call_id, so the server rejects the entire request:
Failed to deserialize the JSON body into the target type:
input: missing field `call_id` at line 1 column 851416
Because the item stays in the session history, the session is permanently bricked: every later request fails the same way, including ordinary user messages. Each failed automation run appends yet another bad item. In our case the automation never ran successfully even once, and the failure was silent.
Steps to reproduce
-
Configure a custom Responses-API provider (
wire_api = "responses") in config.toml. -
Create a heartbeat automation targeting an existing thread (reproduced), or a cron automation bound to a project (also reproduced).
-
Wait for the first trigger.
-
The run ends immediately with the 400 above.
-
In the session rollout JSONL, the injected trigger item looks like this (no
call_id; note the non-standardname/namespacefields and thefco_id prefix):{"type":"function_call_output",
"id":"fco_01a08cf7-e93a-7641-98bf-75581dc6ad04",
"name":"automation_update",
"namespace":"codex_app",
"output":"\r\n <automation_id>automation</automation_id>\r\n <current_time_iso>2026-09-10T20:17:32.150Z</current_time_iso>\r\n...",
"internal_chat_message_metadata_passthrough":{"turn_id":"01a08cf7-...","create_time":1789071452.75}} -
Send any ordinary message in that same thread: it also fails with the same error.
Evidence
- Ordinary turns in another thread work fine against the same provider, so the request path itself is healthy - only the automation-delivered item is malformed.
- All automation failures show the same message with a monotonically growing column, because the session keeps growing (~3 KB per failed run): 839237, 842598, 845959, 849320, 851416.
- A cron automation reproduced it in a brand-new thread too (column 46888), so this is not heartbeat-specific.
- Per the Responses API schema,
function_call_outputitems requirecall_id(see https://developers.openai.com/api/docs/guides/function-calling).
Expected
Automation triggers should be delivered as schema-valid input - e.g. a function_call_output that carries the call_id of the corresponding automation_update function call, or simply as a normal user message. A failed run should not permanently damage the session.
Suggested fix
- Populate
call_idon the injected item (pair it with the automation'sautomation_updatecall), or deliver the trigger as a regular message. - Validate outgoing
inputitems against the Responses schema before sending, and skip/log invalid synthetic items instead of letting the server reject the whole turn. - Make sessions self-healing: do not persist an item the server rejected, or provide a way to drop/repair invalid items from a broken thread.
Impact
- Scheduled automations are unusable (5 failures / 0 successful runs).
- The target conversation is permanently broken and cannot be repaired from the UI.
- Silent monitoring failure: our automation was supposed to watch a live trading loop every 2 hours; it never ran, and nobody noticed until we investigated manually.
Activity
github-actions commentedon Sep 11, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
invalid_prompton OpenRouter provider (Responses wire API) #43740Powered by Codex Action
njwangcn commentedon Sep 11, 2026
Confirming this on a second install, with one extra data point that matters for the fix: supplying
call_idalone is not enough.Environment
26.903.9818.0(Windows 11 x64), bundledcodex-cli 0.153.4config.toml:wire_api = "responses", routed through a local proxy to DeepSeekInstance
A
kind = "heartbeat"automation targeting an existing thread (FREQ=DAILY;BYHOUR=21) fired at2026-09-11T13:00:05.821Zand wrote the malformed item into the thread rollout (ordinal 6972 of that thread's history):{"ordinal":6972,"type":"response_item","payload":{"type":"function_call_output","id":"fco_01a0908d-c6e1-7df2-8290-ce0044f70ae0","name":"automation_update","namespace":"codex_app","output":"<heartbeat>\r\n <automation_id>automation</automation_id>\r\n ...\r\n</heartbeat>\r\n"}}Every later turn in that thread failed with
input: missing field call_id at line 1 column 6848223(column grows across retries: 6847678 → 6848223 → 6849746 → 6850308), including ordinary user messages and the heartbeat run itself. Confirms the "permanently bricked, never a successful run" part.Extra evidence:
call_idalone doesn't fix itI probed the same Responses path directly with two synthetic requests:
{"type":"function_call_output","output":"hi"}Failed to deserialize the JSON body into the target type: input: missing field call_id at line 1 column 56{"type":"function_call_output","call_id":"call_test_1","output":"hi"}No tool call found for tool output with call_id call_test_1So suggestion 1 in the report should be read as "pair the item with the corresponding
function_call", not just "populate the field" — otherwise strict providers still reject it with a different 400. Delivering the trigger as a user message (as the heartbeat spec advertises, and as earlier builds did) avoids the whole class of problem.For reference, in a rollout written by an earlier build (
rollout-2026-08-05T20-39-57-019fd1f0-...jsonl) the same<heartbeat>payload is stored as aresponse_itemof typemessagewithrole: "user"and aninput_textpart — which is what a heartbeat is supposed to be.History integrity check
Scanning that thread's full history: 3146
response_items, exactly one item missingcall_id, and 940function_call/ 940function_call_outputwith no other orphan on either side. The single injected item is the entire cause, and removing it restores the thread.Repair that worked (for anyone stuck)
function_call_outputline and its pairedevent_msg/item_completedline.call_id, tool call/output pairing intact.Worth noting for triage: the malformed item is written to disk before the request is built, so the same item also gets replayed by any later resume — a client-side validation of outgoing
inputitems (report item 2 in this issue) would stop the bleeding even before the delivery path is changed.husongjie521-alt commentedon Sep 11, 2026
husongjie521-alt commentedon Sep 11, 2026
argszero commentedon Sep 11, 2026
Both of these comments are correct, and @njwangcn's correction ("populate
call_id" is not a fix) is the important one. Here is the delivery-path change that introduced this, plus two code facts that matter for the repair.Where it came from
The trigger used to arrive as a user message; it now arrives as a standalone tool output. That switch is commit
e56e4922eb— "Support standalone tool outputs inturn/start" (#41002), merged 2026-08-26, first released inrust-v0.151.0-alpha.4and present in 0.151.0+/0.152.x/0.153.x. Older builds predate it, which is exactly the boundary in @njwangcn's comparison rollout: the 2026-08-05 file stores the same<heartbeat>payload as amessagewithrole: "user"because the standalone-output path did not exist yet.The producer is the app-server
turn/starttoolOutputparameter:param at
turn.rs:176, consumed atapp-server/src/request_processors/turn_processor.rs:592-603, which buildsResponseItem::FunctionCallOutput { id: None, call_id: None, name: Some(..), namespace: .. }— literally withcall_id: Nonehardcoded. Note the type: it has no field that could express a pairing. That is the structural reason a "just add the field" fix cannot be made at the delivery layer — the RPC has no way to name the call the output answers, so @njwangcn's synthetic probe (call_idpresent →No tool call found for tool output) is the expected outcome, not a bug in the probe.The
fco_…id is then synthesized bySession::assign_missing_response_item_id(core/src/session/mod.rs:3453) through the standalone-output arm of turn input construction (core/src/session/turn_input.rs:684-692). It is the signature of an intentionally standalone output, not a lostcall_id.Why nothing catches it
The request path does have an orphan cleaner —
remove_orphan_outputs(core/src/context_manager/normalize.rs:155) — but its arm matchescall_id: Some(call_id)only (:184-190), so acall_id: Noneitem is skipped by construction. That is deliberate and documented one line above the call site: "every output has a corresponding call entry or names an external tool event" (core/src/context_manager/history.rs:705). BecausetoolOutputalso cannot be combined with a nonemptyinput(turn_processor.rs:536-541), the injected item becomes an entire turn's input, and history is replayed on every later turn — which is why the thread is bricked rather than merely warned.On the sqlite rows (@husongjie521-alt)
Your observation is right and the repair is right, but the query should not be read as counting malformed items. The projection stores an app-server
ThreadItem, andFunctionCallOutputItem(protocol/src/items.rs:89) is{ id, name, namespace, output }— there is nocall_idfield in that schema at all, soitem_json not like '%call_id%'excludes nothing; the discriminating part of your query isitem_type = 'functionCallOutput'alone. That column's value for this case happens to be rare for an unrelated reason: the row type has exactly one producer (core/src/hook_runtime.rs:748, inside theTurnInput::FunctionCallOutputarm), which is the same standalone-output delivery. So the DB row is the same item as the rollout item, projected — not a second defect.It is also not what re-poisons history. Model input is loaded from the rollout, not from this table (
thread-store/src/local/model_context.rs:37-76);thread_itemsbacks the list/timeline/UI views (app-server/src/request_processors/thread_processor.rsviadeserialize_stored_thread_item). That is why deleting only one of the two leaves an inconsistent state, and why your recipe deletes both.One caveat on editing the JSONL in place
Deleting a line shortens the file, but nothing reconciles the projection's byte cursor.
thread_history_projection_state.next_rollout_byte_offsetstill points past the new end of file, and the next projection attempt returns"durable rollout shrank before projection"(thread-store/src/local/thread_history_materialization.rs:110-113). That error is warn-only (live_writer.rs:353,session/mod.rs:1349), so the sqlite view silently stops advancing. The codebase already contains the right recovery shape — compare the stored cursor against the actual file length and reproject (rollout_migration.rs:1033-1037) — but it is applied only when recovering a pending published migration, not after manual repair. Practically: after a hand edit, expect the sidebar/timeline for that thread to stay frozen until the rollout regrows past the old cursor, and prefer starting a fresh thread where you can.The fix direction is the one in the first comment: either deliver the automation trigger as a user turn again, or give
toolOutputa way to name the call it pairs with and enforce it at request assembly.bjdx8j4zm5-source commentedon Sep 12, 2026
Workaround (verified): deliver the trigger the way it was delivered before
e56e4922ebSame setup as reported here (Windows, Codex Desktop,
wire_api = "responses", DeepSeek).We hit both halves of the failure: the automation never completed a single run, and the
target thread became permanently unusable — every later user message returned the same
HTTP 400.
As @argszero traced above, the trigger used to arrive as a user message; since
e56e4922ebit arrives as a standalonefunction_call_outputwith nocall_id. And as@njwangcn pointed out, populating
call_idalone is not a fix either — there is nomatching
function_callto pair it with.So rather than trying to make the item valid, add a local passthrough proxy that rewrites
it back into the old form before it reaches the provider:
Everything else — tool calls, reasoning items, streaming — is forwarded unchanged.
Verified end to end:
function_call_output, sent directly toapi.deepseek.commissing field 'call_id'response.completedcodex execrun with the shim asbase_urlGET /modelsand a non-streamingPOST /responsesOutcome: the automation actually runs instead of dying on its first trigger, and no
malformed item is ever persisted — so the "permanently bricked thread" failure mode
disappears.
For threads that are already bricked, the same repo ships a repair script that removes
the orphan outputs from both the rollout JSONL and
thread_history_1.sqlite(
thread_items), realignsthread_history_projection_state, and backs everything upbefore touching it (dry-run by default). Restart Codex afterwards.
Code + write-up: https://github.com/bjdx8j4zm5-source/codex-strict-responses-fix
Caveat: this is a client-side workaround, not an app-server fix. The proper fix is either
attaching a real
call_idwith a matchingfunction_call, or going back touser-message delivery for injected triggers.
中文版
同样的环境(Windows + Codex 桌面版 +
wire_api = "responses"+ DeepSeek)。我们遇到了这个问题的两半:自动化一次都没成功运行过,而且目标会话被永久搞坏——之后每条消息都返回同样的
HTTP 400。
正如 @argszero 上面定位的:触发内容以前是以 user 消息下发的;
e56e4922eb之后改成独立的
function_call_output,且不带call_id。而 @njwangcn 说得对:只补call_id也不行——它没有配对的
function_call。所以不去"修正"这条记录,而是加一个本地透传代理,把它改回旧格式再发给服务商:
其余内容(工具调用、reasoning、流式响应)原样透传。
端到端验证:
function_call_output的请求,直连api.deepseek.commissing field 'call_id'response.completedcodex exec以代理为base_urlGET /models与非流式POST /responses结果:自动化能真正跑起来(而不是在第一次触发就死掉),并且不会再写入坏记录,因此
"会话永久损坏"这个失败模式消失。
对于已经坏掉的会话,同一个仓库里有修复脚本:从 rollout JSONL 和
thread_history_1.sqlite(thread_items)里删除孤儿输出、校正thread_history_projection_state偏移,改动前自动备份(默认 dry-run),修完重启Codex 即可。
代码与说明:https://github.com/bjdx8j4zm5-source/codex-strict-responses-fix
说明:这是客户端绕过方案,不是 app-server 的修复。官方正确修法是:补上真实的
call_id并配对
function_call,或让注入的触发内容改回 user 消息投递。sleep007 commentedon Sep 15, 2026
Confirming this on macOS with Codex Desktop 26.908.40834 and a custom Responses provider (CodexCN).
wire_api = "responses"; Responses WebSocket is not supported by this provider.The cron task fails immediately after Codex injects the standalone
automation_updatefunction_call_output, before the report-generation prompt starts. The provider returns:function_call_output requires call_id on HTTP requests; continuation via previous_response_id is only supported on Responses WebSocket v2Normal conversations work through the same provider. This confirms the issue is not Windows-specific and affects macOS cron automations as well.
sususu98 commentedon Sep 15, 2026
Adding another concrete data point directly from official OpenAI
/v1/responses(not a third-party custom provider), which confirms the wire-level schema failure, sheds light on thecall_id: ""variation, and identifies a second code location that generates this exact pattern.1. Official OpenAI Responses API Error
In our production deployment, a Windows Codex Desktop client hit this exact issue when an automation heartbeat fired at 01:00 AM.
Unlike third-party providers that report
missing field 'call_id', official OpenAI/v1/responsesreturned HTTP 400 with the following schema validation failure:{ "error": { "message": "Invalid 'input[678].call_id': empty string. Expected a string with minimum length 1, but got an empty string instead.", "type": "invalid_request_error", "param": "input[678].call_id", "code": "empty_string" } }The wire payload captured at index 678 was:
{ "type": "function_call_output", "call_id": "", "output": "<heartbeat>\r\n <automation_id>ais</automation_id>\r\n <current_time_iso>2026-09-14T17:00:43.899Z</current_time_iso>\r\n <instructions>\r\n ...\r\n </instructions>\r\n</heartbeat>\r\n" }Because
call_idis serialized as""(empty string) rather than omitted, OpenAI's strict JSON schema validator rejects it under theminLength: 1rule.2. Additional Code Source:
stream_events_utils.rs:366In addition to the
app-serverTurnToolOutputdelivery path traced by @argszero, there is a second direct producer ofcall_id: ""incodex-rs/core/src/stream_events_utils.rs:364-378:Here,
response_input_to_response_item(line 507) converts it intoResponseItem::FunctionCallOutput { call_id: Some("".to_string()), .. }. BecauseOption::is_noneis false, Serde serializes"call_id": "", which immediately gets written to the session's rollout / SQLite database and permanently poisons all future turns against strict OpenAI endpoints.3. Verification of the Proposed Fix
We verified the workaround suggested by @njwangcn and @bjdx8j4zm5-source at the gateway layer:
input[678]fromtype: "function_call_output"into a standard user message:{ "type": "message", "role": "user", "content": [ { "type": "input_text", "text": "<heartbeat>...</heartbeat>" } ] }status: completed). The model smoothly received the heartbeat instructions and resumed the thread without any schema error.Delivering automation triggers and synthetic external context as
role: "user"messages (or pairing them with a validfunction_callwhen a tool interaction is genuinely intended) is definitely the right architectural fix.charlescao0417-svg commentedon Sep 15, 2026
Adding a macOS data point confirming this is still present on app-server
0.154.0-alpha.6.2.Environment
26.908.70816(reproduced earlier on26.903.71938and26.908.40834; updated again 2026-09-15 and the issue persists)0.154.0-alpha.6.2wire_api = "responses",model_provider = deepseekSymptom
Both local cron automations fail on their first turn, roughly 0.3 s after the trigger. No output is produced and there is no retry:
Observed trigger times (Asia/Shanghai)
All six failed identically. The scheduler itself fires correctly — the failure happens purely at request construction, before inference starts.
Recorded item
The injected trigger is persisted as a standalone tool output with no
call_id(and, as others noted, no matchingfunction_callto pair it with):{"type":"function_call_output","id":"fco_...","name":"automation_update","namespace":"codex_app","output":"Automation: <name> ..."}Client-side gate
The desktop client still gates on the same capability and takes the tool-output branch; the shaping function is unchanged in
26.908.70816:The capability table maps
turnToolOutputto0.151.0-alpha.4, so any app-server at or above that version takes the broken branch.Impact
Both automations have failed every scheduled run since the regression. They only work when re-run manually from a normal chat (i.e. user-message delivery). There is no setting or feature flag that forces the legacy text path —
codex features listexposes no relevant toggle, andcodexCLI offers no override for the app-server version.VincentAdamNemessisX commentedon Sep 16, 2026
Fresh reproduction on macOS, adding two details not covered above.
Environment: macOS, ChatGPT.app bundle 152.0.7977.83 (bundled codex 0.154.0-alpha.6.2, originator
Codex Desktop), custom providerwire_api = "responses"→ OpenCode Go (https://opencode.ai/zen/go/v1, DeepSeek V4.1 Flash), which validates input items strictly.Same failure:
Failed to deserialize the JSON body into the target type: input: missing fieldcall_id``. Item shape identical (function_call_output, `name: automation_update`, `namespace: codex_app`, no `call_id`, no matching `function_call`).Two additions:
The heartbeat is injected at turn start and the automation tick's own request already contains the fresh item, so the run can never succeed on a strict upstream — this is stronger than "the thread is bricked for later messages". With an hourly heartbeat automation (:00/:30,
kind = "heartbeat"), every tick appends another malformed item and fails silently until the JSONL rows are repaired by hand. The malformed items are also replayed on every manual turn, so the thread stays unusable in between.Confirmed the repair constraint reported in Standalone injected function_call_output is rejected by strict Responses providers; adding a call_id is not a sufficient repair #45450: adding only a synthetic
call_idmoves the error toNo tool call found for tool output with call_id …. A strict upstream requires a matchingfunction_callitem, or the injection must be delivered as a schema-valid non-tool item.Suggested fix (unchanged, now with the pairing requirement explicit): deliver automation/thread-delegation injections as plain
messageitems (role=user), or emit a pairedautomation_updatefunction_call + function_call_output withcall_id. Either would fix both the tick itself and history replay.