Skip to content

Automation turns persist function_call_output without call_id, permanently breaking sessions on strict Responses endpoints #49173

Open

Description

@milechazi

Summary

When a scheduled/automation turn fires, Codex persists a function_call_output response item
without a call_id into the session rollout file. Any later request that replays that
history is rejected by spec-strict OpenAI-Responses-compatible endpoints with:

400 InvalidParameter: Invalid 'call_id': call_id is required for function_call_output.

The session then becomes permanently unusable: every subsequent user message fails with the
same error, because the bad item is now part of the stored history.

Impact

  • One automation trigger bricks the conversation for any strict Responses endpoint.
  • It is invisible while pointed at a lenient endpoint (our case: a local model gateway that
    ignored the missing field). Switching back to a strict provider — no config change on the
    model side — turns the session into a permanent failure, which looks like a provider outage
    rather than a client-side data bug.
  • Retrying does not help; only editing the rollout or abandoning the session recovers it.

Evidence from our rollout files

~/.codex/sessions/2026-09-28/rollout-2026-09-28T23-30-28-<session>_01a0e8a3-….jsonl (21 lines total):

  • line 17 event_msg / task_started
  • line 18 turn_context
  • line 19 response_item with payload:
{ "type": "function_call_output", "name": "automation_update",
  "namespace": "…", "id": "…",
  "internal_chat_message_metadata_passthrough": "…", "output": … }

Note the absence of call_id, while name/namespace/id are present. The item also has
no matching function_call anywhere in the session (0 function_call items in that file),
i.e. the output is emitted with no preceding call to derive a call_id from — so it is not a
dropped field during serialization, it never had one.

Same pattern in a second, long-running session (…T16-27-17…, 1394 lines, 170 function_call
items vs 171 outputs — exactly one output lacking call_id, at line 1384, again
name = automation_update).

A third, older session (2026-07-11) has the sibling variant: a function_call_output whose
call_id key exists but is the empty string.

Codex version observed: 0.153.4 (Windows 11 26100).

Minimal reproduction against any strict Responses endpoint

Send this input array — it is what Codex emits for a normal tool round trip:

{
  "model": "qwen3.8-flash",
  "store": false,
  "max_output_tokens": 16,
  "tools": [{"type": "function", "name": "dummy_tool", "description": "d",
             "parameters": {"type": "object", "properties": {}, "required": []}}],
  "input": [
    {"type": "message", "role": "user", "content": [{"type": "input_text", "text": "hi"}]},
    {"type": "function_call", "name": "dummy_tool", "arguments": "{}", "call_id": "call_probe_001"},
    {"type": "function_call_output", "call_id": "call_probe_001", "output": "ok"}
  ]
}

Results from the same endpoint, same session, differing only in that one field:

variant result
as above 200
"call_id" removed from the function_call_output item 400 InvalidParameter: Invalid 'call_id': call_id is required for function_call_output.
"call_id": "" 400 InvalidParameter: Invalid 'call_id': call_id must be a string with length between 1 and 64.

Both 400 messages are byte-identical to what users hit when resuming an automation-touched
session on a strict endpoint.

Expected behaviour

function_call_output items written to the rollout (and sent upstream) must always carry a
non-empty call_id referring to a real preceding function_call. For automation/scheduled
turns that do not correspond to a model-issued tool call, the result should not be serialized
as a function_call_output at all — e.g. emit it as an input_text/system message, or
synthesize a paired function_call + function_call_output pair with a valid call_id.

Suggested fixes

  1. Guard at write time: refuse to persist a function_call_output whose call_id is
    missing/empty; log and fall back to a non-tool item type.
  2. Self-heal at load time: when replaying a rollout, drop (or rewrite) function_call_output
    items with a missing/empty call_id, or ones whose call_id has no matching
    function_call. This also un-bricks already-poisoned sessions.
  3. Surface a clear client-side error ("this session contains an orphaned tool output") instead of
    passing the provider's 400 through, which reads like a provider bug to users.

Notes

Happy to provide anonymized rollout excerpts and endpoint request_ids. We worked around it by
deleting the orphan items from the rollout JSONL (with backups), but any session where the
automation fires again gets re-poisoned.

Activity

  1. added
    bug
    session
    custom-model
    on Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    automationsbugcustom-modelsession

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions