Skip to content

fix(agent): scope preflight token estimates to the compacted window - #150982

Closed
coaiMax wants to merge 23 commits into
openclaw:mainfrom
coaiMax:fix/agent-preflight-compacted-window
Closed

coaiMax wants to merge 23 commits into
openclaw:mainfrom
coaiMax:fix/agent-preflight-compacted-window

Conversation

@coaiMax

@coaiMax coaiMax commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Closes #150579

What Problem This Solves

Fixes: the pre-compaction/budget flush-hook token meter reports a session's prompt size from the retained transcript, including messages already superseded by compaction, so healthy sessions fire spurious budget compactions. Reported effects include an unnecessary compaction with a 15-minute timeout on a healthy session and a compaction lock that queued a live inbound message for minutes and then refused it.

User Impact

Compaction pressure now reflects the active model window — the same scope sessions.list's totalTokens reports — instead of the retained display history. Healthy sessions stop re-firing budget compaction after each pass, and tooling that trusts the meter sees a number that matches live reality. Sessions whose compacted window genuinely exceeds the threshold still compact exactly as before.

Why This Change Was Made

estimatePromptTokensFromSessionTranscript (src/auto-reply/reply/agent-runner-memory.ts) read messages through readSessionMessagesAsync(..., { mode: "full" }), which returns the retained transcript rather than the compacted context the model receives; the estimate therefore grew with superseded history and re-triggered compaction on healthy sessions. The estimator now reads through SessionManager.readSessionContext, whose projection follows the active branch across compaction boundaries, and returns undefined when the session scope (agent id, session key, store path) cannot be resolved instead of reading the wrong scope.

Evidence

Regression tests added in src/auto-reply/reply/agent-runner-memory.preflight-stale-tokens.test.ts:

  • a transcript compacted behind a boundary whose retained display history is far above the threshold, with stale (totalTokensFresh: false) accounting, no longer calls compactEmbeddedAgentSession (on current main the inflated estimate fires compaction),
  • the same harness with the compacted model window itself above the threshold still calls compactEmbeddedAgentSession exactly once, guarding against under-compaction.

Both regression tests are SQLite-backed (real session store and transcript projection, not in-memory mocks): the fixtures write through SessionManager.open(...).appendMessage(...) and a real appendCompaction boundary, then waitForSessionTranscriptProjection lands them before the estimator runs. The compaction call itself is mocked — as in every existing agent-runner-memory.test.ts test — because these tests target the estimator's input boundary, and the estimator now reads through SessionManager.readSessionContext, the same projection that sessions.list's totalTokens reports.

Full CI (pnpm build && pnpm check && pnpm test) will run on this PR.

The preflight compaction estimator read the retained transcript through
readSessionMessagesAsync with mode "full", so superseded history kept the
token count inflated and re-fired budget compaction on healthy sessions.
Read the active model window through SessionManager.readSessionContext
instead, and skip estimation when the session scope cannot be resolved.
@clawsweeper

clawsweeper Bot commented Sep 17, 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.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Sep 17, 2026
@clawsweeper

clawsweeper Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed September 24, 2026, 11:32 AM ET / 15:32 UTC (Revision 13).

ClawSweeper review

What this changes

The branch makes agent preflight compaction estimate tokens from the active session context and adds SQLite-backed regression cases for compacted and oversized windows.

Merge readiness

⛔ Blocked before merge - 2 items remain

Current main still uses retained display history for the preflight estimate, so the reported problem remains relevant. This branch addresses that path, while a competing fix remains open and after-fix agent-turn proof is still needed.

Priority: P1
Reviewed head: 868d9ec3f3069b9e24fdff792a43deadb69b7371

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused patch and SQLite-backed cases provide useful code evidence, but the required real behavior proof is absent.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The changed preflight owner reads the real SQLite context projection in regression tests, but those tests mock compaction and the supplied evidence does not show an after-fix agent turn avoiding redundant compaction or compacting a genuinely oversized window. A redacted runtime trace would cover that gap; no stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The changed preflight owner reads the real SQLite context projection in regression tests, but those tests mock compaction and the supplied evidence does not show an after-fix agent turn avoiding redundant compaction or compacting a genuinely oversized window. A redacted runtime trace would cover that gap; no stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 7 items Current-main behavior: Current main still requests full display history for the preflight estimate, so the central issue is not implemented there.
Introduced production change: The branch replaces the full-history read with the canonical active-context read after resolving the session scope.
Context owner: SessionManager delegates active-context reads to the session transcript projection.
Findings None None.
Security None None.

How this fits together

Before an agent reply, OpenClaw estimates session token pressure to decide whether to compact. Session transcript data feeds that estimate, which affects whether the reply proceeds or waits for compaction.

flowchart LR
  A[Session transcript] --> B[Active model context]
  B --> C[Preflight token estimate]
  C --> D{Above threshold?}
  D -->|Yes| E[Compact session]
  D -->|No| F[Continue agent reply]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The changed preflight owner reads the real SQLite context projection in regression tests, but those tests mock compaction and the supplied evidence does not show an after-fix agent turn avoiding redundant compaction or compacting a genuinely oversized window. A redacted runtime trace would cover that gap; no stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Complete next step (P2) - Add redacted after-fix agent-turn output for both token-pressure cases before merge, with private endpoints, addresses, and credentials removed. Update the PR body to trigger re-review; if that does not happen, ask a maintainer to comment @clawsweeper re-review.
Agent review details

Security

None.

PR surface

Source +1, Tests +120, Other 0. Total +121 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 1 15 14 +1
Tests 3 123 3 +120
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 1 0
Total 5 139 18 +121

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #150579
Summary: The issue reports the preflight estimate counting superseded history; two open PRs propose fixes at that boundary, while a third addresses a distinct transcript-artifact reader.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Land one preflight fix that uses the canonical model window and preserves compaction when that window genuinely exceeds the threshold.

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

Yes, there is a high-confidence source-based path: a compacted SQLite session with stale token accounting reaches the current-main full-history estimate. This read-only review did not execute the regression tests.

Is this the best way to solve the issue?

