Skip to content

fix: compact at 80% on every route - #204180

Merged
obviyus merged 1 commit into
mainfrom
compaction-trigger-80
Nov 23, 2026
Merged

obviyus merged 1 commit into
mainfrom
compaction-trigger-80

Conversation

@obviyus

@obviyus obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Related: #204111

What Problem This Solves

Automatic compaction started at two different points. Client maintenance started at 75% of the context window. Since #204111, the request-boundary compaction (ChatGPT V2 checkpoint and the warm text summary on every other route) started at 90%, a side effect of reusing the V2 trigger. No measurement supported 90%. At 90%, the warm summary request (the full window plus an appended instruction and the summary output, thinking included) can run out of room on ~200k windows and silently fall back to the cold summarizer.

User Impact

All built-in routes now compact at the same point: the smaller of 80% of the window and the window minus the compaction reserve. On a 200k window, compaction starts at 160,000 tokens.

  • ChatGPT V2 and the warm text route move from 90% to 80% (180,000 → 160,000 on 200k). The summary request keeps 20% headroom.
  • Client maintenance moves from 75% to 80% (150,000 → 160,000 on 200k; 750,000 → 800,000 on 1M).
  • The reserve cap is unchanged. Manual /compact, overflow recovery and native Codex / Claude CLI policies are unchanged. Request shape is unchanged.

Why This Change Was Made

resolveCompactionThreshold already owns the client trigger. It now uses 0.8, and the request-boundary soft trigger calls it (capped by the reserve-based prompt budget, as before) instead of keeping its own 0.9. One trigger, one owner. Docs that stated 75% or 90% now state 80%, with recomputed examples.

Evidence

  • New test (request-boundary-compaction.chatgpt-v2.test.ts, both native-checkpoint and text variants): on a 200k window the client threshold is 160,000, the boundary sends no compaction request at 159,000, and sends one at 160,000.
    • Red on base (0828443372be): the client threshold is 150,000; with that assertion removed, both variants send no request at 160,000 (base triggers at 180,000).
    • Green on this branch.
  • Updated threshold tables in the agent-core shouldCompact test, setup.test.ts and the refusal compaction test (now derived from the owner, not a hard-coded ratio).
  • Targeted local run: the touched tests plus every test file that imports a changed source.

Merge danger

Two-way door: a revert restores 75% / 90%. No stored state, config or contract changes. Blast radius: when every built-in agent session compacts (slightly later for client maintenance, earlier for ChatGPT V2 and warm text compaction).

One compaction trigger: resolveCompactionThreshold now uses 80% of the window
(capped by window minus reserve), and the request-boundary soft trigger for
ChatGPT V2 and warm text compaction calls it instead of its own 90% literal.
This moves V2/warm compaction from 90% to 80% and client maintenance from 75%
to 80%, leaving headroom for the summary request on ~200k windows.

Co-authored-by: obviyus <[email protected]>
@clawsweeper

clawsweeper Bot commented Nov 23, 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 docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: S labels Nov 23, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 23, 2026
@obviyus
obviyus merged commit 412df90 into main Nov 23, 2026
125 checks passed
@obviyus
obviyus deleted the compaction-trigger-80 branch November 23, 2026 18:12
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 23, 2026
@obviyus

obviyus commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in 412df90. Bug: since #204111, request-boundary compaction (ChatGPT V2 and warm text) started at 90%, and client maintenance at 75%. At 90% the warm summary request could run out of room on ~200k windows. Fix: one trigger at 80% (capped by window minus reserve), owned by resolveCompactionThreshold. The boundary now calls it. Proof: a new 200k test for both variants (red on base, green here), updated consumer tests, CI green, clean local review.

@clawsweeper

clawsweeper Bot commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR gives client maintenance and request-boundary compaction one shared 80% trigger while preserving the reserve cap.

Example: A built-in session has a 200,000-token window and a 20,000-token reserve.

  • Before: Client maintenance uses 150,000 tokens; request-boundary compaction uses 180,000.
  • After: Both calculate a 160,000-token threshold.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is focused and source-consistent, but required runtime evidence for the changed scheduling default is absent.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Automatic warm compaction can start with too little remaining context for its summary request and fall back to a cold summary.
