# Bug: Automations fail with `invalid_prompt` on OpenRouter provider (Responses wire API)
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 125k
- Forks
- 19.4k
- PR merge metrics
- PR metrics pending
Description
What version of the Codex App are you using (From “About Codex” dialog)?
Environment - Codex Desktop on Windows 11, CLI version 0.151.0-alpha.7.2 - Provider config: model_provider = "openrouter", base_url = "https://openrouter.ai/api/v1", wire_api = "responses" - Models tested: z-ai/glm-5.3-flash, moonshotai/kimi-k3 — both fail identically
What subscription do you have?
openrouter
What platform is your computer?
No response
What issue are you seeing?
Symptom
All scheduled automations (2 cron + 1 heartbeat) trigger on time but every run terminates within ~4 seconds, before any business logic executes. The task_complete event carries:
{"error":{"code":"invalid_prompt","message":"Invalid Responses API request"}}
This has failed on every scheduled run since at least 2026-09-02 (multiple CLI versions). Changing the automation's model does NOT help — the same failure occurs on every OpenRouter-backed model.
Root cause (from session logs)
The Zod validation error is at input item index 2:
branch 0: Invalid input: expected string, received array
branch 1: input[2]: Invalid input | input[13]: Invalid input | ...
Item 2 in the automation's initial context is a function_call_output injected by Codex itself, for the codex_app/automation_update tool:
{"type":"function_call_output","id":"fco_...","name":"automation_update","namespace":"codex_app","output":"..."}
This item fails OpenRouter's Responses API schema validation. The same models work fine in normal interactive sessions (which don't contain this injected item), so the issue is specifically the automation-context serialization vs. OpenRouter's Responses validation.
Expected behavior
Automations should run on OpenRouter-backed models, or the injected automation_update function_call_output should be serialized in a shape that passes Responses validation (or omitted from the request).
Reproduction
- Configure Codex with OpenRouter as model provider (
wire_api = "responses"). - Create any automation (cron or heartbeat).
- Wait for a scheduled run — it fails immediately with
invalid_prompt.
Logs
Happy to attach full rollout JSONL from ~/.codex/sessions/ on request.
What steps can reproduce the bug?
Configure Codex with OpenRouter as model provider (wire_api = "responses").
Create any automation (cron or heartbeat).
Wait for a scheduled run — it fails immediately with invalid_prompt.
What is the expected behavior?
No response
Additional information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the automation context and Responses wire API path, tracing the reported function_call_output at input item index 2 and comparing it with the validation error. Reproduce with OpenRouter using wire_api = "responses" and inspect the rollout JSONL under ~/.codex/sessions/; done means scheduled automations complete successfully without invalid_prompt.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100