Skip to content

[Bug]: Delivery retry loop corrupts active sessions (R-004) — retry selector bypasses delivery.mode=none #91420

Closed

Description

@CarotaWealth

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

Version: OpenClaw 2026.6.1 (2e08f0f)
OS: macOS

Bug: When a delivery fails, the gateway retry mechanism cycles through
active sessions as relay vehicles, bypassing delivery.mode=none. This
corrupts the sessions being used as relays, causing LLM schema errors
on next startup.

Pattern observed:

  • Agent sends message, believes it sent
  • Delivery retry fires on alternating channels (webchat → unknown)
  • Same payload delivered 3x in a row
  • Sessions used as relay vehicles become corrupted
  • Affected agents hit "LLM request failed: provider rejected the request
    schema or tool payload" on next turn

Workaround: Manual session clear via sessions.json + gateway restart.

Expected behavior: Retry logic should not use active persistent main
sessions as relay vehicles. delivery.mode=none should be respected at
the retry layer.

Steps to reproduce

  1. Run a multi-agent fleet with persistent main sessions on multiple agents (coordinator, vice-chair, cortex).
  2. Agent attempts to send a message via sessions_send tool.
  3. Delivery fails on primary channel.
  4. Gateway retry mechanism fires — cycles through active persistent main sessions as relay vehicles.
  5. Same payload delivered 3x on alternating channels (webchat → unknown).
  6. Affected relay sessions become corrupted.
  7. On next startup, corrupted agents hit "LLM request failed: provider rejected the request schema or tool payload."

Expected behavior

Retry logic should not use active persistent main sessions as relay vehicles. delivery.mode=none should be respected at the retry layer. Retries should fail gracefully without corrupting unrelated sessions.

Actual behavior

Gateway retry selector bypasses delivery.mode=none by cycling active sessions as relay vehicles. Results in session corruption, LLM schema errors on next startup, and repeated delivery of the same payload on alternate channels. Workaround: manual session clear via sessions.json + gateway restart.

OpenClaw version

2026.6.1 (2e08f0f)

Operating system

macOS 15.4

Install method

npm global

Model

anthropic/claude-opus-4-6 / anthropic/claude-sonnet-4-6

Provider / routing chain

openclaw -> anthropic

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

Affected: All persistent main sessions fleet-wide (16 agents).
Severity: Blocks workflow — corrupted sessions require manual
intervention to clear (sessions.json edit + gateway restart) before
affected agents can function.
Frequency: Intermittent — triggers when delivery fails on a session
that has active persistent main sessions running.
Consequence: Agent downtime, repeated duplicate message delivery
on alternate channels, manual recovery required each occurrence.
In a production multi-agent RIA compliance fleet, this causes
unplanned outages during business hours.

openclaw_june7_log.txt

Additional information

No response

Activity

  1. clawsweeper commented on Jun 8, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 8, 2026, 9:05 AM ET / 13:05 UTC.

    Summary
    Keep open: current main and the latest release still contain the sessions_send active-run fallback and A2A reply-back path implicated by the report, and the attached log shows repeated inter-session deliveries over webchat/unknown routes. The exact current-main failure was not live-reproduced, so this should be repaired with focused regression coverage rather than closed as fixed.

    Reproducibility: no. high-confidence live reproduction was established. The issue is source-reproducible from the attachment plus current code paths that reroute rejected active-run sends into fallback sessions and A2A delivery.

    Ways to help us reproduce this

    • Add a screenshot or short recording showing the behavior.
    • Add expected vs actual behavior.

    Next step
    A focused repair looks possible in the sessions_send active-run fallback/A2A path, but the worker must preserve documented reply-back behavior and stop if the fix requires changing product semantics beyond the unsafe fallback.

    Review details

    Best possible solution:

    Keep sessions_send delivery internal to the intended active/run-scoped target: if the active-run queue rejects a message_tool_only/no-deliver send, fail or surface a delivery error instead of falling back through a persistent main session, with regression coverage for duplicate delivery and transcript safety.

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

    No high-confidence live reproduction was established. The issue is source-reproducible from the attachment plus current code paths that reroute rejected active-run sends into fallback sessions and A2A delivery.

    Is this the best way to solve the issue?

    Yes, the narrowest maintainable direction is to remove or constrain the durable-session fallback on rejected active-run delivery, not to add a new config knob or disable all documented sessions_send reply-back behavior.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The attached log and source path make the report credible, but I did not live-reproduce the corruption path against current main.
    • Existing docs intentionally allow sessions_send reply-back loops and message-tool sends under delivery.mode none, so the repair should target unsafe durable-session fallback and duplicate delivery without removing documented A2A behavior by accident.

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

    Label changes

    Label changes:

    • add P1: The report describes a current shipped workflow that can duplicate inter-session messages, corrupt active session transcripts, and require manual recovery before agents can function.
    • add impact:message-loss: The observed behavior includes duplicated or misrouted delivery over alternate webchat/unknown paths.
    • add impact:session-state: The core complaint is corruption of persistent main session state leading to later provider schema/tool-payload failures.
    • add issue-rating: 🐚 platinum hermit: Current issue advisory state selects this label.
    • add clawsweeper:needs-live-repro: Current issue advisory state selects this label.

    Label justifications:

    • P1: The report describes a current shipped workflow that can duplicate inter-session messages, corrupt active session transcripts, and require manual recovery before agents can function.
    • impact:session-state: The core complaint is corruption of persistent main session state leading to later provider schema/tool-payload failures.
    • impact:message-loss: The observed behavior includes duplicated or misrouted delivery over alternate webchat/unknown paths.
    Evidence reviewed

    Acceptance criteria:

    • node scripts/run-vitest.mjs src/agents/openclaw-tools.sessions.test.ts
    • node scripts/run-vitest.mjs src/agents/tools/sessions-send-tool.a2a.test.ts
    • node scripts/run-vitest.mjs src/agents/tools/sessions-send-helpers.test.ts
    • git diff --check

    What I checked:

    • Attached log supports the reported delivery loop: The downloaded issue attachment includes June 7 entries where an agent reports a single sessions_send producing four deliveries over webchat and unknown paths, plus a restart workaround for the flooded session.
    • Current main can fall back from a run-scoped active session to its durable session key: startAgentRun resolves an active run, derives a fallback session key by stripping the :run suffix, and starts a new agent request on that fallback when queueing is rejected. (src/agents/tools/sessions-send-tool.ts:225, 2858c629bd0f)
    • Fire-and-forget sessions_send enables that fallback: timeoutSeconds=0 calls startAgentRun with allowActiveRunQueueFallback=true, and if the active queue was not used, starts the A2A flow against the fallback session key. (src/agents/tools/sessions-send-tool.ts:645, 2858c629bd0f)
    • A2A flow intentionally wakes requester/target sessions: runSessionsSendA2AFlow alternates agent steps between requester and target sessions and then runs an announce step on the target session, matching the kind of relay behavior reported. (src/agents/tools/sessions-send-tool.a2a.ts:145, 2858c629bd0f)
    • Current docs describe reply-back but not durable-session fallback on queue rejection: The session tool docs say sessions_send can run a reply-back loop up to session.agentToAgent.maxPingPongTurns, while cron docs say delivery.mode none disables only runner fallback delivery and does not remove agent-initiated message sends. Public docs: docs/concepts/session-tool.md. (docs/concepts/session-tool.md:108, 2858c629bd0f)
    • Latest release still contains the active-run fallback path: v2026.6.1 contains the same active-run queue fallback and A2A handoff behavior, so this is not already fixed in the shipped release or by current main. (src/agents/tools/sessions-send-tool.ts:220, 2e08f0f4221f)

    Likely related people:

    • Jason Yao: git blame attributes the current sessions_send tool, A2A flow, and agent-step implementation lines to d1cb6cd in this checkout. (role: introduced current implementation in available history; confidence: medium; commits: d1cb6cd0b58c; files: src/agents/tools/sessions-send-tool.ts, src/agents/tools/sessions-send-tool.a2a.ts, src/agents/tools/agent-step.ts)
    • Peter Steinberger: git log for sessions-send-tool.ts shows repeated session-tool refactors and fixes, including session tool context setup and inter-session provenance work. (role: recent area contributor; confidence: medium; commits: 85409e401b65, 42d6e35cb45f, 3dda75894b80; files: src/agents/tools/sessions-send-tool.ts, src/agents/tools/agent-step.ts)
    • Tak Hoffman: History shows a focused sessions_send fix for stale reply carryover, which is adjacent to the reported duplicate/corrupt reply behavior. (role: adjacent owner; confidence: medium; commits: 5b4669632a9d; files: src/agents/tools/sessions-send-tool.ts)
    • Josh Lehman: History shows a focused sessions_send announce-delivery routing fix, relevant to target/channel/thread delivery behavior. (role: adjacent owner; confidence: medium; commits: 8359e5f584d3; files: src/agents/tools/sessions-send-tool.a2a.ts)
    How this review workflow works
    • 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.
  2. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    on Jun 8, 2026
  3. added a commit that references this issue on Jun 13, 2026
    4c23d1d
  4. added a commit that references this issue on Jun 14, 2026
    87b7cbb
  5. added a commit that references this issue on Jun 17, 2026
    17bb391
  6. locked as resolved and limited conversation to collaborators on Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.bugSomething isn't workingclawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.regressionBehavior that previously worked and now fails

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions