test(codex): pin the retention drop to real endpoints
The salvaged compatibility test stubs `_is_codex_backend=lambda: False` on a SimpleNamespace, so it proves the helper honors its own boolean but not that the boolean is right for any real endpoint. A predicate change that widened the drop onto retention-supporting hosts would keep it green. Adds a parametrized test that builds a real AIAgent per base URL and asserts the drop only fires for chatgpt.com/backend-api/codex, while api.meta.ai, bedrock-mantle.*.api.aws, api.openai.com and a same-host/different-path backend keep their supported 24h value. Also asserts prompt_cache_key survives untouched on every endpoint, since retention and cache-key routing are independent and the guard must not disturb caching. Verified non-vacuous: relaxing the guard's condition to drop on every endpoint fails 4 of the 6 cases (Meta, Bedrock, OpenAI, non-codex path). Drive-by on the guard itself: drop the dead `None` default on the `pop` that is already gated by an `in` check, and record why the predicate is resolved via getattr -- run_codex_stream is driven with lightweight stand-in agents that lack `_is_codex_backend`, so a bare call would raise AttributeError.
This commit is contained in:
@@ -1322,12 +1322,16 @@ def _sanitize_consumer_codex_request(
|
||||
rejected by the provider.
|
||||
"""
|
||||
sanitized = dict(request)
|
||||
# Resolved defensively on purpose: run_codex_stream is also driven with
|
||||
# lightweight stand-in agents that carry only the attributes a given path
|
||||
# needs (see tests/agent/test_codex_request_transport_diagnostics.py), so a
|
||||
# bare agent._is_codex_backend() here would raise AttributeError on them.
|
||||
backend_predicate = getattr(agent, "_is_codex_backend", None)
|
||||
is_consumer_codex = (
|
||||
bool(backend_predicate()) if callable(backend_predicate) else False
|
||||
)
|
||||
if is_consumer_codex and "prompt_cache_retention" in sanitized:
|
||||
sanitized.pop("prompt_cache_retention", None)
|
||||
sanitized.pop("prompt_cache_retention")
|
||||
logger.warning(
|
||||
"Dropped unsupported prompt_cache_retention at consumer Codex "
|
||||
"wire boundary (model=%s).",
|
||||
|
||||
Reference in New Issue
Block a user