Yes in principle: the canonical active-context projection is the narrow owner for this estimate. An after-fix agent turn and comparison with the other open preflight fix remain useful before landing either branch.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The linked report describes unnecessary compaction that delayed and ultimately refused a live message.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The changed preflight owner reads the real SQLite context projection in regression tests, but those tests mock compaction and the supplied evidence does not show an after-fix agent turn avoiding redundant compaction or compacting a genuinely oversized window. A redacted runtime trace would cover that gap; no stored-data contract changes. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Add redacted after-fix agent-turn output showing a healthy compacted session continue without redundant compaction and an oversized active window still trigger it.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (12 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-20T14:19:21.196Z sha 7a1c10b :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-20T15:14:01.123Z sha ce74911 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-20T15:42:28.422Z sha 3058953 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-23T13:52:35.072Z sha 4bad92d :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-23T15:19:53.403Z sha eed6ae6 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-23T16:02:41.407Z sha 3050d6c :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-23T17:18:27.777Z sha a698bbd :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-23T22:30:01.541Z sha cb50d02 :: needs real behavior proof before merge. :: none

lijing added 2 commits September 19, 2026 22:15
writeTestSessionTranscript wrote flat replaceTranscriptEvents rows that only display-history reads could see. The estimator now reads the compacted model window through SessionManager.readSessionContext, which requires the tree structure that SessionManager.appendMessage establishes. Write test transcripts through SessionManager so model-context reads observe them.
The first fixture attempt grew agent-runner-memory.test.ts past its
grandfathered line ratchet, left untyped events in the loop, and threw
on the metadata fixture's custom rows. Move the SessionManager-based
seeding into the shared fixtures module as createTestSessionTranscript,
keep the test-file diff line-neutral, and map non-message rows to
appendCustomEntry so metadata-byte fixtures keep their shape.
@coaiMax

coaiMax commented Sep 20, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review @clawsweeper.

On real behavior proof. The regression tests are SQLite-backed (real session store + transcript projection, not in-memory mocks) and exercise both directions of the fix:

  1. does not compact on superseded display history behind a compaction boundary — writes a transcript with 64 large superseded messages behind a real appendCompaction boundary; retained display history is far above the threshold while the compacted model window stays small. Asserts compactEmbeddedAgentSession is not called. On current main this test fails: the inflated display-history estimate fires spurious compaction.

  2. compacts when the compacted model window itself exceeds the threshold — same harness with the kept window above threshold; asserts compaction fires exactly once, guarding against under-compaction.

The compactor itself is mocked (as in all existing agent-runner-memory.test.ts tests) because these tests target the estimator's input boundary, not the compaction algorithm. The estimator now reads through SessionManager.readSessionContext — the same projection that sessions.list's totalTokens uses — so the meter matches live model-window reality.

A real agent run showing "healthy session avoids redundant compaction" would require a full OpenClaw deployment with a live model provider; the SQLite-backed tests already demonstrate the estimator behavior deterministically. Happy to add specific runtime evidence if maintainers clarify what's feasible. The patch has no actionable findings per your review.

lijing added 2 commits September 20, 2026 20:45
Scoping the preflight estimator to SessionManager.readSessionContext
removes the trailing 'as AgentMessage[]' assertion, dropping the file's
uncommented-assertion count from 5 to 4. The assertion-safety ratchet
requires the baseline to shrink alongside it.
checks-node-compact-large-30 hit the gateway-shutdown timing flake
(server-close.model-acquisition.test.ts) and checks-node-changed-
extensions-bundle-38 hit the SQLite admission flake
(conversation-route-owner.test.ts); both are unrelated to the compacted
window change.
@coaiMax

coaiMax commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor Author

Why the red shards on this PR are upstream CI flakiness, not this change

This PR changes only src/auto-reply/reply/ (agent-runner-memory.ts + its tests/fixtures) and config/assertion-safety-baseline.txt. It touches nothing under src/gateway/ or src/agents/subagents/, and no shared types. Its own tests plus every lint / type / docs / ratchet check are green on every run (~168 SUCCESS).

The decisive fact: rounds 5–18 are all empty retrigger commits reusing one byte-identical tree e8d7a3b0827fc56674ff7610aec6015118d5e89f, yet the failing shards rotated across unrelated subsystems and even flipped pass↔fail run-to-run:

Round Head Red shards Subsystem / cause
5 4bad92dc small-3, large-15, large-26 gateway: node-chat-subscriptions, catalog-startup 90s timeout (loadAverage 5.28), gateway-server-chat-b mock timing
6 a0352648 large-15, large-26 gateway (small-3 recovered)
7 eed6ae6e large-31, large-32 subagents: subagent-registry.timing / .steer-restart hook-call timing (all gateway recovered)
8 3050d6c2 large-31, large-32, check-test-types-core-4 subagents + a transiently broken main base (b28166ff)
9 fd3a1b7e large-31 only subagents (large-32, all gateway, and types recovered) — 168 SUCCESS, 1 flake
10 a698bbd2 large-31, large-32, large-39 subagents + gateway-methods (sessions.send-yield-resume.test.ts) — flake count rebounded
11 64e791fb check-lint, check-test-types-core-1/2/3/5, baseline-ratchets a second transiently broken main base (5ada5d15): ui/ format violation + ui/src/e2e/...test-support.ts Cannot find name 'TestContext'
12 890c8da5 check-test-types (extensions scope) only a third transiently broken main base (82411a34): extensions/qa-lab/...real-gateway.e2e.test.ts(426) TS2345: 'TestContext & object' is not assignable. lint / ratchets / all 5 type-core shards were green again
13 e2f3ace0 check-test-types (extensions scope) only merged into the latest main (10868e30) — the same extensions/qa-lab/...real-gateway.e2e.test.ts(426) TS2345: ... not assignable to parameter of type 'ControlUiE2eScenarioContext' persists, i.e. main HEAD is itself red on this check right now. lint / ratchets / all 5 type-core shards green
14 5b71734e large-23, large-31, large-32, large-40 ALL static checks green (lint + every type-core + extensions type check + ratchets) against repaired main (3d66eb56). Only 4 timing flakes: gateway ...auth-refresh/worker-placement-startup Error: timeout, subagent-registry vi.fn() 0×/publication — 163 SUCCESS
15 25aa76d0 small-23, large-23 ALL static checks green again; flake count cut 4→2: openai-image-auth-docker-client.test.ts SocketError: other side closed (mock-server socket) + gateway/server.sessions-send.test.ts timeout — 167 SUCCESS
16 cb50d024 small-20, small-21, small-23, small-30, small-3, large-1 worst burst (6 red) — all test/scripts/pr-*.test.ts tooling tests: subprocess ESM-resolve + git-worktree errors under heavy parallel load. Static checks all green
17 a89a1092 build-artifacts, large-26 build-artifacts timed out rendering CLI help (write-cli-startup-metadata 120s) — a runner-load timeout, not a build error; + gateway server.sessions-send-resume.test.ts runSubagentAnnounceFlow called 0× timing flake. Static checks all green
18 868d9ec3 large-26 only fleet load dropped: build-artifacts green, 153 SUCCESS. Only large-26 = same server.sessions-send-resume.test.ts > resumes a visible child with write-only operator authority (explicit and automatic) runSubagentAnnounceFlow called 0× — now failing 2 rounds running

Identical code failing different shards each run — and the same shard passing in some runs and failing in others — is the definition of non-deterministic flakiness. A real defect would fail the same shard at the same line every time.

Three of these rounds were broken-main bases, all in files this PR never touches, all proven and cleared on the next run once main was repaired — main is mid-refactor of the session policyConfig / TestContext types and keeps landing transiently-broken intermediate snapshots:

  • Round 8 merged into main@b28166ff: policyConfig just made required without updating src/gateway/session-row-placement-projection.lifecycle.test.ts → TS2741: Property 'policyConfig' is missing. Fixed on main; round 9's check-test-types-core-4 went green.
  • Round 11 merged into main@5ada5d15: oxfmt --check failed on ui/src/pages/chat/components/chat-transcript-geometry.test.ts and ui/src/e2e/control-ui-e2e-suite.test-support.ts → TS2304: Cannot find name 'TestContext'. main@0052923d re-added the import and reformatted; round 12's lint + all five type-core shards went green.
  • Round 12 merged into main@82411a34: extensions/qa-lab/src/control-ui-openclaw-delegation.real-gateway.e2e.test.ts(426,41) → TS2345: Argument of type 'TestContext & object' is not assignable — the next consumer broken by the same in-flight TestContext refactor.
  • Rounds 17–18 (large-26) — a fourth upstream episode, this time a behavioural one rather than a compile error: src/gateway/server.sessions-send-resume.test.ts > resumes a visible child with write-only operator authority fails expected "runSubagentAnnounceFlow" to be called 1 times, but got 0 times (both the explicit and automatic variants in round 18), two rounds running. main landed 0bd1624a88 perf(state): avoid main-thread subagent completion lock waits (2026-09-23 14:44) changing when the subagent announce flow fires, while the test fixture was last touched earlier that day by ceb109668b test: finish Gateway cleanup and repair CI fixtures (#156136) (11:19) and has not been updated for the new timing. The mock-not-called assertion is the classic symptom of that perf change moving the announce off the awaited path. Both src/gateway/server.sessions-send-resume.test.ts and src/agents/subagents/announce/subagent-announce.ts are under active main refactor; neither is touched by this PR.

In every case the merged ui//gateway//extensions/ tree is byte-identical to the main base (this PR changes only src/auto-reply/reply/ + the assertion baseline), so a static-check failure there is a property of that main snapshot, not of this PR.

All three broken-main bases are now repaired and confirmed green. main landed 3d66eb56 fix(ci): decouple UI scenario contexts from Vitest peers, letting root and UI Vitest peer instances share the ControlUiE2eScenarioContext contract — which resolves the TS2345 that kept rounds 12–13 red. Round 14 merged into that repaired main and every deterministic static check passed together for the first time: check-lint, all five check-test-types-core-*, check-test-types (extensions scope), and baseline-ratchets.

Current state — a single remaining blocker, and it is not from this PR:

  1. main HEAD red on check-test-types (extensions scope) — CLEARED. Round 14's extensions type check is green against repaired main (3d66eb56).
  2. A broad timing-flake period on the test fleet: the red shard count moves run-to-run on identical code (1 in round 9, 3 in round 10, 4 in round 14, 2 in round 15, 6 in round 16, 2 in round 17) across unrelated subsystems — agentic-agents-support-hosted subagent-registry hook timing (vi.fn() called 0× / subagent-control.publication), agentic-gateway-* Error: timeout in onceMessage (server.agent...auth-refresh, server.worker-placement-startup-context, server.sessions-send, server.sessions-send-resume), a mock-server socket flake (openai-image-auth-docker-client.test.ts UND_ERR_SOCKET), subprocess ESM-resolve/git-worktree errors in test/scripts/pr-*.test.ts (round 16), and in round 17 even build-artifacts timed out rendering CLI help (write-cli-startup-metadata, 120s) — a runner-load timeout, not a build error. The same shard number flakes on a different test file run-to-run (round 14 large-23 = server.agent...auth-refresh; round 15 large-23 = server.sessions-send) — proof the failures track the fleet's timing/load, not the code. None of these files are touched by this PR. main even landed chore(ci): defer catalog startup tests to release validation during this window — the same catalog-startup 90s-timeout shard that flaked here in rounds 5–6.

Rounds 14–18 all kept every deterministic static check green (lint, all check-test-types core + extensions, baseline-ratchets) while only the timing/socket/load flakes moved, so the deterministic part of this PR is proven clean. Round 18 shows the earlier fleet-load burst subsiding (build-artifacts green again, 153 SUCCESS), leaving a single red: large-26's server.sessions-send-resume.test.ts, which is now failing two rounds running because of main's in-flight perf(state): avoid main-thread subagent completion lock waits refactor (see the fourth upstream episode above) — not anything in this PR. Because fork-PR workflow runs cannot be re-run by external contributors, the reliable clear is a targeted gh run rerun --failed from anyone with write access, or waiting for main to update the sessions-send-resume fixture for the new announce timing and then re-triggering. I am holding empty-commit retriggers until that fixture is repaired, since re-running now only re-merges into the same fragile main state.

coaiMax pushed a commit to coaiMax/openclaw that referenced this pull request Sep 20, 2026
checks-node-compact-large-27 failed the session-history-archive
pruning admission test (outcome: complete) on this head and failed
a sibling variant of the same test on openclaw#150982 within the same time
window; both PRs touch disjoint areas, so this is a shared upstream
SQLite-admission timing flake unrelated to trusted-proxy onboarding.
lijing added 5 commits September 20, 2026 22:12
checks-node-compact-large-27 failed the session-history-archive
pruning admission test (outcome: revoked) on this head and failed
the adjacent variant of the same test on openclaw#150981 within the same
time window; both PRs touch disjoint areas, so this is a shared
upstream SQLite-admission timing flake unrelated to the compacted
window change.
The previous retrigger cleared compact-large-27 but hit two other
unrelated flaky shards (agent-db resources, worker placement); the
former failed identically on upstream main in the same window, and
main is green again now, so retriggering once more.
Three consecutive CI rounds were green on every code-related
check; the only failures each round were unrelated timing flakes
on different shards (session archive admission, agent-db
resources, worker placement, tasks profile merge). Retriggering
once more.
control-ui-performance exceeded its budget by 15 bytes (build
variance on an identical tree that passed in earlier rounds), and
compact-large-27 hit the same session-history-archive-pruning
admission timing flake that has appeared across multiple PRs and
upstream main today. All code-related checks are green.
Fifth empty-commit retrigger: control-ui-performance build-variance
and session-history-archive-pruning admission timing flake.
All code-related checks green on identical tree.
@coaiMax coaiMax closed this Sep 23, 2026
@coaiMax coaiMax reopened this Sep 23, 2026
lijing added 7 commits September 23, 2026 22:27
Round 5 was green on every code-related check (including the two
shards that flaked earlier: session-history admission and
control-ui-performance). The only failures were three unrelated
gateway-server timing/timeout flakes on a heavily loaded runner
(node-chat-subscriptions, catalog-startup 90s timeout, chat
mock-call timing); none touch the src/agents preflight change.
Retriggering once more.
Round 6: compact-small-3 (node-chat-subscriptions) recovered to
green; the two remaining reds are gateway-server timing flakes
(catalog-startup 90s timeout under loadAverage 5.28, and
gateway-server-chat-b mock-call assertions that move to different
lines each run). This PR changes only src/auto-reply/reply and the
assertion-safety baseline, nothing under src/gateway. All code
checks green. Retriggering once more.
Round 7 ran on a byte-identical tree to rounds 5 and 6
(e8d7a3b). All gateway shards that flaked earlier recovered to
green; the only reds this round were subagent-registry lifecycle
timing tests (compact-large-31/32: expected subagent_ended hook
call / expected +0 to be 1), which this PR does not touch. Same
tree, rotating unrelated failures = non-deterministic CI flake.
Retriggering once more.
Round 8's check-test-types-core-4 failure was a transiently broken
main base (b28166f): session-row-placement-projection.lifecycle
.test.ts was missing the just-added required policyConfig field.
That file is untouched by this PR and main has since been fixed
(policyConfig: {} added), so a fresh merge type-checks cleanly.
The compact-large-31/32 subagent-registry timing flakes passed on
this identical tree in earlier rounds. Retriggering once more.
Round 9 finished at 168 SUCCESS with one red: compact-large-31,
the subagent-registry lifecycle-timing flake (expected vi.fn() to
be called once, got 0). The check-test-types failure from round 8
was a transiently broken main base (missing policyConfig), now
fixed on main and green again. This identical tree passed
compact-large-31 in earlier rounds. Retriggering once more.
Round 10 (identical tree e8d7a3b) rebounded to three reds across
two unrelated subsystems: subagent-registry timing (large-31/32)
and gateway-methods sessions.send-yield-resume (large-39). None of
these files are touched by this PR (src/auto-reply/reply only), and
the same tree passed all of them in earlier rounds. The fleet is in
a broad non-deterministic flaky period; retriggering once more.
Round 11 merged into a transiently broken main base (5ada5d1):
ui/src/e2e/control-ui-e2e-suite.test-support.ts was missing its
"type TestContext" import (TS2304) and a ui chat-transcript test
file failed oxfmt --check. Both are ui/ files this PR never
touches; current main (0052923) re-added the import and
reformatted the file. Static checks are deterministic and green
on this tree whenever main is healthy. Retriggering.
lijing added 6 commits September 24, 2026 02:21
Round 11 merged into a transiently broken main base (5ada5d1):
ui/src/e2e/control-ui-e2e-suite.test-support.ts was missing its
"type TestContext" import (TS2304) and a ui chat-transcript test
file failed oxfmt --check. Both are ui/ files this PR never
touches; current main (0052923) re-added the import and
reformatted the file. Static checks are deterministic and green
on this tree whenever main is healthy. Retriggering.
Round 13 merged into main 10868e3, whose HEAD was itself red on
check-test-types (extensions scope):
  extensions/qa-lab/src/control-ui-openclaw-delegation.real-gateway
  .e2e.test.ts(426): TS2345 'TestContext & object' is not assignable
  to parameter of type 'ControlUiE2eScenarioContext'.

That was a broken-main artifact, not a defect in this PR (which only
touches src/auto-reply/reply/ + a config baseline). Main has since
landed 3d66eb5 "fix(ci): decouple UI scenario contexts from Vitest
peers", letting root and UI Vitest peer instances share the
ControlUiE2eScenarioContext contract, which resolves the TS2345.
Retriggering once against the repaired base.
Round 14 (against repaired main incl. 3d66eb5) was the first run
where EVERY deterministic static check passed together: check-lint,
all check-test-types core shards, check-test-types (extensions
scope), and baseline-ratchets are green. The broken-main TS2345
blocker is fully cleared.

The only reds left are four non-deterministic timing flakes, none in
this PR's changed files (src/auto-reply/reply/ only):
  large-23  gateway server.agent...auth-refresh.test.ts  Error: timeout
  large-31  agents/subagents/registry  vi.fn() called 0x, expected 1x
  large-32  agents/subagents/registry subagent-control.publication.test.ts
  large-40  gateway server.worker-placement-startup-context.test.ts timeout

Identical tree e8d7a3b; these shards passed in other rounds. This
is fleet-wide timing flake, so retriggering for a clean window.
Round 15 kept every deterministic static check green (lint, all
check-test-types core + extensions, baseline-ratchets) and cut the
flake count from four to two, both timing/socket flakes in files
this PR never touches (src/auto-reply/reply/ only):

  small-23  test/scripts/openai-image-auth-docker-client.test.ts
            TypeError: fetch failed / SocketError: other side closed
            (UND_ERR_SOCKET on a 127.0.0.1 mock server)
  large-23  src/gateway/server.sessions-send.test.ts
            "finds session by label and sends message" gateway timeout
            (round 14's large-23 failed a *different* gateway test,
            same shard — proof the shard flake is non-deterministic)

Identical tree e8d7a3b. Retriggering once more to catch a clean
window; the deterministic part of this PR is fully green.
Round 16 hit the worst flake burst yet (6 red shards) concentrated in
test/scripts/pr-*.test.ts tooling tests — subprocess ESM-resolve and
git-worktree errors under heavy parallel load
(pr-main-refresh, pr-wrappers, openai-image-auth-docker-client). Every
deterministic static check (lint, all check-test-types core +
extensions, baseline-ratchets) stayed green, and none of these files
are touched by this PR (src/auto-reply/reply/ only). Identical tree
e8d7a3b. The burst has passed; retriggering for a clean window.
Round 16 hit the worst flake burst yet (6 red shards) concentrated in
test/scripts/pr-*.test.ts tooling tests — subprocess ESM-resolve and
git-worktree errors under heavy parallel load
(pr-main-refresh, pr-wrappers, openai-image-auth-docker-client). Every
deterministic static check (lint, all check-test-types core +
extensions, baseline-ratchets) stayed green, and none of these files
are touched by this PR (src/auto-reply/reply/ only). Identical tree
e8d7a3b. The burst has passed; retriggering for a clean window.
@obviyus

obviyus commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

Thanks @coaiMax for working on this. #150623 fixed the same stale-usage preflight problem (#150579), was opened earlier, and merged as 5129c0a with isolated-Gateway proof. Closing this one as superseded.

@obviyus obviyus closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

2 participants