Skip to content

fix(discord): let active turns receive steering - #122452

Merged
obviyus merged 2 commits into
mainfrom
t3code/fix-discord-steer-injection
Aug 12, 2026
Merged

obviyus merged 2 commits into
mainfrom
t3code/fix-discord-steer-injection

Conversation

@obviyus

@obviyus obviyus commented Aug 12, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #48003

What Problem This Solves

Fixes an issue where Discord users sending a correction during an active turn would have that message held until the original turn finished, so default steer mode could not affect the running model.

Why This Change Was Made

Discord no longer serializes complete model turns by session at the transport layer. Each Discord event can reach the shared reply admission path, which already owns session ordering and chooses active-run steering or a queued follow-up.

User Impact

Normal Discord messages sent during an active turn can steer that turn at the next model boundary. Discord busy-state tracking, durable ingress, shutdown cleanup, and transport ordering remain intact.

Evidence

  • Before fix: focused regression failed because the second same-session message completed preflight but never reached message processing while the first run was active.
  • After fix: the same regression passes and records two active Discord events before the first settles. Shared admission then accepts the Discord correction as steer, injects it once, starts no second agent run, and retains the original run owner.
  • Redacted Discord E2E: the first request was held active at the provider for 3 seconds; a second same-session correction arrived 1 second later. The recorder observed one final OPENCLAW_E2E_STEERED_OK and no original-turn completion marker. Message IDs, account IDs, channel IDs, and usernames are omitted.
  • pnpm test -- 'extensions/discord/src/monitor/**/*.test.ts': 89 files, 1,048 tests passed.
  • pnpm vitest run src/auto-reply/reply/agent-runner.runreplyagent.e2e.test.ts: 15 shared-admission tests passed.
  • pnpm test -- extensions/discord/src/monitor/message-handler.queue.test.ts: 15 Discord queue tests passed.
  • pnpm tsgo:prod
  • pnpm check:test-types
  • Targeted Oxlint and Oxfmt on all touched files.
  • Telegram final-head sibling-channel non-regression: a real-user DM produced two typing events and one OPENCLAW_E2E_BASIC reply after one provider request; the isolated gateway scratch state was removed after exit. Account, bot, chat, and message identifiers are omitted.

Production delta: +3/-17 lines. Test delta: +63/-151 lines.

@clawsweeper

clawsweeper Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord size: S maintainer Maintainer-authored PR labels Aug 12, 2026
@obviyus

obviyus commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator Author

Maintainer decision: approved. Shared reply admission is the sole same-session ordering owner for Discord inbound messages. User-facing steer, followup, collect, and interrupt behavior remains owned by shared core; this PR removes only the redundant Discord transport serialization gate.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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. labels Aug 12, 2026
@clawsweeper

clawsweeper Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 12, 2026, 2:14 AM ET / 06:14 UTC.

ClawSweeper review

What this changes

The PR changes Discord inbound scheduling from per-session transport serialization to per-message scheduling so a later message can steer an active agent turn through shared reply admission.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this maintainer-owned repair open: current main serializes Discord jobs by session before shared admission, while the branch lets the correction reach the existing active-turn steering owner. No blocking patch defect was found; landing still needs merge-result review and exact-head required checks.

Priority: P1
Reviewed head: f597ba5ae82314d087a740655663eda27a673c0b

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, net-negative owner-boundary repair with direct source support and targeted regression coverage.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-owned PR is exempt from the external-contributor proof gate; its body nevertheless supplies a redacted after-fix Discord E2E account.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-owned PR is exempt from the external-contributor proof gate; its body nevertheless supplies a redacted after-fix Discord E2E account.
Evidence reviewed 7 items Current transport gate: Current main derives the Discord queue key from route session, base session, or channel, so same-session events share one transport queue before processing.
Queue behavior: The Discord queue enqueues each job under that queue key; the shared queue contract serializes work only when keys match.
Shared owner boundary: Once Discord processing reaches shared reply execution, an active steer path calls the centralized steer adoption logic, which injects through the embedded-agent queue and preserves follow-up fallback handling.
Findings None None.
Security None None.

How this fits together

Discord preflights inbound messages and schedules them before handing them to shared reply admission. Shared admission owns active-turn steering, follow-up queuing, transcript handling, and agent-run ownership.

flowchart LR
  A[Discord inbound message] --> B[Preflight and debounce]
  B --> C[Discord transport scheduler]
  C --> D[Shared reply admission]
  D --> E{Active turn exists}
  E -->|Yes| F[Inject steering message]
  E -->|No| G[Start or queue reply]
  F --> H[Discord response]
  G --> H
Loading

Before merge

  • Resolve merge risk (P1) - The branch is cleanly mergeable but behind main; required checks and merge-result review must cover the exact landing head before merge.
  • Complete next step (P2) - No mechanical repair remains; wait for the exact landing-head checks and merge-result validation.
Agent review details

Security

None.

PR surface

Source -14, Tests -88. Total -102 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 3 17 -14
Tests 3 63 151 -88
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 66 168 -102

Review metrics

Metric Value Why it matters
Production versus test delta production +3/-17 (net -14); tests +63/-151 (net -88) The patch removes the redundant production session gate and replaces its obsolete tests with active-turn behavior coverage.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #48003
Summary: This PR is the candidate repair for the open Discord active-turn steering report.

Members:

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

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the net-negative removal of Discord’s duplicate session serialization after rebasing or otherwise validating the merge result on an exact green head, leaving shared reply admission as the sole session-ordering owner.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the net-negative removal of Discord’s duplicate session serialization after rebasing or otherwise validating the merge result on an exact green head, leaving shared reply admission as the sole session-ordering owner.

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

Yes—source establishes a concrete current-main path: send a second same-session Discord message while the first holds the session, and the transport queue prevents that event from reaching shared steering admission.

Is this the best way to solve the issue?

Yes—the branch removes the duplicate transport-layer session gate instead of reimplementing steering in Discord; shared admission already owns injection, fallback, and active-run state.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 77d89b2fa843.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P1: A correction during an active Discord turn currently misses the configured steering behavior and waits for completion.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🌊 off-meta tidepool and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-owned PR is exempt from the external-contributor proof gate; its body nevertheless supplies a redacted after-fix Discord E2E account.

Evidence

What I checked:

  • Current transport gate: Current main derives the Discord queue key from route session, base session, or channel, so same-session events share one transport queue before processing. (extensions/discord/src/monitor/inbound-job.ts:33, 77d89b2fa843)
  • Queue behavior: The Discord queue enqueues each job under that queue key; the shared queue contract serializes work only when keys match. (extensions/discord/src/monitor/message-run-queue.ts:132, 77d89b2fa843)
  • Shared owner boundary: Once Discord processing reaches shared reply execution, an active steer path calls the centralized steer adoption logic, which injects through the embedded-agent queue and preserves follow-up fallback handling. (src/auto-reply/reply/agent-runner-run.ts:226, 77d89b2fa843)
  • Queue contract: The SDK queue stores a tail per key and explicitly permits unrelated keys to proceed independently, which makes the branch's per-message key change sufficient to remove the duplicate session gate. (src/plugin-sdk/keyed-async-queue.ts:16, 77d89b2fa843)
  • Branch scope and regression coverage: The supplied head diff removes the session-key resolver, uses the Discord message id for transport scheduling, and replaces obsolete queue-key assertions with same-session active-turn coverage plus shared-admission coverage. (extensions/discord/src/monitor/message-run-queue.ts:132, f597ba5ae823)
  • Regression history: Commit 9889c6d records the backpressure/runtime-transition work cited by the linked report; shallow history and unavailable network prevented an exact old-tree line comparison, so provenance is kept non-attributed. (9889c6da537c)

Likely related people:

  • obviyus: The PR discussion records their explicit design decision that shared reply admission owns same-session ordering; repository history also shows prior auto-reply/channel lifecycle work. (role: recent reply-admission contributor and current design commentator; confidence: high; commits: f597ba5ae823, ec4ae78b752e; files: extensions/discord/src/monitor/message-run-queue.ts, src/auto-reply/reply/agent-runner-steer-adoption.ts)
  • Tak Hoffman: Commit 9889c6d is the historical runtime/backpressure change named by the linked steering report; exact line attribution was unavailable in the shallow checkout. (role: historical backpressure contributor; confidence: medium; commits: 9889c6da537c; files: extensions/discord/src/monitor/inbound-job.ts, extensions/discord/src/monitor/message-run-queue.ts)

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 (1 earlier review cycle)
  • reviewed 2026-08-12T06:09:22.286Z sha f597ba5 :: needs maintainer review before merge. :: none

@obviyus obviyus closed this Aug 12, 2026
@obviyus obviyus reopened this Aug 12, 2026
@obviyus
obviyus enabled auto-merge (squash) August 12, 2026 06:10
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 12, 2026
@obviyus
obviyus merged commit dbb9665 into main Aug 12, 2026
152 checks passed
@obviyus
obviyus deleted the t3code/fix-discord-steer-injection branch August 12, 2026 06:18
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 13, 2026
Remove Discord's duplicate whole-turn session serialization so corrections reach shared reply admission and steer the active run. Preserve shared steer, followup, collect, and interrupt behavior.

Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: discord Channel integration: discord maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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.

1 participant