Skip to content

fix(agents): keep delayed sessions_send replies alive - #76484

Merged
vincentkoc merged 1 commit into
mainfrom
fix/sessions-send-a2a-timeout-76443
May 3, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/sessions-send-a2a-timeout-76443

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

Summary

  • Keep sessions_send A2A delivery alive after soft agent.wait window timeouts by returning accepted with pending delivery and launching the delayed requester follow-up.
  • Preserve terminal agent-run timeouts as status: "timeout" so real run failures do not become accepted background work.
  • Pass the pre-run assistant baseline into delayed A2A reads so stale target-session replies are not injected into requester sessions.

Fixes #76443.

Investigation

Checked the requested adjacent refs before publishing:

Validation

  • pnpm test src/agents/openclaw-tools.sessions.test.ts src/agents/tools/sessions-send-tool.a2a.test.ts
  • OPENCLAW_TESTBOX=1 pnpm check:changed

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label May 3, 2026
@vincentkoc vincentkoc self-assigned this May 3, 2026
@openclaw-barnacle openclaw-barnacle Bot added size: M maintainer Maintainer-authored PR labels May 3, 2026
@clawsweeper

clawsweeper Bot commented May 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The PR updates sessions_send/A2A timeout handling, adds stale-reply baseline filtering, covers the behavior in agent tests, and adds a CHANGELOG entry.

Reproducibility: yes. from source inspection. Current main returns from the sessions_send timeout branch before launching A2A follow-up, and the PR adds a focused mock regression for the soft wait-window timeout path; tests were not executed in this read-only review.

Next step before merge
Draft maintainer-labeled PR with no narrow automated repair found; maintainer should review, un-draft when ready, and gate on branch validation.

Security
Cleared: No concrete security or supply-chain concern was found in the PR diff.

Review details

Best possible solution:

Review, validate, and land this PR or a maintainer-approved equivalent so soft wait-window timeouts keep the delayed sessions_send A2A delivery path alive without converting real terminal run timeouts into background work.

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

Yes from source inspection. Current main returns from the sessions_send timeout branch before launching A2A follow-up, and the PR adds a focused mock regression for the soft wait-window timeout path; tests were not executed in this read-only review.

Is this the best way to solve the issue?

Yes. The patch stays inside the existing sessions_send/A2A and run-wait seams, uses current agent.wait lifecycle metadata to separate soft waits from terminal timeouts, and adds stale-reply baseline coverage.

Acceptance criteria:

  • pnpm test src/agents/openclaw-tools.sessions.test.ts src/agents/tools/sessions-send-tool.a2a.test.ts
  • OPENCLAW_TESTBOX=1 pnpm check:changed

What I checked:

  • Current main returns before delayed A2A on timeout: The current timeout branch returns status "timeout" immediately after waitForAgentRunAndReadUpdatedAssistantReply reports timeout, before the later success path calls startA2AFlow. (src/agents/tools/sessions-send-tool.ts:423, e27b7c2d7446)
  • PR launches delayed A2A only for non-terminal timeout: The PR diff adds isTerminalAgentWaitTimeout and changes non-terminal timeout results to startA2AFlow(undefined, runId) and return accepted with pending delivery, while preserving terminal timeout results. (src/agents/tools/sessions-send-tool.ts:427, cce67e63a5a4)
  • Gateway wait metadata supports soft-vs-terminal distinction: agent.wait returns a bare status timeout when the wait window expires with no lifecycle snapshot, while terminal snapshots include lifecycle metadata such as endedAt, stopReason, livenessState, or yielded. (src/gateway/server-methods/agent.ts:1598, e27b7c2d7446)
  • PR covers delayed reply and terminal timeout cases: The PR adds regression coverage for a delayed target reply that wakes the requester after the first wait timeout, and a separate terminal timeout case that must not start A2A. (src/agents/openclaw-tools.sessions.test.ts:1098, cce67e63a5a4)
  • PR state requires maintainer handling: The provided GitHub context marks this PR as draft, labels it maintainer, and shows the author association as MEMBER, so cleanup automation should not close it. (cce67e63a5a4)

Likely related people:

  • steipete: Recent main history shows multiple sessions_send, A2A, and run-wait helper commits in the affected files, including duplicate parent-send handling, A2A control echo suppression, yielded subagent wait handling, and run-wait helper extraction. (role: recent maintainer; confidence: high; commits: 8daf0124c93e, 817e6e810b7d, 6f3b5f8666f3; files: src/agents/tools/sessions-send-tool.ts, src/agents/tools/sessions-send-tool.a2a.ts, src/agents/run-wait.ts)
  • scotthuang: Recent merged work changed requester-owned sessions_send A2A skip behavior, which is directly adjacent to whether delayed follow-up delivery should fire. (role: adjacent owner; confidence: medium; commits: 8a7c21407ae3, 1c3fbbd72a01; files: src/agents/tools/sessions-send-tool.ts)
  • stainlu: Merged nested-lane work touched sessions_send A2A routing and target-session lane behavior, which is part of the same inter-agent delivery path. (role: adjacent owner; confidence: medium; commits: 4da808da5028; files: src/agents/tools/sessions-send-tool.ts, src/agents/tools/sessions-send-tool.a2a.ts)

Remaining risk / open question:

  • This read-only review did not run the PR's targeted tests or changed gate; merge should still wait for exact-branch validation.
  • The PR is draft and maintainer-labeled, so final readiness is a maintainer workflow decision rather than a cleanup decision.

Codex review notes: model gpt-5.5, reasoning high; reviewed against e27b7c2d7446.

@vincentkoc
vincentkoc force-pushed the fix/sessions-send-a2a-timeout-76443 branch from cce67e6 to 3d87e7b Compare May 3, 2026 06:03
@vincentkoc
vincentkoc marked this pull request as ready for review May 3, 2026 06:03
@vincentkoc
vincentkoc merged commit b0a6543 into main May 3, 2026
132 of 146 checks passed
@vincentkoc
vincentkoc deleted the fix/sessions-send-a2a-timeout-76443 branch May 3, 2026 06:08
@clawsweeper clawsweeper Bot mentioned this pull request May 5, 2026
9 of 25 tasks
lxe pushed a commit to lxe/openclaw that referenced this pull request May 6, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 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 maintainer Maintainer-authored PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] agents reply to their own session instead of the sender session (cross-agent comm)

1 participant