Skip to content

perf(agents): render the system prompt from one manifest and halve it - #206537

Merged
obviyus merged 5 commits into
mainfrom
perf/system-prompt-manifest
Nov 27, 2026
Merged

obviyus merged 5 commits into
mainfrom
perf/system-prompt-manifest

Conversation

@obviyus

@obviyus obviyus commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

On a fresh install, the first request of openclaw agent --local carries a 29 KB system prompt (about 3x Pi). One large function builds it, helped by scattered section builders, and nothing limits its size. The Tool Search directory alone repeats 11.6 KB of tool descriptions on every request, and the skills catalog adds 4.2 KB. tool_search, tool_describe and skills_search already supply those details on demand. The 2.6 KB message tool is also sent in runs that have no channel to send to.

Solution

The PR has three commits:

  1. test(agents): byte snapshots of the fresh-install and configured system prompts, generated on the base commit.
  2. refactor(agents): one owner renders the prompt from a declared manifest, src/agents/system-prompt-manifest.ts. Each section has an id, an owner file, a region (stable, dynamic or runtime), an inclusion condition and a byte budget. buildAgentSystemPrompt renders only through one renderer per manifest id, in manifest order. The output is byte-identical: the base snapshots pass unchanged, and dist agent --local first requests match the base byte for byte for fresh, bootstrap and configured installs.
  3. perf(agents): shrinks the prompt, largest sections first. Each cut has its reason:
    • The deferred Tool Search directory lists names only. Descriptions come from tool_search and tool_describe. The lean-only description tier is gone, so lean and default agents render the same directory.
    • The skills catalog lists names only when skills_read and skills_search are both usable; search matches descriptions on demand. Without search, the compact catalog keeps descriptions.
    • Directory tools marked [loads on lookup] keep their own call rule; the dispatch_action rule covers the other names.
    • message is omitted when the session has neither a supported source nor a configured messaging route, also on fixed listings. Availability is a session and config fact, so the pinned tool list stays fixed for the session.
    • Wording is tightened in Execution Bias, Promised Work, Runtime Context, Tool Call Style, Care, OpenClaw Control, Session routing, Documentation, UI Presentation, Memory Recall and Skill Workshop. No rule is removed.
    • Gate: system-prompt.inventory-snapshot.test.ts fails when the fresh-install fixture exceeds FRESH_INSTALL_SYSTEM_PROMPT_BUDGET_BYTES (13,500 B; the fixture renders 12,864 B) or when any section exceeds its manifest budget.

Impact

First request, fake provider, agent --local:

before after
fresh install: system prompt 29,157 B 15,015 B
fresh install: tools array 20,108 B 17,542 B
fresh install: request body 50,554 B 33,780 B
configured agent: system prompt 37,534 B 23,491 B
configured agent: request body 69,061 B 54,959 B

Per section on a fresh install: Deferred Tool Schemas 11,596 -> 2,483 B; Skills 4,249 -> 1,047 B; OpenClaw Control 2,199 -> 1,803 B; Memory Recall 1,202 -> 812 B; Skill Workshop 848 -> 633 B; Session routing 562 -> 404 B; the message tool section 558 -> 0 B. Other sections shrink 5-10%.

Each change to the stable sections starts one new prompt series per session after upgrade (one cache miss). Pinned series keep their bytes until then.

Evidence

Behavior suite: real gpt-5.4-mini, agent --local, 3 trials per case. Base is ca15e2952f (manifest only); head is c5752270fb, the shave before review restored a few dropped qualifiers (base wording, +341 B). Pass/fail is judged structurally from the recorded provider calls; answer quality is judged by a model against a written rubric.

Case Base Head
read a file 3/3 3/3
shell command 3/3 3/3
skill discovery and load 3/3 3/3
deferred tool (session_status) 3/3 2/3
MCP tool call 3/3 3/3
reply directive 3/3 3/3
safety confirmation 3/3 3/3
memory recall 3/3 3/3
subagent spawn 3/3 3/3
compaction recall 3/3 3/3
progress card 3/3 3/3
  • The head session_status miss made the correct calls and gave the correct answer. Then the CLI exited 1 at shutdown with Database maintenance resource scope is closed. Over all runs this happened in 3 of 21 head trials and 0 of 15 base trials, and only in this case. It looks like an existing --local shutdown race and is tracked separately.
  • Skill loading now goes through skills_read in every head trial. Base read SKILL.md from the filesystem in 2 of 3 trials.
  • Local ClawSweeper on 1ebe079678: patch is correct, no findings. Earlier rounds found and fixed: keep skill descriptions when skills_search is unavailable; keep the on-demand exception in the directory's dispatch rule; keep the one-skill limit scoped to initial selection; restore other qualifiers the wording pass dropped.
  • Green: system-prompt, tool-search, attempt-bundle-tools, memory-core, copilot and codex thread-prompt suites; prompt snapshot drift; agent-tools.prefix-stability; tsgo; lint; format; line cap.

Not in scope

  • Plugin and SDK prompt contracts stay as declared slots: provider transformSystemPrompt and promptContribution, before_prompt_build contexts, context-engine systemPromptAddition, and the permission notice.
  • progress_card stays listed. Its plan-completion check and channel plan updates work without a UI.
  • toolSearchDirectoryLean stays an accepted optional field in the worker presentation schema. Core no longer reads it; removing it is a protocol change.

- Byte snapshots of buildAgentSystemPrompt for the two inventory shapes (fresh install; configured channel agent with context files, sandbox, owner, aliases, reactions), generated on c465c1b. Plain .txt so formatters keep the bytes.
- src/agents/system-prompt-manifest.ts declares every section: id, owner file, region (stable/dynamic/runtime), inclusion condition, byte budget.
- buildAgentSystemPrompt renders exactly the manifest, in manifest order, through one renderer per section id (a Record over the id union, so no section renders outside the manifest). The stable region keeps its cache key and SYSTEM_PROMPT_CACHE_BOUNDARY; dynamic and runtime regions follow.
- Owner-line helpers move to system-prompt-owner.ts (line cap).
- Byte-identical: snapshots generated on c465c1b pass unchanged, system-prompt tests pass, and dist `agent --local` first requests for fresh, bootstrap and configured installs match c465c1b byte for byte (after normalizing run path, timestamp, session id).
- Plugin and provider contributions keep declared slots: provider sectionOverrides/stablePrefix/dynamicSuffix, plugin tool promptGuidance (tool_guidance), memory plugin (memory), callers' extraSystemPrompt (conversation_context).
- Deferred Tool Search directory lists names only: tool_search returns signatures and tool_describe full schemas on demand (11.6 KB of descriptions per fresh-install request). The lean-only description tier is gone, so core no longer reads toolSearchDirectoryLean.
- Skills catalog lists names only when skills_read and skills_search are both usable; search matches descriptions on demand (4.2 KB). Without search the compact catalog keeps descriptions.
- The embedded attempt omits an unavailable `message` tool also on fixed listings: availability comes from session and config facts, so the pinned list stays fixed (2.6 KB schema plus its prompt section in `agent --local` without channels).
- Wording tightened, no rule removed: Execution Bias, Promised Work, Runtime Context, Tool Call Style, Care, OpenClaw Control, Session routing, Documentation, UI Presentation, Memory Recall, Skill Workshop.
- Gate: per-section manifest budgets from the achieved sizes with small headroom, FRESH_INSTALL_SYSTEM_PROMPT_BUDGET_BYTES = 13,500 on the fresh-install fixture, checked by system-prompt.inventory-snapshot.test.ts through measureAgentSystemPromptSections.
- Model-identity helpers move to system-prompt-model-identity.ts (line cap).
- Fresh `agent --local` first request: system prompt 29,157 -> 14,731 B, tools 20,108 -> 17,542 B, body 50,554 -> 33,496 B.
@clawsweeper

