Skip to content

fix(gateway): Models page never shows provider usage and re-probes providers on every load - #174741

Merged
obviyus merged 1 commit into
mainfrom
perf/models-rpc-latency
Oct 16, 2026
Merged

obviyus merged 1 commit into
mainfrom
perf/models-rpc-latency

Conversation

@obviyus

@obviyus obviyus commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: the Models page never shows provider usage, and every page load re-runs provider usage probes, when models.authStatus and usage.status are requested together (as the page does).

User Impact

User impact: provider usage appears on the Models page on load. Provider usage endpoints are polled once per 60 s cache window per provider set instead of on every page load.

Why This Change Was Made

Both RPCs share one provider-usage cache entry and one in-flight refresh per agent. They ask for different provider sets: models.authStatus asks for providers with refreshable credentials, and usage.status asks for every usage-capable provider. When they ran together, each read missed the other's entry and started a refresh that superseded the other's in-flight refresh, so the earlier result was discarded. The result:

  • usage.status answered { providers: [], refreshing: true } on every load.
  • models.authStatus carried no usage.
  • Each load re-resolved auth and plugin runtime for every usage provider, and probed provider endpoints.

The cache now keeps one entry and one in-flight refresh per provider set within each agent. Nothing else changes: TTL, credential-bound invalidation, cold-read markers and stale-while-revalidate stay as they were.

a21f235 (#115369) intended the two readers to share this cache. A later change gave them different provider sets.

Evidence

Isolated Gateway on a copy of a real state directory: outbound network denied, base and fix run ABAB on the same restored state.

  • Work count (alternating usage.status / models.authStatus, 8 calls): outbound usage probes on 7 of 8 calls (base) vs only on the first refresh of each provider set (fix).
  • Responses after identical warm-up: agents.list, config.get, models.list and sessions.usage are identical. usage.status now returns the provider snapshots instead of refreshing: true. models.authStatus providers now carry usage.
  • Serial p50 over 20 calls, two rounds: usage.status 4.9/4.3 ms → 0.8/1.0 ms. models.list 30.5/27.2 ms → 2.2/2.5 ms; the per-call refresh was also blocking it on the main thread. The host was heavily loaded, so treat wall times as indicative only.
  • CPU profile: the per-load resolveProviderRuntimePlugin → applyPluginAutoEnable frames (~100 ms main thread per page load) are gone from steady-state page loads.
  • Tests: new regression refreshes each provider set once per TTL when page reads interleave fails on base (4 refreshes in 3 loads) and passes with the fix (2). usage.status-cache, usage-cache and models-auth-status suites pass (66 tests).

…ther's provider usage

Both RPCs share one provider-usage entry per agent but request different
provider sets (refreshable credentials vs every usage descriptor). On the
Models page they run together, so each read missed, started a refresh, and
superseded the other's in-flight refresh. Every page load re-resolved
provider auth and plugin runtime for every usage provider and probed
provider usage endpoints, and usage.status answered refreshing:true.

Keep one entry and one in-flight refresh per provider set.
@clawsweeper

clawsweeper Bot commented Oct 16, 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.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 4a566fb87d1dd9050a0251bdde4f8f0dc0717be3
  • Maintainer: @obviyus
  • Repository role: admin

These security sensitive changes were made:

  • src/gateway/server-methods/models-auth-status-usage-cache.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Oct 16, 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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 16, 2026
@clawsweeper

clawsweeper Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR caches provider usage and coalesces refreshes separately for each provider set within an agent.

Example: Agent main requests OpenAI usage through models.authStatus and OpenAI plus Anthropic through usage.status.

  • Before: The two provider sets replace each other's cached results and in-flight refreshes, causing repeated probes and incomplete usage responses.
  • After: Each provider set retains its own result and refresh, allowing subsequent reads within 60 seconds to reuse usage snapshots.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused implementation is sound and exact-head CI passes; runtime confidence relies on the maintainer's detailed Gateway report without an attached trace.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; its body reports isolated Gateway verification of interleaved status reads, while independently inspectable evidence consists of source and regression tests rather than captured runtime output.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: The Models page repeatedly probes provider usage and can remain without usage snapshots when its status readers request different provider sets.
Reason: The maintainer-authored change restores the shared cache's intended behavior with a narrow implementation and no new user-facing policy.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it fixes a current-main cache collision with a focused change, no introduced defects found, and passing exact-head CI.

Priority: P2
Reviewed head: 4a566fb87d1dd9050a0251bdde4f8f0dc0717be3

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The body reports shipped-Gateway ABAB verification, but no raw RPC or probe trace is attached for independent inspection.
Agent review details

How this fits together

The Gateway's shared provider-usage cache receives agent, configuration, credential, and provider-set identities from status RPCs and returns cached snapshots while coordinating provider HTTP refreshes.

flowchart TD
  A[Models page] --> B[models.authStatus]
  A --> C[usage.status]
  B --> D[Shared agent and provider set cache]
  C --> D
  D --> E[Provider usage loader]
  E --> F[Provider endpoints]
  E --> D
Loading

Technical review

Best possible solution:

Retain this focused repair in the shared cache owner while preserving credential invalidation, lifecycle ownership, and existing cold-read contracts.

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

Current-main source shows differing provider sets competing for a single per-agent entry and refresh; the author additionally reports Gateway ABAB reproduction, which this read-only review did not execute.

Is this the best way to solve the issue?

Partitioning the existing owner's cache and refresh maps by the already-defined provider key fixes the collision without introducing another cache owner or changing RPC contracts.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Shared usage caching and provider-set matching keeps the original intent (a21f235: Reuse the existing credential-aware 60-second cache across usage.status and models.authStatus to eliminate repeated provider HTTP work.)
  • Refresh publication and cleanup ownership keeps the original intent (0d830e9: Keep background refresh publication and finalization inside their tracked work lifetime; the later cleanup retained exact refresh identity.)
  • Nonblocking and blocking cold-read paths keeps the original intent (e9620fb: Return an incomplete marker only to capable clients with bounded retry while preserving blocking reads for other consumers.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit a21f235 adds src/gateway/server-methods/models-auth-status-usage-cache.ts:283 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a21f235fde07; files: src/gateway/server-methods/models-auth-status-usage-cache.ts)
  • Sasan: Raw commit e9620fb adds src/gateway/server-methods/models-auth-status-usage-cache.ts:282 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e9620fba9db4; files: src/gateway/server-methods/models-auth-status-usage-cache.ts)

PR surface

Source +12, Tests +27. Total +39 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 23 11 +12
Tests 1 27 0 +27
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 50 11 +39

Labels

Label changes:

  • add P2: Missing auxiliary provider usage and repeated provider probes affect the Models page without establishing a blocked core agent workflow.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Missing auxiliary provider usage and repeated provider probes affect the Models page without establishing a blocked core agent workflow.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach redacted RPC responses and probe counts from the reported Gateway ABAB run to make its runtime result independently inspectable.

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.

Reviewed October 16, 2026, 6:21 PM ET / 22:21 UTC.

@obviyus

obviyus commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator Author

Runtime evidence from the ABAB Gateway run. Isolated Gateway on a copied state directory, outbound network denied, same restored state for each run. Provider names are the rig's two credentialed usage providers.

Outbound usage probes (socket connects, main thread). Each probe is one usage.status call followed by one models.authStatus call, 3 s apart, after a page warm-up:

run probe 1 probe 2 probe 3 probe 4
base round 1 0 / 2 2 / 2 2 / 2 2 / 2
fix round 1 0 / 0 2 / 2 0 / 0 0 / 0
base round 2 0 / 2 2 / 2 2 / 2 2 / 2
fix round 2 0 / 0 2 / 2 0 / 0 0 / 0

On base every call re-probes. With the fix, each provider set refreshes once inside the 60 s window: the warm-up refreshed one set, probe 2 refreshed the other, then nothing.

Responses after identical warm-up (semantic diff, time fields ignored, base → fix):

agents.list        IDENTICAL
config.get         IDENTICAL
models.list        IDENTICAL
sessions.usage     IDENTICAL
models.authStatus  .providers[0].usage: + {"providerId": "github-copilot", "windows": []}
                   .providers[2].usage: + {"providerId": "xai", "windows": []}
usage.status       .providers: len 0 -> 2
                   .refreshing: - true

On base, usage never arrives on the page (refreshing: true forever, no usage on auth providers). With the fix, both RPCs carry it. windows is empty only because the rig denies provider network.

@obviyus
obviyus merged commit c3f0b6a into main Oct 16, 2026
118 checks passed
@obviyus
obviyus deleted the perf/models-rpc-latency branch October 16, 2026 22:23
@obviyus

obviyus commented Oct 16, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in c3f0b6a.

  • Bug: usage.status and models.authStatus evicted each other's provider-usage cache entry and superseded each other's refresh. The Models page never showed provider usage, and every load re-probed provider usage endpoints.
  • Fix: one cache entry and one in-flight refresh per provider set, per agent.
  • Proof: ABAB Gateway run on copied state (probe counts and response diff above), plus a regression test that fails on base (4 refreshes) and passes with the fix (2). CI green, ClawSweeper ready at the merged head.

obviyus added a commit that referenced this pull request Oct 16, 2026
)

## What Problem This Solves

Fixes: agents keep shipping caches whose key leaves out an input that changes the answer. Callers then collide, serve another agent's or account's data, return stale results, or never hit the cache. No rule in `AGENTS.md` covers cache keys.

## User Impact

No user-visible change. Agents get one rule that tells them what a cache key must contain and how to prove sharing is safe.

## Why This Change Was Made

The rule adds one line under "Runtime and code safeguards":
- key caches, memos, in-flight joins and shared snapshots by scope and request shape;
- give callers asking different questions separate slots;
- keep volatile values out of keys;
- prove sharing with a work-count test where differing callers interleave.

#174741 is the trigger. `usage.status` and `models.authStatus` shared one provider-usage slot per agent but asked for different provider sets. They evicted each other on every Models page load for 80 days, across 7 refactor passes, because no test interleaved the two callers.

## Evidence

I reviewed main since 2026-04-01: every `fix` commit whose diff touched cache-key, cache get/set or in-flight lines (728 commits). Each one was judged by reading its message and diff. **95 fixed a cache identity bug.** That is about 3 per week, steady every month (Apr 14, May 13, Jun 8, Jul 15, Aug 18, Sep 16, Oct 1–16 11).

| Kind | Count | Example |
|---|---|---|
| Key omits an input, so the answer is stale or wrong | 35 | 276ba10: markdown render cache ignored `codeBlockChrome` |
| Data leaks across agent, account or credential scope | 23 | 6a12c6f: run→session lookup keyed by `runId` only; 1487b45: GitHub previews shared across credentials; 51042e8: cron deliveries routed to the wrong agent |
| Different callers collide or evict each other | 14 | c3f0b6a (#174741); f8380a8: route keys with separators collided |
| Key too volatile, so it never hits | 14 | 3f9d241: prompt-cache key was the per-run session id |
| In-flight join dedups unrelated work | 9 | 2aabde7: deep health probe joined a passive refresh; 4ca63cb: dispatch joined a different `executionMode` |

23 of the 95 were data leaks across scopes, so this is a correctness and privacy issue, not only performance.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
…oviders on every load (openclaw#174741)

## What Problem This Solves

Fixes: the Models page never shows provider usage, and every page load re-runs provider usage probes, when `models.authStatus` and `usage.status` are requested together (as the page does).

## User Impact

User impact: provider usage appears on the Models page on load. Provider usage endpoints are polled once per 60 s cache window per provider set instead of on every page load.

## Why This Change Was Made

Both RPCs share one provider-usage cache entry and one in-flight refresh per agent. They ask for different provider sets: `models.authStatus` asks for providers with refreshable credentials, and `usage.status` asks for every usage-capable provider. When they ran together, each read missed the other's entry and started a refresh that superseded the other's in-flight refresh, so the earlier result was discarded. The result:
- `usage.status` answered `{ providers: [], refreshing: true }` on every load.
- `models.authStatus` carried no `usage`.
- Each load re-resolved auth and plugin runtime for every usage provider, and probed provider endpoints.

The cache now keeps one entry and one in-flight refresh per provider set within each agent. Nothing else changes: TTL, credential-bound invalidation, cold-read markers and stale-while-revalidate stay as they were.

`d24100c` (openclaw#115369) intended the two readers to share this cache. A later change gave them different provider sets.

## Evidence

Isolated Gateway on a copy of a real state directory: outbound network denied, base and fix run ABAB on the same restored state.

- **Work count** (alternating `usage.status` / `models.authStatus`, 8 calls): outbound usage probes on 7 of 8 calls (base) vs only on the first refresh of each provider set (fix).
- **Responses after identical warm-up:** `agents.list`, `config.get`, `models.list` and `sessions.usage` are identical. `usage.status` now returns the provider snapshots instead of `refreshing: true`. `models.authStatus` providers now carry `usage`.
- **Serial p50 over 20 calls, two rounds:** `usage.status` 4.9/4.3 ms → 0.8/1.0 ms. `models.list` 30.5/27.2 ms → 2.2/2.5 ms; the per-call refresh was also blocking it on the main thread. The host was heavily loaded, so treat wall times as indicative only.
- **CPU profile:** the per-load `resolveProviderRuntimePlugin` → `applyPluginAutoEnable` frames (~100 ms main thread per page load) are gone from steady-state page loads.
- **Tests:** new regression `refreshes each provider set once per TTL when page reads interleave` fails on base (4 refreshes in 3 loads) and passes with the fix (2). `usage.status-cache`, `usage-cache` and `models-auth-status` suites pass (66 tests).

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 17, 2026
…claw#174837)

## What Problem This Solves

Fixes: agents keep shipping caches whose key leaves out an input that changes the answer. Callers then collide, serve another agent's or account's data, return stale results, or never hit the cache. No rule in `AGENTS.md` covers cache keys.

## User Impact

No user-visible change. Agents get one rule that tells them what a cache key must contain and how to prove sharing is safe.

## Why This Change Was Made

The rule adds one line under "Runtime and code safeguards":
- key caches, memos, in-flight joins and shared snapshots by scope and request shape;
- give callers asking different questions separate slots;
- keep volatile values out of keys;
- prove sharing with a work-count test where differing callers interleave.

openclaw#174741 is the trigger. `usage.status` and `models.authStatus` shared one provider-usage slot per agent but asked for different provider sets. They evicted each other on every Models page load for 80 days, across 7 refactor passes, because no test interleaved the two callers.

## Evidence

I reviewed main since 2026-04-01: every `fix` commit whose diff touched cache-key, cache get/set or in-flight lines (728 commits). Each one was judged by reading its message and diff. **95 fixed a cache identity bug.** That is about 3 per week, steady every month (Apr 14, May 13, Jun 8, Jul 15, Aug 18, Sep 16, Oct 1–16 11).

| Kind | Count | Example |
|---|---|---|
| Key omits an input, so the answer is stale or wrong | 35 | ec1fe7a: markdown render cache ignored `codeBlockChrome` |
| Data leaks across agent, account or credential scope | 23 | 62706db: run→session lookup keyed by `runId` only; 61cfec6: GitHub previews shared across credentials; 07fdf40: cron deliveries routed to the wrong agent |
| Different callers collide or evict each other | 14 | c373547 (openclaw#174741); 6a9b2cb: route keys with separators collided |
| Key too volatile, so it never hits | 14 | 39dd2bb: prompt-cache key was the per-run session id |
| In-flight join dedups unrelated work | 9 | 5db8377: deep health probe joined a passive refresh; 153d5a8: dispatch joined a different `executionMode` |

23 of the 95 were data leaks across scopes, so this is a correctness and privacy issue, not only performance.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Oct 19, 2026
…ession tests (#176630)

## What Problem This Solves

Performance work in OpenClaw keeps fixing the same waste twice: caches that stop hitting, batches that get reverted, and PRs that land with a regression their own numbers already show. Agents had no repository guide for this work, and three flows where the same waste keeps returning had no test that counts it.

## User Impact

No user-visible change. Agents doing performance work now have one OpenClaw skill: measure the real flow with a committed workload, count operations first, delete waste before batching or caching, and land only when every user-facing metric holds or improves. Three work-count tests fail CI if known waste comes back.

## Why This Change Was Made

A corpus of 103 performance cases from the last 90 days on `main` (70 randomly sampled, 33 seeded with every perf revert; each judged from its diff and PR text):

- **Deleting waste lasts:** 3 of 31 random-sample deletes were later re-fixed, and those failed deletes broke a guard, not because the waste returned.
- **Caches, batches and worker moves come back:** 4 of 5, 6 of 7 and 5 of 8 were later re-fixed (biased set, a signal not a rate). In 3 of the 4 cache re-fixes the cache silently stopped hitting, e.g. #115369 → #174741 and #149773 → #149879.
- **Own regressions predict reverts:** 21 PRs landed while their own numbers showed a large regression; 11 of them were later reverted or re-fixed, against 25 of the other 82. Five of the six reverts had shown the regression in their own body.
- **Same waste, again and again:** SQLite schema/admission re-checks (14 PRs, one revert), session list rows (two reverts in two days), model catalog rebuilds.

Changes:

- `.agents/skills/openclaw-performance/SKILL.md`: measure (committed bench per flow, counts first, acceptance rule before the first run, interleaved samples), find waste (10 recurring OpenClaw patterns with real cases), fix order (delete → once at the owner → carry the prepared fact → batch → cache with a written reason, cache-identity rules and an interleaved work-count test), land (no user-facing metric worse unless the owner accepts it).
- Root `AGENTS.md`: the "Do less work" line keeps its core rule and points to the skill.
- Work-count tests (counts, never wall time):
  - `src/state/openclaw-agent-execution.schema-admission.test.ts`: warm chat turns make only their own write requests; no re-open, schema prepare or integrity validation.
  - `src/gateway/session-row-projection.list-page.test.ts`: after an unrelated subagent renewal, repeating the same pages renders 0 rows, materializes 0 more and does 0 worker reads or SQL.
  - `src/gateway/server-methods/models-auth-status.work-count.test.ts` (own file, to keep the existing test under its line cap): interleaved `models.authStatus` and `usage.status` page loads add no provider probes, auth-health builds or catalog loads after warm-up.

## Evidence

| Test | Back-test (parent of the historical fix) |
|---|---|
| Schema admission | fails at `8b7917c79b8^` (#166253): each warm turn adds `open` and `prepare` again |
| Session list | fails at `1b896e6327f^` (#162280): 80 rows materialized instead of 10, plus 1 worker read |
| Models page | fails at `c3f0b6abc01^` (#174741): 3 provider probes in 2 loads; the readers evict each other |

- All three pass on head (each file about 0.3–1.7 s); `models-auth-status.test.ts` still passes 52/52. The Models page test still fails at `c3f0b6abc01^` with real-module mocks (one extra provider probe).
- The pre-commit hook (line-cap ratchet, `AGENTS.md` size) passed; root `AGENTS.md` is 18,917 characters.
- Every PR cited by the skill is merged; every named bench script exists on `main`.

Blind replay of 8 held-out performance tasks (none cited by the skill; each from the parent of its known-good fix), Codex agent with and without the skill, 2 seeds; stopped early after 12 judged pairs to free the host:

| | Without skill | With skill |
|---|---|---|
| Pair wins (blind Codex judge) | 3 | 8 (1 tie) |
| Removed the same waste as the reference fix | 11/14 runs | 11/13 runs |
| Proof includes a work-count test | 5/14 | 11/13 |
| Added a cache | 1 | 1 |
| Judge: proof / waste found / fix order (1-5) | 3.08 / 4.50 / 4.83 | 4.33 / 4.42 / 4.50 |

The skill does not change whether agents find the waste; it changes how they prove it, which is what keeps the waste from returning. One judge and 12 pairs: the win split is not significant (p ≈ 0.23).

**Merge danger:** two-way door; a revert removes the skill and the tests. No runtime change. Blast radius: agent instructions for performance work, and three test files.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 19, 2026
…ession tests (openclaw#176630)

## What Problem This Solves

Performance work in OpenClaw keeps fixing the same waste twice: caches that stop hitting, batches that get reverted, and PRs that land with a regression their own numbers already show. Agents had no repository guide for this work, and three flows where the same waste keeps returning had no test that counts it.

## User Impact

No user-visible change. Agents doing performance work now have one OpenClaw skill: measure the real flow with a committed workload, count operations first, delete waste before batching or caching, and land only when every user-facing metric holds or improves. Three work-count tests fail CI if known waste comes back.

## Why This Change Was Made

A corpus of 103 performance cases from the last 90 days on `main` (70 randomly sampled, 33 seeded with every perf revert; each judged from its diff and PR text):

- **Deleting waste lasts:** 3 of 31 random-sample deletes were later re-fixed, and those failed deletes broke a guard, not because the waste returned.
- **Caches, batches and worker moves come back:** 4 of 5, 6 of 7 and 5 of 8 were later re-fixed (biased set, a signal not a rate). In 3 of the 4 cache re-fixes the cache silently stopped hitting, e.g. openclaw#115369 → openclaw#174741 and openclaw#149773 → openclaw#149879.
- **Own regressions predict reverts:** 21 PRs landed while their own numbers showed a large regression; 11 of them were later reverted or re-fixed, against 25 of the other 82. Five of the six reverts had shown the regression in their own body.
- **Same waste, again and again:** SQLite schema/admission re-checks (14 PRs, one revert), session list rows (two reverts in two days), model catalog rebuilds.

Changes:

- `.agents/skills/openclaw-performance/SKILL.md`: measure (committed bench per flow, counts first, acceptance rule before the first run, interleaved samples), find waste (10 recurring OpenClaw patterns with real cases), fix order (delete → once at the owner → carry the prepared fact → batch → cache with a written reason, cache-identity rules and an interleaved work-count test), land (no user-facing metric worse unless the owner accepts it).
- Root `AGENTS.md`: the "Do less work" line keeps its core rule and points to the skill.
- Work-count tests (counts, never wall time):
  - `src/state/openclaw-agent-execution.schema-admission.test.ts`: warm chat turns make only their own write requests; no re-open, schema prepare or integrity validation.
  - `src/gateway/session-row-projection.list-page.test.ts`: after an unrelated subagent renewal, repeating the same pages renders 0 rows, materializes 0 more and does 0 worker reads or SQL.
  - `src/gateway/server-methods/models-auth-status.work-count.test.ts` (own file, to keep the existing test under its line cap): interleaved `models.authStatus` and `usage.status` page loads add no provider probes, auth-health builds or catalog loads after warm-up.

## Evidence

| Test | Back-test (parent of the historical fix) |
|---|---|
| Schema admission | fails at `04c36511d39^` (openclaw#166253): each warm turn adds `open` and `prepare` again |
| Session list | fails at `d13db6a6cc8^` (openclaw#162280): 80 rows materialized instead of 10, plus 1 worker read |
| Models page | fails at `c373547bbbd^` (openclaw#174741): 3 provider probes in 2 loads; the readers evict each other |

- All three pass on head (each file about 0.3–1.7 s); `models-auth-status.test.ts` still passes 52/52. The Models page test still fails at `c373547bbbd^` with real-module mocks (one extra provider probe).
- The pre-commit hook (line-cap ratchet, `AGENTS.md` size) passed; root `AGENTS.md` is 18,917 characters.
- Every PR cited by the skill is merged; every named bench script exists on `main`.

Blind replay of 8 held-out performance tasks (none cited by the skill; each from the parent of its known-good fix), Codex agent with and without the skill, 2 seeds; stopped early after 12 judged pairs to free the host:

| | Without skill | With skill |
|---|---|---|
| Pair wins (blind Codex judge) | 3 | 8 (1 tie) |
| Removed the same waste as the reference fix | 11/14 runs | 11/13 runs |
| Proof includes a work-count test | 5/14 | 11/13 |
| Added a cache | 1 | 1 |
| Judge: proof / waste found / fix order (1-5) | 3.08 / 4.50 / 4.83 | 4.33 / 4.42 / 4.50 |

The skill does not change whether agents find the waste; it changes how they prove it, which is what keeps the waste from returning. One judge and 12 pairs: the win split is not significant (p ≈ 0.23).

**Merge danger:** two-way door; a revert removes the skill and the tests. No runtime change. Blast radius: agent instructions for performance work, and three test files.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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. gateway Gateway runtime security-sensitive-changed size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant