Skip to content

fix(agents): keep provider local service readiness and stop budgets on the monotonic clock - #182778

Merged
obviyus merged 4 commits into
openclaw:mainfrom
mikasa0818:fix/problem-provider-local-service-monotonic-readiness
Oct 26, 2026
Merged

obviyus merged 4 commits into
openclaw:mainfrom
mikasa0818:fix/problem-provider-local-service-monotonic-readiness

Conversation

@mikasa0818

@mikasa0818 mikasa0818 commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Local provider readiness and process-stop deadlines used wall-clock time. A backward clock correction extended configured timeouts; a forward correction prematurely expired them. Use monotonic elapsed time for these deadlines without changing their configured budgets or settlement behavior.

The regression test now uses the existing local-service fixture's claimPort(), retaining the reservation until managed-child shutdown finishes instead of releasing a getFreePort() reservation before startup.

Evidence

Built the shipped Gateway and CLI on main (bdf12f6b6b1235f10ee361687e0c32db94dd3a6b) and this candidate. A configured local provider served real HTTP readiness responses and Responses inference. Only the Gateway process's Date.now() was stepped; system time, timers, and monotonic clocks were unchanged. Every recorded case required an owned child spawn, an HTTP probe, and child close.

  • Backward five-second step, twice per ref: a 1.5-second readiness budget took 6.75–6.78 seconds on main versus 1.69–1.70 seconds on the candidate, including probe/startup overhead. Both emitted the readiness failure and closed the child.
  • Backward step after SIGTERM, twice per ref: the two-second grace window reached SIGKILL in 7.00–7.05 seconds on main versus 2.05–2.06 seconds on the candidate; child close followed within 11 ms.
  • No-step controls on both refs preserved approximately 1.66-second readiness failure and two-second shutdown escalation.
  • Forward five-second controls: main prematurely stopped readiness at 0.58 seconds and escalated shutdown after 30 ms; the candidate retained approximately 1.55-second readiness and two-second shutdown budgets.
  • All healthy-readiness/shutdown cases completed an actual agent request with the local provider's LOCAL_CLOCK_OK response before idle shutdown. These Linux signal/close observations do not claim native Windows taskkill coverage.

The focused local-service, monotonic, settlement, and shutdown suites pass: 30 tests across four files. The existing failed one-shot-host subprocess fixture now accelerates performance.now() rather than Date.now(), preserving real child cleanup without a 60-second readiness wait. Its previous clock-domain mismatch reproduced on the first candidate and passed on main; adapting the fixture resolves it. Formatting and lint checks pass for all six changed files.

Compatibility and Merge Danger

No configuration, persisted state, or public API changes. This is a two-way door: reverting restores wall-clock deadline behavior. The blast radius is configured local-provider readiness and managed-process shutdown; inference transports and unrelated provider selection are unchanged.

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Oct 24, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 24, 2026
@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR uses monotonic time for local-provider readiness and process-stop deadlines while adapting clock-dependent tests.

Example: The wall clock moves backward five seconds during a 1.5-second readiness budget.

  • Before: Supplied Gateway runs fail readiness and close the child after approximately 6.75 seconds.
  • After: Supplied candidate runs fail readiness and close the child after approximately 1.70 seconds.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused repair with supplied shipped-entry-point proof, all prior findings resolved, and no new actionable defects; exact-head CI remains pending.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Supplied built Gateway/CLI results exercise configured local-provider HTTP readiness and actual Responses inference, forward and backward Date.now steps during readiness and shutdown, unchanged-clock controls, bounded escalation, and child close; native Windows execution is expressly outside the supplied coverage.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A system clock correction can make local-model startup or shutdown expire too early or wait beyond its intended budget.
Reason: The patch restores elapsed-time timeout behavior through existing owners without introducing configuration, persistence, public APIs, or additional lifecycle machinery.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current-main deadline bug, resolves the prior findings, and has no remaining actionable review findings; exact-head CI is still pending.

Priority: P2
Reviewed head: 4dabdf88678f44ea3a18f2909624e8efc97c9113

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The committed readiness regression's red-on-base run is not explicitly reported, although supplied shipped Gateway runs demonstrate the defect before the fix.
Agent review details

How this fits together

Provider requests acquire leases from the shared local-service owner, which starts configured processes, probes HTTP readiness, and joins process-tree cleanup.

flowchart TD
  A[Provider request] --> B[Local service acquisition]
  B --> C[Configured child process]
  B --> D[HTTP readiness probes]
  D --> E[Lease or timeout]
  E --> F[Process tree cleanup]
Loading

Technical review

Best possible solution:

Keep the focused monotonic deadline replacement and its adapted lifecycle fixtures, then land after the existing exact-head gates pass.

Do we have a high-confidence way to reproduce the issue?

Current-main deadline arithmetic establishes the failure mechanism, corroborated by supplied Gateway before/after runs; this read-only review executed no target code.

Is this the best way to solve the issue?

Changing deadline seeds and comparisons in the existing owners is the smallest complete fix, preserving configured budgets, cleanup ordering, and diagnostic timestamps.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 95a3ccde1410.

Provenance checked

  • Readiness deadline normalization keeps the original intent (8ff61be: Normalize and cap configured local-service timers; the reviewed historical diff retains the existing readiness budget.)
  • Process cleanup ownership keeps the original intent (3e68350: Join local-provider child cleanup before releasing ownership.)
  • Windows termination-helper settlement keeps the original intent (fix(agents): avoid false managed local-model shutdown failures #171587: Prevent final exit observation from outrunning the bounded Windows taskkill helper.)
  • Failed one-shot-host fixture acceleration keeps the original intent (improve(tests): accelerate local service timeout fixture #118104: Accelerate the nested host's readiness deadline while preserving real child cleanup and diagnostic-pipe coverage.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 3e68350 adds src/agents/provider-local-service-process.ts:78 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 3e68350c7cd4; files: src/agents/provider-local-service-process.ts)
  • Vincent Koc: Raw commit 84393be adds src/agents/provider-local-service.ts:248 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 84393bea7a7b; files: src/agents/provider-local-service.ts)

PR surface

Source +7, Tests +60. Total +67 across 6 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 2 12 5 +7
Tests 4 66 6 +60
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 78 11 +67

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Clock corrections can prematurely expire or extend managed local-provider startup and shutdown, with limited blast radius.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-10-24T18:50:44.652Z sha cee1a10d73dfe9bb2dc1dd2372bd84222569c52b :: needs real behavior proof before merge. :: [P2] Advance the monotonic clock in existing shutdown fixtures | [P3] Retain a port claim for the spawned regression server
  • reviewed 2026-10-26T05:25:59.668Z sha ee8ea53 :: needs changes before merge. :: [P2] Advance the clock used by the failed one-shot-host fixture

Reviewed October 26, 2026, 1:35 AM ET / 05:35 UTC (Revision 3).

@mikasa0818
mikasa0818 force-pushed the fix/problem-provider-local-service-monotonic-readiness branch from cee1a10 to c6b5526 Compare October 24, 2026 20:30
@mikasa0818

Copy link
Copy Markdown
Contributor Author

Fixed the checks-node-changed-3 failure: the settlement/shutdown suites drive the service lifecycle with fake timers + faked Date but did not fake performance, so the stop deadlines that now run on performance.now() never advanced under advanceTimersByTimeAsync. Added "performance" to their toFake lists; the three suites pass locally (10 passed, 1 skipped).

@obviyus

obviyus commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 26, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 26, 2026
@obviyus

obviyus commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 26, 2026
@obviyus
obviyus merged commit 815a9bd into openclaw:main Oct 26, 2026
131 of 133 checks passed
@obviyus

obviyus commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Landed in 815a9bd. Thanks @mikasa0818. Local provider deadlines now ignore wall-clock jumps.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
…n the monotonic clock (openclaw#182778)

fix(agents): use monotonic time for local provider readiness and stop deadlines

Configured local providers measured their readiness and process-stop deadlines with the wall clock, so a backward clock correction stretched those waits well past their budgets. The deadlines now use monotonic time.

Evidence: built Gateway and CLI with a configured local provider, with the wall clock shifted back inside the process under test only (the system clock was not touched). Readiness took 6.75-6.78s on main and 1.69-1.70s with this change; the SIGTERM-to-SIGKILL stop took 7.00-7.05s on main and 2.05-2.06s with this change. Runs without a clock step or with a forward step behave the same on both refs, and real local inference still works. The regression fixture now holds its port reservation through child launch and shutdown. Production about 17 lines.

Thanks @mikasa0818.

Co-authored-by: Ayaan Zaidi <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 28, 2026
…n the monotonic clock (#182778)

fix(agents): use monotonic time for local provider readiness and stop deadlines

Configured local providers measured their readiness and process-stop deadlines with the wall clock, so a backward clock correction stretched those waits well past their budgets. The deadlines now use monotonic time.

Evidence: built Gateway and CLI with a configured local provider, with the wall clock shifted back inside the process under test only (the system clock was not touched). Readiness took 6.75-6.78s on main and 1.69-1.70s with this change; the SIGTERM-to-SIGKILL stop took 7.00-7.05s on main and 2.05-2.06s with this change. Runs without a clock step or with a forward step behave the same on both refs, and real local inference still works. The regression fixture now holds its port reservation through child launch and shutdown. Production about 17 lines.

Thanks @mikasa0818.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit 815a9bd)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 72995431b55a2cd70f8e5065ece51cf27b9076d5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants