Skip to content

The agent that grows with you

fix(transports): drop prompt_cache_options leaking from request_overrides

kokhlo07da054cf12c
diff --git a/agent/transports/codex.py b/agent/transports/codex.py
index 55a285c73da..4b71acb3741 100644
--- a/agent/transports/codex.py
+++ b/agent/transports/codex.py
@@ -753,6 +753,17 @@ class ResponsesApiTransport(ProviderTransport):
kwargs.update(request_overrides)
kwargs["model"] = wire_model
+ # ``prompt_cache_options`` is not a Responses.create() kwarg in the OpenAI SDK, so a
+ # top-level copy (the only place request_overrides can put it) fails the call before
+ # any request is sent, on every route. Endpoints that manage cache lifetime own it
+ # server-side; a proxy that accepts the field gets it via request_overrides
+ # ``extra_body``, which the SDK merges into the body post-transform.
+ if kwargs.pop("prompt_cache_options", None) is not None:
+ logger.warning(
+ "Dropped prompt_cache_options: not a Responses.create() kwarg "
+ "(use request_overrides={'extra_body': ...} for wire-only fields)."
+ )
+
_sanitize_astra_request_kwargs(kwargs, model, params.get("base_url"))
_bound_prompt_cache_key_field(kwargs)
diff --git a/tests/agent/transports/test_codex_transport.py b/tests/agent/transports/test_codex_transport.py
index 6c03ede0f35..5c4639adf30 100644
--- a/tests/agent/transports/test_codex_transport.py
+++ b/tests/agent/transports/test_codex_transport.py
@@ -97,6 +97,29 @@ class TestCodexBuildKwargs:
assert kw["reasoning"]["effort"] == "none"
assert kw["temperature"] == 0.4
+ def test_prompt_cache_options_dropped_from_overrides(self, transport):
+ """``prompt_cache_options`` has no Responses.create() kwarg, so a top-level copy
+ from request_overrides raises TypeError before any request is sent — on the
+ official API, the Codex backend, and custom Responses endpoints alike."""
+ for base_url, is_codex in (
+ ("https://api.openai.com/v1", False),
+ ("https://chatgpt.com/backend-api/codex", True),
+ ("https://responses.example.com/v1", False),
+ ):
+ kw = transport.build_kwargs(
+ model="gpt-6-astra",
+ messages=[{"role": "user", "content": "Hi"}],
+ tools=[],
+ base_url=base_url,
+ is_codex_backend=is_codex,
+ request_overrides={
+ "prompt_cache_options": {"ttl": "30m"},
+ "store": True,
+ },
+ )
+ assert "prompt_cache_options" not in kw, base_url
+ assert kw["store"] is True
+
def test_900k_context_variant_suffix_stripped_on_wire(self, transport):
"""``-900k`` large-context picker variants are Hermes-side aliases —
the Codex backend only knows the base slug, so build_kwargs must