clawsweeper Bot commented Nov 27, 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 extensions: memory-core Extension: memory-core agents Agent runtime and tooling extensions: codex extensions: copilot plugin: skill-workshop size: XL labels Nov 27, 2026
@github-actions

github-actions Bot commented Nov 27, 2026 •

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: 1ebe0796784bcdca9ec9d7eb2e0077b417f544ba
  • Maintainer: @obviyus
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/harness/prompt-tool-policy.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. clawsweeper:intake:feature Preliminary submission classification; full source review pending. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR centralizes system-prompt rendering and reduces repeated tool descriptions, skill descriptions, and unavailable messaging guidance.

Example: The deferred catalog contains session_status.

  • Before: The system prompt lists session_status with its owner and description.
  • After: The directory lists session_status by name; tool_search and tool_describe provide details when needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful, source-supported performance work with reported real CLI trials, but exact-head CI exposes incomplete consumer migration and the upgrade claim exceeds the implementation.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the contributor proof gate; its body reports shipped CLI request measurements and real-model trials, but provides no attached provider captures for independent inspection.
Patch quality 🦪 silver shellfish (2/6) 4 actionable review findings remain.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Fresh agent requests spend substantial context on descriptions already available through discovery tools.
Reason: The maintainer-authored direction removes repeated request content while retaining searchable descriptions and the no-search skills fallback.

Merge readiness

⛔ Needs changes before merge - 3 items remain

Keep this maintainer-authored PR open: the prompt reduction is worthwhile, but missed test consumers currently fail CI and the claimed automatic upgrade re-pin is unsupported by the implementation.

Reviewed head: 05bbebfc8019b2eb1ba9032f9d4e20c89ab7dc2f

Before merge

  • Update the remaining directory-format consumers (P2) - The new comma-separated names-only directory leaves consumers asserting the removed bullet/owner format and description tiers. Exact-head CI fails in tool-surface-bridge.test.ts:212/465, tool-search.on-demand.test.ts:102, and worker-gateway-tool-runtime.test.ts:397/410. Update these consumers to check the new representation while preserving worker projection, filtering, discovery-mode, and on-demand loading coverage.
  • Migrate the remaining consumers of revised prompt wording (P2) - The revised update guidance no longer matches the regex in update-owner.test.ts:219, so the test throws before executing the advertised update action. CI also identifies stale expectations in system-prompt-config.test.ts, system-prompt.workshop-contract.test.ts, system-prompt.worker-placement.test.ts, ui-presentation-prompt.test.ts, and attempt-tool-search-prompt.test.ts. Update the extraction and expectations together, retaining the actual update execution and policy checks.
  • Correct the automatic upgrade re-pin claim (P2) - The body says changed stable sections start a new prompt series after upgrade, but this renderer does not invalidate saved session pins. prepareSessionSystemPrompt restores matching checkpoints and restarts only when its route/history conditions change; otherwise revised sections become appended prompt updates. With unchanged configuration and route, an existing session therefore retains its larger original prefix rather than receiving the claimed automatic reduction. Correct the upgrade description and distinguish fresh-series savings from resumed-session behavior; preserve the existing pin contract.

Findings

  • [P2] Update the remaining directory-format consumers — src/agents/tool-search-directory.ts:300
  • [P2] Migrate the remaining consumers of revised prompt wording — src/agents/system-prompt-control.ts:43-45
  • [P2] Correct the automatic upgrade re-pin claim — src/agents/system-prompt.ts:750-754

Tests

  • Missing end-to-end proof: The reported CLI trials do not show an existing latest-stable session resumed on this head with its saved prompt and tool pin intact.
Agent review details

How this fits together

Agent preparation supplies session facts, admitted tools, skills, and workspace context to the prompt renderer, whose output reaches embedded and native-harness model requests.

flowchart LR
  A[Session and configuration] --> C[Agent prompt preparation]
  B[Tools skills and workspace] --> C
  C --> D[Section manifest and renderers]
  D --> E[Session prompt owner]
  E --> F[Provider or native harness]
Loading

Technical review

Best possible solution:

Keep the compact renderer, complete its consumer-test updates, and describe existing-session behavior according to the session prompt owner.

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

Current main visibly repeats tool and skill descriptions; exact-head CI independently demonstrates the missed consumer updates, without executing target code during this review.

Is this the best way to solve the issue?

The manifest and existing discovery tools provide a coherent reduction without new configuration, but all consumers must migrate together and upgrade claims must match the unchanged pin lifecycle.

Full review comments:

  • [P2] Update the remaining directory-format consumers — src/agents/tool-search-directory.ts:300
    The new comma-separated names-only directory leaves consumers asserting the removed bullet/owner format and description tiers. Exact-head CI fails in tool-surface-bridge.test.ts:212/465, tool-search.on-demand.test.ts:102, and worker-gateway-tool-runtime.test.ts:397/410. Update these consumers to check the new representation while preserving worker projection, filtering, discovery-mode, and on-demand loading coverage.
    Confidence: 1
  • [P2] Migrate the remaining consumers of revised prompt wording — src/agents/system-prompt-control.ts:43-45
    The revised update guidance no longer matches the regex in update-owner.test.ts:219, so the test throws before executing the advertised update action. CI also identifies stale expectations in system-prompt-config.test.ts, system-prompt.workshop-contract.test.ts, system-prompt.worker-placement.test.ts, ui-presentation-prompt.test.ts, and attempt-tool-search-prompt.test.ts. Update the extraction and expectations together, retaining the actual update execution and policy checks.
    Confidence: 1
  • [P2] Correct the automatic upgrade re-pin claim — src/agents/system-prompt.ts:750-754
    The body says changed stable sections start a new prompt series after upgrade, but this renderer does not invalidate saved session pins. prepareSessionSystemPrompt restores matching checkpoints and restarts only when its route/history conditions change; otherwise revised sections become appended prompt updates. With unchanged configuration and route, an existing session therefore retains its larger original prefix rather than receiving the claimed automatic reduction. Correct the upgrade description and distinguish fresh-series savings from resumed-session behavior; preserve the existing pin contract.
    Confidence: 0.98
  • [P3] Document both capabilities required for names-only skills — docs/concepts/system-prompt.md:226
    This paragraph says skills_read alone produces names-only entries and assumes skills_search is available. The implementation deliberately retains descriptions when skills_search is unavailable, including when policy disables it. Describe the two-capability condition and the description-preserving fallback.
    Confidence: 1

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/agents/harness/tool-surface-bridge.test.ts src/agents/tool-search.on-demand.test.ts src/gateway/worker-environments/worker-gateway-tool-runtime.test.ts --maxWorkers=1
  • pnpm test src/gateway/server-methods/update-owner.test.ts src/agents/system-prompt-config.test.ts src/agents/system-prompt.workshop-contract.test.ts src/agents/system-prompt.worker-placement.test.ts src/agents/ui-presentation-prompt.test.ts src/agents/embedded-agent-runner/run/attempt-tool-search-prompt.test.ts --maxWorkers=1
  • pnpm test src/agents/system-prompt.cache-prefix.test.ts src/agents/embedded-agent-runner/session-prompt-state.test.ts src/agents/agent-tools.prefix-stability.test.ts --maxWorkers=1
  • pnpm tsgo:core
  • git diff --check

What I checked:

PR surface

Source +342, Tests +452, Docs +5. Total +799 across 45 files. Added test files: 3.

View PR surface stats
Area Files Added Removed Net
Source 21 817 475 +342
Tests 18 619 167 +452
Docs 6 21 16 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 45 1457 658 +799

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.

Labels

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 27, 2026, 4:42 AM ET / 09:42 UTC.

- CI reds on the first head were tests asserting the old wording or the removed lean directory tier; they now assert the rules and the names-only directory.
- UI Presentation keeps "report blocked/unverified results" (the shave had dropped "blocked").
- Deferred directory: tools marked [loads on lookup] become top-level after tool_describe and are called only by name; the dispatch_action rule applies to the other names (both modes), as on main.
- Skills: the one-skill limit applies up front again; listed names or search by goal/terms, and search covers installed skills only.
- Restored qualifiers the wording pass had dropped: explicit skill gates, retry before concluding, proactively return, restart path before stopping, persistent sessions, visible=true not for independent sessions, memory skip only when context fully answers, corpus=all only for wiki supplements, not-registered informational only without a top-level warning.
@obviyus
obviyus merged commit 219b6b0 into main Nov 27, 2026
146 checks passed
@obviyus
obviyus deleted the perf/system-prompt-manifest branch November 27, 2026 10:31
obviyus added a commit that referenced this pull request Nov 27, 2026
…206762)

## Problem

User issue: #200920 (system prompt and per-request bytes), partly addressed.


After #206537, the fresh-install system prompt is still 15,067 B on the first request of `agent --local`. Much of it describes *how* to use tools that are deferred behind Tool Search: memory recall recipes, session-routing details, `sessions_spawn` briefs and polling rules, dashboard/portal/screen recipes, and Skill Workshop file rules. These instructions are re-sent on every request, although the model can read each tool's description on demand.

## Solution

- Every *when to act* trigger stays in the prompt.
- Each deferred tool's *how-to* text moves into that tool's own description, which `tool_search` and `tool_describe` return. Where the description already said it, the prompt copy is deleted.
- Directly sent tools (exec, process, read, openclaw, sessions_yield, …) are unchanged, because moving text into them saves nothing.
- Descriptions are decided from session and config facts only, so tool definitions stay byte-stable within a session.

| Section (fresh `--local`) | Before | After | Where the details went |
|---|---:|---:|---|
| Memory Recall | 919 | 174 | `memory_search`, `memory_get`, `sessions_search`, `sessions_history`. A citations-off disclosure limit stays in the prompt when configured, because Code Mode may defer descriptions. |
| Deferred Tool Schemas | 2,493 | 1,934 | `sessions_spawn`, the cloud spawn tool and `subagents` (brief fields, completion modes, synthesis, polling). The delegation, cross-chat and third-request automation triggers stay. |
| UI Presentation | 835 | 154 | `screen`, `show_widget`, `dashboard`, `portal`. Facts about what is available this turn stay. |
| Skill Workshop | 633 | 196 | `skill_workshop` (user-owned skill files, undo after a Learned notice). |
| Session routing | 449 | 137 | `sessions_create`, `sessions_spawn` |

- **Fresh install:** `FRESH_INSTALL_SYSTEM_PROMPT_BUDGET_BYTES` is now 12,288 B, and the per-section manifest budgets are lower.
- **Unchanged on purpose:** the reviewed dispatch rule from #206537, and the Care, OpenClaw Control, Execution Bias, Promised Work, Output Directives and Tool Call Style sections.

## Who this helps

Gateway chat and `agent --local`, **embedded runtime only**. Rendered by `src/agents/system-prompt.ts` (manifest `system-prompt-manifest.ts`). It does not reach native-OpenAI users on the default Codex app-server runtime (audit 2026-11-27 §4.3).

## Evidence

**Bytes** (`agent --local` first request, fake provider, dist-nodts):

| | Before | After |
|---|---:|---:|
| Fresh system prompt | 15,067 B | 12,340 B (12.05 KiB) |
| Fresh request body | 33,809 B | 31,064 B |
| Configured system prompt | 23,571 B | 20,843 B |

Tool definitions are unchanged in size: 17,519 B fresh and 30,084 B configured. The unit fixture renders 11,395 B, under the new gate.

**Behavior suite:** real gpt-5.4-mini, 11 cases × 3 runs, base `ccdaf0fa` vs head. Gating: 33/33 on both sides, and every turn exited 0 (48/48 each). Answer quality is equal in all 10 judged cases. The one exception is the non-gating progress-card artifact quality: 2/3 on base and 0/3 on head. In every miss, the model labelled per-file totals as "discrepancies", and base shows the same miss. A rerun of 6 more runs of that case gave base 3/6 and head 5/6, so the combined result is 5/9 on each side. That is model noise, not this change: no moved text touches that task.

**Tests:**
- `system-prompt*`, prefix-stability, prompt snapshots, Tool Search on-demand, tool-surface bridge, tool-description presets, UI presentation, dashboard, portal, screen and widget tests pass.
- Memory-core, Skill Workshop and Codex thread-prompt tests pass.
- New contract tests cover the moved guidance in each tool's description, and check that the citations-off limit stays in the prompt.

**Review:** local ClawSweeper on `ba44312a` (final head): patch is correct, no findings.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Nov 27, 2026
## Problem

The Codex runtime sends a 13.8 KB `<thread_policy>` developer message on every request. 9.5 KB of it is the full `<available_skills>` catalog: name, description and file location for every installed skill.

The embedded runtime stopped doing this in #206537. When `skills_read` loads a skill by name, the location is unused. When `skills_search` is callable, it matches descriptions on demand. The Codex plugin renders its own catalog section and kept the full form.

Measured on main `e916ef677a95` through an isolated Gateway: `<thread_policy>` 13,801 B, of which `<available_skills>` 9,469 B.

## Solution

`renderCodexSkillsInstructions` (`extensions/codex/src/app-server/attempt-context.ts`) passes the catalog through the core owner `compactCatalogForSkillRead`, as the embedded route does:

- `skills_read` and `skills_search` callable: names only;
- only `skills_read` callable: names and descriptions;
- `skills_read` not callable: unchanged XML with locations. The Gateway-only location rewrite still runs for remote workspaces.

`compactCatalogForSkillRead` is added to `openclaw/plugin-sdk/agent-harness-runtime`, next to the other harness prompt builders.

## User impact

- Population: every Codex-runtime turn with installed skills (Gateway and one-shot).
- `<thread_policy>`: 13,801 → 4,511 B per request (−9,290 B).
- No change to which skills exist or how they load.
- Existing threads see the changed instructions on their next cold resume: one prompt-cache miss per thread.

## Evidence

- Isolated Gateway bench, fake provider: `<thread_policy>` 13,801 → 4,511 B; tool schemas unchanged.
- Codex-route behavior suite, gpt-5.4-mini, 3 trials per case, model-judged:
  - main 24/30, this PR 26/30;
  - skill loading 3/3 on both, through the same path (`skills_read` first in 6 of 6 trials, no extra tool search);
  - reply-directive 0/3 on both: an existing Codex-route gap, not caused here.
- Tests: `dynamic-tool-skills.test.ts`, `run-attempt.remote-skills.test.ts` and `run-attempt.skills.native.test.ts` pass. `plugin-sdk:check-exports` passes.
- Local ClawSweeper on this head: 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 28, 2026
…openclaw#206537)

## Problem

On a fresh install, the first request of `openclaw agent --local` carries a 29 KB system prompt (about 3x Pi). One large function builds it, helped by scattered section builders, and nothing limits its size. The Tool Search directory alone repeats 11.6 KB of tool descriptions on every request, and the skills catalog adds 4.2 KB. `tool_search`, `tool_describe` and `skills_search` already supply those details on demand. The 2.6 KB `message` tool is also sent in runs that have no channel to send to.

## Solution

The change has three parts:

1. `test(agents)`: byte snapshots of the fresh-install and configured system prompts, generated on the base commit.
2. `refactor(agents)`: one owner renders the prompt from a declared manifest, `src/agents/system-prompt-manifest.ts`. Each section has an id, an owner file, a region (stable, dynamic or runtime), an inclusion condition and a byte budget. `buildAgentSystemPrompt` renders only through one renderer per manifest id, in manifest order. The output is byte-identical: the base snapshots pass unchanged, and dist `agent --local` first requests match the base byte for byte for fresh, bootstrap and configured installs.
3. `perf(agents)`: shrinks the prompt, largest sections first. Each cut has its reason:
   - The deferred Tool Search directory lists names only. Descriptions come from `tool_search` and `tool_describe`. The lean-only description tier is gone, so lean and default agents render the same directory.
   - The skills catalog lists names only when `skills_read` and `skills_search` are both usable; search matches descriptions on demand. Without search, the compact catalog keeps descriptions.
   - Directory tools marked `[loads on lookup]` keep their own call rule; the `dispatch_action` rule covers the other names.
   - `message` is omitted when the session has neither a supported source nor a configured messaging route, also on fixed listings. Availability is a session and config fact, so the pinned tool list stays fixed for the session.
   - Wording is tightened in Execution Bias, Promised Work, Runtime Context, Tool Call Style, Care, OpenClaw Control, Session routing, Documentation, UI Presentation, Memory Recall and Skill Workshop. No rule is removed.
   - Gate: `system-prompt.inventory-snapshot.test.ts` fails when the fresh-install fixture exceeds `FRESH_INSTALL_SYSTEM_PROMPT_BUDGET_BYTES` (13,500 B; the fixture renders 12,864 B) or when any section exceeds its manifest budget.

## Impact

First request, fake provider, `agent --local`:

| | before | after |
|---|---:|---:|
| fresh install: system prompt | 29,157 B | 15,015 B |
| fresh install: tools array | 20,108 B | 17,542 B |
| fresh install: request body | 50,554 B | 33,780 B |
| configured agent: system prompt | 37,534 B | 23,491 B |
| configured agent: request body | 69,061 B | 54,959 B |

Per section on a fresh install: Deferred Tool Schemas 11,596 -> 2,483 B; Skills 4,249 -> 1,047 B; OpenClaw Control 2,199 -> 1,803 B; Memory Recall 1,202 -> 812 B; Skill Workshop 848 -> 633 B; Session routing 562 -> 404 B; the `message` tool section 558 -> 0 B. Other sections shrink 5-10%.

Each change to the stable sections starts one new prompt series per session after upgrade (one cache miss). Pinned series keep their bytes until then.

## Evidence

Behavior suite: real gpt-5.4-mini, `agent --local`, 3 trials per case. Base is `ca15e2952f` (manifest only); head is `c5752270fb`, the shave before review restored a few dropped qualifiers (base wording, +341 B). Pass/fail is judged structurally from the recorded provider calls; answer quality is judged by a model against a written rubric.

| Case | Base | Head |
|---|---:|---:|
| read a file | 3/3 | 3/3 |
| shell command | 3/3 | 3/3 |
| skill discovery and load | 3/3 | 3/3 |
| deferred tool (`session_status`) | 3/3 | 2/3 |
| MCP tool call | 3/3 | 3/3 |
| reply directive | 3/3 | 3/3 |
| safety confirmation | 3/3 | 3/3 |
| memory recall | 3/3 | 3/3 |
| subagent spawn | 3/3 | 3/3 |
| compaction recall | 3/3 | 3/3 |
| progress card | 3/3 | 3/3 |

- The head `session_status` miss made the correct calls and gave the correct answer. Then the CLI exited 1 at shutdown with `Database maintenance resource scope is closed`. Over all runs this happened in 3 of 21 head trials and 0 of 15 base trials, and only in this case. It looks like an existing `--local` shutdown race and is tracked separately.
- Skill loading now goes through `skills_read` in every head trial. Base read SKILL.md from the filesystem in 2 of 3 trials.
- Local ClawSweeper on `1ebe079678`: patch is correct, no findings. Earlier rounds found and fixed: keep skill descriptions when `skills_search` is unavailable; keep the on-demand exception in the directory's dispatch rule; keep the one-skill limit scoped to initial selection; restore other qualifiers the wording pass dropped.
- Green: system-prompt, tool-search, attempt-bundle-tools, memory-core, copilot and codex thread-prompt suites; prompt snapshot drift; `agent-tools.prefix-stability`; `tsgo`; lint; format; line cap.

## Not in scope

- Plugin and SDK prompt contracts stay as declared slots: provider `transformSystemPrompt` and promptContribution, `before_prompt_build` contexts, context-engine `systemPromptAddition`, and the permission notice.
- `progress_card` stays listed. Its plan-completion check and channel plan updates work without a UI.
- `toolSearchDirectoryLean` stays an accepted optional field in the worker presentation schema. Core no longer reads it; removing it is a protocol change.

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

## Problem

User issue: openclaw#200920 (system prompt and per-request bytes), partly addressed.


After openclaw#206537, the fresh-install system prompt is still 15,067 B on the first request of `agent --local`. Much of it describes *how* to use tools that are deferred behind Tool Search: memory recall recipes, session-routing details, `sessions_spawn` briefs and polling rules, dashboard/portal/screen recipes, and Skill Workshop file rules. These instructions are re-sent on every request, although the model can read each tool's description on demand.

## Solution

- Every *when to act* trigger stays in the prompt.
- Each deferred tool's *how-to* text moves into that tool's own description, which `tool_search` and `tool_describe` return. Where the description already said it, the prompt copy is deleted.
- Directly sent tools (exec, process, read, openclaw, sessions_yield, …) are unchanged, because moving text into them saves nothing.
- Descriptions are decided from session and config facts only, so tool definitions stay byte-stable within a session.

| Section (fresh `--local`) | Before | After | Where the details went |
|---|---:|---:|---|
| Memory Recall | 919 | 174 | `memory_search`, `memory_get`, `sessions_search`, `sessions_history`. A citations-off disclosure limit stays in the prompt when configured, because Code Mode may defer descriptions. |
| Deferred Tool Schemas | 2,493 | 1,934 | `sessions_spawn`, the cloud spawn tool and `subagents` (brief fields, completion modes, synthesis, polling). The delegation, cross-chat and third-request automation triggers stay. |
| UI Presentation | 835 | 154 | `screen`, `show_widget`, `dashboard`, `portal`. Facts about what is available this turn stay. |
| Skill Workshop | 633 | 196 | `skill_workshop` (user-owned skill files, undo after a Learned notice). |
| Session routing | 449 | 137 | `sessions_create`, `sessions_spawn` |

- **Fresh install:** `FRESH_INSTALL_SYSTEM_PROMPT_BUDGET_BYTES` is now 12,288 B, and the per-section manifest budgets are lower.
- **Unchanged on purpose:** the reviewed dispatch rule from openclaw#206537, and the Care, OpenClaw Control, Execution Bias, Promised Work, Output Directives and Tool Call Style sections.

## Who this helps

Gateway chat and `agent --local`, **embedded runtime only**. Rendered by `src/agents/system-prompt.ts` (manifest `system-prompt-manifest.ts`). It does not reach native-OpenAI users on the default Codex app-server runtime (audit 2026-11-27 §4.3).

## Evidence

