mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-10-26 21:26:39 +00:00
The LLM error-handling middleware's circuit breaker stored its recovery deadline as time.time() + recovery_timeout_sec and fast-failed while time.time() < _circuit_open_until. That is a duration deadline measured on the wall clock, so a backward wall-clock step (NTP correction, VM resume, manual change) while the circuit is open holds the fast-fail window open far past recovery_timeout_sec -- shedding every LLM call until the clock catches up -- while a forward jump ends it early. Measure the recovery window with time.monotonic() instead, matching the rest of the harness (task_tool deadlines, batch lease renewal, guardrail TTLs, secret-file settle windows, journal latency). The clock is held on the instance so tests can inject a deterministic one. The adjacent Retry-After math stays on time.time(): it computes target.timestamp() - time.time() for an absolute HTTP-date, which is genuinely wall-clock. Add two regression tests (an injected-clock recovery test and a backward wall-clock-step test) that go red without the fix, and update the two existing recovery tests to drive the breaker through the same injectable clock seam instead of patching time.time. Signed-off-by: CorgiBoyG <111257566+CorgiBoyG@users.noreply.github.com>