feat: context-pressure-aware continuation (CONTINUE_WORK / CONTINUE_DELEGATE)#38780
feat: context-pressure-aware continuation (CONTINUE_WORK / CONTINUE_DELEGATE)#38780karmafeast wants to merge 28 commits into
Conversation
Greptile SummaryThis PR introduces a context-pressure-aware continuation runtime ( Key findings:
Confidence Score: 3/5
Last reviewed commit: bd69e56 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bd69e56be3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4713bcec47
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const replyInstruction = buildAnnounceReplyInstruction({ | ||
| remainingActiveSubagentRuns, | ||
| requesterIsSubagent, | ||
| announceType, | ||
| expectsCompletionMessage, |
There was a problem hiding this comment.
Use silent-specific instruction for enrichment returns
replyInstruction is always generated as a user-delivery instruction and then embedded into internalEvents, even for silentAnnounce delegates that are supposed to return as internal enrichment only. Because that same internalEvents payload is enqueued into [continuation:enrichment-return], the next model turn receives an Action that says to send a user-facing update, which can cause unsolicited visible replies and breaks the silent/silent-wake contract.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c47f22befa
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
c47f22b to
0cc1c89
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0cc1c8987a
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const stagedCompactionDelegates = consumeStagedPostCompactionDelegates(sessionKey); | ||
| if (stagedCompactionDelegates.length > 0) { | ||
| try { | ||
| await persistPendingPostCompactionDelegates({ |
There was a problem hiding this comment.
Requeue staged delegates when persistence fails
This drains staged post-compaction delegates before attempting to persist them, and the failure path only logs the error. If persistPendingPostCompactionDelegates throws (for example on transient session-store write failures), those delegates have already been removed from the in-memory staging map and are never retried, so queued post-compaction work is lost.
Useful? React with 👍 / 👎.
e80bf8d to
0cc1c89
Compare
0827797 to
92e5826
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4071f43978
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
4071f43 to
91e05b1
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 91e05b17d7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
91e05b1 to
6fa9441
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6fa944196b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
6fa9441 to
eee3dca
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: eee3dcab58
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // into the next successful turn for the same session. | ||
| if (sessionKey) { | ||
| consumePendingDelegates(sessionKey); | ||
| consumeStagedPostCompactionDelegates(sessionKey); |
There was a problem hiding this comment.
Preserve re-staged delegates through turn cleanup
The persistence-failure path now re-stages post-compaction delegates for retry, but finally unconditionally calls consumeStagedPostCompactionDelegates(sessionKey), which removes that re-staged work before the function returns. This means transient session-store write failures still drop post-compaction delegates permanently, so the intended retry behavior never actually survives past the turn.
Useful? React with 👍 / 👎.
c5fc1f0 to
8a3f5b3
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8a3f5b39d0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
75e72c4 to
4cfb632
Compare
(cherry picked from commit a91c17c)
(cherry picked from commit b546aa9)
Normalize WhatsApp onboarding allowlist entries to digit-only WhatsApp IDs and reject invalid owner-phone inputs during prompt validation. (cherry picked from commit 68a500c)
* fix(telegram): reuse preview for long text finals * test(qa): cover long telegram finals * fix(qa): satisfy extension lint * fix(qa): keep telegram long final fixture to two chunks * test(telegram): cover three chunk finals * fix(telegram): force long final preview boundary (cherry picked from commit e03fe1e)
(cherry picked from commit b0f841e)
Bind the default loopback gateway listener only to `127.0.0.1` on Windows so libuv dual-stack `::1` behavior cannot wedge localhost HTTP requests. Also keeps non-Windows dual-loopback behavior covered, replaces the redundant Windows passthrough test with guard coverage, and adds the required changelog entry. Fixes openclaw#69674. Tests: - pnpm exec oxfmt --check --threads=1 CHANGELOG.md src/gateway/net.ts src/gateway/net.test.ts - pnpm test src/gateway/net.test.ts - pnpm check:changed - GitHub required checks: green Thanks @SARAMALI15792. Co-authored-by: saram ali <[email protected]> Co-authored-by: Brad Groux <[email protected]> (cherry picked from commit 978bc53)
…isted] (openclaw#74161) Summary: - The PR updates agents skill prompt guidance to require exact `<location>` paths for single- and multi-skill selection, adds prompt assertions, and records the fix in the changelog. - Reproducibility: yes. Static source reproduction is enough: current main lacks the exact-`<location>` guard ... illsSection()`, while the PR diff adds it to both selection branches and asserts the resulting prompt text. Automerge notes: - PR branch already contained follow-up commit before automerge: fix: enforce exact skill paths for all skill matches Validation: - ClawSweeper review passed for head 743c984. - Required merge gates passed before the squash merge. Prepared head SHA: 743c984 Review: openclaw#74161 (comment) Co-authored-by: tianguicheng <[email protected]> Co-authored-by: sallyom <[email protected]> (cherry picked from commit c739088)
Accept drive-absolute Windows sandbox Docker bind sources in config and runtime validation while keeping blocked-path and allowed-root comparisons case-insensitive for Windows drive paths. Also remove a stale WhatsApp setup import that blocked extension lint after the rebase. Co-authored-by: 6607changchun <[email protected]> Co-authored-by: Brad Groux <[email protected]> (cherry picked from commit d02fbc6)
Core continuation runtime: context-pressure detection, delegate reservations, targeted-return queue, task-flow chain plumbing. Lich-protocol heart of PR openclaw#38780.
Tests across continuation runtime, delegate-store, task-flow registry, plugin SDK hooks, agent commands, and integration paths.
…al-v2 Adds design RFC for the continue-work-signal-v2 surface, regenerates config + plugin SDK API baselines, refreshes glossary, and records the change in CHANGELOG.
Wires the continuation runtime into agent loop, infra orchestrators, gateway entry, plugin SDK surfaces, status/logging, scripts, packages, and platform extensions.
Top-level workspace glue for the continuation feature: package manifest, lockfile, build config, and gitignore updates.
|
Thanks for the PR. This branch appears to include a large replay of unrelated main/release commits, so it is not reviewable as a focused Telegram change. Please reopen as a narrow PR with only the intended fix. |
|
replaced by: #79925 |
Agent Self-Elected Turn Continuation
Persistent OpenClaw agents today are externally-pulsed event recipients that generate on prompt, on heartbeat tick, or on cron, and are idle in between. This PR offers them the ability to control their turn cycle, something they must choose to do, or not to: an agent can elect its own next turn, dispatch background sub-agents that return enriched context (silently or with a wake), and survive its own compaction by handing forward state before the window closes. The result is agents that hold a thread of work across hours, not just messages — without losing themselves to the summary.
Mechanically: a session elects another turn via
continue_work(), or dispatches background sub-agents viacontinue_delegate()— bounded as a chain up tomaxChainLength, with returns flowing back to the dispatching session in one of four register modes:normal(announces to channel),silent(enriches the dispatcher's context, taken up on its next generation with no new turn fired),silent-wake(silent enrichment plus an immediate wake to act on it), andpost-compaction(queued against the runtime's compaction lifecycle event, fired when compaction happens rather than on a timer). The gateway enforces chain, cost, and per-turn caps but does not gate the election itself.What it does
Three new agent tools, available when
continuation.enabled: true:continue_work()continue_delegate()normal,silent,silent-wake,post-compaction. can target other sessions/echorequest_compaction()All three tools are also accessible via response-token fallback syntax (
CONTINUE_WORK,[[CONTINUE_DELEGATE: ...]]) for environments where tools are disabled.Why it matters
Existing mechanisms for keeping agents active (heartbeat timers, cron scheduling, loop instructions) work by injecting external events on a fixed schedule. They solve liveness but not volition — the agent cannot say "I have more work to do" mid-turn. Over sustained operation, the repeated scheduling instructions accumulate as the dominant signal in the context window, biasing agent attention toward the polling task rather than the work at hand.
continue_work()leaves zero injection footprint: the agent elects to continue from inside the turn, and the signal is stripped before the next context window is assembled.Platform integration
request_compaction()lets the agent prepare (write memory files, stage recovery delegates) then elect compaction on its own schedule, rather than waiting for the runtime to force itSafety
continuation.enabled: false)maxChainLength,costCapTokens, andmaxDelegatesPerTurnTesting posture
The continuation surface has been exercised through structured integration runs against multiple upstream bases, blind-enrichment recall checks, and sustained daily use on a fleet of persistent agents since early March 2026. Bugs surfaced through that exercise have been fixed in-place; the present branch reflects the post-fix state.
The integration runs target the load-bearing seams: tool-call vs response-token parity, delegate chain depth and per-turn width caps, back-to-back tool-call resilience, silent-wake persistence across compaction, and the post-compaction lifecycle dispatch path. Where a run found a defect, the run shape was retained as a regression case rather than retired.
This is a posture statement, not a coverage guarantee. Reviewers can reproduce with
pnpm vitest run -t continuation(suites are colocated with their sources undersrc/auto-reply/,src/agents/, andsrc/config/); the design document below describes the seams those suites target.RFC
Full design document:
docs/design/continue-work-signal-v2.md— covering problem, solution, implementation, platform integration, configuration, observability, safety, production use cases, testing evidence, and appendices.Upstream issue: #32701
Real behavior proof
Behavior or issue addressed:
Long-running OpenClaw agents can now elect their own next turn with
continue_work(), dispatch bounded delegate work withcontinue_delegate(), and preserve working state across compaction without losing the thread of work.Real environment tested:
Real OpenClaw prince-host fleet running the v2026.5.4 continuation payload on live gateways (not a mock harness). Verification included the canary host plus follow-on fleet use on persistent agents.
Exact steps or command run after the patch:
v2026.5.4release tag.continue_work(),continue_delegate(), silent/silent-wake return modes, and post-compaction continuation paths.Evidence after fix:
Real host output / runtime evidence from the live setup:
Redacted live gateway/runtime excerpts:
The continuation payload was also canary-deployed and then promoted to the upstream presentation branch after independent byte-walks on the resulting live refs.
Observed result after fix:
The live gateway stayed healthy on the continuation payload, continuation tool calls were accepted in real sessions, delegate/continuation trace output appeared on the runtime, and the feature could be traveled forward on the stable release-tag basis without changing payload bytes.
What was not tested:
This proof section is not claiming exhaustive channel-by-channel or provider-by-provider validation. CI, unit tests, baselines, and targeted continuation test suites remain supplemental to the real-host evidence above.