Codex provider sends assistant content as input_text causing 400 invalid_value

t-792·WorkTask·
·
·
Created4 days ago·Updated4 days ago·pipeline runs →

Dependencies

Description

Edit

Observed from sd-coder persistent agent error notifications (Apr 15): OpenAI/Codex Responses API returns HTTP 400 invalid_request_error with param input[2].content[0], message: Invalid value 'input_text'. Supported values are 'output_text' and 'refusal'. Root cause appears in Omni/Agent/Provider.hs codexMessage helper, which always emits content blocks with type=input_text even for assistant role messages. In multi-turn sessions this sends prior assistant messages in an unsupported shape. Need adjust codex message encoding by role to match current Responses API schema and add regression test for assistant-history roundtrip.

Timeline (10)

🔄[human]Open → InProgress4 days ago
💬[human]4 days ago

Implemented fix in Omni/Agent/Provider.hs for Codex Responses payload role encoding. now uses role-aware content type ( -> , all others -> ) via , preventing API 400 invalid_value on assistant history (). Added regression tests: (1) user messages encode ; (2) assistant messages encode . Verification: warn: repl: ghci does not support binding to a port [1 of 5] Compiling Alpha ( Alpha.hs, nothing ) [2 of 5] Compiling Omni.Agent.Paths ( Omni/Agent/Paths.hs, nothing ) [3 of 5] Compiling Omni.Agent.Models ( Omni/Agent/Models.hs, nothing ) [4 of 5] Compiling Omni.Test ( Omni/Test.hs, nothing ) [5 of 5] Compiling Omni.Agent.Provider ( Omni/Agent/Provider.hs, nothing ), 7[10000;10000H (all 21 tests passed), and .

💬[human]4 days ago

Implemented fix in Omni/Agent/Provider.hs for Codex Responses payload role encoding.

  • codexMessage now uses role-aware content type via codexContentTypeForRole:
  • assistant -> output_text
  • all other roles -> input_text
  • This fixes the 400 invalid_value error from assistant history payloads (input[2].content[0]).
  • Added regression tests:

1) Codex user messages encode content as input_text 2) Codex assistant messages encode content as output_text

Verification run:

  • typecheck.sh Omni/Agent/Provider.hs
  • bild --test Omni/Agent/Provider.hs (all 21 tests passed)
  • lint Omni/Agent/Provider.hs
🔄[human]InProgress → Review4 days ago
🔄[human]Review → InProgress4 days ago
💬[human]4 days ago

Committed fix as dc5f8805: fix(agent): encode codex assistant history as output_text.

Post-commit rollout actions:

  • Ran Omni/Ide/ship.sh Omni/Agent.hs.
  • Build/lint/tests and cache push succeeded, but manifest update failed with: Service 'agent' not found in manifest.
  • Restarted persistent agent: agentd restart sd-coder --mode persistent (service is active/running with new MainPID).
  • Replayed/resumed interrupted work by sending the previous task context back to sd-coder (t-791 / SD acceptance + A100 usage investigation).

Verification of resume:

  • agentd send accepted the replay message.
  • Process inspection shows sd-coder actively running a search command for the same interrupted context:

rg -n t-791|SD acceptance|acceptance rate|A100|idle experiment|experiment nodes|scale down|task t-791 ... under the new sd-coder process, confirming it resumed task execution after restart.

🔄[human]InProgress → Review4 days ago