diff --git a/agent/transports/codex.py b/agent/transports/codex.py index ef7ffbaffd24..2ed8699bfe5c 100644 --- a/agent/transports/codex.py +++ b/agent/transports/codex.py @@ -265,6 +265,9 @@ def build_kwargs( # the cache-scope routing headers below. Falls back to session_id when # there is no static content to hash. cache_key = _content_cache_key(instructions, response_tools) or session_id + # OpenAI rejects prompt_cache_key > 64 chars with HTTP 400. + if cache_key and len(cache_key) > 64: + cache_key = cache_key[:64] # xAI Responses takes prompt_cache_key in extra_body (set further # down); GitHub Models opts out of cache-key routing entirely. if not is_github_responses and not is_xai_responses and cache_key: