Skip to content

fix(slack): visible spawn completion opens a thread under a top-level request - #187965

Merged
obviyus merged 3 commits into
openclaw:mainfrom
masatohoshino:fix/slack-visible-spawn-top-level
Oct 30, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
masatohoshino:fix/slack-visible-spawn-top-level

Conversation

@masatohoshino

@masatohoshino masatohoshino commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Closes #187964

What Problem This Solves

A visible sessions_spawn started from a top-level Slack request captures that message's reply anchor as a thread root. With default replyToMode: "off", its delayed completion then appears in a new thread instead of next to the acknowledgement in the conversation timeline.

User Impact

Top-level requests keep their visible work-session completions top-level. Requests inside genuine Slack threads keep those threads. No configuration change is needed.

Fix

Share the existing #187065 sessions_send requester-delivery rule at the requester-origin owner and apply it when visible spawn captures its completion origin. Only an off-mode Slack synthetic anchor equal to the current message ID is discarded; current-destination precedence and genuine threads are retained. The added replyToMode member is an internal host construction option, not a model-facing or public configuration field.

The existing delayed-send behavior is preserved. cron, ask_user and session_status delivery context is outside this change. The Slack threads documentation names both affected completion paths.

Evidence

Built Gateway, real Slack SDKs and actual delayed completion POSTs:

  • Main aacb5e162cf1d5414c5a716bfefc2502ed75ce56, twice: a top-level visible spawn's final chat.postMessage carries the request's own ts as thread_ts.
  • Candidate, twice: the final POST omits thread_ts and retains the original channel.
  • Genuine-thread control retains its real root on both refs.
  • fix(agents): keep top-level Slack requests' sessions_send completions top-level #187065 delayed sessions_send control stays top-level and retains the original recipient after a later inbound DM on both refs.
  • Actual HMAC-signed Slack HTTP ingress, normal bundled plugin, real Bolt5.1.0/Web API8.2.0 clients, real tool discovery/dispatch, visible child creation, registry, runtime completion event and delivery. Local Slack-compatible API and deterministic provider; no private route/registry callbacks mocked or seeded.
  • The actual child task response is held until after the parent acknowledgement and another conversation's acknowledgement, then released. Eight fresh-profile Gateways all gracefully exited0. Config/state/SQLite paths were printed from each exact CLI first. Secretless Node24.22.1 Docker; no real Slack workspace/UI or real model claim.
  • Focused tests: 106 passed across spawn, visible-spawn and sessions-send admission. The retained consolidated origin regression fails on main with the leaked synthetic thread; sender restriction still passes.

Final head e6fbbf95f0661f126fa8d792e78397c7c4a5603d is test-only after the proven contributor build, with identical production. Contributor commits retained. Production +26/-9, tests +17/-22 (net−5), docs +1/-1. The regression is folded into existing policy/receipt coverage while preserving admitted requester, sender and completion-owner policy assertions; redundant exact default creation fields are covered by the broader spawn tests.

Merge Danger

Two-way door: no schema or configuration migration. Reverting restores old route capture for new visible spawns; admitted origins remain ordinary existing metadata. Blast radius is Slack visible-spawn completion placement and the shared requester-thread rule; genuine-thread and delayed-send controls cover the adjacent paths.

@clawsweeper

clawsweeper Bot commented Oct 30, 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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: slack Channel integration: slack agents Agent runtime and tooling size: S labels Oct 30, 2026
@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. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 30, 2026
@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR keeps visible-spawn completions top-level for top-level Slack requests while preserving genuine threads.

Example: A top-level Slack request starts a visible session with replyToMode set to off.

  • Before: The completion POST includes thread_ts=1793320794.000100 and opens a thread under the request.
  • After: The completion POST omits thread_ts and retains channel C0111111111.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, correct repair with shipped-Gateway transport traces and a reported base-failing regression; external Slack and provider services are local fixtures.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (logs): Supplied logs exercise signed HTTP ingress through built Gateways, the bundled Slack plugin, real Slack SDK clients, visible child creation, completion events, and final POSTs against local Slack-compatible and provider services; top-level completions omit thread_ts, genuine threads retain their roots, and delayed-send controls retain their recipient. Final-head production is identical to the proven candidate.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A visible work session’s result appears in a Slack thread the user never opened and can be missed.
Reason: This restores the documented off-mode placement contract without adding configuration, public API, or another routing owner.

Merge readiness

✅ Ready for maintainer review

Keep this PR: current main still captures Slack’s synthetic reply anchor as a visible-spawn completion thread, and this focused repair has no actionable findings.

Priority: P2
Reviewed head: e6fbbf95f0661f126fa8d792e78397c7c4a5603d

Before merge

None.

Findings

None.

Agent review details

How this fits together

Slack supplies conversation facts to agent tools; visible spawn records the requester origin, and the completion pipeline uses it to deliver the child’s result.

flowchart LR
  A[Slack request] --> B[Threading tool context]
  B --> C[Visible session spawn]
  C --> D[Requester origin]
  D --> E[Child completion]
  E --> F[Slack message delivery]
Loading

Technical review

Best possible solution:

Use the shared requester-origin rule to discard synthetic off-mode Slack anchors while preserving the admitted destination and genuine thread.

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

Current-main source establishes the synthetic-anchor capture path, and the supplied Gateway wire traces demonstrate matching before/after behavior; this read-only review ran no reproduction.

Is this the best way to solve the issue?

The patch fixes the incorrect completion-origin producer, shares the established delayed-send rule, and preserves the separate binding selector’s intentional routing contract.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Delayed-send requester routing keeps the original intent (cb5a438: Exclude synthetic Slack anchors while preserving admitted-current destination and thread precedence.)
  • Visible-spawn completion-origin capture changes intended behavior with a stated reason (ed81a70: Preserve requester and target facts across asynchronous preparation; this PR explains why a synthetic reply anchor must be excluded from the captured thread.)
  • Consolidated policy regression keeps the original intent (9698a5b: Sender-restricted turns cannot create visible sessions; the consolidated test retains that rejection and requester-policy assertions while adding completion-origin coverage.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +17, Tests -5, Docs 0. Total +12 across 6 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 4 26 9 +17
Tests 1 17 22 -5
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 44 32 +12

Review metrics

Metric Value Why it matters
Production versus test LOC Production +26/-9; tests +17/-22. Production growth shares an existing routing rule between two consumers; the regression reuses existing policy coverage without adding test scaffolding.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #187964
Summary: This PR repairs the linked visible-spawn capture defect; the merged delayed-send fix covers a sibling path.

Members:

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Visible work results can be missed in unexpected Slack threads, but the result is delivered and no outage is demonstrated.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-30T00:24:04.926Z sha d3ec2ef :: needs maintainer review before merge. :: none

Reviewed October 29, 2026, 8:50 PM ET / October 30, 2026, 00:50 UTC (Revision 2).

@obviyus

obviyus commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Built Gateway / real Slack SDK differential

Frozen main: aacb5e162cf1d5414c5a716bfefc2502ed75ce56.
Built contributor candidate: d3ec2ef508671acabdc1d99af0c05537ee62fea1.
Final head: e6fbbf95f0661f126fa8d792e78397c7c4a5603d (test-only consolidation after the build; production unchanged).

The defect direction is: a top-level request's visible-spawn completion is incorrectly threaded on main; the candidate keeps it top-level. A request inside a genuine thread must remain threaded.

Both refs were installed/built in secretless Node24.22.1 Docker. The normal bundled Slack plugin received actual HMAC-signed HTTP message events and used real Bolt5.1.0/Web API8.2.0 clients against a local Slack-compatible HTTP service recording every request. A deterministic local provider drove the real agent runtime through advertised tool_search, tool_describe and dispatch_action calls:

{"id":"sessions_spawn","args":{"task":"WORK187965-TOP-1","visible":true,"context":"isolated","model":"fixture/worker"}}

Actual accepted receipt from the candidate:

{"status":"accepted","childSessionKey":"agent:main:dashboard:10631f49-3df6-40bb-b88a-4dd0a5638777","runId":"7a7975dd-eb7b-404f-b962-74dded04b7dd","mode":"run","expectsCompletionMessage":true}

No normalized tool context, requester origin, registry or delivery callback was mocked or seeded. The provider answers label utility requests normally and holds the actual child task response. After observing the parent's real Slack acknowledgement, the driver admits another message in a different conversation and waits for its acknowledgement, then releases the child result. The real completion event returns to the parent runtime, which emits the final reply. This ensures the measured delivery is the delayed completion, not the initial acknowledgement.

Actual chat.postMessage placement

All scenarios use channels.slack.replyToMode: "off". Each successful scenario recorded exactly one final completion POST.

Scenario Main Candidate
Top-level visible spawn, run1 thread_ts=1793320794.000100 (request's own ts) thread_ts omitted
Top-level visible spawn, run2 thread_ts=1793320813.000100 (request's own ts) thread_ts omitted
Genuine-thread visible spawn thread_ts=1793320825.000050 (real root) thread_ts=1793320879.000050 (real root)
#187065 delayed sessions_send control thread_ts omitted thread_ts omitted

Representative actual wire params:

main:      {"channel":"C0111111111","text":"FINAL187965-TOP-1","thread_ts":"1793320794.000100","unfurl_links":"false"}
candidate: {"channel":"C0111111111","text":"FINAL187965-TOP-1","unfurl_links":"false"}

The two top-level candidate requests had source timestamps 1793320853.000100 and 1793320866.000100; neither was sent as a thread root. Both main and candidate acknowledgements for the representative top-level case were already top-level.

The genuine-thread control seeds a real root event first, then admits the request with a distinct message ts and explicit thread_ts; thread-history responses contain only that root/replies. Its completion stays on that real root on both refs.

For the #187065 control, sessions_send starts work in a real pre-created worker session with timeoutSeconds:0; another DM then changes the requester's latest inbound context before the worker finishes. Its completion remains top-level and retains the original recipient on both refs: the raw Slack POST targets U0111111111, with the local Slack-compatible API returning the original D0111111111 receipt, not the later conversation.

Lifecycle, limits and captures

Eight successful fresh-profile Gateway scenarios: main/candidate × (two top-level runs, one genuine-thread control, one delayed-send control). Every Gateway received SIGTERM, was awaited to actual exit, and exited code:0, signal:null; no product process was force-killed. Exact CLI config/state/agent SQLite paths were printed first, all task-owned. No personal Slack account, real Slack UI or real model claim.

Valid capture directories under proofs/187965/:

main-top-1-1793320794960        candidate-top-1-1793320853104
main-top-2-1793320813143        candidate-top-2-1793320866828
main-thread-1-1793320825841     candidate-thread-1-1793320879244
main-send-1-1793320839041       candidate-send-1-1793320892858

Each holds actual SDK/ingress/causal-order wire captures, full provider requests, Gateway logs, resolved paths, result and exit receipts. prove.mjs/run-proof.sh are the harness. Two excluded preparation attempts are documented in invalid-attempts.txt: a missing driver timer import, then a provider fixture that ignored the current runtime completion-event envelope. Neither is counted as a product verdict.

Focused regressions and simplification

106 tests passed across the visible-spawn, spawn-tool and sessions-send admission files. The retained consolidated Slack origin assertion fails on main because the registered requester origin leaks the synthetic threadId; the sender-restricted policy control still passes.

Folded the standalone new regression into existing policy/receipt coverage, retaining current-target precedence, stale-thread exclusion, requester ownership and inherited allow/deny assertions. Removed redundant exact creation/default-field assertions already covered by the broader spawn tests. Tests +17/-22 (net−5); production +26/-9, docs +1/-1. Contributor commits retained. The existing sessions_send rule now has one shared requester-origin owner; no new public option, schema, stored format or SDK contract.

@obviyus

obviyus commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
@obviyus
obviyus merged commit d2d663a into openclaw:main Oct 30, 2026
129 checks passed
@obviyus

obviyus commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Landed in d2d663a. Thanks @masatohoshino. Slack visible spawn completions now post where the request was made.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 30, 2026
… request (openclaw#187965)

fix(slack): post visible spawn completions at the top level for top-level requests

A visible spawn started from a top-level Slack message posted its completion as a thread reply under that message, instead of at the top level where the request was. The completion now uses the same rule delayed sessions_send completions use since openclaw#187065 (moved into a shared helper): a top-level request's completion is posted at the top level, and requests made inside a thread keep their thread.

Evidence: built Gateway with the bundled Slack plugin against a signed HTTP fixture. On main the top-level visible-spawn completion was threaded (twice); with this change it was posted at the top level (twice). Genuine-thread requests stay threaded, and delayed sessions_send completions stay top level with the original recipient after later inbound activity. Details: openclaw#187965 (comment).

Thanks @masatohoshino.

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

fix(slack): post visible spawn completions at the top level for top-level requests

A visible spawn started from a top-level Slack message posted its completion as a thread reply under that message, instead of at the top level where the request was. The completion now uses the same rule delayed sessions_send completions use since openclaw#187065 (moved into a shared helper): a top-level request's completion is posted at the top level, and requests made inside a thread keep their thread.

Evidence: built Gateway with the bundled Slack plugin against a signed HTTP fixture. On main the top-level visible-spawn completion was threaded (twice); with this change it was posted at the top level (twice). Genuine-thread requests stay threaded, and delayed sessions_send completions stay top level with the original recipient after later inbound activity. Details: openclaw#187965 (comment).

Thanks @masatohoshino.

Co-authored-by: Ayaan Zaidi <[email protected]>
(cherry picked from commit d2d663a)
Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 5ab84cee9136fcfef263f30a2b9262ea35558a4a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: slack Channel integration: slack docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

Slack: visible sessions_spawn completion opens a thread under a top-level request when replyToMode is off

2 participants