Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(agents): steer a queued message and mark flush on send (#7420)
Wolf Mermelsteinf97ad132cfc1
diff --git a/apps/web/src/components/ui/components/SendButton.tsx b/apps/web/src/components/ui/components/SendButton.tsxindex 4876a99005..58ca065075 100644--- a/apps/web/src/components/ui/components/SendButton.tsx+++ b/apps/web/src/components/ui/components/SendButton.tsx@@ -6,6 +6,11 @@ import { Button, type ButtonProps } from './Button';export type SendButtonProps = Omit<ButtonProps, 'size' | 'variant'> & {appearance?: 'default' | 'composer';+ /**+ * Empty composer with a queue waiting: the same send control, ringed so it+ * reads as flushing that queue rather than sending a new message.+ */+ intent?: 'send' | 'flush';/** Show a spinner instead of the arrow (e.g. while a send mutation is in-flight). */pending?: boolean;/** Drop the button from the layout — used to hide on mobile when the input is empty. */@@ -24,6 +29,7 @@ export function SendButton(props: SendButtonProps) {'aria-label','tooltip','actionLabel',+ 'intent',]);const resolved = children(() => local.children);@@ -34,11 +40,19 @@ export function SendButton(props: SendButtonProps) {glass={false}size={local.appearance === 'composer' ? 'icon-composer' : 'icon-sm'}draggable={false}- aria-label={local['aria-label'] ?? 'Send'}- tooltip={local.tooltip ?? 'Send'}+ aria-label={+ local['aria-label'] ??+ (local.intent === 'flush' ? 'Flush queued messages' : 'Send')+ }+ tooltip={+ local.tooltip ??+ (local.intent === 'flush' ? 'Flush queued messages' : 'Send')+ }+ data-intent={local.intent === 'flush' ? 'flush' : undefined}class={cn('border-0 bg-ink text-surface-4 touch:size-7.5','not-touch:not-disabled:hover:text-surface-4',+ local.intent === 'flush' && 'ring-2 ring-accent/60',local.appearance === 'composer'? cn('not-touch:not-disabled:bg-composer-action not-touch:not-disabled:text-composer-action-ink not-touch:not-disabled:hover:text-composer-action-ink not-touch:light-mode:shadow-none not-touch:light-mode:backdrop-filter-none not-touch:light-mode:after:hidden',diff --git a/apps/web/src/features/agent-changes/debug/Gallery.tsx b/apps/web/src/features/agent-changes/debug/Gallery.tsxindex d0a0349a9c..f13ee896d8 100644--- a/apps/web/src/features/agent-changes/debug/Gallery.tsx+++ b/apps/web/src/features/agent-changes/debug/Gallery.tsx@@ -149,6 +149,19 @@ export default function AgentChangesGallery() {setQueueItems(remaining);if (remaining.length === 0) setQueued(false);}}+ onSteer={(id) =>+ setQueueItems((items) => {+ const index = items.findIndex(+ (item) => item.actionId === id+ );+ if (index < 0) return items;+ const next = items.slice();+ const [entry] = next.splice(index, 1);+ if (!entry) return items;+ next.unshift(entry);+ return next;+ })+ }/></Show><div class="rounded-2xl border border-edge px-4 py-3 text-sm text-ink-placeholder">diff --git a/apps/web/src/features/agents-view/components/ChatComposer.test.tsx b/apps/web/src/features/agents-view/components/ChatComposer.test.tsxindex a0c685e31f..28ba5d6420 100644--- a/apps/web/src/features/agents-view/components/ChatComposer.test.tsx+++ b/apps/web/src/features/agents-view/components/ChatComposer.test.tsx@@ -229,7 +229,7 @@ describe('Chat session input', () => {expect(editor.enter?.(undefined, '')).toBe(false);expect(stop).not.toHaveBeenCalled();fireEvent.click(- screen.getByRole('button', { name: 'Send next queued message' })+ screen.getByRole('button', { name: 'Flush queued messages' }));expect(stop).toHaveBeenCalledOnce();});diff --git a/apps/web/src/features/agents-view/components/ChatComposer.tsx b/apps/web/src/features/agents-view/components/ChatComposer.tsxindex 09f2bad987..8e853d5029 100644--- a/apps/web/src/features/agents-view/components/ChatComposer.tsx+++ b/apps/web/src/features/agents-view/components/ChatComposer.tsx@@ -360,8 +360,9 @@ export function ChatComposer(props: {><SendButtonappearance="composer"- aria-label="Send next queued message"- tooltip="Send next queued message"+ intent="flush"+ aria-label="Flush queued messages"+ tooltip="Flush queued messages"shortcut="Enter"onClick={sendNext}/>diff --git a/apps/web/src/features/block-agent/agent-session-provider.tsx b/apps/web/src/features/block-agent/agent-session-provider.tsxindex 31ef68ba43..95cd7f4c36 100644--- a/apps/web/src/features/block-agent/agent-session-provider.tsx+++ b/apps/web/src/features/block-agent/agent-session-provider.tsx@@ -25,6 +25,7 @@ import {} from './context/create-queue-controller';import { resolveSessionId } from './context/resolve-session-id';import { createSendNext } from './context/send-next';+import { createSteer } from './context/steer';import { createInteractionController } from './primitives/create-interaction-controller';import type { QuoteInsert } from './ui';@@ -98,6 +99,13 @@ export function AgentSessionProvider(expect: live.expect,retract: live.retract,});+ const steer = createSteer({+ currentTurn: live.currentTurn,+ entries: queue.entries,+ steer: queue.steer,+ expect: live.expect,+ retract: live.retract,+ });const interactions = createInteractionController({sessionId,pending: () => live.metadata()?.pendingInteractions ?? [],@@ -151,6 +159,7 @@ export function AgentSessionProvider(issue: live.issue,selectModel: live.selectModel,sendNext,+ steer,interactions,queue,quoteSelection,diff --git a/apps/web/src/features/block-agent/component/AgentComposer.test.tsx b/apps/web/src/features/block-agent/component/AgentComposer.test.tsxindex f7e220bf92..cf71f08842 100644--- a/apps/web/src/features/block-agent/component/AgentComposer.test.tsx+++ b/apps/web/src/features/block-agent/component/AgentComposer.test.tsx@@ -1,3 +1,4 @@+import type { TurnState } from '@service-agent-fold/generated/types';import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';import { createSignal } from 'solid-js';import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';@@ -8,12 +9,14 @@ import { AgentComposer } from './AgentComposer';const mocks = vi.hoisted(() => ({session: () => ({ canEdit: false as boolean | undefined }),- turn: () => 'idle' as 'idle' | 'working' | 'starting' | 'stopping',+ turn: () => 'idle' as TurnState,issue: vi.fn(),selectModel: vi.fn(),sendNext: vi.fn(),+ steer: vi.fn(),editQueued: vi.fn(),removeQueued: vi.fn(),+ steerQueued: vi.fn(),upload: vi.fn(),consumeNotes: vi.fn(),input: undefined as AgentInputProps | undefined,@@ -53,8 +56,10 @@ vi.mock('../context/AgentSessionContext', () => ({],edit: mocks.editQueued,remove: mocks.removeQueued,+ steer: mocks.steerQueued,},sendNext: mocks.sendNext,+ steer: mocks.steer,turn: () => mocks.turn(),registerQuoteInsert: vi.fn(),}),@@ -115,8 +120,21 @@ describe('view-only session controls', () => {expect(mocks.sendNext).not.toHaveBeenCalled();expect(mocks.upload).not.toHaveBeenCalled();expect(mocks.consumeNotes).not.toHaveBeenCalled();+ mocks.queued?.onSteer?.('queued-1');expect(mocks.editQueued).not.toHaveBeenCalled();expect(mocks.removeQueued).not.toHaveBeenCalled();+ expect(mocks.steer).not.toHaveBeenCalled();+ expect(mocks.queued?.onSteer).toBeUndefined();+ });++ it('steers one queued message while a turn is in flight', () => {+ mocks.session = () => ({ canEdit: true });+ mocks.turn = () => 'running';+ render(() => <AgentComposer />);++ expect(mocks.queued?.onSteer).toEqual(expect.any(Function));+ mocks.queued?.onSteer?.('queued-1');+ expect(mocks.steer).toHaveBeenCalledWith('queued-1');});it('reacts to a permission downgrade without remounting', () => {@@ -155,12 +173,11 @@ describe('view-only session controls', () => {});it('explicitly sends the queue head and disables it while the turn transitions', () => {- const [turn, setTurn] = createSignal<'working' | 'stopping' | 'starting'>(- 'working'- );+ const [turn, setTurn] = createSignal<TurnState>('running');mocks.turn = turn;mocks.session = () => ({ canEdit: true });render(() => <AgentComposer />);+ expect(mocks.queued?.onSteer).toEqual(expect.any(Function));const sendNext = screen.getByRole('button', {name: 'Send next queued message now',});@@ -169,6 +186,7 @@ it('explicitly sends the queue head and disables it while the turn transitions',for (const next of ['stopping', 'starting'] as const) {setTurn(next);expect(sendNext.hasAttribute('disabled')).toBe(true);+ expect(mocks.queued?.onSteer).toBeUndefined();fireEvent.click(sendNext);}expect(mocks.sendNext).toHaveBeenCalledTimes(1);diff --git a/apps/web/src/features/block-agent/component/AgentComposer.tsx b/apps/web/src/features/block-agent/component/AgentComposer.tsxindex b20b35fed2..543ad56d0e 100644--- a/apps/web/src/features/block-agent/component/AgentComposer.tsx+++ b/apps/web/src/features/block-agent/component/AgentComposer.tsx@@ -65,6 +65,7 @@ export function AgentComposer(props: {pending,queue,sendNext,+ steer,turn,registerQuoteInsert,initialInput,@@ -225,6 +226,14 @@ export function AgentComposer(props: {onRemove={(actionId) => {if (!readOnly()) void queue.remove(actionId);}}+ onSteer={+ busy() &&+ !readOnly() &&+ turn() !== 'stopping' &&+ turn() !== 'starting'+ ? (actionId) => steer(actionId)+ : undefined+ }onNavigateBelow={() => focusInput?.()}registerFocusFromBelow={(focus) => {focusQueueBottom = focus;diff --git a/apps/web/src/features/block-agent/context/AgentSessionContext.tsx b/apps/web/src/features/block-agent/context/AgentSessionContext.tsxindex e6b0af7343..a261d5f2c8 100644--- a/apps/web/src/features/block-agent/context/AgentSessionContext.tsx+++ b/apps/web/src/features/block-agent/context/AgentSessionContext.tsx@@ -76,6 +76,12 @@ export type AgentSessionState = {* the server would dispatch that head, not the next one.*/sendNext: () => void;+ /**+ * Steer one queued message: show it as sent, move it to the front of the+ * queue, and cancel the turn in flight so it runs next. No-op while the+ * prompt a previous steer or send-next showed as sent is still unconfirmed.+ */+ steer: (actionId: string) => void;/** The live requests, and the action that answers each one. */interactions: InteractionController;/**diff --git a/apps/web/src/features/block-agent/context/create-queue-controller.ts b/apps/web/src/features/block-agent/context/create-queue-controller.tsindex dfec28c910..859f3029dd 100644--- a/apps/web/src/features/block-agent/context/create-queue-controller.ts+++ b/apps/web/src/features/block-agent/context/create-queue-controller.ts@@ -43,6 +43,12 @@ export type QueueController = {edit: (actionId: string, prompt: string) => Promise<void>;/** Remove a queued action. Same 404 semantics as `edit`. */remove: (actionId: string) => Promise<void>;+ /**+ * Run this queued action next: the server moves it to the front and+ * cancels the turn in flight. `false` when it was not waiting anymore or+ * the request failed.+ */+ steer: (actionId: string) => Promise<boolean>;};export function createQueueController(options: {@@ -148,10 +154,26 @@ export function createQueueController(options: {}};+ const steer = async (actionId: string) => {+ const sessionId = untrack(options.sessionId);+ if (!sessionId) return false;+ const result = await agentHarnessServiceClient+ .steerQueued(sessionId, actionId)+ .catch(() => undefined);+ if (result === undefined || result.isErr()) {+ if (result === undefined || !isDispatched(result)) {+ toast.failure('The queued message could not be steered');+ }+ return false;+ }+ return true;+ };+return {entries: () =>queued().filter((entry) => !dispatchedIds().has(entry.actionId)),edit,remove,+ steer,};}diff --git a/apps/web/src/features/block-agent/context/send-next.ts b/apps/web/src/features/block-agent/context/send-next.tsindex 2e8b13bb6b..c2ed3304b3 100644--- a/apps/web/src/features/block-agent/context/send-next.ts+++ b/apps/web/src/features/block-agent/context/send-next.ts@@ -12,6 +12,17 @@ import type {QueuedActionDto,} from '@service-agent-harness/generated/schemas';+/** The action a queued entry will run as, when the composer can show it sent. */+export function actionForQueuedEntry(+ entry: QueuedActionDto+): AgentAction | undefined {+ if (entry.kind === 'prompt' && entry.prompt != null) {+ return { type: 'prompt', prompt: entry.prompt };+ }+ if (entry.kind === 'compact') return { type: 'compact' };+ return undefined;+}+export function createSendNext(session: {/*** The session's turn as it stands at call time, including what it has@@ -35,12 +46,7 @@ export function createSendNext(session: {if (session.currentTurn() === 'starting') return;const head = session.entries()[0];if (!head) return;- const action: AgentAction | undefined =- head.kind === 'prompt' && head.prompt != null- ? { type: 'prompt', prompt: head.prompt }- : head.kind === 'compact'- ? { type: 'compact' }- : undefined;+ const action = actionForQueuedEntry(head);void session.issue({ type: 'stop' })?.then((result) => {if (result.isErr()) session.retract(head.actionId);});diff --git a/apps/web/src/features/block-agent/context/steer.test.ts b/apps/web/src/features/block-agent/context/steer.test.tsnew file mode 100644index 0000000000..ac19d02267--- /dev/null+++ b/apps/web/src/features/block-agent/context/steer.test.ts@@ -0,0 +1,52 @@+import type { QueuedActionDto } from '@service-agent-harness/generated/schemas';+import { describe, expect, it, vi } from 'vitest';+import { createSteer } from './steer';++const waiting: QueuedActionDto = {+ actionId: 'later',+ kind: 'prompt',+ prompt: 'Steer this',+ attachments: [],+ actorUserId: null,+ createdAt: '2026-10-02T00:00:00Z',+};++describe('createSteer', () => {+ it('shows the chosen prompt as sent and takes it back when the server refuses', async () => {+ const expectAction = vi.fn();+ const retract = vi.fn();+ const steer = vi.fn(async () => false);+ const send = createSteer({+ currentTurn: () => 'running',+ entries: () => [waiting],+ steer,+ expect: expectAction,+ retract,+ });++ send('later');++ expect(expectAction).toHaveBeenCalledWith('later', {+ type: 'prompt',+ prompt: 'Steer this',+ });+ await vi.waitFor(() => expect(retract).toHaveBeenCalledWith('later'));+ });++ it('does not jump another entry while a steer is still unconfirmed', () => {+ const expectAction = vi.fn();+ const steer = vi.fn(async () => true);+ const send = createSteer({+ currentTurn: () => 'starting',+ entries: () => [waiting],+ steer,+ expect: expectAction,+ retract: vi.fn(),+ });++ send('later');++ expect(expectAction).not.toHaveBeenCalled();+ expect(steer).not.toHaveBeenCalled();+ });+});diff --git a/apps/web/src/features/block-agent/context/steer.ts b/apps/web/src/features/block-agent/context/steer.tsnew file mode 100644index 0000000000..61c13d8237--- /dev/null+++ b/apps/web/src/features/block-agent/context/steer.ts@@ -0,0 +1,40 @@+/**+ * "Steer" a queued message: show it as sent now, and ask the server to run+ * it next. The server moves that entry to the front and cancels the turn in+ * flight, so it flushes ahead of anything queued before it. The dispatched+ * row arrives under the same id and promotes this speculation in place.+ */++import type { TurnState } from '@service-agent-fold/generated/types';+import type {+ AgentAction,+ QueuedActionDto,+} from '@service-agent-harness/generated/schemas';+import { actionForQueuedEntry } from './send-next';++export function createSteer(session: {+ /**+ * The session's turn as it stands at call time. A steer that already+ * showed its prompt as sent reads `starting` here, and a second press+ * inside that window must not jump another entry in front of it.+ */+ currentTurn: () => TurnState;+ /** The queue as the composer shows it. */+ entries: () => QueuedActionDto[];+ /** Move `actionId` to the front and cancel the turn in flight. */+ steer: (actionId: string) => Promise<boolean>;+ expect: (actionId: string, action: AgentAction) => void;+ retract: (actionId: string) => void;+}): (actionId: string) => void {+ return (actionId) => {+ if (session.currentTurn() === 'starting') return;+ const entry = session.entries().find((item) => item.actionId === actionId);+ const action = entry ? actionForQueuedEntry(entry) : undefined;+ if (!action) return;+ session.expect(actionId, action);+ void (async () => {+ const accepted = await session.steer(actionId);+ if (!accepted) session.retract(actionId);+ })();+ };+}diff --git a/apps/web/src/features/block-agent/debug/Gallery.tsx b/apps/web/src/features/block-agent/debug/Gallery.tsxindex 924e82ed0a..92e73b6d87 100644--- a/apps/web/src/features/block-agent/debug/Gallery.tsx+++ b/apps/web/src/features/block-agent/debug/Gallery.tsx@@ -39,6 +39,8 @@ import {FailureNoticeCard,PierreDiff,QuestionAnswers,+ type QueuedPromptItem,+ QueuedPrompts,type QuoteInsert,TextShimmer,Thought,@@ -190,6 +192,70 @@ function ReplyToSelectionDemo() {);}+/**+ * An in-flight turn with a queue: each row can steer, and the empty composer+ * shows the ringed flush control instead of stop.+ */+function QueuedInFlightDemo() {+ const [items, setItems] = createSignal<QueuedPromptItem[]>([+ {+ actionId: 'older',+ kind: 'prompt',+ prompt: 'Summarize the queue design',+ },+ {+ actionId: 'newer',+ kind: 'prompt',+ prompt: 'Also mention the flush control',+ },+ ]);+ const [note, setNote] = createSignal(+ 'Steer jumps that message ahead. With the box empty, the ringed arrow flushes the queue.'+ );++ return (+ <div class="flex max-w-xl flex-col gap-2">+ <p class="text-xs text-ink-muted">{note()}</p>+ <QueuedPrompts+ items={items()}+ onEdit={(id, prompt) =>+ setItems((current) =>+ current.map((item) =>+ item.actionId === id ? { ...item, prompt } : item+ )+ )+ }+ onRemove={(id) =>+ setItems((current) => current.filter((item) => item.actionId !== id))+ }+ onSteer={(id) => {+ setItems((current) => {+ const index = current.findIndex((item) => item.actionId === id);+ if (index < 0) return current;+ const next = current.slice();+ const [entry] = next.splice(index, 1);+ if (!entry) return current;+ next.unshift(entry);+ return next;+ });+ setNote(`Steered “${id}” to the front of the queue.`);+ }}+ />+ <AgentInput+ busy+ hasQueuedMessages={items().length > 0}+ onSend={() => setNote('Typed text still sends as a new queued prompt.')}+ onStop={() =>+ setNote('Flush stops the turn so the queue drains, oldest first.')+ }+ onSendNext={() =>+ setNote('Flush stops the turn so the queue drains, oldest first.')+ }+ />+ </div>+ );+}+/** Flips every few seconds so the running→done animations stay observable. */function usePulse(intervalMs = 2500) {const [on, setOn] = createSignal(true);@@ -1250,6 +1316,10 @@ export default function AgentUiGallery() {<ReplyToSelectionDemo /></Item>+ <Item label="Queued messages (steer and flush)">+ <QueuedInFlightDemo />+ </Item>+<Item label="AgentInput (idle / busy)"><AgentInputonSend={(content) => console.info('[gallery] send', content)}diff --git a/apps/web/src/features/block-agent/ui/AgentInput.test.tsx b/apps/web/src/features/block-agent/ui/AgentInput.test.tsxindex c52564562b..92162bc7be 100644--- a/apps/web/src/features/block-agent/ui/AgentInput.test.tsx+++ b/apps/web/src/features/block-agent/ui/AgentInput.test.tsx@@ -100,13 +100,6 @@ vi.mock('@phosphor/spinner-gap.svg', () => ({default: () => <span data-testid="spinner-icon" />,}));-vi.mock(- '@phosphor-icons/core/regular/arrow-bend-down-left.svg?component-solid',- () => ({- default: () => <span data-testid="enter-icon" />,- })-);-beforeEach(() => {vi.stubGlobal('ResizeObserver',@@ -163,7 +156,7 @@ describe('on a touch device', () => {expect(onStop).not.toHaveBeenCalled();fireEvent.click(- screen.getByRole('button', { name: 'Send next queued message' })+ screen.getByRole('button', { name: 'Flush queued messages' }));expect(onStop).toHaveBeenCalledOnce();});@@ -189,7 +182,7 @@ describe('queued message advancement', () => {screen.getByTestId('agent-input-editor').getAttribute('data-disabled')).toBe('true');const stop = screen.getByRole('button', {- name: 'Send next queued message',+ name: 'Flush queued messages',}) as HTMLButtonElement;expect(stop.disabled).toBe(true);fireEvent.click(stop);@@ -202,7 +195,7 @@ describe('queued message advancement', () => {expect(onSendNext).not.toHaveBeenCalled();});- it('shows a send action that advances the next queued message', () => {+ it('shows a ringed send action that flushes the next queued message', () => {const onStop = vi.fn();render(() => (@@ -210,9 +203,11 @@ describe('queued message advancement', () => {));const sendNext = screen.getByRole('button', {- name: 'Send next queued message',+ name: 'Flush queued messages',});expect(sendNext.hasAttribute('disabled')).toBe(false);+ expect(sendNext.getAttribute('data-intent')).toBe('flush');+ expect(screen.getByTestId('send-icon')).toBeTruthy();fireEvent.click(sendNext);expect(onStop).toHaveBeenCalledTimes(1);@@ -261,7 +256,7 @@ describe('queued message advancement', () => {// Attached files are a draft: both tapping Send and Enter send them.expect(- screen.queryByRole('button', { name: 'Send next queued message' })+ screen.queryByRole('button', { name: 'Flush queued messages' })).toBeNull();expect(screen.getByRole('button', { name: 'Send' })).toBeTruthy();expect(screen.queryByRole('button', { name: 'Stop' })).toBeNull();diff --git a/apps/web/src/features/block-agent/ui/AgentInput.tsx b/apps/web/src/features/block-agent/ui/AgentInput.tsxindex 434420ed1d..4140cfca39 100644--- a/apps/web/src/features/block-agent/ui/AgentInput.tsx+++ b/apps/web/src/features/block-agent/ui/AgentInput.tsx@@ -29,7 +29,6 @@ import { isTouchDevice } from '@core/mobile/isTouchDevice';import { useTouchOutsideToDismissKeyboard } from '@core/mobile/useTouchOutsideToDismissKeyboard';import { handleFileFolderDrop } from '@core/util/upload';import { $insertReferencedPaste } from '@macro-inc/lexical-core';-import ArrowUp from '@phosphor/arrow-up.svg';import { Button, ComposerSurface, SendButton } from '@ui';import { createSignal, type JSX, onCleanup, onMount, Show } from 'solid-js';@@ -49,8 +48,9 @@ export interface AgentInputProps {/** The agent is working: the send button becomes a stop square. */busy?: boolean;/**- * A waiting action can be advanced by ending the current turn. While the- * input is empty, Enter and the matching button do exactly that.+ * A waiting action can be flushed by ending the current turn. While the+ * input is empty, Enter and the send button do exactly that. The button+ * stays a send arrow, ringed so it reads as flush rather than a new message.*/hasQueuedMessages?: boolean;/**@@ -430,14 +430,13 @@ export function AgentInput(props: AgentInputProps) {><SendButtonappearance="composer"- aria-label="Send next queued message"- tooltip="Send next queued message"+ intent="flush"+ aria-label="Flush queued messages"+ tooltip="Flush queued messages"shortcut="Enter"onClick={sendNext}disabled={!canSendNext()}- >- <ArrowUp />- </SendButton>+ /></Show></div></div>diff --git a/apps/web/src/features/block-agent/ui/QueuedPrompts.test.tsx b/apps/web/src/features/block-agent/ui/QueuedPrompts.test.tsxindex 415192fa59..3727e240a5 100644--- a/apps/web/src/features/block-agent/ui/QueuedPrompts.test.tsx+++ b/apps/web/src/features/block-agent/ui/QueuedPrompts.test.tsx@@ -220,4 +220,59 @@ describe('queued prompt access', () => {expect(onEdit).toHaveBeenCalledWith('queued-1', 'An edited request');expect(onRemove).toHaveBeenCalledWith('queued-1');});++ it('steers the selected queued message without opening its editor', () => {+ const onSteer = vi.fn();+ render(() => (+ <QueuedPrompts+ items={[+ { actionId: 'first', kind: 'prompt', prompt: 'Next to send' },+ { actionId: 'second', kind: 'prompt', prompt: 'Steer this' },+ ]}+ onEdit={vi.fn()}+ onRemove={vi.fn()}+ onSteer={onSteer}+ />+ ));++ const steer = screen.getAllByRole('button', { name: 'Steer' });+ expect(steer).toHaveLength(2);+ // Newest is rendered first; "Steer this" is the second queued entry.+ fireEvent.click(steer[0]);+ expect(onSteer).toHaveBeenCalledWith('second');+ expect(screen.queryByRole('textbox')).toBeNull();+ });++ it('hides steer when the turn is not in flight and disables it for viewers', () => {+ const onSteer = vi.fn();+ const { unmount } = render(() => (+ <QueuedPrompts+ items={[+ { actionId: 'queued-1', kind: 'prompt', prompt: 'Queued request' },+ ]}+ onEdit={vi.fn()}+ onRemove={vi.fn()}+ />+ ));+ expect(screen.queryByRole('button', { name: 'Steer' })).toBeNull();+ unmount();++ render(() => (+ <QueuedPrompts+ disabled+ items={[+ { actionId: 'queued-1', kind: 'prompt', prompt: 'Queued request' },+ ]}+ onEdit={vi.fn()}+ onRemove={vi.fn()}+ onSteer={onSteer}+ />+ ));+ const steer = screen.getByRole('button', {+ name: 'Steer',+ }) as HTMLButtonElement;+ expect(steer.disabled).toBe(true);+ fireEvent.click(steer);+ expect(onSteer).not.toHaveBeenCalled();+ });});diff --git a/apps/web/src/features/block-agent/ui/QueuedPrompts.tsx b/apps/web/src/features/block-agent/ui/QueuedPrompts.tsxindex 3b61bbb93e..5d78ec1b8d 100644--- a/apps/web/src/features/block-agent/ui/QueuedPrompts.tsx+++ b/apps/web/src/features/block-agent/ui/QueuedPrompts.tsx@@ -11,6 +11,8 @@* Edits debounce and autosave through `onEdit`, with a flush on blur; there* are no save/cancel affordances. Non-prompt entries (compact) are* read-only text but keep their remove affordance, which is always visible.+ * While a turn is in flight, each row offers Steer: that message jumps the+ * queue and the current turn is cancelled so it runs next.*/import { buildConfig } from '@core/component/LexicalMarkdown/builder/MarkdownConfigBuilder';@@ -51,6 +53,12 @@ export interface QueuedPromptsProps {onEdit: (actionId: string, prompt: string) => void;/** Remove a queued action before it dispatches. */onRemove: (actionId: string) => void;+ /**+ * Interrupt the turn in flight and run this queued action next. Absent+ * when nothing is in flight: the queue drains on its own once the turn+ * ends, and the composer's flush control sends the oldest entry.+ */+ onSteer?: (actionId: string) => void;/** Down past the bottom (next-to-send) row — focus returns to the composer. */onNavigateBelow?: () => void;/**@@ -127,6 +135,9 @@ export function QueuedPrompts(props: QueuedPromptsProps) {onMoveDown={() => moveFocus(id, 1)}onEdit={(prompt) => props.onEdit(id, prompt)}onRemove={() => props.onRemove(id)}+ onSteer={+ props.onSteer ? () => props.onSteer?.(id) : undefined+ }/>)}</Show>@@ -148,6 +159,8 @@ type QueuedRowProps = {onMoveDown: () => void;onEdit: (prompt: string) => void;onRemove: () => void;+ /** Interrupt the current turn and send this row next. */+ onSteer?: () => void;};function QueuedRow(props: QueuedRowProps) {@@ -211,6 +224,19 @@ function QueuedRow(props: QueuedRowProps) {{(name) => <> by {name()}</>}</Show></span>+ <Show when={props.onSteer}>+ <Button+ variant="ghost"+ size="xs"+ label="Steer"+ tooltip="Interrupt the current turn and send this message next"+ disabled={props.disabled}+ onClick={() => props.onSteer?.()}+ class="shrink-0"+ >+ Steer+ </Button>+ </Show><Buttonvariant="ghost"size="icon-sm"diff --git a/apps/web/src/lib/service-clients/service-agent-harness/client.ts b/apps/web/src/lib/service-clients/service-agent-harness/client.tsindex 28d418aabd..c34b438428 100644--- a/apps/web/src/lib/service-clients/service-agent-harness/client.ts+++ b/apps/web/src/lib/service-clients/service-agent-harness/client.ts@@ -231,6 +231,18 @@ export const agentHarnessServiceClient = {).then((result) => result.map(() => undefined));},+ /**+ * Run a queued action next. Moves it to the front and cancels the turn in+ * flight so it dispatches ahead of anything queued before it. Answers 404+ * (`NOT_FOUND`) once the action has dispatched.+ */+ steerQueued(sessionId: string, actionId: string) {+ return fetchWithToken<Record<string, never>>(+ `${agentHarnessHost}/agent-sessions/${sessionId}/queue/${actionId}/steer`,+ { method: 'POST' }+ ).then((result) => result.map(() => undefined));+ },+delete(sessionId: string) {return fetchWithToken<Record<string, never>>(`${agentHarnessHost}/agent-sessions/${sessionId}`,diff --git a/apps/web/src/lib/service-clients/service-agent-harness/generated/client.ts b/apps/web/src/lib/service-clients/service-agent-harness/generated/client.tsindex b038bc1ead..7f3c13dd89 100644--- a/apps/web/src/lib/service-clients/service-agent-harness/generated/client.ts+++ b/apps/web/src/lib/service-clients/service-agent-harness/generated/client.ts@@ -1899,6 +1899,78 @@ export const removeQueuedAction = async (} as removeQueuedActionResponse;};+/**+ * @summary Run a queued action next. Moves it ahead of the rest of the queue and+cancels the turn in flight, so this entry dispatches when that turn ends.+ */+export type steerQueuedActionResponse204 = {+ data: void;+ status: 204;+};++export type steerQueuedActionResponse401 = {+ data: string;+ status: 401;+};++export type steerQueuedActionResponse403 = {+ data: string;+ status: 403;+};++export type steerQueuedActionResponse404 = {+ data: string;+ status: 404;+};++export type steerQueuedActionResponse500 = {+ data: string;+ status: 500;+};++export type steerQueuedActionResponseSuccess = steerQueuedActionResponse204 & {+ headers: Headers;+};+export type steerQueuedActionResponseError = (+ | steerQueuedActionResponse401+ | steerQueuedActionResponse403+ | steerQueuedActionResponse404+ | steerQueuedActionResponse500+) & {+ headers: Headers;+};++export type steerQueuedActionResponse =+ | steerQueuedActionResponseSuccess+ | steerQueuedActionResponseError;++export const getSteerQueuedActionUrl = (+ sessionId: string,+ actionId: string+) => {+ return `/agent-sessions/${sessionId}/queue/${actionId}/steer`;+};++export const steerQueuedAction = async (+ sessionId: string,+ actionId: string,+ options?: RequestInit+): Promise<steerQueuedActionResponse> => {+ const res = await fetch(getSteerQueuedActionUrl(sessionId, actionId), {+ ...options,+ method: 'POST',+ });++ const body = [204, 205, 304].includes(res.status) ? null : await res.text();++ const data: steerQueuedActionResponse['data'] = body ? JSON.parse(body) : {};+ return {+ data,+ status: res.status,+ headers: res.headers,+ } as steerQueuedActionResponse;+};+/*** @summary Resize this session's sandbox and remember the size as the owner's default.*/diff --git a/apps/web/src/lib/service-clients/service-agent-harness/openapi.json b/apps/web/src/lib/service-clients/service-agent-harness/openapi.jsonindex 83756cb3b0..cc3da35a63 100644--- a/apps/web/src/lib/service-clients/service-agent-harness/openapi.json+++ b/apps/web/src/lib/service-clients/service-agent-harness/openapi.json@@ -1680,6 +1680,80 @@}}},+ "/agent-sessions/{session_id}/queue/{action_id}/steer": {+ "post": {+ "tags": ["agent-sessions"],+ "summary": "Run a queued action next. Moves it ahead of the rest of the queue and\ncancels the turn in flight, so this entry dispatches when that turn ends.",+ "operationId": "steer_queued_action",+ "parameters": [+ {+ "name": "session_id",+ "in": "path",+ "description": "ID of the agent session",+ "required": true,+ "schema": {+ "type": "string",+ "format": "uuid"+ }+ },+ {+ "name": "action_id",+ "in": "path",+ "description": "ID the action was accepted under",+ "required": true,+ "schema": {+ "type": "string",+ "format": "uuid"+ }+ }+ ],+ "responses": {+ "204": {+ "description": ""+ },+ "401": {+ "description": "",+ "content": {+ "text/plain": {+ "schema": {+ "type": "string"+ }+ }+ }+ },+ "403": {+ "description": "",+ "content": {+ "text/plain": {+ "schema": {+ "type": "string"+ }+ }+ }+ },+ "404": {+ "description": "Already dispatched or never queued",+ "content": {+ "text/plain": {+ "schema": {+ "type": "string"+ }+ }+ }+ },+ "500": {+ "description": "",+ "content": {+ "text/plain": {+ "schema": {+ "type": "string"+ }+ }+ }+ }+ }+ }+ },"/agent-sessions/{session_id}/sandbox-size": {"put": {"tags": ["agent-sessions"],diff --git a/crates/agent_harness/src/domain/model.rs b/crates/agent_harness/src/domain/model.rsindex b1d465d18e..d48dd03ed0 100644--- a/crates/agent_harness/src/domain/model.rs+++ b/crates/agent_harness/src/domain/model.rs@@ -517,6 +517,14 @@ pub enum HarnessCommand {/// The user responsible, as on [`Self::EditQueued`].actor: Option<MacroUserIdStr<'static>>,},+ /// Run a queued action next: move it to the front and, when a turn is in+ /// flight, cancel that turn so this entry flushes ahead of the rest.+ SteerQueued {+ /// The queue entry to run next.+ action_id: AgentActionId,+ /// The user responsible, as on [`Self::EditQueued`].+ actor: Option<MacroUserIdStr<'static>>,+ },/// The session's fold reported a turn fact: an ended turn clears the/// busy mark and dispatches the next queued action; a raised or cleared/// question is published as is. Internal - enqueued by the turn observerdiff --git a/crates/agent_harness/src/domain/queue.rs b/crates/agent_harness/src/domain/queue.rsindex 5646fd1118..9663d53cfb 100644--- a/crates/agent_harness/src/domain/queue.rs+++ b/crates/agent_harness/src/domain/queue.rs@@ -335,6 +335,31 @@ impl SessionQueues {}}+ /// Move a waiting entry to the front, so a steer runs it next.+ ///+ /// An entry that is already next is left where it is. Missing entries are+ /// [`QueueError::NotFound`], the same answer as an edit of something that+ /// already dispatched.+ pub fn move_to_front(+ &self,+ session: AgentSessionId,+ action_id: AgentActionId,+ ) -> Result<(), QueueError> {+ let mut queue = self.queues.get_mut(&session).ok_or(QueueError::NotFound)?;+ let position = queue+ .iter()+ .position(|entry| entry.action_id == action_id)+ .ok_or(QueueError::NotFound)?;+ if position == 0 {+ return Ok(());+ }+ let Some(entry) = queue.remove(position) else {+ return Err(QueueError::NotFound);+ };+ queue.push_front(entry);+ Ok(())+ }+/// Remove a waiting entry.pub fn remove(&self,diff --git a/crates/agent_harness/src/domain/queue/test.rs b/crates/agent_harness/src/domain/queue/test.rsindex f019fbf66f..7735ab415a 100644--- a/crates/agent_harness/src/domain/queue/test.rs+++ b/crates/agent_harness/src/domain/queue/test.rs@@ -196,6 +196,34 @@ fn a_requeued_entry_is_next_in_line() {);}+#[test]+fn move_to_front_promotes_a_waiting_entry_and_keeps_the_rest() {+ let queues = SessionQueues::new();+ let session = AgentSessionId::TEST_A;+ let first = prompt_entry("first");+ let steered = prompt_entry("steer");+ let third = prompt_entry("third");+ queues.enqueue(session, first.clone()).unwrap();+ queues.enqueue(session, steered.clone()).unwrap();+ queues.enqueue(session, third.clone()).unwrap();++ queues.move_to_front(session, steered.action_id).unwrap();+ queues.move_to_front(session, steered.action_id).unwrap();++ assert_eq!(+ queues+ .list(session)+ .iter()+ .map(|entry| entry.action_id)+ .collect::<Vec<_>>(),+ [steered.action_id, first.action_id, third.action_id]+ );+ assert_eq!(+ queues.move_to_front(session, AgentActionId::mint()),+ Err(QueueError::NotFound)+ );+}+#[test]fn enqueue_front_puts_the_entry_ahead_of_waiting_work() {let queues = SessionQueues::new();diff --git a/crates/agent_harness/src/domain/service/lifecycle.rs b/crates/agent_harness/src/domain/service/lifecycle.rsindex d4f9959576..f61f3fd636 100644--- a/crates/agent_harness/src/domain/service/lifecycle.rs+++ b/crates/agent_harness/src/domain/service/lifecycle.rs@@ -151,6 +151,18 @@ where.map_err(into_session_error)}+ async fn steer_queued_control(+ &self,+ id: AgentSessionId,+ action_id: AgentActionId,+ actor: Option<MacroUserIdStr<'static>>,+ ) -> agent_session::domain::error::Result<()> {+ self.execute(id, HarnessCommand::SteerQueued { action_id, actor })+ .await+ .map(drop)+ .map_err(into_session_error)+ }+async fn set_sandbox_size(&self,id: AgentSessionId,diff --git a/crates/agent_harness/src/domain/service/queue.rs b/crates/agent_harness/src/domain/service/queue.rsindex 09fe78a040..b63954b977 100644--- a/crates/agent_harness/src/domain/service/queue.rs+++ b/crates/agent_harness/src/domain/service/queue.rs@@ -317,7 +317,8 @@ where}HarnessCommand::Deliver(DeliverAction { actor, .. })| HarnessCommand::EditQueued { actor, .. }- | HarnessCommand::RemoveQueued { actor, .. } => {+ | HarnessCommand::RemoveQueued { actor, .. }+ | HarnessCommand::SteerQueued { actor, .. } => {let session = self.sessions.get_session(session_id).await?;if session.is_archived {return Err(AgentSessionError::Archived(session_id).into());@@ -383,6 +384,9 @@ whereself.publish_queue(session_id).await;Ok(CommandOutcome::Completed)}+ HarnessCommand::SteerQueued { action_id, actor } => {+ self.steer_queued(session_id, action_id, actor).await+ }HarnessCommand::Turn(TurnSignal::TurnEnded {stop,last_text,@@ -707,6 +711,46 @@ where})}+ /// Move a queued action to the front and cancel the running turn so it+ /// flushes next. The same idea as a channel follow-up's steer, for an+ /// entry that is already waiting: the session page queues without+ /// interrupting, and this is the explicit interrupt.+ ///+ /// A failed cancel is best-effort. The entry is already at the front, so+ /// it still drains when the current turn ends on its own.+ async fn steer_queued(+ &self,+ session_id: AgentSessionId,+ action_id: AgentActionId,+ actor: Option<MacroUserIdStr<'static>>,+ ) -> Result<CommandOutcome> {+ self.revalidate_queue(session_id).await?;+ queue_result(self.queues.move_to_front(session_id, action_id), session_id)?;+ self.persist_or_rollback(session_id).await?;+ if self.busy.turn(session_id).is_some()+ && let Err(error) = self+ .deliver(+ session_id,+ DeliverAction {+ id: AgentActionId::mint(),+ action: AgentAction::Stop,+ actor,+ announce: None,+ },+ )+ .await+ {+ tracing::warn!(+ error = ?error,+ %session_id,+ %action_id,+ "failed to stop the running turn for a steered queue entry"+ );+ }+ self.publish_queue(session_id).await;+ Ok(CommandOutcome::Completed)+ }+/// Cancel a running turn and post the chip on the channel follow-up that/// interrupted it. The follow-up is already at the front of the queue,/// so it flushes as the next prompt once the cancelled turn ends.diff --git a/crates/agent_harness/src/domain/service/test.rs b/crates/agent_harness/src/domain/service/test.rsindex c2c3317932..2b55800ac3 100644--- a/crates/agent_harness/src/domain/service/test.rs+++ b/crates/agent_harness/src/domain/service/test.rs@@ -2560,6 +2560,64 @@ async fn queued_prompts_are_editable_and_removable_until_dispatch() {assert!(matches!(error, AgentSessionError::QueuedControlNotFound));}+#[tokio::test]+async fn steering_a_later_queued_prompt_runs_it_ahead_of_earlier_ones() {+ let ((service, _repo, containers, _announcer, _runtimes), _turns) =+ harness_with_signals(PromptContextMock::default(), PromptComposerMock::default());+ let id = AgentSessionId::new();+ let container = session_with_a_running_turn(&service, &containers, id).await;+ let agent = container.agent();++ let prompt = |text: &str| ControlEvent {+ action: AgentAction::prompt(text),+ action_id: None,+ actor: Some(sender()),+ };+ let first = service+ .control_event(id, prompt("first waiting"))+ .await+ .expect("the first mid-turn prompt queues");+ let steered = service+ .control_event(id, prompt("steer this"))+ .await+ .expect("the second mid-turn prompt queues");++ service+ .steer_queued_control(id, steered.action_id, Some(sender()))+ .await+ .expect("a waiting prompt can be steered");++ assert_eq!(+ cancel_count(&agent),+ 1,+ "steering cancels the turn in flight"+ );+ assert_eq!(+ service+ .queued_controls(id)+ .await+ .expect("queue lists")+ .iter()+ .map(|entry| entry.action_id)+ .collect::<Vec<_>>(),+ [steered.action_id, first.action_id]+ );++ agent.completes_prompt().await;+ agent.wait_for_requests(4).await;+ assert_eq!(+ prompts(&agent)[1],+ vec![ContentBlock::from("steer this")],+ "the steered prompt flushes ahead of the one queued before it"+ );++ let missing = service+ .steer_queued_control(id, steered.action_id, Some(sender()))+ .await+ .expect_err("a prompt that already flushed is not waiting");+ assert!(matches!(missing, AgentSessionError::QueuedControlNotFound));+}+#[tokio::test]async fn a_model_change_bypasses_the_running_turn() {let ((service, _repo, containers, _announcer, _runtimes), _turns) =diff --git a/crates/agent_harness/src/domain/service/test/quota.rs b/crates/agent_harness/src/domain/service/test/quota.rsindex eb9476f548..e2b26ef40e 100644--- a/crates/agent_harness/src/domain/service/test/quota.rs+++ b/crates/agent_harness/src/domain/service/test/quota.rs@@ -502,6 +502,47 @@ async fn billing_outage_preserves_fifo_and_retries_only_on_a_new_event() {assert_eq!(rejected_ids(&restarted), ids);}+#[tokio::test]+async fn steering_during_a_billing_outage_preserves_the_waiting_order() {+ let (service, repo, admission) = bench(None);+ let id = session(&repo, BotId::TEST_A, "in-memory", Owner::User(sender())).await;+ let ids = enqueue_waiting(&service, id).await;+ *admission.failure.lock().unwrap() = Some(AiAdmissionError::Unavailable);++ assert!(matches!(+ service+ .execute_here(+ id,+ HarnessCommand::SteerQueued {+ action_id: ids[1],+ actor: Some(sender()),+ },+ )+ .await,+ Err(HarnessError::Admission(AiAdmissionError::Unavailable))+ ));+ assert_eq!(+ service+ .inner+ .queues+ .list(id)+ .iter()+ .map(|entry| entry.action_id)+ .collect::<Vec<_>>(),+ ids+ );+ assert_eq!(+ repo.list_queued_actions(id)+ .await+ .unwrap()+ .iter()+ .map(|entry| entry.action_id)+ .collect::<Vec<_>>(),+ ids+ );+ assert_no_provisioning(&service);+}+#[tokio::test]async fn admission_changes_during_dispatch_never_reach_the_runtime() {for failure in [denied(), AiAdmissionError::Unavailable] {diff --git a/crates/agent_session/src/domain/ports.rs b/crates/agent_session/src/domain/ports.rsindex 5519de607f..28793286d8 100644--- a/crates/agent_session/src/domain/ports.rs+++ b/crates/agent_session/src/domain/ports.rs@@ -1159,6 +1159,17 @@ pub trait AgentSessionNotificationRecipient: Send + Sync + 'static {actor: Option<MacroUserIdStr<'static>>,) -> impl Future<Output = Result<()>> + Send;+ /// Run a queued action next. Moves it to the front of the queue and, when+ /// a turn is in flight, cancels that turn so this entry dispatches ahead+ /// of anything queued before it. [`AgentSessionError::QueuedControlNotFound`]+ /// once it has dispatched. `actor` as on [`Self::edit_queued_control`].+ fn steer_queued_control(+ &self,+ id: AgentSessionId,+ action_id: AgentActionId,+ actor: Option<MacroUserIdStr<'static>>,+ ) -> impl Future<Output = Result<()>> + Send;+/// Resize this session's sandbox and remember `size` as the owner's default.fn set_sandbox_size(&self,diff --git a/crates/agent_session/src/domain/routines/service/test.rs b/crates/agent_session/src/domain/routines/service/test.rsindex 1e836e8a8e..2967e4726a 100644--- a/crates/agent_session/src/domain/routines/service/test.rs+++ b/crates/agent_session/src/domain/routines/service/test.rs@@ -144,6 +144,14 @@ impl AgentSessionNotificationRecipient for Controls {) -> SessionResult<()> {panic!("not a routine capability")}+ async fn steer_queued_control(+ &self,+ _: AgentSessionId,+ _: AgentActionId,+ _: Option<MacroUserIdStr<'static>>,+ ) -> SessionResult<()> {+ panic!("not a routine capability")+ }async fn set_sandbox_size(&self, _: AgentSessionId, _: SandboxSize) -> SessionResult<()> {panic!("not a routine capability")}diff --git a/crates/agent_session/src/inbound/axum_router.rs b/crates/agent_session/src/inbound/axum_router.rsindex 909312889f..b4711a9133 100644--- a/crates/agent_session/src/inbound/axum_router.rs+++ b/crates/agent_session/src/inbound/axum_router.rs@@ -241,6 +241,10 @@ whereput(edit_queued_action_handler::<R, Access, Auth>).delete(remove_queued_action_handler::<R, Access, Auth>),)+ .route(+ "/{session_id}/queue/{action_id}/steer",+ post(steer_queued_action_handler::<R, Access, Auth>),+ ).route("/{session_id}/sandbox-size",put(put_agent_session_sandbox_size_handler::<R, Access, Auth>),@@ -1176,6 +1180,55 @@ pub async fn remove_queued_action_handler<Ok(StatusCode::NO_CONTENT)}+#[utoipa::path(+ post,+ path = "/agent-sessions/{session_id}/queue/{action_id}/steer",+ tag = "agent-sessions",+ operation_id = "steer_queued_action",+ params(+ ("session_id" = Uuid, Path, description = "ID of the agent session"),+ ("action_id" = Uuid, Path, description = "ID the action was accepted under"),+ ),+ responses(+ (status = 204),+ (status = 401, body = String),+ (status = 403, body = String),+ (status = 404, body = String, description = "Already dispatched or never queued"),+ (status = 500, body = String),+ )+)]+/// Run a queued action next. Moves it ahead of the rest of the queue and+/// cancels the turn in flight, so this entry dispatches when that turn ends.+#[tracing::instrument(+ skip_all,+ fields(actor = %caller.acting_entity(), session_id = %session_id, %action_id),+ err(Debug)+)]+pub async fn steer_queued_action_handler<+ R: AgentSessionNotificationRecipient,+ Access: EntityAccessService,+ Auth: MacroAuthorizationService,+>(+ _access: AgentSessionAccessLevelExtractor<EditAccessLevel, Access, Auth>,+ State(state): State<AgentSessionControlState<R, Access, Auth>>,+ caller: MacroAuthorizationExtractor<Auth, UserBotOrHarness>,+ Path((session_id, action_id)): Path<(Uuid, Uuid)>,+) -> Result<StatusCode, AgentSessionApiError> {+ let session_id = AgentSessionId::new_from_uuid(session_id);+ ensure_harness_serves_session(&caller.authorization, state.recipient.as_ref(), session_id)+ .await?;++ let actor = caller+ .authorization+ .acting_user()+ .map(|user| user.macro_user_id.clone());+ state+ .recipient+ .steer_queued_control(session_id, AgentActionId::from_uuid(action_id), actor)+ .await?;+ Ok(StatusCode::NO_CONTENT)+}+#[utoipa::path(delete,path = "/agent-sessions/{session_id}",diff --git a/crates/agent_session/src/inbound/axum_router/test/user_cleanup.rs b/crates/agent_session/src/inbound/axum_router/test/user_cleanup.rsindex 6ca84f0b89..ef1bab1fc7 100644--- a/crates/agent_session/src/inbound/axum_router/test/user_cleanup.rs+++ b/crates/agent_session/src/inbound/axum_router/test/user_cleanup.rs@@ -40,6 +40,14 @@ impl AgentSessionNotificationRecipient for Recipient {) -> SessionResult<()> {unreachable!()}+ async fn steer_queued_control(+ &self,+ _: AgentSessionId,+ _: AgentActionId,+ _: Option<MacroUserIdStr<'static>>,+ ) -> SessionResult<()> {+ unreachable!()+ }async fn set_sandbox_size(&self, _: AgentSessionId, _: SandboxSize) -> SessionResult<()> {unreachable!()}diff --git a/docs/AGENT_GUIDE/ai-chat.md b/docs/AGENT_GUIDE/ai-chat.mdindex 75972d0387..4f291b7854 100644--- a/docs/AGENT_GUIDE/ai-chat.md+++ b/docs/AGENT_GUIDE/ai-chat.md@@ -51,10 +51,11 @@ legacy list and flag-gated composer flows remain available.While an agent works, a draft can be sent to its queue. Above the queue,**Send next** explicitly interrupts the current turn and sends the oldest queued-message. The empty composer offers the same action when messages are queued;-with a draft it offers **Send**. With no draft or queue, the busy composer offers-**Stop**. Send-next actions disable during stopping/starting and for read-only-sessions.+message. The empty composer offers the same action as **Flush queued messages**+with a ringed send arrow; with a draft it offers **Send**. Each queued row offers+**Steer** while a turn is running, to interrupt it and send that row next. With no+draft or queue, the busy composer offers **Stop**. Send-next actions disable and+Steer is hidden during stopping/starting and for read-only sessions.Phone verification: check portrait and landscape with touch emulation. In theHome composer, enter multiple lines and tap Send, attach, or the model control;@@ -1113,18 +1114,22 @@ must stay hidden; subsequent live messages must still appear.32% of the viewport and 16rem. Click the preview again or press Escape to collapseit, retaining edits and editor state. Each row shows a `Queued` label (with `by{user}` when someone else queued it —- several users can stack prompts in one session's queue) and an always-visible remove- (`X`) button. Type in the expanded editor — changes+ several users can stack prompts in one session's queue), an always-visible remove+ (`X`) button, and, while a turn is in flight, a `Steer` button. Steering moves+ that message to the front of the queue and cancels the current turn, so it runs+ next, ahead of anything queued before it. Type in the expanded editor — changesautosave (debounced, and on blur) with no save button. Editing and removal arepossible only until the entry dispatches; after that the row simply becomes the nextuser message in the transcript.- Keyboard: Up at the very start of the composer input moves focus into thebottom (next-to-send) queue row; further Up presses walk toward newer entries, Downwalks back and past the bottom row returns to the input. When the composer is empty- and a prompt is queued, its action becomes `Send next queued message` (an Enter- symbol); pressing Enter or clicking that button cancels the current turn so the next- queued prompt starts immediately. The advance is held — the control reads `Stop` and- Enter is inert — while a stop is already in flight or while the prompt the last+ and a prompt is queued, its action becomes `Flush queued messages` (the send arrow,+ with a ring so it reads as flushing the queue rather than sending a new message);+ pressing Enter or clicking that button cancels the current turn so the queue drains+ in order, oldest first. Steer on a queued row is the interrupt for that one message;+ flush sends whatever is already next. The advance is held — the flush control is+ disabled and Enter is inert — while a stop is already in flight or while the prompt the lastadvance sent is still unconfirmed (it shows as a pending bubble); once the serverconfirms that prompt as the running turn, Enter advances the queue again. Two rapidEnters therefore advance one entry, not two: each advance ends the turn the server isdiff --git a/packages/sdk/generated/agent-harness/index.ts b/packages/sdk/generated/agent-harness/index.tsindex 916db1281b..c1ba714096 100644--- a/packages/sdk/generated/agent-harness/index.ts+++ b/packages/sdk/generated/agent-harness/index.ts@@ -1,4 +1,4 @@// This file is auto-generated by @hey-api/openapi-tsexport { type Options, Sdk } from './sdk.gen';-export type { AccessLevel, AgentAction, AgentActionId, AgentConfigKindDto, AgentConfigOptionDto, AgentConfigSelectOptionDto, AgentModelDto, AgentModelsStatusDto, AgentPermissionAction, AgentPromptAction, AgentRepositoriesResponse, AgentRepositoryBranchesResponse, AgentRepositoryDto, AgentRespondElicitationAction, AgentSessionChangesPatchResponse, AgentSessionChangesResponse, AgentSessionLogEntryDto, AgentSessionLogResponse, AgentSessionPreviewData, AgentSessionPreviewDto, AgentSessionQueueResponse, AgentSessionResponse, AgentSessionsForPullRequestData, AgentSessionsForPullRequestError, AgentSessionsForPullRequestErrors, AgentSessionsForPullRequestResponse, AgentSessionsForPullRequestResponses, AgentSetConfigOptionAction, AgentSetModelAction, AiAdmissionErrorBody, BotId, CapabilityHarnessDto, CaptureAttemptDto, CaptureOutcomeDto, ChangedFileDto, ChangesetDto, ChangesetSourceDto, ChannelSharePermission, ClientOptions, CompleteData, CompleteErrors, CompleteRequest, CompleteResponse, CompleteResponses, ControlAgentSessionData, ControlAgentSessionError, ControlAgentSessionErrors, ControlAgentSessionResponse, ControlAgentSessionResponses, ControlRequest, ControlResponse, ControlStatusDto, CreateAgentSessionData, CreateAgentSessionError, CreateAgentSessionErrors, CreateAgentSessionRequest, CreateAgentSessionResponse, CreateAgentSessionResponse2, CreateAgentSessionResponses, CreateSessionThread, DeleteAgentSessionData, DeleteAgentSessionError, DeleteAgentSessionErrors, DeleteAgentSessionResponses, DisconnectData, DisconnectErrors, DisconnectResponse, DisconnectResponses, DiscoverAgentCapabilitiesHandlerData, DiscoverAgentCapabilitiesHandlerErrors, DiscoverAgentCapabilitiesHandlerResponse, DiscoverAgentCapabilitiesHandlerResponses, DiscoverAgentCapabilitiesRequest, DiscoverAgentCapabilitiesResponse, DocumentId, EditQueuedActionData, EditQueuedActionError, EditQueuedActionErrors, EditQueuedActionRequest, EditQueuedActionResponse, EditQueuedActionResponses, ElicitationAnswer, ElicitationContentValue, ElicitationRequestId, EmptyRequest, ExternalSessionResponse, FileChangeKindDto, GetAgentSandboxSizeData, GetAgentSandboxSizeError, GetAgentSandboxSizeErrors, GetAgentSandboxSizeResponse, GetAgentSandboxSizeResponses, GetAgentSessionChangesData, GetAgentSessionChangesError, GetAgentSessionChangesErrors, GetAgentSessionChangesPatchData, GetAgentSessionChangesPatchError, GetAgentSessionChangesPatchErrors, GetAgentSessionChangesPatchResponse, GetAgentSessionChangesPatchResponses, GetAgentSessionChangesResponse, GetAgentSessionChangesResponses, GetAgentSessionData, GetAgentSessionError, GetAgentSessionErrors, GetAgentSessionLogData, GetAgentSessionLogError, GetAgentSessionLogErrors, GetAgentSessionLogResponse, GetAgentSessionLogResponses, GetAgentSessionPermissionsData, GetAgentSessionPermissionsError, GetAgentSessionPermissionsErrors, GetAgentSessionPermissionsResponse, GetAgentSessionPermissionsResponses, GetAgentSessionQueueData, GetAgentSessionQueueError, GetAgentSessionQueueErrors, GetAgentSessionQueueResponse, GetAgentSessionQueueResponses, GetAgentSessionResponse, GetAgentSessionResponses, GitRefDto, LinkAgentSessionPullRequestData, LinkAgentSessionPullRequestError, LinkAgentSessionPullRequestErrors, LinkAgentSessionPullRequestResponse, LinkAgentSessionPullRequestResponses, LinkShare, ListAgentRepositoriesData, ListAgentRepositoriesErrors, ListAgentRepositoriesResponse, ListAgentRepositoriesResponses, ListAgentRepositoryBranchesData, ListAgentRepositoryBranchesErrors, ListAgentRepositoryBranchesResponse, ListAgentRepositoryBranchesResponses, ListAgentSessionPullRequestsData, ListAgentSessionPullRequestsError, ListAgentSessionPullRequestsErrors, ListAgentSessionPullRequestsResponse, ListAgentSessionPullRequestsResponses, LoadAgentModelsHandlerData, LoadAgentModelsHandlerErrors, LoadAgentModelsHandlerResponse, LoadAgentModelsHandlerResponses, LoadAgentModelsRequest, LoadAgentModelsResponse, LogDirectionDto, LogFrameDto, MessageParent, ModelHarnessDto, PermissionAnswer, PreviewAgentSessionsData, PreviewAgentSessionsError, PreviewAgentSessionsErrors, PreviewAgentSessionsRequest, PreviewAgentSessionsResponse, PreviewAgentSessionsResponse2, PreviewAgentSessionsResponses, PromptAttachment, PullRequestLinkSource, PullRequestSessionsResponse, PullRequestUrl, PutAgentSandboxSizeData, PutAgentSandboxSizeError, PutAgentSandboxSizeErrors, PutAgentSandboxSizeResponse, PutAgentSandboxSizeResponses, PutAgentSessionSandboxSizeData, PutAgentSessionSandboxSizeError, PutAgentSessionSandboxSizeErrors, PutAgentSessionSandboxSizeResponse, PutAgentSessionSandboxSizeResponses, QueuedActionDto, RefreshAgentSessionChangesData, RefreshAgentSessionChangesError, RefreshAgentSessionChangesErrors, RefreshAgentSessionChangesResponse, RefreshAgentSessionChangesResponses, RemoveQueuedActionData, RemoveQueuedActionError, RemoveQueuedActionErrors, RemoveQueuedActionResponse, RemoveQueuedActionResponses, RenameAgentSessionData, RenameAgentSessionError, RenameAgentSessionErrors, RenameAgentSessionRequest, RenameAgentSessionResponse, RenameAgentSessionResponses, SandboxSize, SandboxSizeBody, SessionBot, SessionPullRequestLink, SessionPullRequestsResponse, SessionStatusDto, SetAgentSessionArchivedData, SetAgentSessionArchivedError, SetAgentSessionArchivedErrors, SetAgentSessionArchivedRequest, SetAgentSessionArchivedResponse, SetAgentSessionArchivedResponses, SharePermissionV2, StartData, StartErrors, StartResponse, StartResponse2, StartResponses, StatusData, StatusErrors, StatusResponse, StatusResponse2, StatusResponses, UnlinkAgentSessionPullRequestData, UnlinkAgentSessionPullRequestError, UnlinkAgentSessionPullRequestErrors, UnlinkAgentSessionPullRequestResponse, UnlinkAgentSessionPullRequestResponses, UpdateAgentSessionPermissionsData, UpdateAgentSessionPermissionsError, UpdateAgentSessionPermissionsErrors, UpdateAgentSessionPermissionsResponse, UpdateAgentSessionPermissionsResponses, UpdateChannelSharePermission, UpdateOperation, UpdateSharePermissionRequestV2, WithAgentSessionId } from './types.gen';+export type { AccessLevel, AgentAction, AgentActionId, AgentConfigKindDto, AgentConfigOptionDto, AgentConfigSelectOptionDto, AgentModelDto, AgentModelsStatusDto, AgentPermissionAction, AgentPromptAction, AgentRepositoriesResponse, AgentRepositoryBranchesResponse, AgentRepositoryDto, AgentRespondElicitationAction, AgentSessionChangesPatchResponse, AgentSessionChangesResponse, AgentSessionLogEntryDto, AgentSessionLogResponse, AgentSessionPreviewData, AgentSessionPreviewDto, AgentSessionQueueResponse, AgentSessionResponse, AgentSessionsForPullRequestData, AgentSessionsForPullRequestError, AgentSessionsForPullRequestErrors, AgentSessionsForPullRequestResponse, AgentSessionsForPullRequestResponses, AgentSetConfigOptionAction, AgentSetModelAction, AiAdmissionErrorBody, BotId, CapabilityHarnessDto, CaptureAttemptDto, CaptureOutcomeDto, ChangedFileDto, ChangesetDto, ChangesetSourceDto, ChannelSharePermission, ClientOptions, CompleteData, CompleteErrors, CompleteRequest, CompleteResponse, CompleteResponses, ControlAgentSessionData, ControlAgentSessionError, ControlAgentSessionErrors, ControlAgentSessionResponse, ControlAgentSessionResponses, ControlRequest, ControlResponse, ControlStatusDto, CreateAgentSessionData, CreateAgentSessionError, CreateAgentSessionErrors, CreateAgentSessionRequest, CreateAgentSessionResponse, CreateAgentSessionResponse2, CreateAgentSessionResponses, CreateSessionThread, DeleteAgentSessionData, DeleteAgentSessionError, DeleteAgentSessionErrors, DeleteAgentSessionResponses, DisconnectData, DisconnectErrors, DisconnectResponse, DisconnectResponses, DiscoverAgentCapabilitiesHandlerData, DiscoverAgentCapabilitiesHandlerErrors, DiscoverAgentCapabilitiesHandlerResponse, DiscoverAgentCapabilitiesHandlerResponses, DiscoverAgentCapabilitiesRequest, DiscoverAgentCapabilitiesResponse, DocumentId, EditQueuedActionData, EditQueuedActionError, EditQueuedActionErrors, EditQueuedActionRequest, EditQueuedActionResponse, EditQueuedActionResponses, ElicitationAnswer, ElicitationContentValue, ElicitationRequestId, EmptyRequest, ExternalSessionResponse, FileChangeKindDto, GetAgentSandboxSizeData, GetAgentSandboxSizeError, GetAgentSandboxSizeErrors, GetAgentSandboxSizeResponse, GetAgentSandboxSizeResponses, GetAgentSessionChangesData, GetAgentSessionChangesError, GetAgentSessionChangesErrors, GetAgentSessionChangesPatchData, GetAgentSessionChangesPatchError, GetAgentSessionChangesPatchErrors, GetAgentSessionChangesPatchResponse, GetAgentSessionChangesPatchResponses, GetAgentSessionChangesResponse, GetAgentSessionChangesResponses, GetAgentSessionData, GetAgentSessionError, GetAgentSessionErrors, GetAgentSessionLogData, GetAgentSessionLogError, GetAgentSessionLogErrors, GetAgentSessionLogResponse, GetAgentSessionLogResponses, GetAgentSessionPermissionsData, GetAgentSessionPermissionsError, GetAgentSessionPermissionsErrors, GetAgentSessionPermissionsResponse, GetAgentSessionPermissionsResponses, GetAgentSessionQueueData, GetAgentSessionQueueError, GetAgentSessionQueueErrors, GetAgentSessionQueueResponse, GetAgentSessionQueueResponses, GetAgentSessionResponse, GetAgentSessionResponses, GitRefDto, LinkAgentSessionPullRequestData, LinkAgentSessionPullRequestError, LinkAgentSessionPullRequestErrors, LinkAgentSessionPullRequestResponse, LinkAgentSessionPullRequestResponses, LinkShare, ListAgentRepositoriesData, ListAgentRepositoriesErrors, ListAgentRepositoriesResponse, ListAgentRepositoriesResponses, ListAgentRepositoryBranchesData, ListAgentRepositoryBranchesErrors, ListAgentRepositoryBranchesResponse, ListAgentRepositoryBranchesResponses, ListAgentSessionPullRequestsData, ListAgentSessionPullRequestsError, ListAgentSessionPullRequestsErrors, ListAgentSessionPullRequestsResponse, ListAgentSessionPullRequestsResponses, LoadAgentModelsHandlerData, LoadAgentModelsHandlerErrors, LoadAgentModelsHandlerResponse, LoadAgentModelsHandlerResponses, LoadAgentModelsRequest, LoadAgentModelsResponse, LogDirectionDto, LogFrameDto, MessageParent, ModelHarnessDto, PermissionAnswer, PreviewAgentSessionsData, PreviewAgentSessionsError, PreviewAgentSessionsErrors, PreviewAgentSessionsRequest, PreviewAgentSessionsResponse, PreviewAgentSessionsResponse2, PreviewAgentSessionsResponses, PromptAttachment, PullRequestLinkSource, PullRequestSessionsResponse, PullRequestUrl, PutAgentSandboxSizeData, PutAgentSandboxSizeError, PutAgentSandboxSizeErrors, PutAgentSandboxSizeResponse, PutAgentSandboxSizeResponses, PutAgentSessionSandboxSizeData, PutAgentSessionSandboxSizeError, PutAgentSessionSandboxSizeErrors, PutAgentSessionSandboxSizeResponse, PutAgentSessionSandboxSizeResponses, QueuedActionDto, RefreshAgentSessionChangesData, RefreshAgentSessionChangesError, RefreshAgentSessionChangesErrors, RefreshAgentSessionChangesResponse, RefreshAgentSessionChangesResponses, RemoveQueuedActionData, RemoveQueuedActionError, RemoveQueuedActionErrors, RemoveQueuedActionResponse, RemoveQueuedActionResponses, RenameAgentSessionData, RenameAgentSessionError, RenameAgentSessionErrors, RenameAgentSessionRequest, RenameAgentSessionResponse, RenameAgentSessionResponses, SandboxSize, SandboxSizeBody, SessionBot, SessionPullRequestLink, SessionPullRequestsResponse, SessionStatusDto, SetAgentSessionArchivedData, SetAgentSessionArchivedError, SetAgentSessionArchivedErrors, SetAgentSessionArchivedRequest, SetAgentSessionArchivedResponse, SetAgentSessionArchivedResponses, SharePermissionV2, StartData, StartErrors, StartResponse, StartResponse2, StartResponses, StatusData, StatusErrors, StatusResponse, StatusResponse2, StatusResponses, SteerQueuedActionData, SteerQueuedActionError, SteerQueuedActionErrors, SteerQueuedActionResponse, SteerQueuedActionResponses, UnlinkAgentSessionPullRequestData, UnlinkAgentSessionPullRequestError, UnlinkAgentSessionPullRequestErrors, UnlinkAgentSessionPullRequestResponse, UnlinkAgentSessionPullRequestResponses, UpdateAgentSessionPermissionsData, UpdateAgentSessionPermissionsError, UpdateAgentSessionPermissionsErrors, UpdateAgentSessionPermissionsResponse, UpdateAgentSessionPermissionsResponses, UpdateChannelSharePermission, UpdateOperation, UpdateSharePermissionRequestV2, WithAgentSessionId } from './types.gen';diff --git a/packages/sdk/generated/agent-harness/sdk.gen.ts b/packages/sdk/generated/agent-harness/sdk.gen.tsindex fbc17b187e..6c0aa24551 100644--- a/packages/sdk/generated/agent-harness/sdk.gen.ts+++ b/packages/sdk/generated/agent-harness/sdk.gen.ts@@ -2,7 +2,7 @@import type { Client, ClientMeta, Options as Options2, RequestResult, TDataShape } from './client';import { client } from './client.gen';-import type { AgentSessionsForPullRequestData, AgentSessionsForPullRequestErrors, AgentSessionsForPullRequestResponses, CompleteData, CompleteErrors, CompleteResponses, ControlAgentSessionData, ControlAgentSessionErrors, ControlAgentSessionResponses, CreateAgentSessionData, CreateAgentSessionErrors, CreateAgentSessionResponses, DeleteAgentSessionData, DeleteAgentSessionErrors, DeleteAgentSessionResponses, DisconnectData, DisconnectErrors, DisconnectResponses, DiscoverAgentCapabilitiesHandlerData, DiscoverAgentCapabilitiesHandlerErrors, DiscoverAgentCapabilitiesHandlerResponses, EditQueuedActionData, EditQueuedActionErrors, EditQueuedActionResponses, GetAgentSandboxSizeData, GetAgentSandboxSizeErrors, GetAgentSandboxSizeResponses, GetAgentSessionChangesData, GetAgentSessionChangesErrors, GetAgentSessionChangesPatchData, GetAgentSessionChangesPatchErrors, GetAgentSessionChangesPatchResponses, GetAgentSessionChangesResponses, GetAgentSessionData, GetAgentSessionErrors, GetAgentSessionLogData, GetAgentSessionLogErrors, GetAgentSessionLogResponses, GetAgentSessionPermissionsData, GetAgentSessionPermissionsErrors, GetAgentSessionPermissionsResponses, GetAgentSessionQueueData, GetAgentSessionQueueErrors, GetAgentSessionQueueResponses, GetAgentSessionResponses, LinkAgentSessionPullRequestData, LinkAgentSessionPullRequestErrors, LinkAgentSessionPullRequestResponses, ListAgentRepositoriesData, ListAgentRepositoriesErrors, ListAgentRepositoriesResponses, ListAgentRepositoryBranchesData, ListAgentRepositoryBranchesErrors, ListAgentRepositoryBranchesResponses, ListAgentSessionPullRequestsData, ListAgentSessionPullRequestsErrors, ListAgentSessionPullRequestsResponses, LoadAgentModelsHandlerData, LoadAgentModelsHandlerErrors, LoadAgentModelsHandlerResponses, PreviewAgentSessionsData, PreviewAgentSessionsErrors, PreviewAgentSessionsResponses, PutAgentSandboxSizeData, PutAgentSandboxSizeErrors, PutAgentSandboxSizeResponses, PutAgentSessionSandboxSizeData, PutAgentSessionSandboxSizeErrors, PutAgentSessionSandboxSizeResponses, RefreshAgentSessionChangesData, RefreshAgentSessionChangesErrors, RefreshAgentSessionChangesResponses, RemoveQueuedActionData, RemoveQueuedActionErrors, RemoveQueuedActionResponses, RenameAgentSessionData, RenameAgentSessionErrors, RenameAgentSessionResponses, SetAgentSessionArchivedData, SetAgentSessionArchivedErrors, SetAgentSessionArchivedResponses, StartData, StartErrors, StartResponses, StatusData, StatusErrors, StatusResponses, UnlinkAgentSessionPullRequestData, UnlinkAgentSessionPullRequestErrors, UnlinkAgentSessionPullRequestResponses, UpdateAgentSessionPermissionsData, UpdateAgentSessionPermissionsErrors, UpdateAgentSessionPermissionsResponses } from './types.gen';+import type { AgentSessionsForPullRequestData, AgentSessionsForPullRequestErrors, AgentSessionsForPullRequestResponses, CompleteData, CompleteErrors, CompleteResponses, ControlAgentSessionData, ControlAgentSessionErrors, ControlAgentSessionResponses, CreateAgentSessionData, CreateAgentSessionErrors, CreateAgentSessionResponses, DeleteAgentSessionData, DeleteAgentSessionErrors, DeleteAgentSessionResponses, DisconnectData, DisconnectErrors, DisconnectResponses, DiscoverAgentCapabilitiesHandlerData, DiscoverAgentCapabilitiesHandlerErrors, DiscoverAgentCapabilitiesHandlerResponses, EditQueuedActionData, EditQueuedActionErrors, EditQueuedActionResponses, GetAgentSandboxSizeData, GetAgentSandboxSizeErrors, GetAgentSandboxSizeResponses, GetAgentSessionChangesData, GetAgentSessionChangesErrors, GetAgentSessionChangesPatchData, GetAgentSessionChangesPatchErrors, GetAgentSessionChangesPatchResponses, GetAgentSessionChangesResponses, GetAgentSessionData, GetAgentSessionErrors, GetAgentSessionLogData, GetAgentSessionLogErrors, GetAgentSessionLogResponses, GetAgentSessionPermissionsData, GetAgentSessionPermissionsErrors, GetAgentSessionPermissionsResponses, GetAgentSessionQueueData, GetAgentSessionQueueErrors, GetAgentSessionQueueResponses, GetAgentSessionResponses, LinkAgentSessionPullRequestData, LinkAgentSessionPullRequestErrors, LinkAgentSessionPullRequestResponses, ListAgentRepositoriesData, ListAgentRepositoriesErrors, ListAgentRepositoriesResponses, ListAgentRepositoryBranchesData, ListAgentRepositoryBranchesErrors, ListAgentRepositoryBranchesResponses, ListAgentSessionPullRequestsData, ListAgentSessionPullRequestsErrors, ListAgentSessionPullRequestsResponses, LoadAgentModelsHandlerData, LoadAgentModelsHandlerErrors, LoadAgentModelsHandlerResponses, PreviewAgentSessionsData, PreviewAgentSessionsErrors, PreviewAgentSessionsResponses, PutAgentSandboxSizeData, PutAgentSandboxSizeErrors, PutAgentSandboxSizeResponses, PutAgentSessionSandboxSizeData, PutAgentSessionSandboxSizeErrors, PutAgentSessionSandboxSizeResponses, RefreshAgentSessionChangesData, RefreshAgentSessionChangesErrors, RefreshAgentSessionChangesResponses, RemoveQueuedActionData, RemoveQueuedActionErrors, RemoveQueuedActionResponses, RenameAgentSessionData, RenameAgentSessionErrors, RenameAgentSessionResponses, SetAgentSessionArchivedData, SetAgentSessionArchivedErrors, SetAgentSessionArchivedResponses, StartData, StartErrors, StartResponses, StatusData, StatusErrors, StatusResponses, SteerQueuedActionData, SteerQueuedActionErrors, SteerQueuedActionResponses, UnlinkAgentSessionPullRequestData, UnlinkAgentSessionPullRequestErrors, UnlinkAgentSessionPullRequestResponses, UpdateAgentSessionPermissionsData, UpdateAgentSessionPermissionsErrors, UpdateAgentSessionPermissionsResponses } from './types.gen';export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {/**@@ -362,6 +362,14 @@ export class Sdk extends HeyApiClient {});}+ /**+ * Run a queued action next. Moves it ahead of the rest of the queue and+ * cancels the turn in flight, so this entry dispatches when that turn ends.+ */+ public steerQueuedAction<ThrowOnError extends boolean = false>(options: Options<SteerQueuedActionData, ThrowOnError>): RequestResult<SteerQueuedActionResponses, SteerQueuedActionErrors, ThrowOnError> {+ return (options.client ?? this.client).post<SteerQueuedActionResponses, SteerQueuedActionErrors, ThrowOnError>({ url: '/agent-sessions/{session_id}/queue/{action_id}/steer', ...options });+ }+/*** Resize this session's sandbox and remember the size as the owner's default.*/diff --git a/packages/sdk/generated/agent-harness/types.gen.ts b/packages/sdk/generated/agent-harness/types.gen.tsindex 9042979cb8..2898097152 100644--- a/packages/sdk/generated/agent-harness/types.gen.ts+++ b/packages/sdk/generated/agent-harness/types.gen.ts@@ -2161,6 +2161,40 @@ export type EditQueuedActionResponses = {export type EditQueuedActionResponse = EditQueuedActionResponses[keyof EditQueuedActionResponses];+export type SteerQueuedActionData = {+ body?: never;+ path: {+ /**+ * ID of the agent session+ */+ session_id: string;+ /**+ * ID the action was accepted under+ */+ action_id: string;+ };+ query?: never;+ url: '/agent-sessions/{session_id}/queue/{action_id}/steer';+};++export type SteerQueuedActionErrors = {+ 401: string;+ 403: string;+ /**+ * Already dispatched or never queued+ */+ 404: string;+ 500: string;+};++export type SteerQueuedActionError = SteerQueuedActionErrors[keyof SteerQueuedActionErrors];++export type SteerQueuedActionResponses = {+ 204: void;+};++export type SteerQueuedActionResponse = SteerQueuedActionResponses[keyof SteerQueuedActionResponses];+export type PutAgentSessionSandboxSizeData = {body: SandboxSizeBody;path: {diff --git a/packages/sdk/specs/agent-harness.json b/packages/sdk/specs/agent-harness.jsonindex 83756cb3b0..cc3da35a63 100644--- a/packages/sdk/specs/agent-harness.json+++ b/packages/sdk/specs/agent-harness.json@@ -1680,6 +1680,80 @@}}},+ "/agent-sessions/{session_id}/queue/{action_id}/steer": {+ "post": {+ "tags": ["agent-sessions"],+ "summary": "Run a queued action next. Moves it ahead of the rest of the queue and\ncancels the turn in flight, so this entry dispatches when that turn ends.",+ "operationId": "steer_queued_action",+ "parameters": [+ {+ "name": "session_id",+ "in": "path",+ "description": "ID of the agent session",+ "required": true,+ "schema": {+ "type": "string",+ "format": "uuid"+ }+ },+ {+ "name": "action_id",+ "in": "path",+ "description": "ID the action was accepted under",+ "required": true,+ "schema": {+ "type": "string",+ "format": "uuid"+ }+ }+ ],+ "responses": {+ "204": {+ "description": ""+ },+ "401": {+ "description": "",+ "content": {+ "text/plain": {+ "schema": {+ "type": "string"+ }+ }+ }+ },+ "403": {+ "description": "",+ "content": {+ "text/plain": {+ "schema": {+ "type": "string"+ }+ }+ }+ },+ "404": {+ "description": "Already dispatched or never queued",+ "content": {+ "text/plain": {+ "schema": {+ "type": "string"+ }+ }+ }+ },+ "500": {+ "description": "",+ "content": {+ "text/plain": {+ "schema": {+ "type": "string"+ }+ }+ }+ }+ }+ }+ },"/agent-sessions/{session_id}/sandbox-size": {"put": {"tags": ["agent-sessions"],diff --git a/packages/sdk/src/entities/agent-sessions/queued-action.ts b/packages/sdk/src/entities/agent-sessions/queued-action.tsindex 991d641eec..becfc3ea6b 100644--- a/packages/sdk/src/entities/agent-sessions/queued-action.ts+++ b/packages/sdk/src/entities/agent-sessions/queued-action.ts@@ -8,8 +8,8 @@ import type { MacroClient } from '../../utils/client';/*** One action waiting in an agent session's server-side queue: a prompt or a* compact accepted while a turn was running, dispatching when that turn- * ends. Until then it can be edited (prompts only) or removed; once it has- * dispatched, both answer 404 — there is no un-sending.+ * ends. Until then it can be edited (prompts only), steered, or removed; once+ * it has dispatched, these actions answer 404 — there is no un-sending.** List-sourced only - there is no per-action GET, only the queue snapshot -* so this wraps whatever DTO the caller already has, the same shape@@ -20,14 +20,14 @@ export class QueuedAction {private constructor(private readonly client: MacroClient,private readonly sessionId: string,- private dto: QueuedActionDto,+ private dto: QueuedActionDto) {}/** Wrap a queue entry already in hand (e.g. from `AgentSession.queue()`). */static from(client: MacroClient,sessionId: string,- dto: QueuedActionDto,+ dto: QueuedActionDto): QueuedAction {return new QueuedAction(client, sessionId, dto);}@@ -75,18 +75,27 @@ export class QueuedAction {await this.client.agentHarness.editQueuedAction({path: { session_id: this.sessionId, action_id: this.actionId },body: { prompt },- }),+ }));this.dto = { ...this.dto, prompt };return this;}+ /** Move this action to the front and interrupt the current turn to run it next. */+ async steer(): Promise<void> {+ unwrap(+ await this.client.agentHarness.steerQueuedAction({+ path: { session_id: this.sessionId, action_id: this.actionId },+ })+ );+ }+/** Remove this action from the queue before it dispatches. */async remove(): Promise<void> {unwrap(await this.client.agentHarness.removeQueuedAction({path: { session_id: this.sessionId, action_id: this.actionId },- }),+ }));}}diff --git a/packages/sdk/tests/agent-sessions.test.ts b/packages/sdk/tests/agent-sessions.test.tsindex dbab932873..143ec9b4e0 100644--- a/packages/sdk/tests/agent-sessions.test.ts+++ b/packages/sdk/tests/agent-sessions.test.ts@@ -301,7 +301,7 @@ describe('AgentSession', () => {});});- test('lists the queue and edits or removes an entry through its handle', async () => {+ test('lists the queue and edits, steers, or removes an entry through its handle', async () => {const actionId = '0198a4cc-e138-7670-a308-a6b766602704';const requests: Request[] = [];globalThis.fetch = (async (input) => {@@ -338,11 +338,13 @@ describe('AgentSession', () => {expect(queued?.createdAt).toBe('2026-08-24T12:01:00Z');await queued?.edit('Also update the README');+ await queued?.steer();await queued?.remove();expect(requests.map((request) => request.method)).toEqual(['GET','PUT',+ 'POST','DELETE',]);expect(requests[1]?.url).toBe(@@ -352,6 +354,10 @@ describe('AgentSession', () => {prompt: 'Also update the README',});expect(requests[2]?.url).toBe(+ `https://agent.example.test/agent-sessions/${sessionId}/queue/${actionId}/steer`+ );+ expect(requests[2]?.headers.get('authorization')).toBe('Bearer user-token');+ expect(requests[3]?.url).toBe(`https://agent.example.test/agent-sessions/${sessionId}/queue/${actionId}`);});diff --git a/services/agent_harness_service/src/api/swagger.rs b/services/agent_harness_service/src/api/swagger.rsindex 34adabee36..6fc103f4c9 100644--- a/services/agent_harness_service/src/api/swagger.rs+++ b/services/agent_harness_service/src/api/swagger.rs@@ -72,6 +72,7 @@ impl Modify for SecurityAddon {axum_router::get_agent_session_queue_handler,axum_router::edit_queued_action_handler,axum_router::remove_queued_action_handler,+ axum_router::steer_queued_action_handler,axum_router::delete_agent_session_handler,axum_router::put_agent_session_sandbox_size_handler,axum_router::get_agent_sandbox_size_handler,diff --git a/services/agent_harness_service/src/main.rs b/services/agent_harness_service/src/main.rsindex 5f84446fe1..96e4bad89f 100644--- a/services/agent_harness_service/src/main.rs+++ b/services/agent_harness_service/src/main.rs@@ -1376,6 +1376,7 @@ async fn run() -> anyhow::Result<()> {// HTTP, and the turn signals are the harness's own.HarnessCommand::EditQueued { .. }| HarnessCommand::RemoveQueued { .. }+ | HarnessCommand::SteerQueued { .. }| HarnessCommand::Turn(_)| HarnessCommand::SessionStopped { .. } => "agent_trigger.unexpected",};