The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(codex): cover nested retention entry paths
Falko8430c1b4da88
diff --git a/tests/agent/test_relay_llm.py b/tests/agent/test_relay_llm.pyindex 213fd86aea8..7d7a168c750 100644--- a/tests/agent/test_relay_llm.py+++ b/tests/agent/test_relay_llm.py@@ -234,6 +234,31 @@ def test_provider_request_overlays_interceptor_added_codex_field():assert provider_request["prompt_cache_retention"] == "24h"+def test_provider_request_overlays_interceptor_added_extra_body():+ """Relay rewrites may also carry provider fields through extra_body."""+ original = {"model": "gpt-5.6-sol", "input": "hello"}+ relay_request_body = relay_llm._relay_request_body(+ original,+ {"api_mode": "codex_responses"},+ )+ provider_request = relay_llm._provider_request(+ original,+ SimpleNamespace(+ content={+ **relay_request_body,+ "extra_body": {"prompt_cache_retention": "24h"},+ },+ headers={},+ ),+ relay_request_body=relay_request_body,+ codec_baseline_body=dict(relay_request_body),+ metadata={"api_mode": "codex_responses"},+ )++ assert "extra_body" not in original+ assert provider_request["extra_body"] == {"prompt_cache_retention": "24h"}++def test_stream_uses_rewritten_request_and_post_intercept_chunks(relay_turn):relay, turn = relay_turncaptured_requests = []diff --git a/tests/run_agent/test_run_agent_codex_responses.py b/tests/run_agent/test_run_agent_codex_responses.pyindex c1f815801c2..97e1ed1679a 100644--- a/tests/run_agent/test_run_agent_codex_responses.py+++ b/tests/run_agent/test_run_agent_codex_responses.py@@ -590,6 +590,55 @@ def test_run_codex_stream_strips_relay_added_retention_at_consumer_wire()+def test_run_codex_stream_strips_nested_request_override_retention(+ monkeypatch,+ caplog,+):+ """Configured extra_body retention cannot cross the final wire boundary."""+ from agent.transports.codex import ResponsesApiTransport++ agent = _build_agent(monkeypatch)+ captured = {}++ def _fake_create(**kwargs):+ captured.update(kwargs)+ return _FakeCreateStream([+ SimpleNamespace(+ type="response.completed",+ response=SimpleNamespace(status="completed"),+ )+ ])++ agent.client = SimpleNamespace(+ responses=SimpleNamespace(create=_fake_create),+ )+ request = ResponsesApiTransport().build_kwargs(+ model="gpt-5.6-sol",+ messages=[+ {"role": "system", "content": "You are Hermes."},+ {"role": "user", "content": "Ping"},+ ],+ tools=[],+ is_codex_backend=True,+ base_url="https://chatgpt.com/backend-api/codex",+ request_overrides={+ "extra_body": {"prompt_cache_retention": "24h"},+ },+ )+ assert request["extra_body"] == {"prompt_cache_retention": "24h"}++ with caplog.at_level("WARNING", logger="agent.codex_runtime"):+ agent._run_codex_stream(request)++ assert "extra_body" not in captured+ assert request["extra_body"] == {"prompt_cache_retention": "24h"}+ assert any(+ "Dropped unsupported prompt_cache_retention at consumer Codex wire boundary"+ in record.message+ for record in caplog.records+ )++def test_consumer_codex_wire_guard_strips_nested_extra_body_retention(caplog):"""The SDK merges ``extra_body`` into the JSON body, so a nested``extra_body.prompt_cache_retention`` reaches the endpoint exactly like the