Skip to content

fix(outbound): recognize current-source message-tool sends - #116560

Merged
fuller-stack-dev merged 4 commits into
openclaw:mainfrom
fuller-stack-dev:codex/fix-thread-message-tool-fallback
Jul 30, 2026
Merged

fuller-stack-dev merged 4 commits into
openclaw:mainfrom
fuller-stack-dev:codex/fix-thread-message-tool-fallback

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Jul 30, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes false no-visible-reply fallbacks after the message tool already delivered the response to the exact source conversation. The missing delivery classification affected shared automatic-mode sends, including reported Slack cases, as well as Discord threads created and adopted during the active turn.

Why This Change Was Made

The shared outbound runner now records successful, authorized sends to the exact current source in every reply mode. This is channel-agnostic: core and plugin-backed message.send transports use the same route and receipt classifier, while unrelated channels, accounts, and threads remain unrelated.

Discord keeps a narrow adapter for its unique mid-turn adopted-thread transition because that newly created route does not exist in the original turn context. Generic Discord send, upload, and thread-reply actions reuse that active route only after a positive runtime delivery receipt.

This is intentionally delivery-based rather than relying on a final NO_REPLY token. A failed or unrelated send must leave the source fallback eligible.

User Impact

Slack and other channels no longer append a misleading no-reply failure after a successful message-tool response to the current conversation. Discord adopted-thread workflows receive the same behavior. Failed sends and sends elsewhere still retain the fallback.

A confirmed automatic-mode current-source send is intentionally mirrored into Control UI chat history. The structured route receipt is authoritative for current runtimes; the target/text/media matcher remains only as a legacy-evidence fallback.

Evidence

  • Exact reviewed head: 5fa72a7ef2cdfb8801b5f075cc501fae8096a85b.
  • Shared Slack reproduction: automatic-mode message.send to the trusted current conversation was red before the shared change (1 failed, 26 passed) and green after it (27/27).
  • Projection-level regression proves a successful automatic-mode Slack current-source receipt is visible in Control UI history.
  • Shared downstream source-reply classifier: 25/25 passed.
  • Discord adopted-thread and action suites: 36/36 passed.
  • Negative controls cover another account, another thread, a newly entered thread, an unrelated target, a matching adopted-thread result with ok: false, and suppressed/unconfirmed projection routes.
  • Latest focused Blacksmith Testbox proof: 54/54 passed; tbx_01kytghtyt26tyxn08y3g8yq01; https://github.com/openclaw/openclaw/actions/runs/30585410621.
  • Targeted formatting and git diff --check passed.
  • Fresh structured Codex autoreview reported no actionable findings (correctness 0.93).

Related PR Comparison

#116548 addresses the separate semantic question of preserving explicit NO_REPLY silence. It is not a substitute for this delivery-accounting repair: delivery evidence is required so failed or unrelated sends cannot suppress the fallback.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord size: S maintainer Maintainer-authored PR labels Jul 30, 2026
@fuller-stack-dev
fuller-stack-dev marked this pull request as ready for review July 30, 2026 21:05
@fuller-stack-dev fuller-stack-dev self-assigned this Jul 30, 2026
@clawsweeper

clawsweeper Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 30, 2026, 6:07 PM ET / 22:07 UTC.

ClawSweeper review

What this changes

This PR records confirmed message-tool delivery to the active source conversation in automatic reply mode, including Discord adopted threads, so OpenClaw does not append a false no-visible-reply fallback.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep this PR open for explicit maintainer review. It is authored by a repository member and carries the protected maintainer label; the supplied review discussion resolves the two identified design questions, but the branch is behind current main and changes the boundary that suppresses a user-visible fallback message.

Priority: P1
Reviewed head: 5fa72a7ef2cdfb8801b5f075cc501fae8096a85b
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has focused positive and negative coverage and addresses the reviewer’s cross-consumer questions; a refreshed merge result is the remaining merge-relevant check.
Proof confidence 🌊 off-meta tidepool Not applicable: The PR author is a repository member, so the external-contributor real-behavior-proof gate does not apply; the PR nevertheless provides focused Testbox evidence and a red-to-green Slack scenario.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The PR author is a repository member, so the external-contributor real-behavior-proof gate does not apply; the PR nevertheless provides focused Testbox evidence and a red-to-green Slack scenario.
Evidence reviewed 5 items Reviewed design follow-up: The review comment identified the Control UI projection consumer and the legacy matcher; the author responded that automatic current-source receipts should mirror into Control UI and that the structured receipt is canonical while the matcher remains legacy compatibility evidence.
Shared receipt classification: The branch removes the reply-mode restriction from current-source delivery marking, so a successful authorized send can record current-source in automatic mode as well as message-tool-only mode.
Projection regression coverage: The added projection case asserts that an automatic-mode successful message-tool result carrying sourceReplyRoute: current-source is mirrored into Control UI chat history.
Findings None None.
Security None None.

How this fits together

Outbound message actions return delivery receipts after a channel transport accepts a send. Auto-reply finalization and Control UI projection consume those receipts to decide whether a source conversation already received a visible response or still needs fallback handling.

flowchart LR
  A[Inbound source conversation] --> B[Agent message tool]
  B --> C[Outbound channel send]
  C --> D[Authorized delivery receipt]
  D --> E[Source-reply classification]
  E --> F[Fallback decision]
  E --> G[Control UI transcript]
  F --> H[Visible channel outcome]
Loading

Decision needed

Question Recommendation
After the branch is refreshed against current main, should OpenClaw adopt structured current-source delivery receipts as the automatic-mode authority for both fallback suppression and Control UI mirroring? Approve receipt-first delivery accounting: Rebase and land the branch once the exact merge result and required checks preserve the focused successful and negative route cases.

Why: This is a deliberate cross-channel delivery semantic change with a protected maintainer label; source tests support the implementation, but final acceptance determines the durable delivery and projection contract.

Before merge

  • Resolve merge risk (P2) - A mistaken current-source classification suppresses the visible fallback, so the exact merge result must retain the successful-send, failed-send, unrelated-route, and adopted-thread negative boundaries before landing.
  • Resolve merge risk (P1) - The PR is behind current main; its merge result and remaining required checks need refresh before a maintainer lands this delivery-path change.
  • Complete next step (P2) - The only remaining action is protected-label maintainer acceptance of the receipt-first delivery and projection contract after the branch is refreshed; there is no discrete mechanical defect for an automated repair lane.
Agent review details

Security

None.

PR surface

Source +28, Tests +246. Total +274 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 45 17 +28
Tests 3 246 0 +246
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 291 17 +274

Review metrics

Metric Value Why it matters
Reply-mode coverage 1 additional mode classified The current-source receipt now applies to automatic mode, changing when an already delivered response suppresses fallback and appears in Control UI history.

Merge-risk options

Maintainer options:

  1. Refresh and verify the merged delivery path (recommended)
    Rebase onto current main and confirm the merge result retains the positive current-source receipt cases plus failed, unrelated, and new-thread negative controls.
  2. Accept the expanded receipt contract
    A maintainer may intentionally accept automatic-mode Control UI mirroring as part of the current-source delivery receipt contract after reviewing the refreshed result.
  3. Pause the broadened behavior
    Pause this PR if maintainers want fallback suppression repaired without making automatic-mode receipts visible to Control UI.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Rebase onto current main, rerun the focused outbound, projection, and Discord adopted-thread tests, and confirm the merge result preserves failed/unrelated-route fallback eligibility.

Technical review

Best possible solution:

Rebase onto current main, preserve receipt-first current-source classification with the legacy aggregate matcher only as a compatibility fallback, and land after the refreshed merge result confirms the documented negative delivery cases.

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

Yes, source-reproducible: an automatic-mode message-tool send with a successful authorized current-source receipt reaches the changed classifier, while failed, unrelated, and newly entered-thread receipts must remain ineligible. The PR also supplies focused red-to-green Testbox evidence, though this review did not independently execute it.

Is this the best way to solve the issue?

Yes, conditionally: recording the fact at the outbound delivery boundary is safer than inferring it later from model output or target/text aggregates. The retained matcher should remain explicitly limited to legacy results, as the updated call-site comment states.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 4c331166c40c.

Labels

Label justifications:

  • P1: The PR repairs false fallback messages in active channel conversations, where users can otherwise receive a misleading second response after successful delivery.
  • merge-risk: 🚨 message-delivery: The change decides whether a source conversation received a response and therefore whether fallback delivery is suppressed or projected as visible history.
  • 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 PR author is a repository member, so the external-contributor real-behavior-proof gate does not apply; the PR nevertheless provides focused Testbox evidence and a red-to-green Slack scenario.

Evidence

What I checked:

  • Reviewed design follow-up: The review comment identified the Control UI projection consumer and the legacy matcher; the author responded that automatic current-source receipts should mirror into Control UI and that the structured receipt is canonical while the matcher remains legacy compatibility evidence. (src/auto-reply/reply/agent-runner-result-payloads.ts:182, 5fa72a7ef2cd)
  • Shared receipt classification: The branch removes the reply-mode restriction from current-source delivery marking, so a successful authorized send can record current-source in automatic mode as well as message-tool-only mode. (src/infra/outbound/message-action-runner.ts:291, 5fa72a7ef2cd)
  • Projection regression coverage: The added projection case asserts that an automatic-mode successful message-tool result carrying sourceReplyRoute: current-source is mirrored into Control UI chat history. (src/gateway/chat-display-projection.test.ts:4, 5fa72a7ef2cd)
  • Discord negative boundary: The Discord adapter only upgrades a result after a positive details.ok receipt and only when the parsed channel target matches the active adopted-thread route, preserving fallback eligibility for failed or unrelated sends. (extensions/discord/src/actions/handle-action.ts:111, 5fa72a7ef2cd)
  • Focused behavior proof supplied: The PR body reports a red-to-green shared Slack reproduction, projection regression coverage, adopted-thread negative controls, and a 54/54 focused Testbox run for the reviewed head. (5fa72a7ef2cd)

Likely related people:

  • fuller-stack-dev: Authored the four commits that expanded current-source delivery classification, added the Discord adopted-thread boundary, and answered the follow-up design questions. (role: current change owner; confidence: high; commits: 7f3139bcb2cb, 3ff66e2eeb00, 0b822530d2ab; files: src/infra/outbound/message-action-runner.ts, extensions/discord/src/actions/handle-action.ts, src/gateway/chat-display-projection.test.ts)
  • obviyus: Raised the two concrete cross-consumer questions about Control UI projection and canonical receipt ownership that the latest commit and response address. (role: reviewer of delivery and projection boundaries; confidence: high; files: src/gateway/chat-display-projection.message-tool.ts, src/auto-reply/reply/agent-runner-result-payloads.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rebase onto current main and rerun the focused receipt, projection, and adopted-thread tests against the exact merge result.

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 (4 earlier review cycles)
  • reviewed 2026-07-30T21:10:27.642Z sha 7f3139b :: found issues before merge. :: [P1] Do not mark failed sends as delivered
  • reviewed 2026-07-30T21:25:18.446Z sha 3ff66e2 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-30T21:32:51.286Z sha 0b82253 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-30T21:37:16.989Z sha 0b82253 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added the rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. label Jul 30, 2026
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Jul 30, 2026
@fuller-stack-dev fuller-stack-dev changed the title fix(discord): avoid no-reply fallback after thread response fix(outbound): recognize current-source message-tool sends Jul 30, 2026
@obviyus

obviyus commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Thanks for this — the shape looks right: the outbound runner is where the delivery receipt exists, so classifying the route there beats inferring it downstream.

Two things I would like resolved before merge, both about the widened marker rather than the Discord adapter:

1. Second consumer of sourceReplyRoute. src/gateway/chat-display-projection.message-tool.ts:323-333 gates on this marker whenever a send carries an explicit route (requiresSourceRouteConfirmation, line 171). In automatic mode those sends never confirmed before, so the Control UI projection took its other branch; after this change they confirm. That may well be the outcome we want, but it is a user-visible projection change the current evidence does not cover. Could you confirm the intended Control UI behavior, ideally with a projection-level case?

The other consumer looks unaffected, for what it is worth: isDeliveredMessageToolOnlySourceReplyResult (src/agents/embedded-agent-message-tool-source-reply.ts:563) returns early unless the mode is message_tool_only, so automatic runs never reach it.

2. Two answers to one question. src/auto-reply/reply/agent-runner-result-payloads.ts:182-197 still derives the same fact by matching sent targets/texts/media (hasSourceRoutedMessagingToolDelivery). Is the receipt meant to supersede that matcher, or do both stay? If both stay, the older inference is free to drift from the recorded route as channels change — a short comment naming which one owns the decision would help future readers.

Nothing else blocking from me. The negative controls you added (failed send, other account, other thread, unrelated target) are the right ones to have.

@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Jul 30, 2026
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Addressed in 5fa72a7ef2c.

  1. Confirmed: a successful automatic-mode send with a structured current-source receipt should be mirrored into Control UI history. That keeps the UI transcript aligned with the response already delivered to the source channel. I added a projection-level Slack case in src/gateway/chat-display-projection.test.ts; the existing unconfirmed explicit-route and suppressed-send cases remain negative controls.

  2. The structured source-reply delivery evidence is canonical for current runtimes. hasSourceRoutedMessagingToolDelivery remains only as compatibility evidence for legacy results that recorded successful target/text/media aggregates before structured receipts. The owner/fallback boundary is now documented at the call site in src/auto-reply/reply/agent-runner-result-payloads.ts.

Focused Testbox proof is 54/54 green across the projection, shared outbound runner, and source-reply classifier: https://github.com/openclaw/openclaw/actions/runs/30585410621. Fresh autoreview is clean.

@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Pre-land note on the latest ClawSweeper rank-up move: I am not rewriting the shared contributor branch solely because main advanced. Repository-native prepare-run refreshed current main, confirmed the PR remains cleanly mergeable, validated the exact reviewed head, and accepted fully successful hosted CI for 5fa72a7ef2c (run 30585684794). The intervening main movement did not touch the outbound runner, projection, auto-reply, or Discord paths in this repair. The focused receipt/projection/adopted-thread proof also remains green. Proceeding with the repo-native merge path.

@fuller-stack-dev
fuller-stack-dev merged commit dc34274 into openclaw:main Jul 30, 2026
131 of 135 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

@fuller-stack-dev
fuller-stack-dev deleted the codex/fix-thread-message-tool-fallback branch July 30, 2026 22:30
vincentkoc added a commit that referenced this pull request Jul 31, 2026
…-supported-paths

* origin/main: (168 commits)
  fix(plugins): keep registry sqlite root consistent (#116427)
  fix(cli): keep Gateway auth failures parseable in JSON (#116597)
  fix(trajectory): preserve prompts in oversized events (#116220)
  test(buzz): add live QA Lab channel lane (#116298)
  chore(i18n): refresh native locales (#116567)
  feat: add OpenClaw TUI prototype skill (#116583)
  fix(update): accept concrete versions selected by ranges (#116585)
  fix(agents): preserve locked session model routes
  test(qa-lab): preserve Matrix fault proxy identity
  fix(ci): extend OpenAI live profile setup budget (#116580)
  fix: prevent configured models from stalling startup (#116553)
  fix(cli): close MCP listener after one-shot commands
  fix(auto-reply): keep explicit NO_REPLY silent (#116548)
  test(discord): cover deferred backpressure terminals
  fix(discord): cancel backpressured realtime playback
  test(discord): cover realtime output backpressure
  fix(codex): add remote WebSocket heartbeat and reconnect (#116135)
  fix(macos): wait for the current reconnect snapshot (#116550)
  fix(outbound): recognize current-source message-tool sends (#116560)
  fix(voice-call): type cancelled consult outcomes
  ...

# Conflicts:
#	extensions/google/setup-api.test.ts
#	ui/src/e2e/model-setup.e2e.test.ts
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 31, 2026
…116560)

* fix(discord): recognize adopted thread sends

* fix(discord): require successful adopted thread delivery

* fix(outbound): mark automatic current-source sends

* test(gateway): cover automatic source projection
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 1, 2026
…-supported-paths

* origin/main: (168 commits)
  fix(plugins): keep registry sqlite root consistent (openclaw#116427)
  fix(cli): keep Gateway auth failures parseable in JSON (openclaw#116597)
  fix(trajectory): preserve prompts in oversized events (openclaw#116220)
  test(buzz): add live QA Lab channel lane (openclaw#116298)
  chore(i18n): refresh native locales (openclaw#116567)
  feat: add OpenClaw TUI prototype skill (openclaw#116583)
  fix(update): accept concrete versions selected by ranges (openclaw#116585)
  fix(agents): preserve locked session model routes
  test(qa-lab): preserve Matrix fault proxy identity
  fix(ci): extend OpenAI live profile setup budget (openclaw#116580)
  fix: prevent configured models from stalling startup (openclaw#116553)
  fix(cli): close MCP listener after one-shot commands
  fix(auto-reply): keep explicit NO_REPLY silent (openclaw#116548)
  test(discord): cover deferred backpressure terminals
  fix(discord): cancel backpressured realtime playback
  test(discord): cover realtime output backpressure
  fix(codex): add remote WebSocket heartbeat and reconnect (openclaw#116135)
  fix(macos): wait for the current reconnect snapshot (openclaw#116550)
  fix(outbound): recognize current-source message-tool sends (openclaw#116560)
  fix(voice-call): type cancelled consult outcomes
  ...

# Conflicts:
#	extensions/google/setup-api.test.ts
#	ui/src/e2e/model-setup.e2e.test.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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