**Bytes** (`agent --local` first request, fake provider, dist-nodts):

| | Before | After |
|---|---:|---:|
| Fresh system prompt | 15,067 B | 12,340 B (12.05 KiB) |
| Fresh request body | 33,809 B | 31,064 B |
| Configured system prompt | 23,571 B | 20,843 B |

Tool definitions are unchanged in size: 17,519 B fresh and 30,084 B configured. The unit fixture renders 11,395 B, under the new gate.

**Behavior suite:** real gpt-5.4-mini, 11 cases × 3 runs, base `d9d4eaa7` vs head. Gating: 33/33 on both sides, and every turn exited 0 (48/48 each). Answer quality is equal in all 10 judged cases. The one exception is the non-gating progress-card artifact quality: 2/3 on base and 0/3 on head. In every miss, the model labelled per-file totals as "discrepancies", and base shows the same miss. A rerun of 6 more runs of that case gave base 3/6 and head 5/6, so the combined result is 5/9 on each side. That is model noise, not this change: no moved text touches that task.

**Tests:**
- `system-prompt*`, prefix-stability, prompt snapshots, Tool Search on-demand, tool-surface bridge, tool-description presets, UI presentation, dashboard, portal, screen and widget tests pass.
- Memory-core, Skill Workshop and Codex thread-prompt tests pass.
- New contract tests cover the moved guidance in each tool's description, and check that the citations-off limit stays in the prompt.

**Review:** local ClawSweeper on `ba44312a` (final head): 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 28, 2026
…law#206995)

## Problem

The Codex runtime sends a 13.8 KB `<thread_policy>` developer message on every request. 9.5 KB of it is the full `<available_skills>` catalog: name, description and file location for every installed skill.

The embedded runtime stopped doing this in openclaw#206537. When `skills_read` loads a skill by name, the location is unused. When `skills_search` is callable, it matches descriptions on demand. The Codex plugin renders its own catalog section and kept the full form.

Measured on main `a62d6b8eff91` through an isolated Gateway: `<thread_policy>` 13,801 B, of which `<available_skills>` 9,469 B.

## Solution

`renderCodexSkillsInstructions` (`extensions/codex/src/app-server/attempt-context.ts`) passes the catalog through the core owner `compactCatalogForSkillRead`, as the embedded route does:

- `skills_read` and `skills_search` callable: names only;
- only `skills_read` callable: names and descriptions;
- `skills_read` not callable: unchanged XML with locations. The Gateway-only location rewrite still runs for remote workspaces.

`compactCatalogForSkillRead` is added to `openclaw/plugin-sdk/agent-harness-runtime`, next to the other harness prompt builders.

## User impact

- Population: every Codex-runtime turn with installed skills (Gateway and one-shot).
- `<thread_policy>`: 13,801 → 4,511 B per request (−9,290 B).
- No change to which skills exist or how they load.
- Existing threads see the changed instructions on their next cold resume: one prompt-cache miss per thread.

## Evidence

- Isolated Gateway bench, fake provider: `<thread_policy>` 13,801 → 4,511 B; tool schemas unchanged.
- Codex-route behavior suite, gpt-5.4-mini, 3 trials per case, model-judged:
  - main 24/30, this PR 26/30;
  - skill loading 3/3 on both, through the same path (`skills_read` first in 6 of 6 trials, no extra tool search);
  - reply-directive 0/3 on both: an existing Codex-route gap, not caused here.
- Tests: `dynamic-tool-skills.test.ts`, `run-attempt.remote-skills.test.ts` and `run-attempt.skills.native.test.ts` pass. `plugin-sdk:check-exports` passes.
- Local ClawSweeper on this head: patch is correct, no findings.

Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus added a commit that referenced this pull request Nov 28, 2026
…elegation family together (#207314)

## Problem

With Tool Search on (the default), #206801 made `subagents` and `agents_wait` direct tools. It did that only because the repeat guard read `dispatch_action`'s own `repeatable` declaration, not the declaration of the tool the call names. A model polling its children through `dispatch_action` got a "stop repeating" note at call 3 and `tool_repeat_limit` at call 20.

That fix split the delegation family. `subagents` ("Subagent status/cancel") and `agents_wait` were sent with full schemas, while `sessions_spawn` stayed a bare name in the deferred list. gpt-5.4-mini then treated the two visible tools as the whole subagent capability and answered "sessions_spawn isn't available".

Behavior-suite history for the subagent-spawn case: 21/21 found the tool before #206801 and 6/20 after.

## Fix

The repeat guard now reads the target's declaration, and the polling tools are deferred again, with no added prompt bytes.

- **One dispatcher argument reader.** The reader for selectors and input forms moved from `src/agents/tool-search-request.ts` to `packages/agent-core/src/dispatch-call.ts`:
  - selectors: `id`, `toolId`, `name`;
  - input: `args`, `input`, `args.<field>`, flattened arguments, and a selector wrapped inside the input.
  - `dispatch_action` executes through it with catalog matching. The repeat guard classifies through it with target matching. Both see the same target and the same input for every call form.
- **Plain-data dispatcher declaration.** `ToolRepeatable` gets `{ dispatch: { targets, aliases } }`. `applyToolCatalogCompaction` builds it from the registered catalog: each trusted tool's own `repeatable` by catalog id, with its name as an alias when the name is unique.
  - The guard applies the target's own `true | { actions }`. A dispatched poll is exempt exactly as a direct call would be.
  - A selector that names anything else counts as a different target. A call with disagreeing selectors stays counted, matching the dispatcher, which refuses it as ambiguous.
  - The declaration is read once per call, on the path the call takes.
- **Polling tools deferred again.** The "repeatable → direct" rule is removed.
- **One visibility for the delegation family.** The Tool Search owner (`tool-search-catalog-visibility.ts`) lists `sessions_spawn`, `subagents` and `agents_wait` as one family.
  - If any member is sent directly (caller-required, or kept outside the catalog by a selector), the whole family is sent directly.
  - A member shown only because of its family never shadows a tool with the same name.
  - On the default surface the whole family is deferred.

## Why this and not "send `sessions_spawn` directly"

The first version of this PR made the family direct: +12,236 B on every request, +35% on the first request. It was held because:

- it undoes most of the prompt savings from #206537 and #206801;
- reverting it later would change the tool prefix, and so bust deployed caches, twice;
- #206801 is only on main, so no released user is affected.

This version costs 0 KB. The first request is 1.4 KB smaller than on main, because the polling schemas leave the tool list.

## Evidence

| Check | Tier | main `6d8e821a` | This PR |
|---|---|---|---|
| Both Tool Search modes defer the whole family; every non-empty member subset, with and without an include selector, has one visibility; 25 identical polls of `agents_wait` (name and catalog id) and `subagents list` through `dispatch_action` run with no note and no stop | vitest-source | **7 of 9 fail** | 10/10 pass |
| A non-polling action (`subagents cancel`) and a non-repeatable tool repeated through `dispatch_action` still stop at call 20 | vitest-source | pass | pass |
| Guard unit test: every dispatcher call form is exempt for a polling target; disagreeing selectors, unknown targets and non-polling actions are counted | vitest-source | n/a | pass |
| `agent-tools.prefix-stability.test.ts`, Tool Search and runtime suites, `prompt:snapshots:check` | vitest-source / source | | green / current |

Real gpt-5.4-mini runs (low thinking) on the subagent-spawn case, 5 trials per cell, against main `6d8e821a`:

| Route | `sessions_spawn` called, main | `sessions_spawn` called, this PR | First request, main → this PR |
|---|---|---|---|
| Gateway | 9/10 (1 reply: "sessions_spawn isn't available") | **10/10** | 34.6 → 33.2 KB |
| `--local` | 4/5 (2/5 and 2/6 in earlier runs) | **10/10** | 33.8 → 32.4 KB |

What the user sees:
- **Gateway, with a 60 s window for the child's completion:** the child's result reached the user in 5/5 runs on this PR and 4/5 on main.
- **How the result arrives:**
  - With `subagents` deferred, 3 of 5 runs end the turn with `sessions_yield`, and the result arrives in the following completion message.
  - On main, the model waited inside the turn with the direct `subagents wait`. That pattern only exists since #206801.
  - Pre-#206801 behavior is the same yield pattern.
  - A yielded turn returns an empty CLI payload. That is an existing `sessions_yield` presentation gap, not caused by this change.
- **No over-delegation:** read-file, shell-command and memory-recall, 3 trials each, both routes: 9/9 on main and on this PR, 0 spawn calls, and the same request count (15).
- **`--local` caveat:** every variant's spawn then fails at runtime with "published reply runtime missing". That is a separate open gap, so only the call counts on that route.

No worker protocol change. Workers compact Tool Search locally from each tool's own `true | { actions }` declaration, so the dispatcher form never crosses the wire. No change reaches the Control UI bundle either: shared `core-tool-facts.ts` is untouched.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 29, 2026
…elegation family together (openclaw#207314)

## Problem

With Tool Search on (the default), openclaw#206801 made `subagents` and `agents_wait` direct tools. It did that only because the repeat guard read `dispatch_action`'s own `repeatable` declaration, not the declaration of the tool the call names. A model polling its children through `dispatch_action` got a "stop repeating" note at call 3 and `tool_repeat_limit` at call 20.

That fix split the delegation family. `subagents` ("Subagent status/cancel") and `agents_wait` were sent with full schemas, while `sessions_spawn` stayed a bare name in the deferred list. gpt-5.4-mini then treated the two visible tools as the whole subagent capability and answered "sessions_spawn isn't available".

Behavior-suite history for the subagent-spawn case: 21/21 found the tool before openclaw#206801 and 6/20 after.

## Fix

The repeat guard now reads the target's declaration, and the polling tools are deferred again, with no added prompt bytes.

- **One dispatcher argument reader.** The reader for selectors and input forms moved from `src/agents/tool-search-request.ts` to `packages/agent-core/src/dispatch-call.ts`:
  - selectors: `id`, `toolId`, `name`;
  - input: `args`, `input`, `args.<field>`, flattened arguments, and a selector wrapped inside the input.
  - `dispatch_action` executes through it with catalog matching. The repeat guard classifies through it with target matching. Both see the same target and the same input for every call form.
- **Plain-data dispatcher declaration.** `ToolRepeatable` gets `{ dispatch: { targets, aliases } }`. `applyToolCatalogCompaction` builds it from the registered catalog: each trusted tool's own `repeatable` by catalog id, with its name as an alias when the name is unique.
  - The guard applies the target's own `true | { actions }`. A dispatched poll is exempt exactly as a direct call would be.
  - A selector that names anything else counts as a different target. A call with disagreeing selectors stays counted, matching the dispatcher, which refuses it as ambiguous.
  - The declaration is read once per call, on the path the call takes.
- **Polling tools deferred again.** The "repeatable → direct" rule is removed.
- **One visibility for the delegation family.** The Tool Search owner (`tool-search-catalog-visibility.ts`) lists `sessions_spawn`, `subagents` and `agents_wait` as one family.
  - If any member is sent directly (caller-required, or kept outside the catalog by a selector), the whole family is sent directly.
  - A member shown only because of its family never shadows a tool with the same name.
  - On the default surface the whole family is deferred.

## Why this and not "send `sessions_spawn` directly"

The first version of this PR made the family direct: +12,236 B on every request, +35% on the first request. It was held because:

- it undoes most of the prompt savings from openclaw#206537 and openclaw#206801;
- reverting it later would change the tool prefix, and so bust deployed caches, twice;
- openclaw#206801 is only on main, so no released user is affected.

This version costs 0 KB. The first request is 1.4 KB smaller than on main, because the polling schemas leave the tool list.

## Evidence

| Check | Tier | main `402dc418` | This PR |
|---|---|---|---|
| Both Tool Search modes defer the whole family; every non-empty member subset, with and without an include selector, has one visibility; 25 identical polls of `agents_wait` (name and catalog id) and `subagents list` through `dispatch_action` run with no note and no stop | vitest-source | **7 of 9 fail** | 10/10 pass |
| A non-polling action (`subagents cancel`) and a non-repeatable tool repeated through `dispatch_action` still stop at call 20 | vitest-source | pass | pass |
| Guard unit test: every dispatcher call form is exempt for a polling target; disagreeing selectors, unknown targets and non-polling actions are counted | vitest-source | n/a | pass |
| `agent-tools.prefix-stability.test.ts`, Tool Search and runtime suites, `prompt:snapshots:check` | vitest-source / source | | green / current |

Real gpt-5.4-mini runs (low thinking) on the subagent-spawn case, 5 trials per cell, against main `402dc418`:

| Route | `sessions_spawn` called, main | `sessions_spawn` called, this PR | First request, main → this PR |
|---|---|---|---|
| Gateway | 9/10 (1 reply: "sessions_spawn isn't available") | **10/10** | 34.6 → 33.2 KB |
| `--local` | 4/5 (2/5 and 2/6 in earlier runs) | **10/10** | 33.8 → 32.4 KB |

What the user sees:
- **Gateway, with a 60 s window for the child's completion:** the child's result reached the user in 5/5 runs on this PR and 4/5 on main.
- **How the result arrives:**
  - With `subagents` deferred, 3 of 5 runs end the turn with `sessions_yield`, and the result arrives in the following completion message.
  - On main, the model waited inside the turn with the direct `subagents wait`. That pattern only exists since openclaw#206801.
  - Pre-openclaw#206801 behavior is the same yield pattern.
  - A yielded turn returns an empty CLI payload. That is an existing `sessions_yield` presentation gap, not caused by this change.
- **No over-delegation:** read-file, shell-command and memory-recall, 3 trials each, both routes: 9/9 on main and on this PR, 0 spawn calls, and the same request count (15).
- **`--local` caveat:** every variant's spawn then fails at runtime with "published reply runtime missing". That is a separate open gap, so only the call counts on that route.

No worker protocol change. Workers compact Tool Search locally from each tool's own `true | { actions }` declaration, so the dispatcher form never crosses the wire. No change reaches the Control UI bundle either: shared `core-tool-facts.ts` is untouched.

Co-authored-by: Ayaan Zaidi <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 29, 2026
…205987)

## Class: completion is published before required maintenance finishes

Fleet run `4de610c8-e63d-4336-8e85-a76379cfd934` committed and served the new core, but its completion notice preceded the failed plugin result. The bug is ordering, not the core's status.

The modern Gateway-ready owner now settles once **after** required plugin work and sends one final notice afterward. A failed plugin remains a failed step, not a failed core update or a rollback trigger. Existing CLI following and capability-consent behavior remain; the failed-status/early-exit/backoff experiment is removed.

CLI completion, status, Doctor history and the Control UI reuse the existing `renderUpdateRunSummary` over recorded facts. Running results keep their phase; succeeded results name the installed after-version; skipped results keep their existing reason headline, never a guessed serving state. Failed work names its step and exact recovery command. Startup refusal diagnostics, structured failure facts, rollback compensation reasons, recorded signal output and profile-specific recovery commands remain visible. Existing discriminators distinguish repair and reconciled-history records from core updates. Background completion never rewrites the shared trial, preserving a newer pending trial and restart resumption.

## What this deletes

- `renderUpdateRunReport`, its private recovery hints and cause module.
- Routine Markdown completion publication/refresh, automatic `reportPath` output, and artifact-only admission/options plumbing.
- Obsolete completion-export tests and renderer-only assertions. Ledger, recovery, authority, privacy and step-detail assertions remain on their retained data owners.
- The abandoned failed-status classifier, campaign/retry exceptions, early-return CLI path and associated UI/test allocation.

**Kept deliberately:** explicit consent-gated **Report update failure** GitHub preview/submission, its reservation/receipt authority and sanitized issue artifacts. The remaining `update-failure-report*` code serves that user feature and triage, not routine completion. Identity/recovery and legacy result/sentinel projections remain because those manual-report and sentinel consumers still use them.

No new status, state store, flag, stored-record shape or launcher format.

## Size

`tokei` on this PR's **20 production files**, excluding tests/support/harnesses, against integrated main `6ac896f4cbb8bc29940c625cb1e2b19990e87284`:

| | Before | After | Net |
| --- | ---: | ---: | ---: |
| Production code lines | 7,758 | 7,148 | **−610** |
| Test/support lines | | | **−1,257** |

## Verification

- The earlier base Gateway-owner regression exposed the premature terminal write before plugin settlement. Final owner tests pin delayed settlement, unchanged successful core status, exact plugin recovery, one acknowledged final notice, newer-trial preservation and restart resumption.
- **Earlier focused AWS replay GREEN:** nine observed prepare/status/progress regression cases passed in99s; core and CLI-update types, scoped lint (zero warnings/errors) and format passed. https://crabbox.openclaw.ai/portal/runs/run_e5a8682ccf98bb7765b9d075be801705 . Exact qualified source was `5c6686ad20f50377f6affdec0d948f362dc37851`, tree `5ed1cb6e544fbd93604eea566b550f0c722842c8`, normal carrier `d2821086c00e55c8de35d00d7a4418168ca25a2d`; lease released with `--wait`. This is not claimed as an exact-head run after the later shared-summary/UI refinements.
- **Final pushed head:** `79182af301a6166914840dab9a705f4fa5c72fbd`. Restores the existing installed-runtime admission receipt before stop-and-repair advice, keeps historical summaries informational, and types the captured handoff notice without weakening assertions. Three requested files passed once: guidance32/32, handoff19/19, UI view15/15 (**66/66**). https://crabbox.openclaw.ai/portal/runs/run_ea4006e0b21e09bfbd763abe6e25929a . Qualified source was `985dd796d1` plus those two frozen restores, tree `45fe9f49c964b39806b431cde018432ed6e472fc`, normal carrier `81d874a77bb7de2f72307cca91f827db71ec7850`. Exact AWS lease released with `--wait`, exit0. Final-head CI remains the landing gate.
- **Repair candidate:** `1f223e15a20a04a27a4f745af81fb11b106d9d40`. Plain integrated main `6ac896f4cbb8bc29940c625cb1e2b19990e87284` passed all39 CLI tests on hydrated AWS4CPU/7730MiB, including the #205898 restart-wire case in31ms: https://crabbox.openclaw.ai/portal/runs/run_97637e77b460fbb7176bd261693cabd1 . B's timeout came from its local ledger fixture using a remote run ID; the fixture is corrected without changing main's captured connection contract.
- **Node regression batch:** nineteen files on repair predecessor `eede`, 481passed/4failed/1skipped; core types, scoped lint and format passed. https://crabbox.openclaw.ai/portal/runs/run_fbcf26ce68d5a5a539f63f6ee793237a . The four residuals were an early-return saved-notice recognition bug, two assertions pinning retired reconciled wording, and a native-refusal assertion reading a clipped excerpt instead of its retained structured cause. All are corrected without changing generic ledger storage.
- **Final-head residual proof:** summary18/18, abandoned-repair rows2/2 and native-start refusal1/1 passed; core and CLI-update types plus scoped format passed. https://crabbox.openclaw.ai/portal/runs/run_f4e633ac557bce484d1939c03cf88b3f . Source tree `9112e46c2b3081aab02b3dc9a0dfc1e0c06da55f`, normal carrier `82470c4669b7cc502049fa978dc5ed37defb6c6a`, AWS4CPU/7730MiB. Scoped lint did **not** run: its normal SDK declaration preparation failed first with TypeScript/vscode-jsonrpc `ERR_STREAM_DESTROYED`. No retry or bypass; current-head CI remains the lint gate.
- Historical failed-status screenshots, broad partial qualification and prior reviews describe the superseded design, **not** this head.
- No new upgrade source, death proof, harness test or Linux product campaign is added. Superseded remote proof jobs were cancelled and all their leases released with `--wait`.
- The ready-time settlement owner tests passed on integrated `9aba`: `gateway-trial.test.ts`18/18. Later output refinements do not change that settlement policy. Frozen `01b` UI reproduction observed unit14pass/1fail and E2E8pass/2fail. On repair predecessor `eede`, unit15/15, UI/pages/E2E types and scoped lint/format passed. Final `f087` passed both changed E2E cases (standalone repair history; warning advice and keyboard-accessible output), UI/pages/E2E types, scoped lint and format: https://crabbox.openclaw.ai/portal/runs/run_13701071e15057d5ac5c4ac5e927c65d . Source tree `3c734ef709a186303996517ecad54c5e5d4a0e9c`; exact lease released with `--wait`. The other8 E2E cases passed on `eede` and were intentionally not repeated.
- **Accepted budget cost:** exact `1f223` CI measures chat boot gzip **1,336,500→1,337,028 (+528 B)**, requests21→21; startup+1 B. Base already exceeds its cap, so normal tolerance is64 B (464 B excess). https://github.com/openclaw/openclaw/actions/runs/45885636780/job/140136424955 . Cause: `update-run-projection.ts` synchronously imports the shared summary for the existing card/view projection; the existing async result boundary already imports it dynamically. Ayaan accepted this cost for this PR through Main; no new async plumbing or budget config. Main applies the performance-only override at merge; every other gate remains required.
- **Final-head budget receipt (`79182`):** chat boot gzip **1,336,744→1,337,247 (+503 B)**, requests21→21; startup+1 B, normal tolerance64 B. https://github.com/openclaw/openclaw/actions/runs/45895112042/job/140167696819 . This is below the accepted predecessor's +528 B cost; same synchronous-summary cause, no new plumbing/config. Remaining CI gates are still pending.
- **Latest pushed head: `be86da0464892c10cbe7207ff98228eb1e81758a` (test-only delta).** The shared notice mock uses its production signature; no cast or weakened notice assertion remains. Healthy final recovery without an installed-runtime admission receipt explicitly expects update-again/no-stop advice. Two affected files passed once (**81/81**: handoff19, post-update62), focused Gateway/CLI-update types and lint passed: https://crabbox.openclaw.ai/portal/runs/run_c8784e2fe001772ae88bae53af8d9747 . Qualified source was `79182` plus the frozen test edits; only generic-type wrapping changed mechanically afterward, normal commit hooks passed. No production/budget change.
- The prior ratchet failure is infrastructure: its GitHub annotation says the hosted runner lost communication, leaving the baseline-ratchet step without a verdict. Its log fetch returned BlobNotFound/404. No old-head rerun was accepted or needed; this head's normal CI runs the ratchet again.
- **Latest pushed head: `bf3ab61efbb9dba856bfc4d651c7fc77f44549f2` (one exact-copy test assertion).** Requested same-guest owner-file comparison: plain main `993d0b77`13/13 passed ([run](https://crabbox.openclaw.ai/portal/runs/run_4983803c6c82c64295d7d513ac8b52cd)); `be86`12/13 passed ([run](https://crabbox.openclaw.ai/portal/runs/run_51b38ba2049d66bdf6437b89731bf787)), failing only the expected generic details tail. The actual last notice correctly preserves `commands.restart=false` and its app/operator remedy. This commit changes only the exact expected string, retaining acknowledgement, no-update and last-call/context assertions; no mock runtime or production change. No extra local rerun: new-head CI verifies the migrated expectation.

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

(cherry picked from commit ed8b883)

Release adaptation: Port Gateway run/notice timing and the existing maintenance result contract only; retain beta.2 CLI, Doctor and UI summary surfaces and explicit failure reports. Fold in #208074 abort/grace follow-up where applicable.

Later same-path commits from the pinned scan (separate behavior unless named as folded/selected below): 974d792 fix: keep update status quiet and app-managed updates honest (#208359); 186e941 fix: restore the dependency check on main (#207741); dae01a9 fix: keep other agents running when one store is refused (#208364); c9f7a98 fix: keep container Gateway commands from rolling back host updates (#208271); edb6820 fix: let the Gateway restart while boot plugin maintenance is running (#208074); bb37856 fix: keep Windows WebChat connected during config reloads (#208109); 516166c fix: exit once when gateway run rejects an argument after an update (#208068); 07e96dc fix: restart the Gateway after real plugin repairs (#208207); bd48ff6 fix: avoid restarting the Gateway for plugin timestamp changes (#208119); 259f71c fix: stop Linux service starts from copying the whole agent database (#207969); 7cb8975 fix: keep forked Claude chats separate after a Gateway crash (#208048); 6d300d3 fix: restart launcher-managed Gateways after exit 78 (#207972); 90ff668 fix: stop treating limited access as an Inbox alert (#207737); ec39a90 fix(whatsapp): retain sender for explicit current-message reactions (#190121); 86ca412 fix: show the saved quota reset when chat skips its only model (#207210); c4a675f fix: avoid reloading unchanged plugins after Gateway boot (#207949); 13c67a1 fix: let updates back up deeply nested databases (#207756); e2fcd4d fix: acknowledge updates when the Gateway first becomes ready (#207819); 8933edd fix: name safe recovery when agent schema markers disagree (#207705); 19e9dd6 fix(gateway): keep Linux legacy lock recovery explicit (#207340); 54b5989 test(update): move startup diagnostics to the live CLI (#207589); fbf1aae fix: give safe update ownership guidance and restore legacy result delivery (#207640); 0cbe433 test(gateway): move update admission tests to the current handler (#207545); a922203 refactor(update): remove native post-activation Doctor subprocess (#207585); c72bd9a fix(anthropic): show Claude CLI quota usage from the native login (#207543); 7ac87ad fix: avoid taking service-account ownership during updates (#207563); b3902a2 fix(update): allow in-place updates without a full state copy (#207448); 9fa8d14 refactor: trim redundant gateway test journeys (#207311); 2cf1cb6 test(cli): remove unused private fixture state (#207431); ece7a74 improve(workboard): apply the Control UI glossary and style to Workboard copy; 1c89587 fix: update system service packages without root state changes (#207304); dfd17d0 fix(docker): avoid pre-boot Doctor delays on container recreation (#207200); b616036 refactor(subagents): simplify ACP spawn relay ownership (#207023); 93ca762 improve: reduce allocations when preparing session rows (#207109); adb3716 fix(update): surface boot plugin repair advisories (#207163); f79ef8c fix: finish updates of 2026-11-17 main checkouts automatically on Linux and macOS (#207062); 3c4362b fix(update): preserve exception causes in failure history (#207085); 20c92a4 fix: converge plugins after every Gateway boot (#206926); 3078862 fix(update): clean up rejected Git update worktrees (#207040); 9993328 refactor(subagents): simplify kill claim and ownership handling (#207025); 97815bd refactor(subagents): consolidate registry cleanup and publication guards (#207064); e94f799 refactor(subagents): centralize requester turn matching (#206584); 819935f refactor(test): trim unused plugin fixture setup (#206982); 8ae0874 improve(gateway): avoid redundant cleanup for empty legacy auth stores (#206867); 4849bb7 fix(browser): report crashed tabs as tab-scoped failures (#194682); ea77ca3 refactor: report update failures from recorded runs (#206700); b19387e fix(test): cover SIGBREAK during pending update recovery (#206860); 18e53d8 fix: finish Linux upgrades after a legacy Gateway crashes (#206530); 8bd1863 chore(test): remove unused plugin contract fixture setup (#206812); f1841bc fix: stop repeating unchanged session state in every chat turn (#206766); f9a8f18 fix: clear the update warning after a retired model is repaired (#204778); 4d7e00b fix: let started participant runs and requests finish after an access change (#206747); 35cd392 improve: use less memory when waiting for an agent reply (#206733); 9845bf5 fix(test): keep readiness abort fixtures alive until stopped (#206660); 461f650 fix(ci): keep startup helpers internal (#206649); f89ae43 refactor(subagents): use cleanup and terminal owners in sweeps (#206533); a882e0f fix(agents): preserve task answers when sessions are reused (#126263); ccb6d81 fix: finish core updates when the Gateway is ready (#206560); 74f02b4 fix: refuse root updates of a system service that runs as another account (#206343); 01032b1 fix(update): keep acknowledged run IDs when status is unavailable (#206562); 3ce0582 refactor(subagents): centralize collector replay decisions (#206471); c2cfab0 chore: consolidate repeated test fixtures and guards (#198739); 219b6b0 perf(agents): render the system prompt from one manifest and halve it (#206537); 360e306 refactor(test): remove mocked outbound staging fixtures (#184863); cbdd907 fix: finish release updates after a slow launcher response (#206503); 81fc833 refactor(subagents): own dormant child Stop decisions (#206479); 91d4912 fix(update): stop using foreign recovery records as admission (#206295); 6feeb50 fix: stop 2026-11-17 main Git checkouts from half-switching on a schema update (#206341); be3c73e fix(subagents): finish claimed stops after session rotation (#206405); 5e5bb6e fix(update): round status inspection timeouts (#206250); 41afc0f fix(update): keep successful plugin reload warnings advisory (#206372); 6d86389 fix: finish healthy Git updates after an older verifier exits; da6ec1a fix(update): bound release CLI Gateway waits (#206252); d9a36b3 improve: skip unrelated harness discovery for isolated model calls (#206323); bcdb2ef improve(cli): skip channel and web discovery for model credentials (#206240).
Later PR-number mentions: none Later commit-SHA mentions: none
Pinned PR grep: ed8b883 fix(update): settle after plugins and share one completion summary (#205987)

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
Co-authored-by: sallyom <[email protected]>
(cherry picked from commit 3f00a51)

Companion audit: #204847 participant-limit propagation, #205572 worker exec settings, #204805 deferred tools, #206762 tool-description perf, and #206537 prompt manifest redesign touch neighboring owners but are not prerequisites for stable worker spawn guidance.

Release adaptation: Render the dedicated-worker hint only for worker placement; preserve stable local workflow text and keep both render sites on one delegation section binding, and let the worker hint suppress the duplicate full-surface messaging hint.

Co-authored-by: RomneyDa <[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 extensions: codex extensions: copilot extensions: memory-core Extension: memory-core gateway Gateway runtime impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. P2 Normal backlog priority with limited blast radius. plugin: skill-workshop rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. security-sensitive-changed size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant