fix: drop the redundant _request_is_current() from the first-event stamp guard

_on_event is only ever installed as on_event=_fenced(_on_event), and _fenced
already refuses every call once the request is retired, so the inner predicate
could never be false when reached. Comment now points at the fence.
This commit is contained in:
teknium1
2026-09-19 01:17:19 -07:00
committed by Teknium
parent 34ca29ad73
commit 68ef35deec

View File

@@ -951,9 +951,9 @@ def run_codex_stream(agent, api_kwargs: dict, client: Any = None, on_first_delta
def _on_event(event: Any) -> None: # TTFB/activity touch — once per SSE event.
now = time.time()
# Lifecycle frames can precede text, so the first accepted parsed event is the Responses
# equivalent of Chat Completions' first chunk. Preserve the per-attempt reset and never let
# a retired worker overwrite the timestamp owned by a newer request.
if getattr(agent, "_last_api_first_chunk_at", None) is None and _request_is_current():
# equivalent of Chat Completions' first chunk. Preserve the per-attempt reset; the ``_fenced``
# wrapper around this callback already keeps a retired worker from overwriting a newer request.
if getattr(agent, "_last_api_first_chunk_at", None) is None:
agent._last_api_first_chunk_at = now
has_progress = _codex_event_has_content(event)
if watchdog_state is not None: