Repository navigation
perf(models): avoid catalog workers for native login rechecks - #166434
Conversation
Observe native CLI login availability through the existing credential preparer and pair it with the published auth store. Keep explicit credential refresh in the worker, coalesce pending native checks, and publish only changed availability while retaining cancellation and generation checks. Add regression coverage for checks without worker requests, login/logout, saved-profile precedence, and retirement. Native checks dispatch zero worker requests instead of one; the synthetic models.list benchmark remains below 200 ms p99.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
|
Codex review: blocked before merge. Reviewed October 6, 2026, 11:49 PM ET / October 7, 2026, 03:49 UTC. ClawSweeper reviewWhat this changesPeriodic native CLI login checks reuse OpenClaw’s credential preparer and published profiles instead of rebuilding authentication through a catalog worker, with regression coverage for freshness, precedence, and retirement. Merge readiness⛔ Blocked before merge - 1 item remains The optimization remains useful: current main still dispatches periodic login checks through the catalog worker. No actionable introduced defect was found, and this maintainer-authored PR should remain open. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s prepared model catalog combines configured models with credential availability for model pickers. Background native-login observations update that availability while explicit credential refresh continues through the catalog worker. flowchart TD
A[Model list request] --> B[Recheck window and pending check]
B --> C[Native CLI availability probe]
D[Current published profiles] --> E[Combine credential availability]
C --> E
E --> F[Current generation and changed availability]
F --> G[Publish model picker update]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +55, Tests +240. Total +295 across 5 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep native availability observation within the existing catalog generation, preserve saved-profile precedence, and reserve worker reconstruction for explicit credential refresh. Do we have a high-confidence way to reproduce the issue? Yes, source establishes that a due current-main native-login check reaches worker-backed authentication refresh; the captured body also reports a failing baseline regression. No runtime reproduction was executed during this read-only review. Is this the best way to solve the issue? Yes, the patch reuses the canonical credential preparer and current catalog owner while retaining explicit worker refresh, bounded checks, and retirement fencing. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 30d563e262aa. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
…aw#166434) Observe native CLI login availability through the existing credential preparer and pair it with the published auth store. Keep explicit credential refresh in the worker, coalesce pending native checks, and publish only changed availability while retaining cancellation and generation checks. Add regression coverage for checks without worker requests, login/logout, saved-profile precedence, and retirement. Native checks dispatch zero worker requests instead of one; the synthetic models.list benchmark remains below 200 ms p99.
What Problem This Solves
Periodic native CLI login checks repeat catalog-worker preparation even when the published model catalog and stored credentials have not changed.
User Impact
Model lists keep detecting external CLI login/logout in the background while reusing the existing catalog across connections. Ordinary native-login checks no longer enter the prepared-model-catalog worker. Provider discovery and explicit credential refresh retain their existing behavior.
Why This Change Was Made
The catalog already belongs to the configured runtime generation; connection IDs do not select a new owner. The remaining minute-based native-login check captured availability in the parent and then dispatched an auth-refresh worker request that reconstructed plugin context and reread stored auth. Reuse the canonical ambient-credential preparer for this observation and pair it with the latest owner-held profiles. Only changed availability publishes; pending checks coalesce and retirement cancels their probe.
Production LOC delta: +55 across four files (tests excluded). The documented native-login freshness contract requires keeping background login/logout detection. Separating that observation from durable credential refresh needs a small generation-scoped preparer and cancellation boundary. The old periodic worker path is removed; explicit credential refresh remains the worker's responsibility. There is no fallback path or new configuration.
Related: #166037.
Evidence
Validated on Blacksmith Testbox
tbx_01m49yskmx42zfegnhxny4ryr1(blacksmith-testbox,openclaw-check):node scripts/run-vitest.mjs src/agents/prepared-model-runtime.native-login.test.ts --maxWorkers=1: 3 passed, 23 ms test time, 22.11 s cold wrapper duration including compiled-worker preparation.node scripts/run-vitest.mjs src/gateway/server-methods/models.prepared.test.ts: 2 passed.node scripts/run-vitest.mjs src/plugins/provider-runtime.synthetic-auth-discovery.test.ts src/agents/agent-auth-discovery.external-cli.test.ts src/agents/prepared-model-runtime.catalog-owner.test.ts: 41 passed.node scripts/run-vitest.mjs src/agents/prepared-model-runtime.native-login.test.ts src/agents/prepared-model-runtime.scoped-refresh.test.ts: lint clean, 22 passed ontbx_01m4a2pgdqchafm5qn358dwe1y; 66.3 s combined remote command. This brings focused coverage to 65 distinct passing tests.OPENCLAW_BENCH_MODELS_LIST=1benchmark through the realmodels.listhandler, 120 requests / 6 concurrent callers: p50 31.32 → 26.96 ms, p99 72.94 → 47.85 ms, two session reads per warm request in both. Both baselines were already below 200 ms; this is a foreground regression guard, not a claim that production tail latency fell by the same amount.node scripts/run-tsgo.mjs -p tsconfig.core.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core.tsbuildinfoand the changed-fileagents-othertest type graph: passed (combined remote command 161.5 s).Independent Codex autoreview returned scoped-clean through P2, with no actionable findings. Subsequent gate cleanup reused the canonical preparation-options type and simplified an equivalent native-scope conditional. The complete staged gate passed with exit 0 on the isolated Linux rig after Testbox remained queued for more than twenty minutes:
node scripts/check-changed.mjs --staged, on base513871f9ca8e072b3af03a739091b34c61ee9048. It checked the exact five-file staged patch, passed all 27 core test type graphs, reported zero lint warnings/errors and zero runtime import cycles, and completed the native-state, database, sidecar, webhook, and pairing guards. No checks were disabled. The full gate ran from 03:03–03:38 UTC on October 7. The commit was then rebased cleanly onto currentmain; stable patch IDs before and after are identical. Published-head CI passed onea96ec1c4ed36619080dbbbd43f7e97b1d05c342in 456 s including admission. The new regression file passed all 3 cases in 60 ms of test time / 7.61 s reported file duration; its containing job took 130 s. The PR merged as0a5311bc95c2b24fb664e9497ac110931f028ab3.The supplied observation has 3,082.4 ms average worker duration at 0.9 tasks/minute and 948.3 ms
models.listp99. Worker telemetry combines discovery and auth-refresh requests, so it does not establish that each slow model-list response awaited discovery. Production p99 after deployment remains unmeasured.