Skip to content

fix(auto-reply): key command-turn reply operations to the source session - #104144

Merged
obviyus merged 1 commit into
mainfrom
fix/command-turn-source-admission
Jul 11, 2026
Merged

obviyus merged 1 commit into
mainfrom
fix/command-turn-source-admission

Conversation

@obviyus

@obviyus obviyus commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Native slash-command turns key their reply operation to the command-target session. When the target has an active run, admitReplyTurn treats the command turn as "visible" and dead-waits on replyRunRegistry.waitForIdle(target) (reply-turn-admission.ts:294) — /stop waits on the very run it is supposed to kill, /status waits on the run it should report on. Production incident on 2026-07-11 (Telegram group): a group member's /stop — channel-authorized via groupAllowFrom: ["*"] but declined by commands.ownerAllowFrom at the pre-admission fast-abort — wedged its slash session (queued_work_without_active_run), held the per-chat Telegram control lane guarded for 5 minutes, blocked the owner's own /stop behind it, and forced a watchdog ingress restart whose backlog drain collaterally aborted an unrelated codex harness startup. The run itself was never stopped. Fixes #104142.

Why This Change Was Made

The deadlock is latent since #85100 introduced target-aware operation keying, and was masked on Telegram because — until #103664 — any group inbound aborted the active run at the transport fence, so command turns never met a busy target. #103664 correctly removed that transport kill authority; core must now handle command turns while runs are active.

#85100's own contract says "abort ownership stays source-keyed" and "/stop does not self-abort its own command". This PR aligns the reply-operation key with that contract:

  • dispatch-from-config.ts: dispatchOperationSessionKey resolves source-first (ctx.SessionKey); the session-store entry used for operation identity follows the source when it diverges from the command target. initialSessionStoreEntry stays target-aware for command handlers (status/stop/model act on the target via CommandTargetSessionKey).
  • reply-turn-admission.ts: the control_abort turn kind had zero producers (designed seam, never wired) and is now removed.

Command turns admit instantly on their (idle-by-construction) source session; effects on the target keep flowing through the run registry / session store as before.

User Impact

  • /stop works during active runs for everyone the config authorizes, and unauthorized senders get an immediate "not authorized" reply instead of a silent 5-minute wedge.
  • /status (and other native commands) answer immediately mid-run instead of never.
  • A wedged command can no longer poison the per-chat Telegram control lane, so one sender's blocked command no longer disables /stop for the whole chat or triggers watchdog channel restarts.

Evidence

  • Regression tests (dispatch-from-config.acp-abort.test.ts): unauthorized native /stop and authorized /status against a session with an active run must settle in <200ms with the target run untouched; the Fix Discord session recovery abort ownership #85100 ownership test now asserts the source-keyed contract.
  • Testbox (Blacksmith): run-vitest on dispatch-from-config.acp-abort.test.ts, abort.test.ts, reply-turn-admission.test.ts — 83/83 passed; run-tsgo core + core-test lanes clean; oxlint clean on changed files.
  • Live-gateway E2E (mock Telegram Bot API + mock OpenAI provider, 40s streamed turn, command injected mid-turn), before → after on the incident recipes:
    • incident shape (groupAllowFrom: ["*"] + commands.ownerAllowFrom, non-owner /stop): silent wedge, run unaffected → fast reply, no wedge, run unaffected
    • authorized /status mid-run: no reply ever → immediate status reply, run survives
    • authorized /stop mid-run: abort ~1s (unchanged)

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Jul 11, 2026
@obviyus
obviyus merged commit fab6951 into main Jul 11, 2026
110 of 114 checks passed
@obviyus
obviyus deleted the fix/command-turn-source-admission branch July 11, 2026 03:56
obviyus added a commit that referenced this pull request Jul 12, 2026
…e into agent turns

Native command turns keep #104144 source-keyed admission, but a turn that
continues into a full agent turn (/steer fallback, /goal, /learn, unhandled
body) now moves its reservation and lifecycle lease to the target session
before running. Concurrent target inbounds see the owner and queue/steer
instead of double-admitting and splitting the session into two conversation
families; steering also targets the registered run owner instead of a stale
source-keyed reservation.

Fixes #104844
obviyus added a commit that referenced this pull request Jul 12, 2026
…e into agent turns

Native command turns keep #104144 source-keyed admission, but a turn that
continues into a full agent turn (/steer fallback, /goal, /learn, unhandled
body) now moves its reservation and lifecycle lease to the target session
before running. Concurrent target inbounds see the owner and queue/steer
instead of double-admitting and splitting the session into two conversation
families; steering also targets the registered run owner instead of a stale
source-keyed reservation.

Fixes #104844
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 12, 2026
…e into agent turns

Native command turns keep openclaw#104144 source-keyed admission, but a turn that
continues into a full agent turn (/steer fallback, /goal, /learn, unhandled
body) now moves its reservation and lifecycle lease to the target session
before running. Concurrent target inbounds see the owner and queue/steer
instead of double-admitting and splitting the session into two conversation
families; steering also targets the registered run owner instead of a stale
source-keyed reservation.

Fixes openclaw#104844
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Native slash commands dead-wait behind the target session's active run: /stop can't stop, /status never answers, Telegram control lane wedges

1 participant