Skip to content

fix(brain): emit user message_start for steer in Claude SDK brain#186

Open
jacoblee-io wants to merge 1 commit into
mainfrom
fix/steer-ui-display
Open

fix(brain): emit user message_start for steer in Claude SDK brain#186
jacoblee-io wants to merge 1 commit into
mainfrom
fix/steer-ui-display

Conversation

@jacoblee-io
Copy link
Copy Markdown
Collaborator

Problem

Steer messages sent during agent execution show as amber chips in the input area but never appear in the chat history. The chips stay forever.

Root Cause

The Claude SDK brain queues steer messages and runs them as follow-up queries via runQuery(). But runQuery() only emits turn_start → assistant messages → turn_end. It never emits a message_start with role: "user" for the steer text.

The frontend (usePilot.ts:521-538) listens for message_start with role: "user" to match against pendingMessages. Without this event, the match never happens → steer stays as amber chip.

Pi-agent brain is not affected because the pi-agent session handles user message emission internally.

Solution

Emit message_start with role: "user" and the steer text before calling runQuery() for each queued steer message. Applied to both:

  • Main steer drain loop (after current query)
  • DP auto-continue steer drain loop

Test plan

  • Send steer message during agent execution → appears in chat history (not stuck as chip)
  • DP hypothesis confirmation during agent run → message displayed correctly
  • Pi-agent brain steer still works (unchanged)

@jacoblee-io jacoblee-io force-pushed the fix/steer-ui-display branch from c8ec41b to 8f15f7a Compare March 27, 2026 16:38
Steer messages (sent during agent execution) were not showing in the
chat. Two issues:

1. Frontend: steer messages were added to pendingMessages (amber chips)
   instead of messages (chat history). They relied on a message_start
   event echo from the brain to move from chip to chat, but pi-agent
   may not emit this event. Fix: add steer messages directly to the
   messages array, same as normal sends.

2. Gateway: chat.steer RPC didn't save the user message to the
   database. On page refresh, steer messages were lost.
   Fix: appendMessage to DB before forwarding to agentbox.
@jacoblee-io jacoblee-io force-pushed the fix/steer-ui-display branch from 8f15f7a to 9b7043e Compare March 27, 2026 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant