Skip to content

The agent that grows with you

refactor(compression): import the codex cooldown lookup at module level

kshitijk4poor5b3c8b3240c8
diff --git a/agent/client_lifecycle.py b/agent/client_lifecycle.py
index 892ac952165..4ce4e539d01 100644
--- a/agent/client_lifecycle.py
+++ b/agent/client_lifecycle.py
@@ -930,7 +930,6 @@ class ClientLifecycleMixin:
rt[k] = new_token
# The turn's aux runtime was published before the first request triggered this refresh, so
# same-turn `auto` aux calls (approvals, goal judge, plugin llm) would still send the revoked token.
- # Mutated in place: the refresh may run in a request worker's copied Context.
from agent.auxiliary_key_rotation import rotate_runtime_main_api_key
rotate_runtime_main_api_key(old_token, new_token)
return True
diff --git a/agent/conversation_compression.py b/agent/conversation_compression.py
index 9edc9711b64..7f7e0281d05 100644
--- a/agent/conversation_compression.py
+++ b/agent/conversation_compression.py
@@ -30,6 +30,7 @@ from typing import Any, Callable, Dict, List, Literal, Optional, Tuple
from agent.auxiliary_client import AuxiliaryExplicitCancellation
from agent.context_engine import automatic_compaction_status_message, sanitize_memory_context
+from agent.conversation_compression_codex import _codex_compaction_cooldown_remaining
from agent.conversation_compression_telemetry import _emit_aborted_attempt_telemetry, _emit_compression_attempt_telemetry
from agent.memory_provider import PRE_COMPRESS_CHECKPOINT_API_VERSION
from agent.model_metadata import estimate_messages_tokens_rough, estimate_request_tokens_rough
@@ -4329,7 +4330,6 @@ def _compress_context_via_codex_app_server(
elif not force:
# Automatic entrypoints honor the compressor-owned cooldown: a recent compaction
# failed, and retrying every turn is what thrashes.
- from agent.conversation_compression_codex import _codex_compaction_cooldown_remaining
_cooldown_remaining = _codex_compaction_cooldown_remaining(agent)
if _cooldown_remaining > 0:
skip_reason = f"failure cooldown active for {_cooldown_remaining:.0f}s"
diff --git a/agent/conversation_compression_codex.py b/agent/conversation_compression_codex.py
index 5db8b095f41..b1700cfae93 100644
--- a/agent/conversation_compression_codex.py
+++ b/agent/conversation_compression_codex.py
@@ -1,6 +1,6 @@
"""Codex app-server compaction cooldown lookup.
-Sibling of ``agent/conversation_compression.py`` (the facade), which late-imports it at its call site;
+Split from ``agent/conversation_compression.py`` (facade size cap), which imports it at module level;
this module must never import the facade (import cycle). It logs under the facade's logger name so log
consumers keep one source.
"""