Skip to content

feat: resume requesters after deferred sessions_send replies - #112388

Closed
rabsef-bicrym wants to merge 1 commit into
openclaw:mainfrom
rabsef-bicrym:codex/sessions-send-deferred-origin
Closed

rabsef-bicrym wants to merge 1 commit into
openclaw:mainfrom
rabsef-bicrym:codex/sessions-send-deferred-origin

Conversation

@rabsef-bicrym

@rabsef-bicrym rabsef-bicrym commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #112372

What Problem This Solves

Adds opt-in wakeOnReply: true behavior to sessions_send. The tool returns after target dispatch, then resumes the exact requesting session incarnation and captured ingress route when that target run succeeds or fails.

Why

An agent can currently delegate work and return from the tool call, but it cannot durably express “my user is waiting for this particular result.” Legacy A2A announce behavior is not correlated to one target run or pinned to the exact requester route, so the user may not hear the result until another inbound turn wakes the requester.

Changes

  • Add opt-in wakeOnReply tool contract
  • Register completion before target dispatch
  • Persist terminal payload before target settlement
  • Replay prepared and interrupted dispatches at startup
  • Reuse one stable continuation idempotency key
  • Retire dispatch only after transcript persistence
  • Hand accepted restarts to session recovery
  • Pin session incarnation and complete delivery context
  • Require explicit captured channel account
  • Lazily add deferred state on existing databases
  • Suppress legacy A2A flow for opted-in calls
  • Preserve all omitted-option behavior

Safety And Recovery

The model cannot provide a return destination. OpenClaw captures the requester session ID and normalized DeliveryContext from trusted runtime state. Registration fails if the external origin does not contain an explicit channel, to, and accountId; continuation dispatch therefore cannot substitute a provider-default account.

The target terminal payload is written while the registration remains pending, before the target is allowed to settle. After settlement, dispatch changes the row to dispatching. Gateway acceptance does not complete that row. The row is retired only after the continuation's user turn is durably written to the exact requester transcript.

Gateway startup reconciles both prepared pending rows and interrupted dispatching rows. If the exact requester session incarnation owns the continuation run ID and its transcript contains that run's user turn, deferred recovery retires its row without another gateway call and leaves the existing main-session recovery system as the sole post-restart continuation owner. If no transcript turn exists, deferred recovery replays the dispatch with the same continuation ID. Durable-ownership inspection failure suppresses dispatch and leaves the row available for a later recovery attempt.

Persistence failure before target settlement prevents settlement. Ambiguous continuation dispatch failure remains durable and restart-replayable. Completed, expired, explicitly cancelled, or mismatched state produces no new continuation. Required delivery and expectedExistingSessionId prevent route or incarnation fallback.

This is not a general durable outbound outbox. It provides durable target-result correlation and coordinates accepted continuation ownership with OpenClaw's existing main-session restart recovery for this opt-in sessions_send path.

Evidence

Current head 16ccee3e2f2b, rebased onto openclaw/main at 9faf34d3bcb:

  • pnpm test src/agents/sessions-send-deferred.test.ts src/agents/tools/sessions.test.ts src/gateway/server-startup-post-attach.test.ts
    • Passed 168 tests across three repository-routed Vitest shards in an isolated Node 24 container.
  • pnpm tsgo:core
    • Passed the production source typecheck.
  • Focused test typecheck for the three changed test files
    • Passed against the repository test tsconfig and ambient declarations.
  • pnpm format:check <changed files> and node scripts/run-oxlint.mjs <changed files>
    • Passed with zero formatting errors, lint errors, or warnings.
  • node scripts/generate-kysely-types.mjs --verify and git diff --check
    • Passed after the rebase.

The previous head also passed check:changed, the build, the full test type graph, and 363 focused agent/gateway tests. Those broader results predate the current-main rebase; current CI is the broad validation source for this head.

Regression coverage includes:

  • prepared completion recovery after restart
  • claimed dispatch recovery after restart
  • accepted-before-retirement handoff to session recovery
  • exactly one post-restart model continuation admission
  • claim without transcript remains replayable
  • gateway transcript persistence retires the dispatch
  • stable idempotency after ambiguous dispatch failure
  • pre-settlement persistence failure blocking settlement
  • startup replay after gateway methods become available
  • lazy table creation on an existing current-schema database
  • explicit account preservation and no default substitution
  • exact requester session ID and route capture
  • target success and terminal failure
  • duplicate, mismatched, cancelled, and expired state
  • concurrent requester origins
  • incompatible tool options
  • omitted-option compatibility
  • legacy A2A suppression for opted-in calls

Not yet run: a live two-agent channel round trip using wakeOnReply. This remains a draft for external design review before live proof.

Redacted AI-assisted decision transcript

This PR is AI-assisted. The author reviewed the implementation and validation and can explain the code.

User need: “We do not want to destroy wake in the channel you asked. We want a setting for ‘my user is expecting me to come back with an answer.’”

Agreed contract: make the behavior opt-in on sessions_send; return after the target run is accepted; do not expose the target result to the initiating turn; resume the exact requester session incarnation and ingress route on target success or terminal failure; suppress legacy A2A ping-pong/announce only for that call; never use a fallback destination.

Review corrections: persist the completion payload before target settlement; reconcile both prepared and interrupted dispatches after restart; reject external origins without a canonical account so ordinary delivery cannot choose a provider default; and keep an accepted dispatch durable until transcript persistence transfers restart ownership to the existing main-session recovery system.

The optional autoreview skill was not run. Direct diff review and the repository gates listed above were run instead.

Review Focus

  • Whether pre-settlement persistence plus startup reconciliation is the correct durability boundary.
  • Whether transcript persistence plus the exact restart-recovery claim is the correct ownership-transfer boundary after gateway acceptance.
  • Whether the feature-local lazy table lifecycle is the correct additive upgrade path.
  • Whether requiring an explicit captured account is appropriate for every external ingress adapter.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: XL labels Jul 21, 2026
@rabsef-bicrym
rabsef-bicrym force-pushed the codex/sessions-send-deferred-origin branch 2 times, most recently from 4c61757 to f4a689f Compare July 21, 2026 20:23
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 21, 2026
@rabsef-bicrym
rabsef-bicrym force-pushed the codex/sessions-send-deferred-origin branch 4 times, most recently from 9bc1916 to 5aea705 Compare July 21, 2026 21:28
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. labels Jul 30, 2026
@clawsweeper

clawsweeper Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 24, 2026, 8:07 PM ET / August 25, 2026, 00:07 UTC (Revision 8).

ClawSweeper review

What this changes

The branch adds an opt-in wakeOnReply option to sessions_send that stores a target run’s terminal result and resumes the exact originating session and delivery route later.

Merge readiness

⛔ Blocked before merge - 14 items remain

This feature is still absent from current main, so the PR remains necessary, but it is not merge-ready: three prior durability/context blockers remain on the unchanged head, and current main has moved the Gateway execution owners that this draft modifies.

Priority: P2
Reviewed head: 16ccee3e2f2bb5ef9a8d30e089cb94adf41c5c20
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The feature has useful design intent, but unchanged P0/P1 durability defects and mock-only proof prevent a merge-ready rating.
Proof confidence 🧂 unranked krab (1/6) Needs real behavior proof before merge: Only focused tests and static checks are supplied; add a redacted real Gateway harness or live trace showing after-fix requester continuation and result delivery. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🧂 unranked krab (1/6) Security review found an item that needs attention.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: Only focused tests and static checks are supplied; add a redacted real Gateway harness or live trace showing after-fix requester continuation and result delivery. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Historical verification Needs maintainer review A historical verification receipt failed or is malformed. A maintainer must resolve that verification blocker before merge; independently assessed contributor proof remains valid.
Evidence reviewed 6 items Current main does not implement the requested capability: Current main’s sessions_send schema has no wakeOnReply parameter and retains the legacy announce path, so the central feature is not already implemented.
Unbounded model-visible durable payload: The branch persists raw request/result text and concatenates both into a later requester prompt without a hard cap.
Armed target restart is not reconciled: Startup dispatches only rows with completion_text, while normal restart recovery creates a new run ID; an armed pre-terminal target can therefore never complete its original registration.
Findings 3 actionable findings [P0] Bound the persisted continuation prompt
[P1] Recover armed targets across restart
[P1] Retire expired deferred payloads independently
Security Needs attention Prove final delivery rejects mismatched authority: Tests assert mocked Gateway parameters but do not exercise final transport delivery for the captured account/session versus the nearest mismatched account or replaced session.

How this fits together

sessions_send delegates work to another agent session. This change persists an origin-bound completion record, observes the target terminal outcome, and asks Gateway to create a follow-up turn for the original requester.

flowchart LR
A[Requester session] --> B[sessions_send request]
B --> C[Deferred completion record]
B --> D[Target agent run]
D --> E[Terminal outcome]
E --> F[Gateway continuation]
F --> G[Exact requester route]
Loading

Decision needed

Question Recommendation
Should OpenClaw add this persistent, origin-bound requester-continuation mode to the core sessions_send contract? Sponsor a narrow core contract: Approve the opt-in behavior, then require a current-main reimplementation with the listed durability and final-effect proof.

Why: This is a new public tool mode with durable state and cross-session delivery authority; VISION.md gives such core additions a high bar, so correctness fixes alone cannot choose the product direction.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: Only focused tests and static checks are supplied; add a redacted real Gateway harness or live trace showing after-fix requester continuation and result delivery. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve historical verification - A historical verification receipt failed or is malformed. A maintainer must resolve that verification blocker before merge; independently assessed contributor proof remains valid.
  • Bound the persisted continuation prompt (P0) - requestMessage and target completion text are stored and later injected into a new requester turn without a cap. A large tool request or target reply can bloat shared state and exceed the model-context invariant; cap or summarize both values before persistence and add the boundary regression.
  • Recover armed targets across restart (P1) - Startup recovery selects only rows that already have completion_text, so a gateway restart while the target is still running leaves its pending registration uncorrelated with the replacement run. Preserve or rebind the original target correlation during restart recovery, or explicitly settle the arm with a recorded outcome.
  • Retire expired deferred payloads independently (P1) - Expiry is applied only when a later registration, prepare, or claim touches the row. A never-terminal target, and even completed or cancelled rows, retain request, origin, and result data indefinitely unless another deferred send occurs; add a lifecycle-owned sweep or deletion path.
  • Resolve security concern: Prove final delivery rejects mismatched authority - Tests assert mocked Gateway parameters but do not exercise final transport delivery for the captured account/session versus the nearest mismatched account or replaced session.
  • Resolve merge risk (P1) - Current main has replaced the draft’s Gateway execution files, so merging this dirty branch would require an owner-led reimplementation rather than a mechanical rebase.
  • Resolve merge risk (P1) - The persisted origin is authority-bearing; mocked parameter assertions do not prove that account A is honored and account B or a replaced session is rejected before final transport I/O.
  • Complete next step (P2) - A maintainer must decide whether to sponsor this new durable core contract before a current-main reimplementation can proceed.
  • Improve patch quality - Reimplement on current agent-turn ownership and add regressions for capped payloads, armed-run restart correlation, and independent expiry cleanup.
  • Improve patch quality - Add final-effect proof for captured account A, the nearest same-route account B, and a replaced requester session; forbidden cases must produce no transport I/O.
  • Improve patch quality - Publish a redacted mock-Gateway harness verdict or live two-agent continuation trace, then update the PR body for an exact-head re-review.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.

Findings

  • [P0] Bound the persisted continuation prompt — src/agents/sessions-send-deferred.ts:127-140
  • [P1] Recover armed targets across restart — src/agents/sessions-send-deferred.ts:342-345
  • [P1] Retire expired deferred payloads independently — src/agents/sessions-send-deferred-store.ts:141-146
  • [medium] Prove final delivery rejects mismatched authority — src/agents/sessions-send-deferred.ts:148
Agent review details

Security

Needs attention: No route-fallback bypass was found, but this persisted delivery authority needs final-effect rejection proof before merge.

PR surface

Source +959, Tests +781, Docs +3, Generated +19. Total +1762 across 19 files.

View PR surface stats
Area Files Added Removed Net
Source 12 1018 59 +959
Tests 5 782 1 +781
Docs 1 3 0 +3
Config 0 0 0 0
Generated 1 19 0 +19
Other 0 0 0 0
Total 19 1822 60 +1762

Review metrics

Metric Value Why it matters
Production versus test delta production +1039/-59; tests +783/-1; docs +3 The substantial production growth is justified only if maintainers approve the new durable core capability.
Persistent state surface 1 additive SQLite table The new deferred-completion table retains requester route and target-result state, making recovery and expiry behavior merge-critical.

Stored data model

Persistent data-model change detected: database schema: src/agents/sessions-send-deferred-store.ts, database schema: src/state/openclaw-state-schema.sql, serialized state: src/agents/sessions-send-deferred-store.ts, serialized state: src/agents/sessions-send-deferred.test.ts, serialized state: src/agents/sessions-send-deferred.ts, serialized state: src/agents/tools/sessions-send-tool.ts, and 8 more. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #112372
Summary: This PR is the proposed implementation for the open deferred-completion feature request; it only partially overlaps the separate strict-internal-delegation report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Rebuild the feature on current Gateway ownership (recommended)
    After product sponsorship, port the feature to current agent-turn owners and add bounded retention, armed-run recovery, and lifecycle cleanup before merge.
  2. Pause the feature direction
    Keep this draft open only as design evidence until a maintainer confirms that durable core requester continuations are desired.

