Skip to content

fix: use isActive instead of isStreaming for steer mode message injection - #52351

Closed
scottyallen wants to merge 3 commits into
openclaw:mainfrom
scottyallen:fix/steer-mode-isactive
Closed

scottyallen wants to merge 3 commits into
openclaw:mainfrom
scottyallen:fix/steer-mode-isactive

Conversation

@scottyallen

Copy link
Copy Markdown

Summary

  • Problem: Steer mode messages (sent via sessions_send or similar) are silently dropped when injected into a running agent session. Users send a steer message expecting it to be injected into the agent's conversation, but nothing happens.
  • Why it matters: Steer mode is a core interaction pattern - users rely on it to guide running agents mid-conversation. Silent message loss breaks this workflow with no error feedback.
  • Root cause: Two code paths gate on isStreaming (whether the LLM response stream has started) instead of isActive (whether the agent session is running). When a session is active but the stream has not started yet, isStreaming is false and steer messages are rejected. isActive correctly reflects whether the session can accept injected messages.
  • What changed: (1) agent-runner.ts line 196: changed the steer condition from shouldSteer && isStreaming to shouldSteer && isActive. (2) runs.ts queueEmbeddedPiMessage: removed the isStreaming() early-return guard so messages can be queued whenever the run is active and not compacting.
  • What did NOT change (scope boundary): No changes to the isStreaming property itself, no changes to the EmbeddedPiQueueHandle interface, no changes to compaction guards or abort logic.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

User-visible / Behavior Changes

Steer mode messages are no longer silently dropped when the agent session is active but not yet streaming. Users will see their steer messages injected into the agent conversation as expected.

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Repro + Verification

Environment

  • OS: Linux (gateway)
  • Runtime/container: Node.js
  • Model/provider: Any
  • Integration/channel: Any channel with steer mode

Steps

  1. Start an agent session (e.g. via auto-reply or sessions_spawn)
  2. While the session is active but before the LLM stream has started, send a steer message
  3. Observe whether the message is injected into the agent conversation

Expected

Steer message is injected into the running agent session.

Actual (before fix)

Steer message is silently dropped. queueEmbeddedPiMessage returns false with diagnostic log reason=not_streaming.

Evidence

  • Code inspection: isStreaming is false when a session is active but stream has not started; isActive correctly reflects the session state
  • pnpm check passes (all lint, format, type checks green)
  • Diagnostic log path confirms the not_streaming rejection

Human Verification (required)

  • Verified scenarios: Code review of both call sites confirms isActive is in scope and semantically correct for the steer guard
  • Edge cases checked: Compaction guard remains in queueEmbeddedPiMessage - messages are still rejected during compaction. The no_active_run guard remains as well.
  • What I did not verify: End-to-end runtime testing with a live OpenClaw instance (no local instance available in this environment). Build passes but full test suite was not run.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: Revert this commit (two files, minimal diff)
  • Files/config to restore: src/auto-reply/reply/agent-runner.ts, src/agents/pi-embedded-runner/runs.ts
  • Known bad symptoms reviewers should watch for: Messages being injected when they should not be (e.g. during compaction), or duplicate message injection

Risks and Mitigations

  • Risk: Removing the isStreaming guard from queueEmbeddedPiMessage could allow messages to be queued before the stream infrastructure is ready to process them.
    • Mitigation: The queueMessage handle is only registered in ACTIVE_EMBEDDED_RUNS after the run is fully initialized, so the handle existing implies the infrastructure is ready. The compaction guard remains as an additional safety check.

AI-Assisted PR

  • This PR was authored with AI assistance (Claude via OpenClaw)
  • Testing level: lightly tested - pnpm check passes (lint, format, types), full test suite not run
  • Codex review: codex CLI not available in this environment; noted for reviewer awareness
  • I understand what the code does: The fix changes the boolean guard for steer message injection from stream-started to session-active, matching the actual semantic requirement

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Mar 22, 2026
openclaw/refinery added 3 commits March 22, 2026 17:14
…aths (op-na9)

Conflict-resolved rebase of polecat/slit/fix-heartbeat-slack onto main.
Original src/slack/monitor/replies.ts and src/channels/plugins/outbound/slack.ts
have moved to extensions/slack/src/monitor/replies.ts and
extensions/slack/src/outbound-adapter.ts; changes applied to new locations.
Test file adapted to extension test conventions.
…tion

Fixes steer mode messages not being injected because the code gates on
isStreaming (which is false when the stream hasn't started yet) instead
of isActive (which correctly reflects whether the session is running).

Also removes the isStreaming guard from queueEmbeddedPiMessage in runs.ts
for the same reason - the function should accept queued messages whenever
the run is active, not only when it is already streaming.

Fixes openclaw#48003
Add tests covering:
- queueEmbeddedPiMessage: no active run, active but not streaming
  (original bug case), active but compacting, active and streaming
- Steer guard in runReplyAgent: shouldSteer+isActive injects message,
  shouldSteer+!isActive skips injection, !shouldSteer skips injection

These tests verify the fix that changed the steer guard from
isStreaming to isActive (issue openclaw#48003 / PR openclaw#52351).
scottyallen pushed a commit to scottyallen/openclaw that referenced this pull request Mar 22, 2026
Add tests covering:
- queueEmbeddedPiMessage: no active run, active but not streaming
  (original bug case), active but compacting, active and streaming
- Steer guard in runReplyAgent: shouldSteer+isActive injects message,
  shouldSteer+!isActive skips injection, !shouldSteer skips injection

These tests verify the fix that changed the steer guard from
isStreaming to isActive (issue openclaw#48003 / PR openclaw#52351).
@scottyallen
scottyallen force-pushed the fix/steer-mode-isactive branch from 46f5879 to 7057b6c Compare March 22, 2026 21:56
@openclaw-barnacle openclaw-barnacle Bot added channel: slack Channel integration: slack size: M and removed size: XS labels Mar 22, 2026
scottyallen pushed a commit to scottyallen/openclaw that referenced this pull request Mar 27, 2026
Add tests covering:
- queueEmbeddedPiMessage: no active run, active but not streaming
  (original bug case), active but compacting, active and streaming
- Steer guard in runReplyAgent: shouldSteer+isActive injects message,
  shouldSteer+!isActive skips injection, !shouldSteer skips injection

These tests verify the fix that changed the steer guard from
isStreaming to isActive (issue openclaw#48003 / PR openclaw#52351).
@clawsweeper

clawsweeper Bot commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Closing this as duplicate or superseded after Codex automated review.

Close PR #52351 as superseded by #65010. Current main still has the isStreaming steering gates, so this is not implemented yet, but #65010 is the newer canonical PR for the same bug and extends the fix to the additional reply-run queue path with a more precise isStopped lifecycle guard.

Best possible solution:

Close #52351 as superseded and continue review on #65010 as the canonical implementation for the steer/interrupt queue lifecycle fix. The final landed change should cover agent-runner.ts, runs.ts, and the reply-run registry path with regression tests for active-but-not-streaming tool execution and stopped/startup windows.

What I checked:

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

Codex Review notes: model gpt-5.5, reasoning high; reviewed against 76cf013df507.

@clawsweeper clawsweeper Bot closed this Apr 26, 2026
Senorsen added a commit to Senorsen/openclaw-fork that referenced this pull request May 14, 2026
Senorsen added a commit to Senorsen/openclaw-fork that referenced this pull request May 14, 2026
Senorsen added a commit to Senorsen/openclaw-fork that referenced this pull request May 19, 2026
…nclaw#52351 openclaw#73365)

Add isStopped() to EmbeddedPiQueueHandle so messages can be queued
during tool-call phases (active but not streaming). The steer gate in
agent-runner now checks isActive instead of isStreaming.
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 size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Steer mode does not inject messages mid-turn for main sessions

1 participant