Reason: The maintainer-authored direction unifies inconsistent scheduling through an existing owner and explicitly accepts slightly later client maintenance.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR makes a focused compaction-policy correction absent from current main; no introduced correctness or security defect was found.

Priority: P2
Reviewed head: 0c2b05aafae1ab5c23648df35477ecb433c8f546

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted Gateway output on this head showing successful warm compaction near 80% of a 200k window and resumed inference, including a latest-stable existing-session upgrade with settings and history preserved.
Agent review details

How this fits together

The embedded runner prices prepared provider requests, schedules compaction through the session owner, and resumes inference using the compacted history.

flowchart TD
 A[Prepared provider request] --> B[Context pressure calculation]
 C[Shared compaction threshold] --> B
 B --> D[Native checkpoint]
 B --> E[Warm text summary]
 D --> F[Session transcript owner]
 E --> F
 F --> G[Resumed inference]
Loading

Technical review

Best possible solution:

Keep the existing shared threshold owner, reserve cap, hard-window admission, and compaction writers.

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

Source confirms the divergent triggers, but the claimed warm-summary exhaustion on approximately 200k windows has no supplied failing runtime trace.

Is this the best way to solve the issue?

The smallest coherent correction is to reuse the existing threshold calculation at the request boundary; the diff does that without adding machinery or changing fallback ownership.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Client maintenance threshold changes intended behavior with a stated reason (e0ed68c: Start maintenance early during long tool turns without expanding the separate summary reserve.)
  • Request-boundary soft trigger changes intended behavior with a stated reason (8589115: Give native ChatGPT compaction room before large context jumps; the later warm-compaction feature reused that trigger.)
  • Warm text compaction scheduling changes intended behavior with a stated reason (e5dcfa0: Reuse the session's warm request prefix on non-native routes while retaining existing compaction writers and recovery.)
  • Soft-pressure fallback keeps the original intent (fb9337a: Only requests that cannot fit may fail a turn; maintenance waits for a settled tool boundary.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit e0ed68c adds packages/agent-core/src/harness/compaction/compaction-threshold.ts:7 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e0ed68c7b845; files: packages/agent-core/src/harness/compaction/compaction-threshold.ts)

PR surface

Source +9, Tests +41, Docs +3. Total +53 across 10 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 15 6 +9
Tests 4 50 9 +41
Docs 4 18 15 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 83 30 +53

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Compaction scheduling default Client: 75% → 80%; request boundary: 90% → 80% Changes automatic scheduling across built-in sessions without introducing a configuration option.

Labels

Label changes:

  • add P2: This is a focused context-headroom improvement without evidence of an urgent outage or broken first-run workflow.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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: This is a focused context-headroom improvement without evidence of an urgent outage or broken first-run workflow.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

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 November 23, 2026, 1:11 PM ET / 18:11 UTC.

obviyus added a commit that referenced this pull request Nov 24, 2026
…and transport owners (#204292)

## Result

Pull request CI now selects every test whose runtime imports reach a changed file under `src/agents/`, `src/auto-reply/reply/agent-runner*`, `packages/agent-core/src/harness/compaction/` or `packages/ai/src/transports/`, directly or transitively. Replaying the file lists of #204111 and #204180 now selects the four tests that first failed on scheduled `main` (#204252).

**Cost, read this first:** for these owners the transitive closure covers almost the whole runtime suite. A PR that touches them now runs a full-suite-sized Node plan, about 21x to 105x the previous predicted test time. Exact numbers are below. The plan stays inside the existing row cap and per-job time objective. Nothing is capped or dropped.

Closes #204252.

## Why the tests were missed

PR CI uses `selectionMode: "aggressive"` (`scripts/ci-build-manifest.mjs`). In `resolveBoundedChangedTestTargetPlan`, aggressive mode walks reverse imports to **depth 2**, and only to **depth 1** when the changed module has 20 or more direct importers (the hub cutoff). There are no owner-list routes for these files and no shard owner list filters them. The tests are simply too far away:

| Changed owner | Import distance to the missed tests |
|---|---|
| `src/auto-reply/reply/agent-runner-memory.ts` | 3 (agent-runner tests) |
| `src/agents/compaction.ts` | 5 (agent-runner), 7 (prompt-cache) |
| `src/agents/embedded-agent-runner/run/request-boundary-compaction.ts` | 5 (agent-runner), 10 (prompt-cache) |
| `src/agents/embedded-agent-runner/run/attempt-prompt-submit.ts` | 7 (prompt-cache), 9 (agent-runner) |
| `packages/ai/src/transports/anthropic-messages.ts` | 6 (prompt-cache), 8 (agent-runner) |
| `packages/agent-core/src/harness/compaction/summarization-completion.ts` | 6-7 |

`session-context-accounting.gateway.integration.test.ts` is not reached within 10 imports of any compaction owner. It is reached only through the full closure, which runs through the Gateway into the runner.

## Fix

The PR plan owner (`resolveChangedNodeTestTargets`) passes `transitiveOwners` to the bounded target walk. For a changed file that matches, the walk has no depth limit and no hub cutoff. All other paths keep the two-import walk. `docs/ci/scope-and-routing/node-test-lanes.md` describes the rule.

## Selection growth (replayed through the PR planner, hybrid backend, 130-row cap)

| Replay | Before: tests / jobs / predicted test-seconds (max job) | After |
|---|---|---|
| #204111 (31 files) | 300 / 14 / 1,767 s (228 s) | 12,562 / 131 / 36,859 s (469 s) |
| #204180 (9 files) | 22 / 5 / 351 s (140 s) | 12,405 / 131 / 36,673 s (468 s) |

- The closure is nearly the whole runtime inventory. An unbounded walk from `request-boundary-compaction.ts` alone reaches 12,397 test files.
- 48 of the last 200 first-parent commits on `main` (24%) touch these owners. At the replayed size, each PR push of that kind adds about 35,000 predicted test-seconds.
- Shard budget: the plans stay at the compact Node row cap (130 rows plus one dist row) and below the 480-second per-job objective (max 469 s). They use the full PR row envelope that the registration budget already allows, so concurrent PRs of this kind compete for the same rows.
- I tested no smaller rule that still selects the four tests. A walk depth of 10 already selects 2,401-7,129 tests (13,797-26,905 s) and still misses the Gateway integration test.

## Evidence

- New test in `test/scripts/ci-changed-node-test-plan.integration.test.ts`. For 7 changed owners from #204111 and #204180, it asserts that the plan selects the four named tests and **every** test in the owner's unbounded runtime-import closure. It fails on `main` and passes on this head.
- Replay script results above, on `main` and on this head.
- One existing fixture expectation changed: `ci-changed-node-test-plan.selection.test.ts` used a `src/agents/example` source to pin the depth-two stop; it now expects the distant consumer.
- Planner and workflow tests (13 files, 1,573 tests): all pass except `ci-changed-node-test-plan.test.ts` "retains precise process ownership (github)", which fails the same way on `main` (`expected 120 to be less than or equal to 60`). It is not caused by this change.
- `pnpm check:changed`: pass.
- CI on the head: green except 3 checks that fail the same way on scheduled main at the base (see the Maintainer override comment). Local ClawSweeper: patch is correct, no findings.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Nov 24, 2026
…nd a declared behavior set (#204346)

## Result

PR CI for agent, compaction, prompt and transport owners goes from a full-suite plan back to a bounded one, about 13x smaller. It still selects the four tests that #204252 was about.

| Replay (PR planner, hybrid, 130-row cap) | Before (#204292) | After |
|---|---|---|
| #204111 (31 files) | 12,562 tests / 131 jobs / 36,859 s | **967 tests / 21 jobs / 2,881 s** (max job 271 s) |
| #204180 (9 files) | 12,405 / 131 / 36,673 s | **302 / 14 / 1,393 s** (max job 250 s) |

Both replays select `embedded-agent-runner.prompt-cache.test.ts`, `agent-runner-required-maintenance.pending-input.test.ts`, `agent-runner-compaction-fallback.test.ts` and `session-context-accounting.gateway.integration.test.ts`.

## Change

For a changed source file under `src/agents/`, `src/auto-reply/reply/agent-runner*`, `packages/agent-core/src/harness/compaction/` or `packages/ai/src/transports/`, the aggressive PR plan now selects:

1. the normal two-import walk, as for every other file;
2. every transitive importer test **in the changed file's own directory**. A file directly in a package root (for example `src/agents/compaction.ts`) skips this step, because that directory is the whole package (1,795 tests for `src/agents/`);
3. a **declared behavior set**: every `*prompt-cache*` and `*compaction*` test under `src/` and `packages/` (118 files), plus `agent-runner-required-maintenance.pending-input.test.ts` and `session-context-accounting.gateway.integration.test.ts`.

A test-only edit under these owners runs itself and does not pull in the declared set.

Full mode (manual and hourly) is unchanged and still walks every importer.

## Decision recorded

The follow-up asked for "importers within the same package". With the package root as the scope, #204111 selects 2,424 tests / 7,519 s, which misses the target of about 1,200 tests / 3,700 s. I used the changed file's directory instead, which meets the target. Coverage given up: cross-directory transitive importers, outside the declared set, of a file under these owners. The hourly full plan still runs them. This is reversible: widening the scope is a one-line change.

| Variant | #204111 | #204180 |
|---|---|---|
| Declared set only | 369 / 1,888 s | 135 / 1,035 s |
| **Same directory + declared (this PR)** | **967 / 2,881 s** | **302 / 1,393 s** |
| Same package root + declared | 2,424 / 7,519 s | 308 / 1,393 s |
| #204292 (unbounded) | 12,562 / 36,859 s | 12,405 / 36,673 s |

## Evidence

- `ci-changed-node-test-plan.integration.test.ts`: for 7 owners from #204111 and #204180, the plan selects the four named tests and every same-directory importer test.
- `ci-changed-node-test-plan.selection.test.ts`: the fixture case again expects the two-import stop for a distant consumer in another directory (the pre-#204292 expectation).
- Planner, project and workflow tests (11 files): 1,322 passed. `pnpm check:changed`: pass.


## Coverage decision and closing loop

- The maintainer accepted the same-directory scope as the coverage contract for these owners. The local review asked for this decision.
- **Closing loop:** when a scheduled red traces to a green PR through a cross-directory importer, the fix PR adds that importer test to the owner's declared set. The declared sets grow only from real misses.
- **Measurement:** 24 h after merge, compare agent-core PR rows and wall time with the #204292 numbers above.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 24, 2026
Related: openclaw#204111

## What Problem This Solves

Automatic compaction started at two different points. Client maintenance started at 75% of the context window. Since openclaw#204111, the request-boundary compaction (ChatGPT V2 checkpoint and the warm text summary on every other route) started at 90%, a side effect of reusing the V2 trigger. No measurement supported 90%. At 90%, the warm summary request (the full window plus an appended instruction and the summary output, thinking included) can run out of room on ~200k windows and silently fall back to the cold summarizer.

## User Impact

All built-in routes now compact at the same point: the smaller of 80% of the window and the window minus the compaction reserve. On a 200k window, compaction starts at 160,000 tokens.

- ChatGPT V2 and the warm text route move from 90% to 80% (180,000 → 160,000 on 200k). The summary request keeps 20% headroom.
- Client maintenance moves from 75% to 80% (150,000 → 160,000 on 200k; 750,000 → 800,000 on 1M).
- The reserve cap is unchanged. Manual `/compact`, overflow recovery and native Codex / Claude CLI policies are unchanged. Request shape is unchanged.

## Why This Change Was Made

`resolveCompactionThreshold` already owns the client trigger. It now uses 0.8, and the request-boundary soft trigger calls it (capped by the reserve-based prompt budget, as before) instead of keeping its own `0.9`. One trigger, one owner. Docs that stated 75% or 90% now state 80%, with recomputed examples.

## Evidence

- New test (`request-boundary-compaction.chatgpt-v2.test.ts`, both `native-checkpoint` and `text` variants): on a 200k window the client threshold is 160,000, the boundary sends no compaction request at 159,000, and sends one at 160,000.
  - Red on base (`6d8b616e5305`): the client threshold is 150,000; with that assertion removed, both variants send no request at 160,000 (base triggers at 180,000).
  - Green on this branch.
- Updated threshold tables in the agent-core `shouldCompact` test, `setup.test.ts` and the refusal compaction test (now derived from the owner, not a hard-coded ratio).
- Targeted local run: the touched tests plus every test file that imports a changed source.

## Merge danger

Two-way door: a revert restores 75% / 90%. No stored state, config or contract changes. Blast radius: when every built-in agent session compacts (slightly later for client maintenance, earlier for ChatGPT V2 and warm text compaction).

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 24, 2026
…and transport owners (openclaw#204292)

## Result

Pull request CI now selects every test whose runtime imports reach a changed file under `src/agents/`, `src/auto-reply/reply/agent-runner*`, `packages/agent-core/src/harness/compaction/` or `packages/ai/src/transports/`, directly or transitively. Replaying the file lists of openclaw#204111 and openclaw#204180 now selects the four tests that first failed on scheduled `main` (openclaw#204252).

**Cost, read this first:** for these owners the transitive closure covers almost the whole runtime suite. A PR that touches them now runs a full-suite-sized Node plan, about 21x to 105x the previous predicted test time. Exact numbers are below. The plan stays inside the existing row cap and per-job time objective. Nothing is capped or dropped.

Closes openclaw#204252.

## Why the tests were missed

PR CI uses `selectionMode: "aggressive"` (`scripts/ci-build-manifest.mjs`). In `resolveBoundedChangedTestTargetPlan`, aggressive mode walks reverse imports to **depth 2**, and only to **depth 1** when the changed module has 20 or more direct importers (the hub cutoff). There are no owner-list routes for these files and no shard owner list filters them. The tests are simply too far away:

| Changed owner | Import distance to the missed tests |
|---|---|
| `src/auto-reply/reply/agent-runner-memory.ts` | 3 (agent-runner tests) |
| `src/agents/compaction.ts` | 5 (agent-runner), 7 (prompt-cache) |
| `src/agents/embedded-agent-runner/run/request-boundary-compaction.ts` | 5 (agent-runner), 10 (prompt-cache) |
| `src/agents/embedded-agent-runner/run/attempt-prompt-submit.ts` | 7 (prompt-cache), 9 (agent-runner) |
| `packages/ai/src/transports/anthropic-messages.ts` | 6 (prompt-cache), 8 (agent-runner) |
| `packages/agent-core/src/harness/compaction/summarization-completion.ts` | 6-7 |

`session-context-accounting.gateway.integration.test.ts` is not reached within 10 imports of any compaction owner. It is reached only through the full closure, which runs through the Gateway into the runner.

## Fix

The PR plan owner (`resolveChangedNodeTestTargets`) passes `transitiveOwners` to the bounded target walk. For a changed file that matches, the walk has no depth limit and no hub cutoff. All other paths keep the two-import walk. `docs/ci/scope-and-routing/node-test-lanes.md` describes the rule.

## Selection growth (replayed through the PR planner, hybrid backend, 130-row cap)

| Replay | Before: tests / jobs / predicted test-seconds (max job) | After |
|---|---|---|
| openclaw#204111 (31 files) | 300 / 14 / 1,767 s (228 s) | 12,562 / 131 / 36,859 s (469 s) |
| openclaw#204180 (9 files) | 22 / 5 / 351 s (140 s) | 12,405 / 131 / 36,673 s (468 s) |

- The closure is nearly the whole runtime inventory. An unbounded walk from `request-boundary-compaction.ts` alone reaches 12,397 test files.
- 48 of the last 200 first-parent commits on `main` (24%) touch these owners. At the replayed size, each PR push of that kind adds about 35,000 predicted test-seconds.
- Shard budget: the plans stay at the compact Node row cap (130 rows plus one dist row) and below the 480-second per-job objective (max 469 s). They use the full PR row envelope that the registration budget already allows, so concurrent PRs of this kind compete for the same rows.
- I tested no smaller rule that still selects the four tests. A walk depth of 10 already selects 2,401-7,129 tests (13,797-26,905 s) and still misses the Gateway integration test.

## Evidence

- New test in `test/scripts/ci-changed-node-test-plan.integration.test.ts`. For 7 changed owners from openclaw#204111 and openclaw#204180, it asserts that the plan selects the four named tests and **every** test in the owner's unbounded runtime-import closure. It fails on `main` and passes on this head.
- Replay script results above, on `main` and on this head.
- One existing fixture expectation changed: `ci-changed-node-test-plan.selection.test.ts` used a `src/agents/example` source to pin the depth-two stop; it now expects the distant consumer.
- Planner and workflow tests (13 files, 1,573 tests): all pass except `ci-changed-node-test-plan.test.ts` "retains precise process ownership (github)", which fails the same way on `main` (`expected 120 to be less than or equal to 60`). It is not caused by this change.
- `pnpm check:changed`: pass.
- CI on the head: green except 3 checks that fail the same way on scheduled main at the base (see the Maintainer override comment). Local ClawSweeper: patch is correct, no findings.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 24, 2026
…nd a declared behavior set (openclaw#204346)

## Result

PR CI for agent, compaction, prompt and transport owners goes from a full-suite plan back to a bounded one, about 13x smaller. It still selects the four tests that openclaw#204252 was about.

| Replay (PR planner, hybrid, 130-row cap) | Before (openclaw#204292) | After |
|---|---|---|
| openclaw#204111 (31 files) | 12,562 tests / 131 jobs / 36,859 s | **967 tests / 21 jobs / 2,881 s** (max job 271 s) |
| openclaw#204180 (9 files) | 12,405 / 131 / 36,673 s | **302 / 14 / 1,393 s** (max job 250 s) |

Both replays select `embedded-agent-runner.prompt-cache.test.ts`, `agent-runner-required-maintenance.pending-input.test.ts`, `agent-runner-compaction-fallback.test.ts` and `session-context-accounting.gateway.integration.test.ts`.

## Change

For a changed source file under `src/agents/`, `src/auto-reply/reply/agent-runner*`, `packages/agent-core/src/harness/compaction/` or `packages/ai/src/transports/`, the aggressive PR plan now selects:

1. the normal two-import walk, as for every other file;
2. every transitive importer test **in the changed file's own directory**. A file directly in a package root (for example `src/agents/compaction.ts`) skips this step, because that directory is the whole package (1,795 tests for `src/agents/`);
3. a **declared behavior set**: every `*prompt-cache*` and `*compaction*` test under `src/` and `packages/` (118 files), plus `agent-runner-required-maintenance.pending-input.test.ts` and `session-context-accounting.gateway.integration.test.ts`.

A test-only edit under these owners runs itself and does not pull in the declared set.

Full mode (manual and hourly) is unchanged and still walks every importer.

## Decision recorded

The follow-up asked for "importers within the same package". With the package root as the scope, openclaw#204111 selects 2,424 tests / 7,519 s, which misses the target of about 1,200 tests / 3,700 s. I used the changed file's directory instead, which meets the target. Coverage given up: cross-directory transitive importers, outside the declared set, of a file under these owners. The hourly full plan still runs them. This is reversible: widening the scope is a one-line change.

| Variant | openclaw#204111 | openclaw#204180 |
|---|---|---|
| Declared set only | 369 / 1,888 s | 135 / 1,035 s |
| **Same directory + declared (this PR)** | **967 / 2,881 s** | **302 / 1,393 s** |
| Same package root + declared | 2,424 / 7,519 s | 308 / 1,393 s |
| openclaw#204292 (unbounded) | 12,562 / 36,859 s | 12,405 / 36,673 s |

## Evidence

- `ci-changed-node-test-plan.integration.test.ts`: for 7 owners from openclaw#204111 and openclaw#204180, the plan selects the four named tests and every same-directory importer test.
- `ci-changed-node-test-plan.selection.test.ts`: the fixture case again expects the two-import stop for a distant consumer in another directory (the pre-openclaw#204292 expectation).
- Planner, project and workflow tests (11 files): 1,322 passed. `pnpm check:changed`: pass.


## Coverage decision and closing loop

- The maintainer accepted the same-directory scope as the coverage contract for these owners. The local review asked for this decision.
- **Closing loop:** when a scheduled red traces to a green PR through a cross-directory importer, the fix PR adds that importer test to the owner's declared set. The declared sets grow only from real misses.
- **Measurement:** 24 h after merge, compare agent-core PR rows and wall time with the openclaw#204292 numbers above.

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

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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.

1 participant