Skip to content

Steer queue mode silently degrades to followup — messages never injected mid-turn at tool call boundaries #50880

Closed as not planned

Description

@ppamment

Summary

When messages.queue.mode is set to "steer", inbound messages are never injected into the active agent turn at tool call boundaries as documented. Instead, they silently degrade to followup behavior (waiting for end-of-turn, then triggering a new turn). There is zero diagnostic logging when this occurs.

Expected behavior

Per queue.md docs:

steer: inject immediately into the current run (cancels pending tool calls after the next tool boundary). If not streaming, falls back to followup.

Messages sent while the agent is executing tool calls should be:

  1. Picked up by queueEmbeddedPiMessage()
  2. Pushed into the pi-agent-core steering queue via activeSession.steer(text) → agent.steer()
  3. Dequeued by getSteeringMessages() at the next tool call boundary in agent-loop.js
  4. Injected into the conversation, skipping remaining pending tool calls

Actual behavior

Messages sent during active tool execution:

  1. Arrive at the gateway reply pipeline
  2. Are not injected mid-turn at any tool call boundary
  3. Are queued as a followup and processed only after the current turn ends
  4. Trigger a new agent turn (identical to followup mode behavior)

No diagnostic logging occurs when steer degrades to followup. The diag.debug lines in queueEmbeddedPiMessage() (reasons: no_active_run, not_streaming, compacting) do not appear in /tmp/openclaw/*.log even with logging.level: "debug".

Reproduction

  1. Set messages.queue.mode: "steer" globally in config
  2. Send a message that triggers the agent to make multiple sequential tool calls (e.g. a research question requiring several exec/Read calls)
  3. While tool calls are executing, send additional messages
  4. Observe: none of the messages are injected mid-turn. All wait for end-of-turn and trigger new turns.

This was reproduced live across ~10 consecutive turns with 30+ tool call boundaries total. Zero mid-turn injections occurred.

Config

{
  "messages": {
    "queue": {
      "mode": "steer",
      "debounceMs": 1000,
      "cap": 20,
      "drop": "summarize"
    }
  }
}

Channel: Discord
Version: 2026.3.13
Model: anthropic/claude-opus-4-6

Code path analysis (from source inspection)

The pi-agent-core layer (agent-loop.js) correctly implements steering:

  • getSteeringMessages() is polled between sequential tool executions and after each turn
  • When steering messages are found, remaining tool calls are skipped with "Skipped due to queued user message"
  • The steeringQueue on the agent is a simple array that steer() pushes to and dequeueSteeringMessages() drains

The gateway bridge layer connects these via:

  • queueEmbeddedPiMessage(sessionId, text) → handle.queueMessage(text) → activeSession.steer(text) → agent.steer(message)
  • Guards: handle.isStreaming() and !handle.isCompacting() — note that isStreaming is set to true for the entire agent loop duration (including tool execution), so this guard should pass during active runs
  • Gateway reply pipeline checks shouldSteer && isStreaming before attempting steer injection
  • Fallback: when steer injection fails for any reason, resolveActiveRunQueueAction() returns "enqueue-followup" for queueMode === "steer", silently degrading to followup

The exact failure point is unclear from static source analysis alone. The pi-agent-core steering mechanism and the gateway bridge both appear correct in isolation. The failure may be:

  • A race condition in session/sessionId resolution before the embedded run handle is registered
  • Something in the event subscription layer that drops or ignores the injected steering turn
  • A timing issue between the gateway reply pipeline and the embedded run lifecycle
  • Tool execution mode (parallel vs sequential) affecting when steering is polled

Instrumentation or debugger attachment would be needed to determine the exact failure point.

Suggestions

  1. Add logging when steer injection fails and falls back to followup — currently this is completely silent
  2. Log the specific guard that rejected the steer (was it isStreaming, isCompacting, no_active_run, or something else?)
  3. Ensure the diag.debug lines in queueEmbeddedPiMessage() are actually routed to the file logger when logging.level: "debug" is set

Activity

  1. Ryce commented on Mar 20, 2026

    @Ryce
  2. Ryce commented on Mar 20, 2026

    @Ryce
  3. ppamment commented on Mar 22, 2026

    @ppamment
    ContributorAuthor

    Root cause found via instrumentation

    I patched reply-Bm8VrLQh.js with fs.appendFileSync logging at every decision point. Results from /tmp/steer-debug.log:

    [2026-03-20T07:48:53.266Z] runReplyAgent CALLED mode=steer shouldSteer=true isActive=false isStreaming=false
    [2026-03-20T07:48:53.269Z] entry: shouldSteer=true isStreaming=false isActive=false sessionId=... mode=steer
    [2026-03-20T07:48:53.271Z] steer path SKIPPED: shouldSteer=true isStreaming=false
    [2026-03-20T07:48:53.272Z] activeRunQueueAction=run-now
    

    Every inbound message that arrives during an active run shows isActive=false and isStreaming=false when it reaches runReplyAgent. This means:

    1. The per-session lane queue (session:<key>) serializes all runs for a given session
    2. When a second message arrives while a run is active, it is held in the session lane queue
    3. It only dequeues and calls runReplyAgent after the first run completes
    4. By that time, isActive=false and isStreaming=false, so the steer path is skipped and activeRunQueueAction=run-now triggers a fresh run

    The steer decision code inside runReplyAgent works correctly — it just never gets a chance to run while a run is active. The session lane queue prevents it.

    The fix needs to happen upstream: when mode=steer and a run is active, the inbound message should bypass the session lane queue and call queueEmbeddedPiMessage directly (before entering runReplyAgent), or the lane queue should check for steer mode and short-circuit to the steer injection path.

  4. ppamment commented on Mar 22, 2026

    @ppamment
    ContributorAuthor

    Correction to my previous comment: The log entries I posted were all hourly heartbeats (spaced ~65min apart), not user messages or steer attempts. They only prove that heartbeats reach runReplyAgent with isActive=false — which is expected (heartbeats should run when the session is idle).

    The instrumentation has not yet captured an actual inbound user message arriving while a run is active. This means either:

    1. Inbound messages during active runs take a different code path that bypasses runReplyAgent entirely (handled by the session lane queue before reaching this function)
    2. Or they do reach runReplyAgent but through a path I haven't instrumented

    The root cause conclusion about "session lane queue blocking" may still be correct, but the evidence I cited doesn't prove it. Still investigating.

  5. paulodearaujo commented on Mar 31, 2026

    @paulodearaujo

    +1

  6. openclaw-barnacle commented on Apr 29, 2026

    @openclaw-barnacle

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  7. added
    stale
    on Apr 29, 2026
  8. clawsweeper commented on Apr 29, 2026

    @clawsweeper
    Contributor

    Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

    Close as duplicate of the earlier open tracker #48003. Current main still shows the steer-to-followup behavior shape, but #48003 already tracks the same remaining root issue and open PRs #73365 and #75226 are the active fix candidates; this issue’s Discord reproduction and diagnostic notes should be preserved there as supporting context.

    So I’m closing this here and keeping the remaining discussion on the canonical linked item.

    Review details

    Best possible solution:

    Keep #48003 as the canonical open tracker, review or replace #73365/#75226 for the code fix, and carry this issue’s Discord diagnostics into that thread.

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

    Yes. Source inspection on current main shows same-session Discord work is serialized, steering is attempted only while isStreaming is true, non-streaming embedded handles reject steering, and active steer falls through to followup.

    Is this the best way to solve the issue?

    Yes. Closing this as a duplicate is the best tracking outcome because #48003 is already open for the same remaining bug and the active fix work belongs in #73365, #75226, or a focused replacement.

    Security review:

    Security review: No patch is attached to this issue, so there is no PR security or supply-chain diff to review.

    What I checked:

    Likely related people:

    • vincentkoc: The supplied context identifies open PR fix: allow steer messages during active non-streaming runs #73365 as a focused fix for active non-streaming steer handling covering Steer mode does not inject messages mid-turn for main sessions #48003 and this issue; prior review context also ties Vincent Koc to embedded queue steering work. (role: likely follow-up owner; confidence: medium; commits: b29ea4e33486, 2db10fb1d4; files: src/auto-reply/reply/agent-runner.ts, src/agents/pi-embedded-runner/runs.ts, src/auto-reply/reply/queue-policy.ts)
    • howardclaw26: The supplied context identifies open PR fix(reply): steer active embedded Pi runs between streams #75226 as addressing part of this issue by steering active embedded Pi runs between streams and adding a forward-compatible tool-boundary seam. (role: adjacent follow-up owner; confidence: medium; commits: e7f32e3271e2; files: src/auto-reply/reply/agent-runner.ts, src/agents/pi-embedded-runner/runs.ts)
    • steipete: Prior ClawSweeper context and the queue docs/history point to Peter Steinberger as a maintainer of the queue-mode behavior, docs, and followup policy area. (role: recent maintainer / queue-mode owner; confidence: medium; commits: 8dda07a1e9, ac36eba822, 971b98c96d; files: docs/concepts/queue.md, docs/concepts/queue-steering.md, src/auto-reply/reply/queue-policy.ts)
    • Tak Hoffman: The related Steer mode does not inject messages mid-turn for main sessions #48003 context attributes the regression-era same-session serialization/backpressure change to commit 9889c6d; current Discord still serializes same-key inbound work through the channel run queue. (role: introduced adjacent serialization behavior; confidence: low; commits: 9889c6da53; files: extensions/discord/src/monitor/message-run-queue.ts, src/plugin-sdk/channel-lifecycle.core.ts, src/plugin-sdk/keyed-async-queue.ts)

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

  9. clawsweeper commented on Apr 29, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve.

    Keep open. Current main still does not satisfy the steer contract: current-run injection remains gated on streaming, active non-streaming embedded handles are rejected, active steer resolves to followup, and Discord same-session work is still serialized before reply handling can attempt steering. The focused related fix PR #73365 is open and unmerged, so this should not be closed as implemented.

    Required change / next step:

    No separate ClawSweeper repair job should be queued because open maintainer-labeled PR #73365 already covers the focused fix; the maintainer action is to review, land, or replace that PR.

    Review details

    Best possible solution:

    The desired end state is lifecycle-aware steer delivery: eligible same-session messages should reach the embedded steering queue while a run is active, rejected steer attempts should emit useful diagnostics, followup fallback should remain deliberate, and docs/tests should describe the actual injection boundary consistently.

    What I checked:

    Likely related people:

    • vincentkoc: The supplied GitHub context identifies open maintainer PR fix: allow steer messages during active non-streaming runs #73365 as the focused lifecycle-aware steer handling fix for this issue and Steer mode does not inject messages mid-turn for main sessions #48003; git ls-remote confirms the PR head ref still exists. (role: likely follow-up owner; confidence: medium; commits: b29ea4e33486; files: src/auto-reply/reply/agent-runner.ts, src/agents/pi-embedded-runner/runs.ts, src/auto-reply/reply/queue-policy.ts)
    • steipete: Current checkout blame on the central reply runner, embedded run helper, queue policy, Discord queue path, and queue docs points to Peter Steinberger on recent main commits; this is routing evidence, not fault attribution. (role: recent maintainer / adjacent owner; confidence: medium; commits: 34d11d57579d, 61d53f98; files: src/auto-reply/reply/agent-runner.ts, src/agents/pi-embedded-runner/runs.ts, src/auto-reply/reply/queue-policy.ts)

    Remaining risk / open question:

    • No live Discord reproduction was run during this read-only review; the keep-open decision is based on current source, docs, tests, and the supplied issue/PR context.
    • The current docs disagree on whether steer cancels remaining pending tool calls or waits until the next model boundary, so the eventual fix should also align the public contract.

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

  10. removed
    stale
    on Apr 30, 2026
  11. Deniable9570 commented on May 6, 2026

    @Deniable9570

    Can confirm this also affects steer-backlog mode. Telegram user on 2026.4.2, same behavior — messages queued as followup instead of being injected mid-turn. queueDepth=0 at every run start confirms messages arrive after prior turn completed.

  12. locked as resolved and limited conversation to collaborators on May 7, 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

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions