Skip to content

fix(agents): stop sessions_send from blocking turns past its timeout - #201373

Merged
steipete merged 3 commits into
mainfrom
codex/sessions-send-deadline
Nov 18, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/sessions-send-deadline

Conversation

@steipete

@steipete steipete commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A sessions_send to a busy child can remain blocked before its reply wait. Without a declared host deadline, a Code Mode call can hold the turn until the 15-minute watchdog aborts it, delaying queued user messages; the next turn can repeat the same hang.

The reproducible unbounded await is active-child steering in src/agents/tools/sessions-send-tool.delivery.ts:275: deliveryTimeoutMs: undefined leaves transcript acknowledgment unbounded at lines 324–334. The original tool entry point supplied no admission ceiling or execution deadline. The incident arguments are unavailable, so the exact production await and proposed announcement cycle remain unproven.

Fix

A fixed, named 30-second admission ceiling covers requester-source acquisition, target lookup, preparation, admission, and transcript acknowledgment, including zero-wait sends. After acceptance, timeoutSeconds retains its existing reply-only contract (default 30 seconds; zero skips waiting). Direct calls and retained replay share this owner. The declared watchdog deadline is tool start plus the admission ceiling plus the reply wait.

Admission expiry returns a visible timeout advising inspection before retry, fences new sender effects, and releases communication subscriptions without cancelling receiver-owned input. Late materialized results still transfer to the existing reply-delivery owner. No watchdog window, retry policy, or configuration changes.

The follow-up fixes a regression in 8588ea86849b: the initial combined budget could return false ambiguous timeouts when admission exceeded a short reply timeout. Documentation now states the two independent budgets.

The github_publish sibling already has bounded response waits on this base via #200927; its previously verified Node and QuickJS Code Mode regressions pass. Its separate deferred workspace handoff was not reproduced as hanging or changed here.

Evidence

  • The deterministic one-second reply / two-second admission case fails on 8588ea86849b and passes with this fix. It is folded into the existing fake-timer child-result case.
  • The busy-child transcript-ack ceiling and long declared deadline / late child-result regressions remain green. The original two owner regressions were also proven red on base 04cb8179ccd66.
  • The exact requested three-file command with --maxWorkers=8 passes 83/83: admission 18, sessions 57, agent-step 8; 178.81 seconds locally. These real owner compositions exercise SQLite-backed admission, caller authority, and completion custody.
  • The 11 sibling files cover 163 unique tests. The first batch passed 162; the retention fixture failed because GC was unavailable. A direct CLI GC flag did not reach that worker. The repository runner (node scripts/run-vitest.mjs run --maxWorkers=8 src/agents/tools/sessions-send-followup.test.ts) supplies the required flags and passes all five tests in that file. No production changes or test bypass were needed.
  • Core and agent-tool test typechecks, touched-file lint/format, documentation lint, and diff checks pass. No production access or external Gateway was used.
  • Author simplification and Codex autoreview of the complete staged branch diff are complete; review is scoped-clean at P0–P2 with no actionable findings.

Whole-PR test lines: +164 / -164, net 0. Production: +118 net; documentation: +5 net. Duplicate notification assertions and redundant test state were removed while preserving the admission, receiver-custody, inline-reply, and late-result contracts.

Auto-merge remains disabled. This follow-up is pushed for coordinator verification; it does not authorize or perform landing.

@clawsweeper

clawsweeper Bot commented Nov 18, 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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T20:03:30.295933Z e3f0bf2 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: M labels Nov 18, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8588ea8684

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +413 to +417
// A deadline can win during reply materialization; the accepted result still needs a consumer.
if (params.signal?.aborted && delayedDelivery.status === "pending" && !registryCompletion) {
await startReplyFlow(true, reply);
} else {
completion?.close();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve registry-owned replies when the outer deadline wins

For a registry-owned child followup, a terminal result can arrive just before the send deadline and then spend the remaining budget in acknowledgment or reply materialization (for example, the history lookup for a reply ending in …). The new outer race returns a timeout, but acknowledgeSubagentResultForRequesterTurn() has already marked the registry obligation delivered and disabled its completion message. This branch explicitly excludes registryCompletion, so the eventual inline result is discarded without restoring or transferring delivery: the requester receives neither the answer nor a late completion. Preserve the registry obligation until inline delivery is assured, or reconcile it when the deadline wins.

AGENTS.md reference: src/agents/AGENTS.md:L37-L38

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 18, 2026
@clawsweeper

clawsweeper Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

Bounds sessions_send with one overall deadline while preserving receiver-owned work after the sender times out.

Example: A parent sends guidance to its busy child with the default 30-second timeout.

  • Before: Waiting for transcript acknowledgment can keep the sending turn blocked beyond 30 seconds.
  • After: The sender returns a visible timeout at its deadline while accepted guidance remains owned by the child.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The repair has clear value, but registry-owned reply loss blocks correctness and supplied validation does not establish real behavior.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🦪 silver shellfish (2/6) 1 actionable review finding remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Sending guidance to a busy child can leave the parent turn blocked past the requested timeout and delay subsequent messages.
Reason: The source establishes a violated timeout contract, and the maintainer-authored direction bounds sender observation without cancelling accepted receiver work or adding configuration.

Merge readiness

⛔ Needs changes before merge - 1 item remains

This PR addresses a current timeout defect, but the new deadline can discard a registry-owned child reply after its delivery obligation has already been acknowledged.

Priority: P1
Reviewed head: 8588ea86849bcbad13311acc64da54072973070f

Before merge

  • Preserve registry completion when the outer deadline wins (P2) - For a registry-owned child follow-up, a terminal reply can arrive just before the deadline and then wait in acknowledgment or full-reply recovery. For example, timeoutSeconds=1 can expire while resolveSessionsSendReply reads history for a preview ending in an ellipsis. acknowledgeSubagentResultForRequesterTurn has already cleared expectsCompletionMessage and marked delivery complete, but the outer race returns only a timeout. This branch excludes registryCompletion, and startReplyFlow also skips it, so the eventual inline result is discarded and no late completion remains. Keep the registry obligation until inline delivery is assured, or reconcile it when the deadline wins; add a regression using the registry-owned path.

Findings

  • [P2] Preserve registry completion when the outer deadline wins — src/agents/tools/sessions-send-reply-flow.ts:413-417

Tests

  • Missing end-to-end proof: Provide redacted Gateway/model output showing a busy-child send returning at its deadline while accepted receiver work and eventual completion remain intact, including an explicit long wait.
Agent review details

How this fits together

The sessions_send tool resolves and authorizes a destination, admits guidance or a follow-up turn, and returns its result inline or transfers completion to an existing delivery owner.

flowchart TD
 A[Calling agent] --> B[Send deadline]
 B --> C[Target and communication admission]
 C --> D[Receiver steering or followup]
 D --> E[Reply observation]
 E --> F[Inline tool result]
 E --> G[Existing completion owner]
 B --> H[Visible timeout]
Loading

Technical review

Best possible solution:

Keep the shared sender deadline and preserve the existing registry completion obligation whenever the timeout prevents inline delivery.

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

Current-main source shows an unbounded steering acknowledgment before the bounded reply wait; the PR reports red/green regressions, but the exact production incident await remains unknown and no code was executed during this review.

Is this the best way to solve the issue?

A single deadline around the existing send owner is appropriate, but completion acknowledgment must remain consistent with whether the outer race actually returns the child result.

Full review comments:

  • [P2] Preserve registry completion when the outer deadline wins — src/agents/tools/sessions-send-reply-flow.ts:413-417
    For a registry-owned child follow-up, a terminal reply can arrive just before the deadline and then wait in acknowledgment or full-reply recovery. For example, timeoutSeconds=1 can expire while resolveSessionsSendReply reads history for a preview ending in an ellipsis. acknowledgeSubagentResultForRequesterTurn has already cleared expectsCompletionMessage and marked delivery complete, but the outer race returns only a timeout. This branch excludes registryCompletion, and startReplyFlow also skips it, so the eventual inline result is discarded and no late completion remains. Keep the registry obligation until inline delivery is assured, or reconcile it when the deadline wins; add a regression using the registry-owned path.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.96

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 3da0bc802e10.

Provenance checked

  • Steering acknowledgment and sender timeout changes intended behavior with a stated reason (2d9033c: Wait for durable transcript persistence before acknowledging steering, and never replay input whose consumption is uncertain.)
  • Default sends to busy children keeps the original intent (a49d0b2: Parent guidance must reach a busy child's current run rather than queue duplicate work after it finishes.)
  • Inline and late registry completion keeps the original intent (a8a3680: Use one registry obligation for child follow-ups, consuming it for an inline result or retaining it for late delivery; the patch intends to preserve this contract but has the listed custody defect.)
  • Retained replay execution keeps the original intent (bca8823: Replay a definitively unaccepted self-held send once through ordinary execution with its original identity and current policy.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/agents/tools/sessions-send-tool.admission.test.ts src/agents/tools/sessions-send-reply-flow.requester.test.ts --maxWorkers=1
  • pnpm test src/agents/openclaw-tools.sessions.test.ts src/agents/tools/agent-step.test.ts --maxWorkers=1
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit a8a3680 adds src/agents/tools/sessions-send-reply-flow.ts:424 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a8a3680f3749; files: src/agents/tools/sessions-send-reply-flow.ts)
  • Ayaan Zaidi: Raw commit a49d0b2 adds src/agents/tools/sessions-send-executor.ts:607 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a49d0b22933f; files: src/agents/tools/sessions-send-executor.ts)
  • Jason (Json): Raw commit bca8823 adds src/agents/tools/sessions-send-executor.ts:618 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: bca882333b9d; files: src/agents/tools/sessions-send-executor.ts)

PR surface

Source +99, Tests 0, Docs +3. Total +102 across 9 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 132 33 +99
Tests 3 132 132 0
Docs 1 7 4 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 271 169 +102

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add P1: An unbounded session send can block an agent turn and delay queued user messages until the watchdog intervenes.
  • add merge-risk: 🚨 message-delivery: The introduced deadline can suppress both inline delivery and the registry's late completion for an accepted child result.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P1: An unbounded session send can block an agent turn and delay queued user messages until the watchdog intervenes.
  • merge-risk: 🚨 message-delivery: The introduced deadline can suppress both inline delivery and the registry's late completion for an accepted child result.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed November 18, 2026, 1:43 PM ET / 18:43 UTC.

@steipete
steipete enabled auto-merge (squash) November 18, 2026 18:55
@steipete
steipete disabled auto-merge November 18, 2026 19:47

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e3f0bf2a7a

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +109 to +113
SESSIONS_SEND_ADMISSION_TIMEOUT_MS,
() => true,
{ signal: opts?.signal },
);
return admissionExpired ? timeout() : await execution;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Exclude pending human approval from the admission ceiling

When either session's communication preference is Ask, preparation awaits requestSessionCommunicationApproval(), whose question owner explicitly allows 15 minutes and registers a human-input wait. This unconditional 30-second admission timer instead aborts the signal and cancels that question after at most 30 seconds, so an operator responding later can no longer authorize the message. Increasing timeoutSeconds cannot help because this ceiling is fixed; if both endpoints require approval, they also share that short window. Suspend the admission budget during the registered human-input wait, or otherwise preserve the question owner's approval timeout.

Useful? React with 👍 / 👎.

@steipete
steipete merged commit da8fd16 into main Nov 18, 2026
124 of 131 checks passed
@steipete
steipete deleted the codex/sessions-send-deadline branch November 18, 2026 21:10
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 19, 2026
…penclaw#201373)

* fix(agents): bound sessions_send waits and declare deadlines

* fix(agents): retain replies when send deadlines expire

* fix(agents): separate sessions_send admission and reply timeouts
RomneyDa added a commit that referenced this pull request Nov 19, 2026
…201373)

* fix(agents): bound sessions_send waits and declare deadlines

* fix(agents): retain replies when send deadlines expire

* fix(agents): separate sessions_send admission and reply timeouts

(cherry picked from commit da8fd16)

Co-authored-by: RomneyDa <[email protected]>
github-actions Bot pushed a commit to clawhaven/openclaw that referenced this pull request Nov 23, 2026
…penclaw#201373)

* fix(agents): bound sessions_send waits and declare deadlines

* fix(agents): retain replies when send deadlines expire

* fix(agents): separate sessions_send admission and reply timeouts

Release adaptation: Source fixed admission deadline and separate reply wait propagated through baseline callers.

(cherry picked from commit da8fd16)

Co-authored-by: RomneyDa <[email protected]>
tideclaw-bot pushed a commit that referenced this pull request Nov 24, 2026
…201373)

Baseline adaptation: Bound admission and inline reply observation in the shipped sessions_send owner without importing the upstream executor split, self-held replay, or steering changes. Handoff retains accepted replies with the existing continuation or registry owner. Preserve receipts on caller revocation and use the existing error schema for uncertain admission timeout, matching the targeted fixes in #203901 and #202139.

(cherry picked from commit da8fd16)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit c6c889760104d608842b9e97e308aad201f1ca30)
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 merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant