Repository navigation
fix(skills): keep background reviews out of saturated token budgets - #173889
Merged
steipete merged 2 commits intoOct 16, 2026
Merged
Conversation
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
steipete
marked this pull request as ready for review
October 16, 2026 06:08
Contributor
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
steipete
deleted the
steipete/perf-micro-skill-workshop-tpm-burn-20260919
branch
October 16, 2026 06:40
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 17, 2026
…penclaw#173889) * fix(skills): keep background reviews out of saturated token budgets * fix(skills): isolate background review prompt and delivery context
leapdragon
pushed a commit
to leapdragon/openclaw-upstream
that referenced
this pull request
Oct 17, 2026
…penclaw#173889) * fix(skills): keep background reviews out of saturated token budgets * fix(skills): isolate background review prompt and delivery context (cherry picked from commit 9a6c6b1)
This was referenced Oct 19, 2026
RomneyDa
added a commit
that referenced
this pull request
Oct 20, 2026
…s in the Ultra lane Since #161057 the Skill Workshop counts iterations per session, so Ultra probe sessions trigger a background review after idling. The review runs under its own skill-workshop-review: run and does not inherit the session's thinking level, so the lane's every-request-is-max assertion failed on 2026.10.5 whenever a review reached the provider. On main, #173889 pins review runs to thinkLevel "low" (review-run.ts), which the OpenAI stream wrapper sends as effort "low". Expect that effort for review runs; Ultra runs and their sessions must still be max, and independent heartbeats stay medium. The live file is over the line cap, so the Ultra wire effort policy moves to a sibling helper with its observation type, and the deterministic review cases run in the normal helper suite. (cherry picked from commit ca15213, adapted to main's review thinking level)
RomneyDa
added a commit
that referenced
this pull request
Oct 20, 2026
…7319) * fix(test): treat the env-gated Agents API live proof as optional shard evidence test/gateway-agentsapi.live.test.ts (new since 2026.10.4) skips its only case unless OPENCLAW_LIVE_AGENTS_API=1, which the native live test-harness shard never sets, so the shard's no-passing-assertions guard failed it on every 2026.10.5 candidate once the other harness tests went green. Register it in the existing whole-file opt-in map like the other env-gated live proofs. (cherry picked from commit 761ef64) * fix(test): decode the Codex CLI JSON error after plugin uninstall The live Codex npm plugin lane matched the expected post-uninstall error against raw --json stdout, where quotes are escaped, so the correct owner-plugin-not-activatable error never matched. Decode the canonical CLI error message first, as the 2026.10.4 release line does (a9fd56d). (cherry picked from commit e8772a9) * fix(test): scope CLI announcement barrier to parent probe (cherry picked from commit d5c0db7) (cherry picked from commit a48d4a8) * test(live): wait out the crash-loop breaker before the orphan settles The native subagent restart live proof SIGKILLs the Gateway three times in about two minutes. The third unclean boot trips the documented restart-loop breaker (3 unclean boots within 5 minutes, #166238), which pauses restart settlement, including interrupted subagent recovery (#166846), until the unclean window drains. The orphan assertion added with the #169144 backport only waited 30 seconds, so the nonannouncing child was still `running`. Wait up to 360 seconds for the orphan settlement so the proof covers the breaker pause and the automatic resume after its window. Assertions are unchanged. 2026.10.4 passed because it predates the breaker pause, startup subagent reconciliation, and this assertion. Deterministic proof: the quiet-child e2e twin with SIGKILL restarts and an exec-blocked child passes with one prior kill; with two warm-up kills it logs "restart-loop breaker tripped" and the parent continuation never arrives within 60 seconds; with a 400-second wait it settles and passes (338s). (cherry picked from commit 1a4c2a0) * test(qa-lab): skip user-role runtime carriers in visible-child send proof The sessions_send visible-child proof timed out on every 2026.10.5 candidate: its synthetic provider picked the latest user item that lacked the legacy <<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>> marker as the user prompt. Since #168546 (backport 8d66b94), OpenAI-compatible Responses endpoints, including mock-openai, keep runtime context in a user-role "OpenClaw runtime context:" carrier after the user turn instead of a developer message. The fixture then read that carrier as the prompt, never saw the "send" prompt on turn 2, answered PARENT_READY again, and the test waited for PARENT_DONE until timeout. Captured provider requests: v2026.10.4 sends the turn-2 carrier with role developer; the 10.5 tip sends it with role user. Reverting a293f2e (#168410) left the failure unchanged. Select the prompt with the shared qa-lab isInternalRuntimeContextCarrierText helper, which already accepts current and legacy carrier shapes. (cherry picked from commit d3a06e7) * test(buzz): skip real reconnect backoff in cold-start recovery (cherry picked from commit fa2049a) * fix(release): let the Telegram release lane finish its 25 scenarios The isolated Telegram candidate job hit its 60-minute limit at scenario 24/25 on every 2026.10.5 candidate (about 62 minutes needed at 102-108s per packaged Gateway start). main carries the same Telegram scenario set and job, so raise the job budget to 90 minutes; the calling release-checks job keeps its 210-minute bound. Also carry the 2026.10.4 release-line fixture fix for telegram-prepared-delivery-recovery (8b78670): keep the audit receipt in the shared Gateway workspace and create it up front so the isolated SUT can append without EACCES. main still writes it under the private tempRoot. (cherry picked from commit 3cb49f0, adapted to main's runner anchor) * test(gateway): probe startup readiness on fresh connections The deferred-fleet startup test failed twice in 2026.10.5 FRV #12 with `fetch failed` / `read ECONNRESET`. Its Gateway shares the test process's event loop. A /healthz or /readyz probe could reuse a keep-alive socket that Undici still treated as live; when the request was written and a synchronous main-thread startup stall followed, the server's idle-timer callback ran before the poll phase read the request and destroyed the socket with the request unread, so the kernel reset the connection. main still probes with default keep-alive fetches. Probe with `Connection: close`, matching existing Gateway test probes. Assertions are unchanged. (cherry picked from commit e3c63f2, adapted to main's probe sites) * test(live): expect review effort for Skill Workshop background reviews in the Ultra lane Since #161057 the Skill Workshop counts iterations per session, so Ultra probe sessions trigger a background review after idling. The review runs under its own skill-workshop-review: run and does not inherit the session's thinking level, so the lane's every-request-is-max assertion failed on 2026.10.5 whenever a review reached the provider. On main, #173889 pins review runs to thinkLevel "low" (review-run.ts), which the OpenAI stream wrapper sends as effort "low". Expect that effort for review runs; Ultra runs and their sessions must still be max, and independent heartbeats stay medium. The live file is over the line cap, so the Ultra wire effort policy moves to a sibling helper with its observation type, and the deterministic review cases run in the normal helper suite. (cherry picked from commit ca15213, adapted to main's review thinking level) * test(release): forward-port 2026.10.4-line upgrade-survivor and runtime-smoke harness fixes Release-line harness fixes that 2026.10.1-2026.10.5 carried but main never received: - cron-scheduled-authority: seed the cron authority specimen through the published baseline's own SQLite writer (seedPublishedCronJobs) instead of a raw cron/jobs.json that current candidates treat as a retired pre-July store; drop owner fields for pre-2026.7.1 baselines (usesCronOwnerAtBaseline). The dispatcher passes the package root to seedState, and the scenario now requires a published baseline. - bundled plugin runtime smoke: join deferred read-only update discovery via update.status before the package-manager child watchdog. main still defers install discovery (`<manager> root -g`) until after ready, so it can race the watchdog's no-package-manager-children check. Skips the codex npm plugin live source-reply grep from the release commit: main already probes dynamic-tool-source-reply.ts and dynamic-tools.ts. (cherry picked from commit fcdf0d1, codex grep hunk dropped; cron seed test adapted to main's executable-mode fixture writes)
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 21, 2026
…nclaw#177319) * fix(test): treat the env-gated Agents API live proof as optional shard evidence test/gateway-agentsapi.live.test.ts (new since 2026.10.4) skips its only case unless OPENCLAW_LIVE_AGENTS_API=1, which the native live test-harness shard never sets, so the shard's no-passing-assertions guard failed it on every 2026.10.5 candidate once the other harness tests went green. Register it in the existing whole-file opt-in map like the other env-gated live proofs. (cherry picked from commit 761ef64) * fix(test): decode the Codex CLI JSON error after plugin uninstall The live Codex npm plugin lane matched the expected post-uninstall error against raw --json stdout, where quotes are escaped, so the correct owner-plugin-not-activatable error never matched. Decode the canonical CLI error message first, as the 2026.10.4 release line does (a9fd56d). (cherry picked from commit e8772a9) * fix(test): scope CLI announcement barrier to parent probe (cherry picked from commit d5c0db7) (cherry picked from commit a48d4a8) * test(live): wait out the crash-loop breaker before the orphan settles The native subagent restart live proof SIGKILLs the Gateway three times in about two minutes. The third unclean boot trips the documented restart-loop breaker (3 unclean boots within 5 minutes, openclaw#166238), which pauses restart settlement, including interrupted subagent recovery (openclaw#166846), until the unclean window drains. The orphan assertion added with the openclaw#169144 backport only waited 30 seconds, so the nonannouncing child was still `running`. Wait up to 360 seconds for the orphan settlement so the proof covers the breaker pause and the automatic resume after its window. Assertions are unchanged. 2026.10.4 passed because it predates the breaker pause, startup subagent reconciliation, and this assertion. Deterministic proof: the quiet-child e2e twin with SIGKILL restarts and an exec-blocked child passes with one prior kill; with two warm-up kills it logs "restart-loop breaker tripped" and the parent continuation never arrives within 60 seconds; with a 400-second wait it settles and passes (338s). (cherry picked from commit 1a4c2a0) * test(qa-lab): skip user-role runtime carriers in visible-child send proof The sessions_send visible-child proof timed out on every 2026.10.5 candidate: its synthetic provider picked the latest user item that lacked the legacy <<<BEGIN_OPENCLAW_INTERNAL_CONTEXT>>> marker as the user prompt. Since openclaw#168546 (backport 8d66b94), OpenAI-compatible Responses endpoints, including mock-openai, keep runtime context in a user-role "OpenClaw runtime context:" carrier after the user turn instead of a developer message. The fixture then read that carrier as the prompt, never saw the "send" prompt on turn 2, answered PARENT_READY again, and the test waited for PARENT_DONE until timeout. Captured provider requests: v2026.10.4 sends the turn-2 carrier with role developer; the 10.5 tip sends it with role user. Reverting a293f2e (openclaw#168410) left the failure unchanged. Select the prompt with the shared qa-lab isInternalRuntimeContextCarrierText helper, which already accepts current and legacy carrier shapes. (cherry picked from commit d3a06e7) * test(buzz): skip real reconnect backoff in cold-start recovery (cherry picked from commit fa2049a) * fix(release): let the Telegram release lane finish its 25 scenarios The isolated Telegram candidate job hit its 60-minute limit at scenario 24/25 on every 2026.10.5 candidate (about 62 minutes needed at 102-108s per packaged Gateway start). main carries the same Telegram scenario set and job, so raise the job budget to 90 minutes; the calling release-checks job keeps its 210-minute bound. Also carry the 2026.10.4 release-line fixture fix for telegram-prepared-delivery-recovery (8b78670): keep the audit receipt in the shared Gateway workspace and create it up front so the isolated SUT can append without EACCES. main still writes it under the private tempRoot. (cherry picked from commit 3cb49f0, adapted to main's runner anchor) * test(gateway): probe startup readiness on fresh connections The deferred-fleet startup test failed twice in 2026.10.5 FRV openclaw#12 with `fetch failed` / `read ECONNRESET`. Its Gateway shares the test process's event loop. A /healthz or /readyz probe could reuse a keep-alive socket that Undici still treated as live; when the request was written and a synchronous main-thread startup stall followed, the server's idle-timer callback ran before the poll phase read the request and destroyed the socket with the request unread, so the kernel reset the connection. main still probes with default keep-alive fetches. Probe with `Connection: close`, matching existing Gateway test probes. Assertions are unchanged. (cherry picked from commit e3c63f2, adapted to main's probe sites) * test(live): expect review effort for Skill Workshop background reviews in the Ultra lane Since openclaw#161057 the Skill Workshop counts iterations per session, so Ultra probe sessions trigger a background review after idling. The review runs under its own skill-workshop-review: run and does not inherit the session's thinking level, so the lane's every-request-is-max assertion failed on 2026.10.5 whenever a review reached the provider. On main, openclaw#173889 pins review runs to thinkLevel "low" (review-run.ts), which the OpenAI stream wrapper sends as effort "low". Expect that effort for review runs; Ultra runs and their sessions must still be max, and independent heartbeats stay medium. The live file is over the line cap, so the Ultra wire effort policy moves to a sibling helper with its observation type, and the deterministic review cases run in the normal helper suite. (cherry picked from commit ca15213, adapted to main's review thinking level) * test(release): forward-port 2026.10.4-line upgrade-survivor and runtime-smoke harness fixes Release-line harness fixes that 2026.10.1-2026.10.5 carried but main never received: - cron-scheduled-authority: seed the cron authority specimen through the published baseline's own SQLite writer (seedPublishedCronJobs) instead of a raw cron/jobs.json that current candidates treat as a retired pre-July store; drop owner fields for pre-2026.7.1 baselines (usesCronOwnerAtBaseline). The dispatcher passes the package root to seedState, and the scenario now requires a published baseline. - bundled plugin runtime smoke: join deferred read-only update discovery via update.status before the package-manager child watchdog. main still defers install discovery (`<manager> root -g`) until after ready, so it can race the watchdog's no-package-manager-children check. Skips the codex npm plugin live source-reply grep from the release commit: main already probes dynamic-tool-source-reply.ts and dynamic-tools.ts. (cherry picked from commit fcdf0d1, codex grep hunk dropped; cron seed test adapted to main's executable-mode fixture writes)
obviyus
added a commit
that referenced
this pull request
Oct 29, 2026
… plugin extraction (#173557) ## What Problem This Solves Skill Workshop is moving from core into a bundled, enabled-by-default plugin (#173605). Its current tests mostly call Workshop internals directly, so they can't show that behavior stays the same after the code moves. ## User Impact None. This PR adds tests only: no production changes. ## Why This Change Was Made These are characterization tests: each one pins the behavior an operator sees today at the entry point they use. They import only modules that stay in core after the move (the agent tool set, the Gateway dispatcher, the CLI program, the command pipeline, the skills loader, Doctor, Gateway maintenance, the Gateway server, and the Control UI app), never Workshop modules. The same files are meant to pass unchanged before and after the cutover. Refreshed on current `main`. Updated to intended changes since the first draft: - The CLI archive hint now names `--agent`. - The tool has `draft` and `discard`. - Doctor exports retired proposals to `.drafts/`, and moves earlier `.archive/.retired-proposals/` exports there too. - Background reviews call `skill_workshop` directly, without Tool Search (#173889). - Channel notices carry the Learned marker (#182329). - The `/learn` tests now pin how the request reaches the agent, not the full prompt wording, which Workshop owns. New contracts: - **Propose mode and drafts:** a review in `propose` mode can only save drafts and cannot discard them; the foreground lists, views and discards drafts (tool). `skills.workshop.list`/`read` return on-disk drafts for `operator.read`; `applyDraft` and `discardDraft` are `operator.admin` only, and apply refuses a mismatched skill name (RPC). A real-Gateway review in `propose` mode saves one draft, changes no skill and posts no notice (e2e). The Control UI shows drafts as a diff against the live skill and sends `applyDraft`/`discardDraft` (UI e2e). - **`/learn drafts`:** with no drafts it answers without a model turn; otherwise it rewrites the turn over the selected drafts, narrowed by skill name, with the focus text. - **`/learn` and memory plugins:** with a selected memory plugin's learning tools, one turn routes to both skills and memory; with `skill_workshop` denied it learns into memory alone; with both denied it replies with the combined refusal. - **Review timing and admission:** the 30-second quiet period and the recheck of current config and tool policy when a review becomes due are timer contracts. They are covered with a controlled clock in the scheduler and review unit tests, which move with the Workshop code. The real-Gateway e2e checks only effects, and waits for the review's Gateway root work to settle before it asserts that nothing changed. - **Daily maintenance:** an oversized, settled learned skill is dieted as one `curator` change that `restore` undoes. Unused-skill cleanup does not run in `propose` mode or when tool policy denies `skill_workshop`. ## Evidence Local runs on this branch (the Gateway e2e and unit tests after merging `main` at `e125921a28ebb`): | Area | Result | | --- | --- | | Tool, RPC, CLI, `/learn`, config, Doctor, skill loading, maintenance (10 files) | 64 tests pass | | Real-Gateway review (e2e file) | 9 pass | | Scheduler and review unit tests (controlled clock) | all pass; the 2 new tests fail when the quiet-period restart or the due-time config read is removed | | Control UI (app e2e) | 5 pass | `pnpm tsgo:core:test`, oxfmt, type-aware oxlint and `git diff --check` pass on the changed files. Merge danger: two-way door. Blast radius: tests only. Tracking issue: #173605 Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 30, 2026
… plugin extraction (openclaw#173557) ## What Problem This Solves Skill Workshop is moving from core into a bundled, enabled-by-default plugin (openclaw#173605). Its current tests mostly call Workshop internals directly, so they can't show that behavior stays the same after the code moves. ## User Impact None. This PR adds tests only: no production changes. ## Why This Change Was Made These are characterization tests: each one pins the behavior an operator sees today at the entry point they use. They import only modules that stay in core after the move (the agent tool set, the Gateway dispatcher, the CLI program, the command pipeline, the skills loader, Doctor, Gateway maintenance, the Gateway server, and the Control UI app), never Workshop modules. The same files are meant to pass unchanged before and after the cutover. Refreshed on current `main`. Updated to intended changes since the first draft: - The CLI archive hint now names `--agent`. - The tool has `draft` and `discard`. - Doctor exports retired proposals to `.drafts/`, and moves earlier `.archive/.retired-proposals/` exports there too. - Background reviews call `skill_workshop` directly, without Tool Search (openclaw#173889). - Channel notices carry the Learned marker (openclaw#182329). - The `/learn` tests now pin how the request reaches the agent, not the full prompt wording, which Workshop owns. New contracts: - **Propose mode and drafts:** a review in `propose` mode can only save drafts and cannot discard them; the foreground lists, views and discards drafts (tool). `skills.workshop.list`/`read` return on-disk drafts for `operator.read`; `applyDraft` and `discardDraft` are `operator.admin` only, and apply refuses a mismatched skill name (RPC). A real-Gateway review in `propose` mode saves one draft, changes no skill and posts no notice (e2e). The Control UI shows drafts as a diff against the live skill and sends `applyDraft`/`discardDraft` (UI e2e). - **`/learn drafts`:** with no drafts it answers without a model turn; otherwise it rewrites the turn over the selected drafts, narrowed by skill name, with the focus text. - **`/learn` and memory plugins:** with a selected memory plugin's learning tools, one turn routes to both skills and memory; with `skill_workshop` denied it learns into memory alone; with both denied it replies with the combined refusal. - **Review timing and admission:** the 30-second quiet period and the recheck of current config and tool policy when a review becomes due are timer contracts. They are covered with a controlled clock in the scheduler and review unit tests, which move with the Workshop code. The real-Gateway e2e checks only effects, and waits for the review's Gateway root work to settle before it asserts that nothing changed. - **Daily maintenance:** an oversized, settled learned skill is dieted as one `curator` change that `restore` undoes. Unused-skill cleanup does not run in `propose` mode or when tool policy denies `skill_workshop`. ## Evidence Local runs on this branch (the Gateway e2e and unit tests after merging `main` at `2592002ce0ede`): | Area | Result | | --- | --- | | Tool, RPC, CLI, `/learn`, config, Doctor, skill loading, maintenance (10 files) | 64 tests pass | | Real-Gateway review (e2e file) | 9 pass | | Scheduler and review unit tests (controlled clock) | all pass; the 2 new tests fail when the quiet-period restart or the due-time config read is removed | | Control UI (app e2e) | 5 pass | `pnpm tsgo:core:test`, oxfmt, type-aware oxlint and `git diff --check` pass on the changed files. Merge danger: two-way door. Blast radius: tests only. Tracking issue: openclaw#173605 Co-authored-by: Ayaan Zaidi <[email protected]>
This was referenced Oct 30, 2026
leapdragon
pushed a commit
to leapdragon/openclaw-upstream
that referenced
this pull request
Nov 3, 2026
…penclaw#173889) * fix(skills): keep background reviews out of saturated token budgets * fix(skills): isolate background review prompt and delivery context (cherry picked from commit 9a6c6b1)
obviyus
added a commit
that referenced
this pull request
Nov 17, 2026
…00545) ## What Problem This Solves Background work that reads a chat, such as Skill Workshop's learning review or a plugin reviewer, runs as a hidden "fork" of that chat. Forks that could use tools sent a cut-down request instead of the chat's own, so they paid full price for the whole conversation every time instead of reading it from the provider's prompt cache. They also stopped whenever anything else on the Gateway started (a cron job, a turn in another chat), and a Workshop review was silently cut off after two minutes. ## User Impact - Background reviews and plugin forks read the conversation from the provider's prompt cache. In the live probe below, the first request of a fork with tools read 98% of its input from cache on Anthropic and OpenAI (was 0%); tool-free forks on OpenAI went from 0% to 99%. - A fork keeps running when other chats or cron jobs run. - Skill Workshop reviews run for the agent's own run timeout instead of two minutes. - Reviews now see the full conversation, not a 32 KiB excerpt. ## Why This Change Was Made OpenClaw had two session forks: - `subagent.forkSession` (tool-free, #170146) replayed the parent's prepared request, so the provider cache hit. It ran its own 3-call model loop beside the agent runner. - `runSessionFork` / `subagent.runForkedTurn` (tools, #190158, #190950) built a fresh, cut-down request: a 32 KiB / 64-event excerpt with tool results dropped, `promptMode: "minimal"`, only the caller's tools listed, a 16,384-token context budget, 2,048 output tokens, low thinking, a 120 s ceiling (`Math.min(timeoutMs, 120_000)`), and it aborted whenever any session on the Gateway started a run. Every one of those clamps came from #173889 (a Skill Workshop rate-limit fix) and moved verbatim into the generic owner. Now there is one fork primitive: `runSessionFork` in `src/agents/session-fork-run.ts`. `forkSession`, `runForkedTurn` and Skill Workshop all fork through it. - **Same request as the parent.** While the parent's run is live, each fork request replays its last prepared request byte for byte and appends the fork's own items (`embedded-agent-runner/session-fork-request.ts`, the replay moved from the old `forkSession` loop). After the run settles, the fork reads the session's `openclaw.system-prompt` checkpoint and its own requests send that pinned system prompt verbatim (no prompt-update delta) and the pinned tool definitions in their order. It also sends the parent's `promptCacheKey` and the session's thinking level. - **Tools listed, gated at run time.** The session's tools stay in the request. Only the caller's tools run, through the existing `toolExecutionAllow` gate; others return "`<tool>` is not available in this background run." A tool-free fork is an empty allow list plus `tool_choice: none` (Anthropic, OpenAI Responses, Chat Completions). - **Clamps deleted:** the context excerpt, `promptMode: "minimal"`, `bootstrapContextMode: "lightweight"`, `contextTokenBudget: 16_384`, `maxTokens: 2_048`, `thinkLevel: "low"`, the narrowed `toolsAllow`, `codeModeOverride`/`disableToolSearch`/`forceMessageTool` overrides, and `Math.min(timeoutMs, 120_000)`. Output tokens follow the session; `runForkedTurn` gains an optional `maxTokens`. - **Global yield deleted.** Runs in other sessions (cron included) no longer stop a fork. No new cancellation code. - **Duplicate path deleted:** `embedded-agent-runner/session-fork.ts`, `session-fork-context.ts`, `tool-result-projection-replay.ts`, `runBtwSessionFork`, the built-in `toolCalls: "deny"` branch in `btw.ts`, the now-unproduced `uncachedSuffixMessage` / `independentResponsesRequest` transport markers, and the two perf scripts that only measured the deleted fork owner (`session-fork-retention-measure.mjs`, `responses-continuation-measure.mjs`). `btw.ts` keeps only harness dispatch for `forkSession`: Codex sessions still run Codex's own tool-free side question; built-in sessions call `runSessionFork`; CLI runtimes stay refused. - **The fork reads the chat as the chat does.** It keeps its source conversation's channel history window (`dmHistoryLimit` and the like): the run resolves the limit from the policy key (`sandboxSessionKey`), which only a fork sets apart from its own key. A fork without an explicit entry anchors at the last message, because the leaf can be the prompt checkpoint. A tool call still running at the anchor reads as pending ("still running"), not failed, and only the unfinished calls of a partly finished batch get that placeholder; the source transcript is never written. Safety checks kept: requester policy before any model call (`prepareSessionFork`), plugins grant only their own tools (#190950), detached admission and restart drain, plugin authority before each tool call and before `onSettled`, hidden run, never writing the source transcript, source checks for reset/replace/delete/rewrite, locked model with no fallbacks or transient retries. Changed on purpose: - A fork lists every session tool instead of only its own (execution is still gated). - Background forks no longer yield to other sessions' runs. Skill Workshop's 15/30/60-minute rate-limit backoff is unchanged and still protects interactive capacity. - A built-in tool-free fork now writes cache for its own suffix (~300 tokens in the probe below); the old loop opted its question out of Anthropic cache checkpoints. - A tool-free fork whose anchored turn no longer holds its input still runs; a fork with tools still refuses, because sender-specific tool policy needs the turn's requester. Accepted edge case: if a parent's turn crashed after its prompt checkpoint and before any reply, an idle-parent fork cannot see that checkpoint and sends its own rebuilt prompt (no cache hit). A running parent is replayed from its live request, and a completed turn ends with a reply after the checkpoint. Left out on purpose: - Codex `thread/fork` adapter (`extensions/codex/harness.ts:577`): unchanged, still reached through `btw.ts` for Codex-session `forkSession`. - Plain `/btw` with tools (`commands-btw.ts`, `tui/embedded-backend.ts`): unchanged. - CLI runtimes: forks stay refused. ### Plugin SDK impact `plugin-sdk-impact` on ClawHub (2026-11-17, 2,657 eligible releases; 2,235 complete, 420 partial, 2 failed): **0** static references to `runtime.subagent.forkSession` and **0** to `runtime.subagent.runForkedTurn`. Coverage is incomplete, so this is not proof of no use. Bundled callers (source search): Advisor (`forkSession`) and Skill Workshop (`runForkedTurn`). The `forkSession` signature is unchanged; `runForkedTurn` gains an optional `maxTokens`. No export added or removed. ## Evidence **Byte match on real providers.** Tier: source (`ocx src` scratch Gateways, isolated profile). A recording proxy captured every provider request. Each provider: two parent turns (one `ls` tool call), then one `runForkedTurn` (tools `[]`) and one `forkSession` through the plugin runtime. Digests are SHA-256 prefixes of `snapshotProviderPrefix` segments (`scripts/e2e/lib/anthropic-cache/prefix-stability.mts`). OpenAI Responses sends the system prompt as the first input item, so its `system` digest is `null` and the system prompt is checked as history item 0. Anthropic `claude-sonnet-5-5`, parent last request (after run): system `e18e68ef17d925ff`, tools `33603f8641deb7e5` (13), cache key `b8ccb287386e0e54`. The system digest differs between runs (each run uses a new scratch workspace); "same" compares fork and parent within one run. | Fork, first request | Before: system / tools / key / history | Before: cacheRead | After: system / tools / key / history | After: cacheRead / input | |---|---|---|---|---| | `runForkedTurn` | differs / differs (0 tools) / same / 7 of 7 | **0** (cacheWrite 2,810) | same / same / same / 7 of 7 | **19,141** / 19,446 | | `forkSession` | same / same / same / 7 of 7 | 19,141 | same / same / same / 7 of 7 | 19,141 / 19,446 | OpenAI `gpt-5.6-luna`, parent last request: tools `4481fd05f2c1d4c6` (12), cache key `975dd83e68fb404a`. | Fork, first request | Before: tools / key / history | Before: cacheRead | After: tools / key / history | After: cacheRead / input | |---|---|---|---|---| | `runForkedTurn` | differs (0 tools) / same / 0 of 9 | **0** | same / same / 9 of 9 | **11,332** / 11,605 | | `forkSession` | same / same / 9 of 9 | **0** (request dropped `text.verbosity`) | same / same / 9 of 9 | **11,530** / 11,605 | **Tests** (vitest-source): - `gateway-plugin-forked-turn.e2e`: the fork's first request now extends the parent's last request (system, tools, cache key, history) and its other fields (output limit, reasoning, instructions) equal the parent's. The reload-drain case now runs a turn in another session while the fork's model call is held, and the fork still settles `ok`. The mock model calls the plugin's tool through `dispatch_action`, because the fork now lists the session's tool catalog. - `session-fork-request.test.ts`: replay ordering and ID spelling, transport handles, continuation fallback, `tool_choice` per API, replay skip when the parent lacks the fork's tool or lists a hosted tool, caller output limit. - Unchanged assertions: `agent-tools.prefix-stability`, `session-fork-run`, Advisor, Skill Workshop suites. - `server-plugin-subagent-runtime.fork-transport`: a `forkSession` on a Telegram DM with `dmHistoryLimit: 1` and a compacted history sends the session's pinned system prompt, drops history outside the parent's window, and sends nothing for another operator's session. - `session-manager-model-context-limits`: a still-running call in a partly finished batch reads as pending while the finished call keeps its real result, and the source transcript is unchanged. - Contract assertions updated because the contract changed: the e2e "fork sees only the caller's tool" and "system message differs by design" checks; `btw` deny tests now pass `sessionFork`; three Codex WebSocket tests of the deleted fork loop and two tests of the deleted fork context builder are removed. **Size:** 51 files, +1,099 −3,438 (net −2,339). Production +776 −1,990; tests +222 −1,274; docs +101 −174. Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Nov 18, 2026
…enclaw#200545) ## What Problem This Solves Background work that reads a chat, such as Skill Workshop's learning review or a plugin reviewer, runs as a hidden "fork" of that chat. Forks that could use tools sent a cut-down request instead of the chat's own, so they paid full price for the whole conversation every time instead of reading it from the provider's prompt cache. They also stopped whenever anything else on the Gateway started (a cron job, a turn in another chat), and a Workshop review was silently cut off after two minutes. ## User Impact - Background reviews and plugin forks read the conversation from the provider's prompt cache. In the live probe below, the first request of a fork with tools read 98% of its input from cache on Anthropic and OpenAI (was 0%); tool-free forks on OpenAI went from 0% to 99%. - A fork keeps running when other chats or cron jobs run. - Skill Workshop reviews run for the agent's own run timeout instead of two minutes. - Reviews now see the full conversation, not a 32 KiB excerpt. ## Why This Change Was Made OpenClaw had two session forks: - `subagent.forkSession` (tool-free, openclaw#170146) replayed the parent's prepared request, so the provider cache hit. It ran its own 3-call model loop beside the agent runner. - `runSessionFork` / `subagent.runForkedTurn` (tools, openclaw#190158, openclaw#190950) built a fresh, cut-down request: a 32 KiB / 64-event excerpt with tool results dropped, `promptMode: "minimal"`, only the caller's tools listed, a 16,384-token context budget, 2,048 output tokens, low thinking, a 120 s ceiling (`Math.min(timeoutMs, 120_000)`), and it aborted whenever any session on the Gateway started a run. Every one of those clamps came from openclaw#173889 (a Skill Workshop rate-limit fix) and moved verbatim into the generic owner. Now there is one fork primitive: `runSessionFork` in `src/agents/session-fork-run.ts`. `forkSession`, `runForkedTurn` and Skill Workshop all fork through it. - **Same request as the parent.** While the parent's run is live, each fork request replays its last prepared request byte for byte and appends the fork's own items (`embedded-agent-runner/session-fork-request.ts`, the replay moved from the old `forkSession` loop). After the run settles, the fork reads the session's `openclaw.system-prompt` checkpoint and its own requests send that pinned system prompt verbatim (no prompt-update delta) and the pinned tool definitions in their order. It also sends the parent's `promptCacheKey` and the session's thinking level. - **Tools listed, gated at run time.** The session's tools stay in the request. Only the caller's tools run, through the existing `toolExecutionAllow` gate; others return "`<tool>` is not available in this background run." A tool-free fork is an empty allow list plus `tool_choice: none` (Anthropic, OpenAI Responses, Chat Completions). - **Clamps deleted:** the context excerpt, `promptMode: "minimal"`, `bootstrapContextMode: "lightweight"`, `contextTokenBudget: 16_384`, `maxTokens: 2_048`, `thinkLevel: "low"`, the narrowed `toolsAllow`, `codeModeOverride`/`disableToolSearch`/`forceMessageTool` overrides, and `Math.min(timeoutMs, 120_000)`. Output tokens follow the session; `runForkedTurn` gains an optional `maxTokens`. - **Global yield deleted.** Runs in other sessions (cron included) no longer stop a fork. No new cancellation code. - **Duplicate path deleted:** `embedded-agent-runner/session-fork.ts`, `session-fork-context.ts`, `tool-result-projection-replay.ts`, `runBtwSessionFork`, the built-in `toolCalls: "deny"` branch in `btw.ts`, the now-unproduced `uncachedSuffixMessage` / `independentResponsesRequest` transport markers, and the two perf scripts that only measured the deleted fork owner (`session-fork-retention-measure.mjs`, `responses-continuation-measure.mjs`). `btw.ts` keeps only harness dispatch for `forkSession`: Codex sessions still run Codex's own tool-free side question; built-in sessions call `runSessionFork`; CLI runtimes stay refused. - **The fork reads the chat as the chat does.** It keeps its source conversation's channel history window (`dmHistoryLimit` and the like): the run resolves the limit from the policy key (`sandboxSessionKey`), which only a fork sets apart from its own key. A fork without an explicit entry anchors at the last message, because the leaf can be the prompt checkpoint. A tool call still running at the anchor reads as pending ("still running"), not failed, and only the unfinished calls of a partly finished batch get that placeholder; the source transcript is never written. Safety checks kept: requester policy before any model call (`prepareSessionFork`), plugins grant only their own tools (openclaw#190950), detached admission and restart drain, plugin authority before each tool call and before `onSettled`, hidden run, never writing the source transcript, source checks for reset/replace/delete/rewrite, locked model with no fallbacks or transient retries. Changed on purpose: - A fork lists every session tool instead of only its own (execution is still gated). - Background forks no longer yield to other sessions' runs. Skill Workshop's 15/30/60-minute rate-limit backoff is unchanged and still protects interactive capacity. - A built-in tool-free fork now writes cache for its own suffix (~300 tokens in the probe below); the old loop opted its question out of Anthropic cache checkpoints. - A tool-free fork whose anchored turn no longer holds its input still runs; a fork with tools still refuses, because sender-specific tool policy needs the turn's requester. Accepted edge case: if a parent's turn crashed after its prompt checkpoint and before any reply, an idle-parent fork cannot see that checkpoint and sends its own rebuilt prompt (no cache hit). A running parent is replayed from its live request, and a completed turn ends with a reply after the checkpoint. Left out on purpose: - Codex `thread/fork` adapter (`extensions/codex/harness.ts:577`): unchanged, still reached through `btw.ts` for Codex-session `forkSession`. - Plain `/btw` with tools (`commands-btw.ts`, `tui/embedded-backend.ts`): unchanged. - CLI runtimes: forks stay refused. ### Plugin SDK impact `plugin-sdk-impact` on ClawHub (2026-11-17, 2,657 eligible releases; 2,235 complete, 420 partial, 2 failed): **0** static references to `runtime.subagent.forkSession` and **0** to `runtime.subagent.runForkedTurn`. Coverage is incomplete, so this is not proof of no use. Bundled callers (source search): Advisor (`forkSession`) and Skill Workshop (`runForkedTurn`). The `forkSession` signature is unchanged; `runForkedTurn` gains an optional `maxTokens`. No export added or removed. ## Evidence **Byte match on real providers.** Tier: source (`ocx src` scratch Gateways, isolated profile). A recording proxy captured every provider request. Each provider: two parent turns (one `ls` tool call), then one `runForkedTurn` (tools `[]`) and one `forkSession` through the plugin runtime. Digests are SHA-256 prefixes of `snapshotProviderPrefix` segments (`scripts/e2e/lib/anthropic-cache/prefix-stability.mts`). OpenAI Responses sends the system prompt as the first input item, so its `system` digest is `null` and the system prompt is checked as history item 0. Anthropic `claude-sonnet-5-5`, parent last request (after run): system `e18e68ef17d925ff`, tools `33603f8641deb7e5` (13), cache key `b8ccb287386e0e54`. The system digest differs between runs (each run uses a new scratch workspace); "same" compares fork and parent within one run. | Fork, first request | Before: system / tools / key / history | Before: cacheRead | After: system / tools / key / history | After: cacheRead / input | |---|---|---|---|---| | `runForkedTurn` | differs / differs (0 tools) / same / 7 of 7 | **0** (cacheWrite 2,810) | same / same / same / 7 of 7 | **19,141** / 19,446 | | `forkSession` | same / same / same / 7 of 7 | 19,141 | same / same / same / 7 of 7 | 19,141 / 19,446 | OpenAI `gpt-5.6-luna`, parent last request: tools `4481fd05f2c1d4c6` (12), cache key `975dd83e68fb404a`. | Fork, first request | Before: tools / key / history | Before: cacheRead | After: tools / key / history | After: cacheRead / input | |---|---|---|---|---| | `runForkedTurn` | differs (0 tools) / same / 0 of 9 | **0** | same / same / 9 of 9 | **11,332** / 11,605 | | `forkSession` | same / same / 9 of 9 | **0** (request dropped `text.verbosity`) | same / same / 9 of 9 | **11,530** / 11,605 | **Tests** (vitest-source): - `gateway-plugin-forked-turn.e2e`: the fork's first request now extends the parent's last request (system, tools, cache key, history) and its other fields (output limit, reasoning, instructions) equal the parent's. The reload-drain case now runs a turn in another session while the fork's model call is held, and the fork still settles `ok`. The mock model calls the plugin's tool through `dispatch_action`, because the fork now lists the session's tool catalog. - `session-fork-request.test.ts`: replay ordering and ID spelling, transport handles, continuation fallback, `tool_choice` per API, replay skip when the parent lacks the fork's tool or lists a hosted tool, caller output limit. - Unchanged assertions: `agent-tools.prefix-stability`, `session-fork-run`, Advisor, Skill Workshop suites. - `server-plugin-subagent-runtime.fork-transport`: a `forkSession` on a Telegram DM with `dmHistoryLimit: 1` and a compacted history sends the session's pinned system prompt, drops history outside the parent's window, and sends nothing for another operator's session. - `session-manager-model-context-limits`: a still-running call in a partly finished batch reads as pending while the finished call keeps its real result, and the source transcript is unchanged. - Contract assertions updated because the contract changed: the e2e "fork sees only the caller's tool" and "system message differs by design" checks; `btw` deny tests now pass `sessionFork`; three Codex WebSocket tests of the deleted fork loop and two tests of the deleted fork context builder are removed. **Size:** 51 files, +1,099 −3,438 (net −2,339). Production +776 −1,990; tests +222 −1,274; docs +101 −174. Co-authored-by: Ayaan Zaidi <[email protected]>
RomneyDa
added a commit
that referenced
this pull request
Nov 19, 2026
…00545) Background work that reads a chat, such as Skill Workshop's learning review or a plugin reviewer, runs as a hidden "fork" of that chat. Forks that could use tools sent a cut-down request instead of the chat's own, so they paid full price for the whole conversation every time instead of reading it from the provider's prompt cache. They also stopped whenever anything else on the Gateway started (a cron job, a turn in another chat), and a Workshop review was silently cut off after two minutes. - Background reviews and plugin forks read the conversation from the provider's prompt cache. In the live probe below, the first request of a fork with tools read 98% of its input from cache on Anthropic and OpenAI (was 0%); tool-free forks on OpenAI went from 0% to 99%. - A fork keeps running when other chats or cron jobs run. - Skill Workshop reviews run for the agent's own run timeout instead of two minutes. - Reviews now see the full conversation, not a 32 KiB excerpt. OpenClaw had two session forks: - `subagent.forkSession` (tool-free, #170146) replayed the parent's prepared request, so the provider cache hit. It ran its own 3-call model loop beside the agent runner. - `runSessionFork` / `subagent.runForkedTurn` (tools, #190158, #190950) built a fresh, cut-down request: a 32 KiB / 64-event excerpt with tool results dropped, `promptMode: "minimal"`, only the caller's tools listed, a 16,384-token context budget, 2,048 output tokens, low thinking, a 120 s ceiling (`Math.min(timeoutMs, 120_000)`), and it aborted whenever any session on the Gateway started a run. Every one of those clamps came from #173889 (a Skill Workshop rate-limit fix) and moved verbatim into the generic owner. Now there is one fork primitive: `runSessionFork` in `src/agents/session-fork-run.ts`. `forkSession`, `runForkedTurn` and Skill Workshop all fork through it. - **Same request as the parent.** While the parent's run is live, each fork request replays its last prepared request byte for byte and appends the fork's own items (`embedded-agent-runner/session-fork-request.ts`, the replay moved from the old `forkSession` loop). After the run settles, the fork reads the session's `openclaw.system-prompt` checkpoint and its own requests send that pinned system prompt verbatim (no prompt-update delta) and the pinned tool definitions in their order. It also sends the parent's `promptCacheKey` and the session's thinking level. - **Tools listed, gated at run time.** The session's tools stay in the request. Only the caller's tools run, through the existing `toolExecutionAllow` gate; others return "`<tool>` is not available in this background run." A tool-free fork is an empty allow list plus `tool_choice: none` (Anthropic, OpenAI Responses, Chat Completions). - **Clamps deleted:** the context excerpt, `promptMode: "minimal"`, `bootstrapContextMode: "lightweight"`, `contextTokenBudget: 16_384`, `maxTokens: 2_048`, `thinkLevel: "low"`, the narrowed `toolsAllow`, `codeModeOverride`/`disableToolSearch`/`forceMessageTool` overrides, and `Math.min(timeoutMs, 120_000)`. Output tokens follow the session; `runForkedTurn` gains an optional `maxTokens`. - **Global yield deleted.** Runs in other sessions (cron included) no longer stop a fork. No new cancellation code. - **Duplicate path deleted:** `embedded-agent-runner/session-fork.ts`, `session-fork-context.ts`, `tool-result-projection-replay.ts`, `runBtwSessionFork`, the built-in `toolCalls: "deny"` branch in `btw.ts`, the now-unproduced `uncachedSuffixMessage` / `independentResponsesRequest` transport markers, and the two perf scripts that only measured the deleted fork owner (`session-fork-retention-measure.mjs`, `responses-continuation-measure.mjs`). `btw.ts` keeps only harness dispatch for `forkSession`: Codex sessions still run Codex's own tool-free side question; built-in sessions call `runSessionFork`; CLI runtimes stay refused. - **The fork reads the chat as the chat does.** It keeps its source conversation's channel history window (`dmHistoryLimit` and the like): the run resolves the limit from the policy key (`sandboxSessionKey`), which only a fork sets apart from its own key. A fork without an explicit entry anchors at the last message, because the leaf can be the prompt checkpoint. A tool call still running at the anchor reads as pending ("still running"), not failed, and only the unfinished calls of a partly finished batch get that placeholder; the source transcript is never written. Safety checks kept: requester policy before any model call (`prepareSessionFork`), plugins grant only their own tools (#190950), detached admission and restart drain, plugin authority before each tool call and before `onSettled`, hidden run, never writing the source transcript, source checks for reset/replace/delete/rewrite, locked model with no fallbacks or transient retries. Changed on purpose: - A fork lists every session tool instead of only its own (execution is still gated). - Background forks no longer yield to other sessions' runs. Skill Workshop's 15/30/60-minute rate-limit backoff is unchanged and still protects interactive capacity. - A built-in tool-free fork now writes cache for its own suffix (~300 tokens in the probe below); the old loop opted its question out of Anthropic cache checkpoints. - A tool-free fork whose anchored turn no longer holds its input still runs; a fork with tools still refuses, because sender-specific tool policy needs the turn's requester. Accepted edge case: if a parent's turn crashed after its prompt checkpoint and before any reply, an idle-parent fork cannot see that checkpoint and sends its own rebuilt prompt (no cache hit). A running parent is replayed from its live request, and a completed turn ends with a reply after the checkpoint. Left out on purpose: - Codex `thread/fork` adapter (`extensions/codex/harness.ts:577`): unchanged, still reached through `btw.ts` for Codex-session `forkSession`. - Plain `/btw` with tools (`commands-btw.ts`, `tui/embedded-backend.ts`): unchanged. - CLI runtimes: forks stay refused. `plugin-sdk-impact` on ClawHub (2026-11-17, 2,657 eligible releases; 2,235 complete, 420 partial, 2 failed): **0** static references to `runtime.subagent.forkSession` and **0** to `runtime.subagent.runForkedTurn`. Coverage is incomplete, so this is not proof of no use. Bundled callers (source search): Advisor (`forkSession`) and Skill Workshop (`runForkedTurn`). The `forkSession` signature is unchanged; `runForkedTurn` gains an optional `maxTokens`. No export added or removed. **Byte match on real providers.** Tier: source (`ocx src` scratch Gateways, isolated profile). A recording proxy captured every provider request. Each provider: two parent turns (one `ls` tool call), then one `runForkedTurn` (tools `[]`) and one `forkSession` through the plugin runtime. Digests are SHA-256 prefixes of `snapshotProviderPrefix` segments (`scripts/e2e/lib/anthropic-cache/prefix-stability.mts`). OpenAI Responses sends the system prompt as the first input item, so its `system` digest is `null` and the system prompt is checked as history item 0. Anthropic `claude-sonnet-5-5`, parent last request (after run): system `e18e68ef17d925ff`, tools `33603f8641deb7e5` (13), cache key `b8ccb287386e0e54`. The system digest differs between runs (each run uses a new scratch workspace); "same" compares fork and parent within one run. | Fork, first request | Before: system / tools / key / history | Before: cacheRead | After: system / tools / key / history | After: cacheRead / input | |---|---|---|---|---| | `runForkedTurn` | differs / differs (0 tools) / same / 7 of 7 | **0** (cacheWrite 2,810) | same / same / same / 7 of 7 | **19,141** / 19,446 | | `forkSession` | same / same / same / 7 of 7 | 19,141 | same / same / same / 7 of 7 | 19,141 / 19,446 | OpenAI `gpt-5.6-luna`, parent last request: tools `4481fd05f2c1d4c6` (12), cache key `975dd83e68fb404a`. | Fork, first request | Before: tools / key / history | Before: cacheRead | After: tools / key / history | After: cacheRead / input | |---|---|---|---|---| | `runForkedTurn` | differs (0 tools) / same / 0 of 9 | **0** | same / same / 9 of 9 | **11,332** / 11,605 | | `forkSession` | same / same / 9 of 9 | **0** (request dropped `text.verbosity`) | same / same / 9 of 9 | **11,530** / 11,605 | **Tests** (vitest-source): - `gateway-plugin-forked-turn.e2e`: the fork's first request now extends the parent's last request (system, tools, cache key, history) and its other fields (output limit, reasoning, instructions) equal the parent's. The reload-drain case now runs a turn in another session while the fork's model call is held, and the fork still settles `ok`. The mock model calls the plugin's tool through `dispatch_action`, because the fork now lists the session's tool catalog. - `session-fork-request.test.ts`: replay ordering and ID spelling, transport handles, continuation fallback, `tool_choice` per API, replay skip when the parent lacks the fork's tool or lists a hosted tool, caller output limit. - Unchanged assertions: `agent-tools.prefix-stability`, `session-fork-run`, Advisor, Skill Workshop suites. - `server-plugin-subagent-runtime.fork-transport`: a `forkSession` on a Telegram DM with `dmHistoryLimit: 1` and a compacted history sends the session's pinned system prompt, drops history outside the parent's window, and sends nothing for another operator's session. - `session-manager-model-context-limits`: a still-running call in a partly finished batch reads as pending while the finished call keeps its real result, and the source transcript is unchanged. - Contract assertions updated because the contract changed: the e2e "fork sees only the caller's tool" and "system message differs by design" checks; `btw` deny tests now pass `sessionFork`; three Codex WebSocket tests of the deleted fork loop and two tests of the deleted fork context builder are removed. **Size:** 51 files, +1,099 −3,438 (net −2,339). Production +776 −1,990; tests +222 −1,274; docs +101 −174. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 2a7ca16) Release adaptation: preserve the baseline removal of the session identity allowlist; the remaining fork owner and callers apply unchanged. Follow-up disposition: source bounded owner history reviewed; focused prefix and fork proof required on this lane. Co-authored-by: RomneyDa <[email protected]> (cherry picked from commit f080b30127abe414dbf9a4fbe0be2b550139fa10)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Fixes background Skill Workshop reviews competing with interactive turns during provider TPM saturation. Every ten eligible foreground model iterations could queue a review that replayed the full conversation and tool catalog. Disabling model fallback did not disable same-model retries or credential rotation.
User Impact
Reviews now use a recent bounded excerpt, yield to active work, and pause across sessions after rate limiting. Foreground learning and saved changes remain available. Background learning may skip lessons whose required context cannot fit; it no longer browses files, the web, or other sessions to expand its evidence.
Why This Change Was Made
Keep the existing review scheduler, transcript reader, tool policy, and retry owner. Replace full conversation replay with at most 64 events / 32 KiB (large tool bodies may be omitted), expose only
skill_workshop, omit foreground bootstrap/catalog/client instructions and cache/delivery context, and use low reasoning with 2,048 output tokens. Retain background queue priority and classify model admission as background even when user provenance was inherited. An active interactive run cancels the review without replay.A run-only retry option disables transient replay and credential rotation for reviews. The scheduler backs off all queued reviews for 15, then 30, then 60 minutes on repeated throttling; fresh foreground throttling extends the current wait. Failed reviews are discarded, while pending work continues to coalesce per session. Short-window review throttling does not cool the shared interactive auth profile.
The provider's reported “Requested ~141k” is not a measured input-token count: the catalog's 128,000 output default is also sent when no override is present. This change bounds both retained input and ordinary output reservation. A 16,384-token context target and two-minute timeout constrain normal review work; normal compaction remains available, so this is not a hard total-token budget for successful multi-step reviews.
Evidence
git diff --checkpassed. Initial three-file command took 442s including worker compilation; updated scheduler took 61s and urgency took 1.8s. No local broad suite, build, typecheck, or remote lease.skill_workshop,max_output_tokens: 2048, and no retry after a TPM 429. Updated the existing successful-learning Gateway proof for the narrower tool surface. Both Gateway E2E cases passed in PR CI, including the final revision with foreground cache/delivery isolation. Baseline execution of the new regressions and live-provider billing measurements were not performed locally.Production LOC grows by 77 lines: the required cross-session backoff, active-work cancellation, and run-owned retry policy did not exist. The full-context review path and broad review toolbox are replaced rather than retained as alternatives. No schema, dependency, or user configuration changes.
Final-head CI: run 38861173821 passed on
d79c290dc2f3be8eb471254356687d43baae4495, including Gateway E2E, static checks, and security gates. The initial run failed only lint/types for an unchanged unused UI import, independently fixed on main; the final revision passed without rerunning CI or copying that fix into this branch.