Skip to content

The agent that grows with you

test: move the unified-cron cache-scope regression to a sibling file

Tekniumbb74e7ffa9fa
diff --git a/tests/agent/transports/test_codex_transport.py b/tests/agent/transports/test_codex_transport.py
index 1cd50a8e91b..95fc50046db 100644
--- a/tests/agent/transports/test_codex_transport.py
+++ b/tests/agent/transports/test_codex_transport.py
@@ -207,30 +207,6 @@ class TestCodexBuildKwargs:
)
assert kw1["prompt_cache_key"] == kw2["prompt_cache_key"]
- def test_cache_key_stable_for_unified_cron_session_ids(self, transport):
- """A scheduler admission, not the local physical id, scopes cron cache reuse."""
- from gateway.session_cron import _execution
-
- messages = [{"role": "user", "content": "Hi"}]
- token = _execution.set((object(), "local-first-fire", "job42", "fire-1"))
- try:
- first = transport.build_kwargs(
- model="gpt-5.4", messages=messages, tools=[], session_id="local-first-fire",
- )
- _execution.set((object(), "local-second-fire", "job42", "fire-2"))
- second = transport.build_kwargs(
- model="gpt-5.4", messages=messages, tools=[], session_id="local-second-fire",
- )
- _execution.set((object(), "local-other-job", "job99", "fire-3"))
- other = transport.build_kwargs(
- model="gpt-5.4", messages=messages, tools=[], session_id="local-other-job",
- )
- finally:
- _execution.reset(token)
-
- assert first["prompt_cache_key"] == second["prompt_cache_key"]
- assert first["prompt_cache_key"] != other["prompt_cache_key"]
-
def test_cache_key_differs_across_unrelated_sessions(self, transport):
"""#78941: two unrelated sessions (different users/conversations)
sharing the same static prefix must NOT collapse onto the same
diff --git a/tests/agent/transports/test_codex_transport_cron_scope.py b/tests/agent/transports/test_codex_transport_cron_scope.py
new file mode 100644
index 00000000000..3c8c575f2ab
--- /dev/null
+++ b/tests/agent/transports/test_codex_transport_cron_scope.py
@@ -0,0 +1,37 @@
+"""Unified-runtime cron fires share one Codex prompt-cache scope per job (#139434)."""
+
+import pytest
+
+from agent.transports import get_transport
+
+
+def transport():
+ import agent.transports.codex
+ return get_transport("codex_responses")
+
+
+def test_cache_key_stable_for_unified_cron_session_ids(transport):
+ """A scheduler admission, not the opaque local physical id, scopes cron cache reuse."""
+ from gateway.session_cron import _execution
+
+ messages = [{"role": "user", "content": "Hi"}]
+
+ def build(sid):
+ return transport.build_kwargs(model="gpt-5.4", messages=messages, tools=[], session_id=sid)
+
+ token = _execution.set((object(), "local-first-fire", "job42", "fire-1"))
+ try:
+ first = build("local-first-fire")
+ _execution.set((object(), "local-second-fire", "job42", "fire-2"))
+ second = build("local-second-fire")
+ # A session that is not the bound admission (e.g. a delegated child) keeps its own scope.
+ child = build("local-child-of-fire")
+ _execution.set((object(), "local-other-job", "job99", "fire-3"))
+ other = build("local-other-job")
+ finally:
+ _execution.reset(token)
+
+ assert first["prompt_cache_key"] == second["prompt_cache_key"]
+ assert first["prompt_cache_key"] != other["prompt_cache_key"]
+ assert child["prompt_cache_key"] != first["prompt_cache_key"]