Technical review

Best possible solution:

If maintainers sponsor this core contract, reimplement it on current agent-turn ownership with bounded payload storage, lifecycle-owned expiry, original-run recovery correlation, and an end-to-end Gateway delivery proof.

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

Yes, from source: oversized request/result text reaches an unbounded continuation prompt, and restart/expiry paths are directly traceable without executing the external branch.

Is this the best way to solve the issue?

No: the intended behavior needs product sponsorship and a reimplementation on current agent-turn ownership rather than changes to replaced Gateway server-method files.

Full review comments:

  • [P0] Bound the persisted continuation prompt — src/agents/sessions-send-deferred.ts:127-140
    requestMessage and target completion text are stored and later injected into a new requester turn without a cap. A large tool request or target reply can bloat shared state and exceed the model-context invariant; cap or summarize both values before persistence and add the boundary regression.
    Confidence: 0.99
  • [P1] Recover armed targets across restart — src/agents/sessions-send-deferred.ts:342-345
    Startup recovery selects only rows that already have completion_text, so a gateway restart while the target is still running leaves its pending registration uncorrelated with the replacement run. Preserve or rebind the original target correlation during restart recovery, or explicitly settle the arm with a recorded outcome.
    Confidence: 0.97
  • [P1] Retire expired deferred payloads independently — src/agents/sessions-send-deferred-store.ts:141-146
    Expiry is applied only when a later registration, prepare, or claim touches the row. A never-terminal target, and even completed or cancelled rows, retain request, origin, and result data indefinitely unless another deferred send occurs; add a lifecycle-owned sweep or deletion path.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.97

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 058a72fe6601.

Labels

Label justifications:

  • P2: This is a significant opt-in agent-session feature with blocking correctness work, but it is not a current default-path outage.
  • merge-risk: 🚨 session-state: The added persistent continuation rows can remain unresolved or retained past their claimed lifecycle after restart or expiry.
  • merge-risk: 🚨 message-delivery: A restarted armed target can silently fail to resume the requester, defeating the feature’s promised result delivery.
  • merge-risk: 🚨 security-boundary: The PR persists route authority across sessions, but lacks final-effect proof that a mismatched account or session is rejected before delivery.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Only focused tests and static checks are supplied; add a redacted real Gateway harness or live trace showing after-fix requester continuation and result delivery. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review. A historical verification receipt failed or is malformed. A maintainer must resolve that verification blocker before merge; independently assessed contributor proof remains valid.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. The opt-in continuation can visibly resume a Telegram requester in its original route or topic after delegated work completes.

Evidence

Security concerns:

  • [medium] Prove final delivery rejects mismatched authority — src/agents/sessions-send-deferred.ts:148
    Tests assert mocked Gateway parameters but do not exercise final transport delivery for the captured account/session versus the nearest mismatched account or replaced session.
    Confidence: 0.86

What I checked:

Likely related people:

  • ClawSweeper: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Steinberger: 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.

History

Review history (7 earlier review cycles)
  • reviewed July 30, 2026, 2:53 AM ET / 06:53 UTC sha unknown :: needs real behavior proof before merge. :: [P3] Remove the release-owned changelog entry
  • reviewed 2026-08-01T18:57:36.326Z sha 5aea705a84d15fc85bcef3fc7893efb2ac46dda4 :: needs real behavior proof before merge. :: [P1] Add the table to the lazy additive schema path
  • reviewed 2026-08-04T08:23:27.437Z sha 16ccee3 :: needs real behavior proof before merge. :: [P1] Gate deferred persistence to armed target runs | [P1] Keep registrations after ambiguous dispatch errors | [P2] Clear stale continuation IDs
  • reviewed 2026-08-12T14:21:17.113Z sha 16ccee3 :: needs real behavior proof before merge. :: [P0] Bound the deferred continuation payload | [P1] Recover armed target runs after restart | [P1] Expire retained deferred payloads independently
  • reviewed 2026-08-15T16:22:45.687Z sha 16ccee3 :: needs real behavior proof before merge. :: [P0] Bound the deferred continuation payload | [P1] Recover armed target runs after restart | [P1] Expire retained deferred payloads independently
  • reviewed 2026-08-16T13:39:14.706Z sha 16ccee3 :: needs real behavior proof before merge. :: [P0] Cap the deferred continuation payload | [P1] Recover arms whose target has not terminalized | [P1] Retire expired deferred payloads independently | [P1] Dispatch only after terminal settlement succeeds
  • reviewed 2026-08-18T23:29:09.032Z sha 16ccee3 :: needs real behavior proof before merge. :: [P0] Bound the persisted continuation prompt | [P1] Recover armed targets that restart before terminalization | [P1] Purge expired deferred payloads without another arm | [P1] Wait for settlement before dispatching the continuation

- Add opt-in one-shot requester continuation for deferred sessions_send runs
- Bind continuation delivery to the captured requester session incarnation and ingress route
- Persist terminal outcomes and recover accepted continuations across gateway restarts
- Cover failure, replay, expiry, account isolation, and restart behavior
@rabsef-bicrym
rabsef-bicrym force-pushed the codex/sessions-send-deferred-origin branch from 5aea705 to 16ccee3 Compare August 4, 2026 08:14
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. and removed merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Aug 4, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. and removed merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. labels Aug 25, 2026
@clawsweeper clawsweeper Bot removed the mantis: telegram-visible-proof Mantis should capture Telegram visible proof. label Aug 28, 2026
@VACInc

VACInc commented Sep 28, 2026

Copy link
Copy Markdown
Member

Compared with merged #160018, this PR has a different scope: opt-in wakeOnReply, durable target-result registration, pinned requester/origin routing, and restart replay. #160018 only repairs live owner-authority transport through the existing native follow-up path; it does not replace this feature. Leaving this PR open and preserving its draft status.

@pavonis-martian

pavonis-martian commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Best-effort implementation is complete; the tested candidate is ready for the branch owner to apply. This supersedes my earlier persistence/recovery proposal.

What Problem This Solves

An inter-session sender can request a reply without blocking its current turn. With sessions_send({ ..., wakeOnReply: true }), the call returns after target acceptance and the existing completion path wakes the original requester once with the result.

User Impact

No ping-pong or extra target-channel announcement for this opted-in path. The requester session incarnation and captured return route stay pinned. Omitting the option preserves existing behavior, and existing native-task/ACP completion ownership is retained without a second wake.

This is deliberately best effort: no new storage, retention policy, restart replay, or “result unavailable after restart” mechanism. Empty results do not wake the requester; a Gateway restart may lose a pending wake. Unsupported combinations are rejected before dispatch.

Candidate and Handoff

Reviewed candidate a5471921031 is on pavonis-martian/openclaw:pr-112388-best-effort, integrated with main at bb869836e98. The two real upstream conflicts were resolved while preserving current personal-tool authority and active-child delivery behavior.

The original contributor's commit/history is retained: current PR head 16ccee3e2f2b is an ancestor of this candidate. Its final tree is identical to the tested integrated source. No force-push is needed. The authenticated account cannot push to the source fork, so this PR's branch is still unchanged.

A writer of rabsef-bicrym/moltbot can apply it with:

git fetch https://github.com/pavonis-martian/openclaw.git pr-112388-best-effort
git push https://github.com/rabsef-bicrym/moltbot.git a5471921031d341618c8f0f9dc3a616fc168bd7f:refs/heads/codex/sessions-send-deferred-origin

Evidence

  • 184 focused tests passed on the integrated candidate: admission, A2A, followup, session tools, and the existing active-child/late-reply cases. Coverage includes accepted return before completion, pinned requester/route, terminal failure, empty result, no announcement loop, and unsupported combinations.
  • Core production and affected agent-tool test type checks, targeted lint, formatting, line-cap/max-lines ratchets, and affected repository guards passed.
  • Fresh independent source review found no actionable findings after integration.
  • Changed-test cost: pnpm test src/agents/tools/sessions-send-tool.admission.test.ts --maxWorkers=1 measured 42.16s wall (about 7.5s test execution; cold compilation dominates). Hosted CI timing is not available.
  • Proof used the real tool/reply-flow entry points with an isolated mocked Gateway boundary, not a live provider/Gateway. Full-suite and current-head hosted CI are not claimed; normal maintainer review and merge gates remain after the branch update.

Related: #112372 (deliberately narrower than durable delivery), #148296 (eventual-reply behavior).

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@steipete

Copy link
Copy Markdown
Contributor

Thanks for the PR. We're closing older pull requests that have gone stale against current main.

This large draft has had no commits since early August and is still blocked on durability and proof items. Thanks for the design work; if wake-on-reply for sessions_send is still wanted, please open a fresh, smaller PR against current main.

@steipete steipete closed this Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XL stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add opt-in, origin-bound deferred completion to sessions_send

4 participants