The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(agent): drop the write-only agent-level codex watchdog timestamps
kshitijk4poor3ac671dbba0b
diff --git a/agent/chat_completion_helpers.py b/agent/chat_completion_helpers.pyindex 1f388c1abb5..687ef025758 100644--- a/agent/chat_completion_helpers.py+++ b/agent/chat_completion_helpers.py@@ -1223,12 +1223,8 @@ class _NonStreamRequest:def _codex_watchdog_snapshot(self):state = self.codex_watchdog_state- if state is None:- return (- getattr(self.agent, "_codex_stream_last_event_ts", None),- getattr(self.agent, "_codex_stream_last_progress_ts", None),- None,- )+ if state is None: # non-codex request: no watchdog reads these+ return (None, None, None)with state.lock:return state.last_event_ts, state.last_progress_ts, state.retry_started_ts@@ -1325,8 +1321,6 @@ class _NonStreamRequest:if wd.codex:# Reset before the worker starts so a marker left over from a previous# call on this agent can't be misread as the first event for this one.- agent._codex_stream_last_event_ts = None- agent._codex_stream_last_progress_ts = Nonewith self.codex_watchdog_state.lock:self.codex_watchdog_state.last_event_ts = Noneself.codex_watchdog_state.last_progress_ts = Nonediff --git a/agent/codex_runtime.py b/agent/codex_runtime.pyindex 43d1ba49713..2a5d271d36f 100644--- a/agent/codex_runtime.py+++ b/agent/codex_runtime.py@@ -889,10 +889,6 @@ def run_codex_stream(agent, api_kwargs: dict, client: Any = None, on_first_deltawatchdog_state.last_event_ts = nowif has_progress:watchdog_state.last_progress_ts = now- else: # legacy callers without a request-local state (aux/streaming fallback)- agent._codex_stream_last_event_ts = now- if has_progress:- agent._codex_stream_last_progress_ts = nowagent._touch_activity("receiving stream response")def _interrupt_or_superseded() -> bool:diff --git a/tests/agent/test_codex_ttfb_watchdog.py b/tests/agent/test_codex_ttfb_watchdog.pyindex a6e80a869fe..daf663400de 100644--- a/tests/agent/test_codex_ttfb_watchdog.py+++ b/tests/agent/test_codex_ttfb_watchdog.py@@ -8,7 +8,7 @@ retry loop can reconnect promptly. Once any stream event arrives, the TTFBwatchdog is satisfied and a separate idle watchdog handles streams that stopemitting SSE events.-Parsed-event activity is recorded in ``agent._codex_stream_last_event_ts``;+Parsed-event activity is recorded on the request-local watchdog state;substantive model progress is recorded separately. For the implicit officialOpenAI Codex policy on large contexts, lifecycle frames satisfy TTFB withoutarming the short post-progress idle budget. Small requests, explicit overrides,@@ -260,7 +260,6 @@ def test_ttfb_does_not_kill_when_events_flow(tmp_path, monkeypatch):state = _codex_watchdog_state_var.get()with state.lock:state.last_event_ts = now- agent._codex_stream_last_event_ts = nowif on_first_delta:on_first_delta()time.sleep(0.9)