Skip to content

feat: retain required results without model polling - #162707

Merged
VACInc merged 2 commits into
mainfrom
openclaw/required-work-event-driven-continuation-20261001
Oct 1, 2026
Merged

VACInc merged 2 commits into
mainfrom
openclaw/required-work-event-driven-continuation-20261001

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #143701. Follow-up to #162303, which repairs collection guidance rather than enforcing collection.

What Problem This Solves

Agents can return an answer while a needed command result remains uncollected, or spend repeated model turns polling a still-pending tool or collector.

User Impact

required: true lets a caller make command or collector results a runtime-owned prerequisite for finishing the call. Required Code Mode work stays active and resumes from completion events without model polling or replaying completed actions. Explicitly detached servers keep their current behavior, including notifyOnExit=false.

This is opt-in at call admission, not semantic judgment of a plan or retroactive tracking of previously detached handles. Ordinary announcing children keep their existing sessions_yield protocol. Required calls occupy their existing execution capacity; Stop, source replacement, and run/tool/process deadlines still apply. Only off-VM tool waiting pauses the Code Mode execution allowance; computation, checkpoint/restore work, and guest timers remain charged. No new configuration, persisted schema, retention policy, scheduler, or notification setting.

Why This Change Was Made

Keep required work at its existing producer and pending-call owner instead of adding a competing task ledger or blocking a native Stop hook. Shell exec collects its terminal result; collector waits join all requested authorized results through registry events; Code Mode retains the exact continuation and its unused execution allowance. A normal final cannot bypass the still-pending call.

Evidence

  • Exact-head CI run 36865914071 passed; both required openclaw/ci-gate entries were green. ClawSweeper’s completed review pins e722df18cf1508ce7ec437b9ad9617f6a337973c and reports no findings, security concerns, or before-merge items. Verification completed at 13:19 UTC; @VACInc merged the PR at 13:58:50 UTC on October 1, 2026.
  • Initial registered-exec/AgentSession reproduction on pinned base 4d199b32c789175c20d3123449dcae93c52f8e85: the required-result case failed because finalization completed while the process remained pending; the detached control passed. The repair moves enforcement earlier, to the pending execution owner.
  • 84 focused tests passed across the execution boundary, collector ownership/replacement, Code Mode waiting, existing headless budgets, detached-process cancellation, and native dynamic-tool suites. The extracted boundary and required-collector files were rerun after the mechanical helper/test split.
  • A simulated 60-second wait produces zero additional model requests. Completion supplies the result to the existing continuation exactly once. Two simulated minute-long tool waits preserve the original guest allowance (1000 → 900 → 800 ms with controlled execution costs), not fresh slices. Failure, cancellation, replacement, guest-timer exhaustion, explicit-yield refusal, and detached controls are covered.
  • Native parity is an app-server boundary fixture with the real OpenClaw exec producer and host capability, a controlled process supervisor, and one pending native tool request. It is not a live model/OS-process test or a change to Codex-owned unified exec. Personally inspected sibling Codex 8f73cdee456b6c46b791780d40cadf9d556d22a4, core/src/session/turn.rs: in-flight tool futures drain before the next model continuation.
  • Independent AutoReview through P1: scoped-clean. Subsequent changes were mechanical extraction and lint-only cleanup; no review findings were waived.
  • All selected changed-check gates passed across the initial run and scoped lint fixes: core and extension production/test types (including 27 core-test graphs), SDK boundaries, formatting, lint (zero warnings/errors), dead-export scans, import cycles, and repository guards. git diff --check passed. No unrelated full-suite or deployment claim.
Test cost and overlap scope

Focused Node tests used --maxWorkers=1 for measurement only; no worker pin or serial configuration was added.

New/materially changed file Measured wall / test body
attempt-required-work.test.ts 38.83 s cold project / 1.01 s
agents-wait-tool.required.test.ts 5.22 s / 0.10 s
code-mode.wait.test.ts 24.25 s / 2.02 s
Codex run-attempt.dynamic-tools.test.ts 43.43 s / 14.79 s

Cold compilation accounts for 33.30 s of the first boundary run. The native file exercises the actual app-server/host-tool composition and existing runtime preparation; a helper-only test would not prove that boundary. New waits use controlled promises and fake clocks, not real polling sleeps. CI-reported test-case sums (not file wall time): attempt-required-work.test.ts 1.175 s across 4 cases; agents-wait-tool.required.test.ts 0.056 s across 2 cases; code-mode.wait.test.ts 2.345 s across 22 cases (six required-work cases: 0.556 s); native run-attempt.dynamic-tools.test.ts 17.866 s across 6 cases (new required-command case: 14.623 s).

Bounded upstream/local overlap audit found adjacent work, not this explicit required pending-call contract: #103586 (goal contracts/timer barriers/optional judge), #106110 (goal tests), #154954 (child yield claims excluding collectors), #112388 (deferred replies), #129388 (future-work/child-return subsystem, sampled statically), #159040 (plugin callbacks), and #160297 (plan self-check). Existing child cancellation/custody work remains with its owner and was not copied. This PR reuses the existing process, collector, and Code Mode owners; it does not restore Tasks/TaskFlow or supersede those PRs.

Requested by and co-authored with @VACInc.

Worked on by

Work sessions


View the OpenClaw team session

roboclaw-bot and others added 2 commits October 1, 2026 12:56
Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>
OpenClaw-Publication: cec817cf-dea5-4829-859b-02ad1b724e19
@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling extensions: codex size: L labels Oct 1, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review October 1, 2026 13:02
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 1, 2026
@clawsweeper

clawsweeper Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 9:10 AM ET / 13:10 UTC.

ClawSweeper review

What this changes

The PR adds optional required-result handling to shell commands, collector waits, and OpenClaw Code Mode so pending results can complete without repeated model polling.

Merge readiness

✅ Ready for maintainer review

Keep open: current main lacks this completion contract, and source review found no concrete blocking defect. The merged collection-guidance work does not supersede it.

Priority: P2
Reviewed head: e722df18cf1508ce7ec437b9ad9617f6a337973c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with meaningful boundary coverage and no concrete blocking findings; reported execution results were not independently rerun.
Proof confidence 🌊 off-meta tidepool Not applicable: The bot-authored PR is exempt from ordinary external-contributor live proof. Its registered session and native adapter tests exercise the changed exec and continuation owners using controlled processes, providers, and app-server requests; these are boundary validation, not a live-process claim. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The bot-authored PR is exempt from ordinary external-contributor live proof. Its registered session and native adapter tests exercise the changed exec and continuation owners using controlled processes, providers, and app-server requests; these are boundary validation, not a live-process claim. No stored-data contract changes.
Evidence reviewed 10 items Pinned introduction and merge ownership: Reviewed the merge-base-to-head introduced changes. Raw test-merge parent records contain the pinned base followed by the exact PR head; base-only changes were not attributed to this PR.
Required shell ownership: Required commands disable foreground-to-background promotion within the existing exec owner. Terminal collection, process deadlines, approval checks, and foreground cancellation remain on the existing execution path; explicit detached commands retain their behavior.
Event-driven continuation and budget: Required Code Mode waits retain the existing continuation, race settlement against owner cancellation, and restore only the unused execution allowance. Pending guest timers use the charged waiting path, and unfinished required programs cannot publish a waiting handle.
Findings None None.
Security None None.

How this fits together

OpenClaw's agent runtime executes model-requested tools and returns their results to the conversation. Code Mode coordinates JavaScript programs with those tools, retaining their continuation while required work settles.

flowchart TD
 A[Model tool call] --> B{Required result?}
 B -->|No| C[Existing continuation behavior]
 B -->|Yes| D[Pending call owner]
 E[Process or collector completion] --> D
 D --> F[Resume exact program]
 F --> G[Return collected result]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +146, Tests +596, Docs +42. Total +784 across 19 files.

View PR surface stats
Area Files Added Removed Net
Source 10 161 15 +146
Tests 5 597 1 +596
Docs 4 43 1 +42
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 19 801 17 +784

Review metrics

Metric Value Why it matters
Completion contract 3 optional tool parameters; 0 operator configuration keys Required behavior is selected per call while existing omitted-option behavior remains intact.
Production versus test growth production +145 net lines; tests and test support +597 net lines Production growth implements owner-held waits and budget preservation; boundary coverage accounts for most added code.

Technical review

Best possible solution:

Keep required-result enforcement with the existing process, collector, and Code Mode owners while preserving detached services and cancellation limits.

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

Not applicable as a new opt-in capability. The supplied registered-boundary regressions demonstrate the intended pending-call scenario with controlled processes and providers; no live reproduction was run here.

Is this the best way to solve the issue?

Yes: extending the existing pending-call owners avoids a competing task ledger and preserves the exact continuation, established access checks, and execution allowance.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a bounded opt-in improvement to result collection and model-request efficiency.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The bot-authored PR is exempt from ordinary external-contributor live proof. Its registered session and native adapter tests exercise the changed exec and continuation owners using controlled processes, providers, and app-server requests; these are boundary validation, not a live-process claim. No stored-data contract changes.

Label justifications:

  • P2: This is a bounded opt-in improvement to result collection and model-request efficiency.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The bot-authored PR is exempt from ordinary external-contributor live proof. Its registered session and native adapter tests exercise the changed exec and continuation owners using controlled processes, providers, and app-server requests; these are boundary validation, not a live-process claim. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduction and merge ownership: Reviewed the merge-base-to-head introduced changes. Raw test-merge parent records contain the pinned base followed by the exact PR head; base-only changes were not attributed to this PR. (1644e66ec821)
  • Required shell ownership: Required commands disable foreground-to-background promotion within the existing exec owner. Terminal collection, process deadlines, approval checks, and foreground cancellation remain on the existing execution path; explicit detached commands retain their behavior. (src/agents/bash-tools.exec-run.ts:222, e722df18cf15)
  • Event-driven continuation and budget: Required Code Mode waits retain the existing continuation, race settlement against owner cancellation, and restore only the unused execution allowance. Pending guest timers use the charged waiting path, and unfinished required programs cannot publish a waiting handle. (src/agents/code-mode-execution.ts:496, e722df18cf15)
  • Collector access and compatibility: Required collection changes the existing event-driven reader from first-completion to all-authorized-results settlement. Every read still checks current collector ownership; omitted required retains the existing timeout and first-completion behavior. No stored schema or operator configuration changes. (src/agents/tools/agents-wait-tool.ts:272, e722df18cf15)
  • Boundary validation scope: Inspected registered AgentSession, collector, Code Mode, and native adapter tests. They cover zero extra polling requests during controlled waits, result delivery, original-budget preservation, cancellation, replacement, guest-timer exhaustion, and detached controls. The body reports 84 focused tests passing and measured file costs; tests were not executed during this read-only review. (src/agents/code-mode.wait.test.ts:44, e722df18cf15)
  • Codex dependency signal: The introduced native adapter test exercises an app-server pending dynamic-tool request using the actual OpenClaw exec producer and host capability, with controlled process execution. This test and the PR's native-parity claim establish the Codex dependency inspection requirement; OpenClaw Code Mode itself remains separately implemented. (extensions/codex/src/app-server/run-attempt.dynamic-tools.test.ts:53, e722df18cf15)

Likely related people:

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

Rating scale

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

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

Workflow

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

@VACInc
VACInc merged commit 98f9d59 into main Oct 1, 2026
215 of 220 checks passed
@VACInc
VACInc deleted the openclaw/required-work-event-driven-continuation-20261001 branch October 1, 2026 13:58
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 2, 2026
* feat: retain required results without model polling

Co-authored-by: VACInc <[email protected]>

* feat: retain required results without model polling

Worked on by:
- @VACInc

Co-authored-by: VACInc <[email protected]>
OpenClaw-Publication: cec817cf-dea5-4829-859b-02ad1b724e19

---------

Co-authored-by: roboclaw-bot <[email protected]>
Co-authored-by: VACInc <[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 gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants