What happened?
OpenAI rejects Codex Responses requests whose prompt_cache_key is >64 chars:
Error: Invalid 'prompt_cache_key': string too long. Expected a string with maximum length 64, but got a string with length 67 instead.
At packages/ai/src/providers/openai-codex-responses.ts:381 Pi sets prompt_cache_key: options?.sessionId with no length clamp. Session ids from composite forms (e.g. client_<uuid>:<agent_type>) routinely exceed 64.
Steps to reproduce
- Invoke
streamOpenAICodexResponses (or streamSimpleOpenAICodexResponses) with an options.sessionId longer than 64 chars — e.g. client_d4a85a75-2483-4b2d-b15b-b97d182711ef:openai-codex (69 chars).
- First response frame returns the 400 above; turn fails before any output.
Expected behavior
Pi clamps prompt_cache_key to 64 chars before sending (deterministic prefix slice keeps prefix caching working). The turn completes normally.
Version
@earendil-works/pi-ai from current main (verified against packages/ai/src/providers/openai-codex-responses.ts:381 as of 2026-05-19).
Proposed fix
5-line helper at the file's config-constants block; one-line change at the call site. Branch ready (fix/codex-prompt-cache-key-length on kobiebendalak/pi); happy to re-open the PR once an lgtmi lands here.
What happened?
OpenAI rejects Codex Responses requests whose
prompt_cache_keyis >64 chars:At
packages/ai/src/providers/openai-codex-responses.ts:381Pi setsprompt_cache_key: options?.sessionIdwith no length clamp. Session ids from composite forms (e.g.client_<uuid>:<agent_type>) routinely exceed 64.Steps to reproduce
streamOpenAICodexResponses(orstreamSimpleOpenAICodexResponses) with anoptions.sessionIdlonger than 64 chars — e.g.client_d4a85a75-2483-4b2d-b15b-b97d182711ef:openai-codex(69 chars).Expected behavior
Pi clamps
prompt_cache_keyto 64 chars before sending (deterministic prefix slice keeps prefix caching working). The turn completes normally.Version
@earendil-works/pi-aifrom currentmain(verified againstpackages/ai/src/providers/openai-codex-responses.ts:381as of 2026-05-19).Proposed fix
5-line helper at the file's config-constants block; one-line change at the call site. Branch ready (
fix/codex-prompt-cache-key-lengthonkobiebendalak/pi); happy to re-open the PR once anlgtmilands here.