Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(agent): confirm model and effort before the first prompt (#6388)

Eric Hayesc966b79d4079
diff --git a/apps/web/src/features/agents-view/views/AgentPicker.tsx b/apps/web/src/features/agents-view/views/AgentPicker.tsx
index 4f4f07d2c9..4b98310b04 100644
--- a/apps/web/src/features/agents-view/views/AgentPicker.tsx
+++ b/apps/web/src/features/agents-view/views/AgentPicker.tsx
@@ -1,6 +1,7 @@
import { ModelCatalogMenu } from '@core/component/AI/component/input/ModelCatalogPicker';
import { ProviderIcon } from '@core/component/AI/component/ProviderIcon';
import { modelLabel } from '@core/component/AI/constant/model-label';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
import CaretDownIcon from '@phosphor/caret-down.svg';
import CaretRightIcon from '@phosphor/caret-right.svg';
import CheckIcon from '@phosphor/check.svg';
@@ -8,6 +9,11 @@ import CodeIcon from '@phosphor/code.svg';
import PlusIcon from '@phosphor/plus.svg';
import { Dropdown } from '@ui';
import { createSignal, For, Show } from 'solid-js';
+import { AgentModelMenuItem } from '../../block-agent/component/AgentModelMenuItem';
+import type {
+ EffortChoice,
+ EffortSelection,
+} from '../../block-agent/state/session-config';
import { AgentIcon } from '../components/AgentGlyph';
import {
MACRO_PERSONA_ID,
@@ -22,7 +28,15 @@ export function AgentPicker(props: {
selected?: RosterAgent;
modelOverride?: string;
loading: boolean;
+ effortLabel?: string;
+ effortSelection?: EffortSelection;
onSelect: (agent: RosterAgent, model?: string) => void;
+ /** Supply only when the host can persist and apply effort selections. */
+ onSelectEffort?: (
+ agent: RosterAgent,
+ model: string,
+ effort: EffortChoice
+ ) => void;
onConnect: (agent: RosterAgent) => void;
onCreate: () => void;
}) {
@@ -37,15 +51,25 @@ export function AgentPicker(props: {
props.modelOverride ??
props.selected?.defaultModel ??
catalog.currentModel();
- const label = () =>
+ const baseLabel = () =>
modelLabel(
model(),
catalog.models().find((option) => option.id === model())?.name
);
+ const label = () =>
+ [baseLabel(), props.effortLabel].filter(Boolean).join(' · ');
const choose = (agent: RosterAgent, model?: string) => {
props.onSelect(agent, model);
setOpen(false);
};
+ const chooseEffort = (
+ agent: RosterAgent,
+ model: string,
+ effort: EffortChoice
+ ) => {
+ props.onSelectEffort?.(agent, model, effort);
+ setOpen(false);
+ };
return (
<Dropdown open={open()} onOpenChange={setOpen} placement="top-end">
<Dropdown.Trigger
@@ -107,6 +131,24 @@ export function AgentPicker(props: {
group: option.group ?? undefined,
}))}
onSelect={(id) => choose(agent(), id)}
+ modelRow={
+ props.onSelectEffort
+ ? (row) => (
+ <AgentModelMenuItem
+ {...row}
+ harness={agent().harness}
+ effortValue={
+ row.selected
+ ? props.effortSelection?.value
+ : undefined
+ }
+ onSelectEffort={(effort) =>
+ chooseEffort(agent(), row.option.id, effort)
+ }
+ />
+ )
+ : undefined
+ }
emptyMessage={macroCatalog.message()}
/>
)}
@@ -128,7 +170,18 @@ export function AgentPicker(props: {
? props.modelOverride
: undefined
}
+ effortSelection={
+ agent.id === props.selected?.id
+ ? props.effortSelection
+ : undefined
+ }
onSelect={(model) => choose(agent, model)}
+ onSelectEffort={
+ props.onSelectEffort
+ ? (model, effort) =>
+ chooseEffort(agent, model, effort)
+ : undefined
+ }
onConnect={() => {
setOpen(false);
props.onConnect(agent);
@@ -171,7 +224,9 @@ function AgentPickerRow(props: {
agent: RosterAgent;
selected: boolean;
modelOverride?: string;
+ effortSelection?: EffortSelection;
onSelect: (model?: string) => void;
+ onSelectEffort?: (model: string, effort: EffortChoice) => void;
onConnect: () => void;
}) {
const [open, setOpen] = createSignal(false);
@@ -209,11 +264,13 @@ function AgentPickerRow(props: {
</Dropdown.Item>
}
>
- <Dropdown.Sub open={open()} onOpenChange={setOpen}>
+ <Dropdown.Sub open={open()} onOpenChange={setOpen} overlap>
<Dropdown.SubTrigger
class="min-w-0 flex-1 gap-2"
textValue={props.agent.name}
- onClick={() => props.onSelect()}
+ onClick={() => {
+ if (!isTouchDevice()) props.onSelect();
+ }}
onKeyDown={(event) => {
if (event.key !== 'Enter' && event.key !== ' ') return;
event.preventDefault();
@@ -235,7 +292,9 @@ function AgentPickerRow(props: {
<AgentModels
agent={props.agent}
modelOverride={props.modelOverride}
+ effortSelection={props.effortSelection}
onSelect={props.onSelect}
+ onSelectEffort={props.onSelectEffort}
/>
</Show>
</Dropdown.SubContent>
@@ -248,7 +307,9 @@ function AgentPickerRow(props: {
function AgentModels(props: {
agent: RosterAgent;
modelOverride?: string;
+ effortSelection?: EffortSelection;
onSelect: (model?: string) => void;
+ onSelectEffort?: (model: string, effort: EffortChoice) => void;
}) {
const catalog = createComposerModels(() => props.agent);
const defaultModel = () => props.agent.defaultModel ?? catalog.currentModel();
@@ -263,6 +324,22 @@ function AgentModels(props: {
group: option.group ?? undefined,
}))}
onSelect={props.onSelect}
+ modelRow={
+ props.onSelectEffort
+ ? (row) => (
+ <AgentModelMenuItem
+ {...row}
+ harness={props.agent.harness}
+ effortValue={
+ row.selected ? props.effortSelection?.value : undefined
+ }
+ onSelectEffort={(effort) =>
+ props.onSelectEffort?.(row.option.id, effort)
+ }
+ />
+ )
+ : undefined
+ }
emptyMessage={catalog.message()}
/>
);
diff --git a/apps/web/src/features/agents-view/views/AgentsView.tsx b/apps/web/src/features/agents-view/views/AgentsView.tsx
index b522dbbe76..4ec78a09c1 100644
--- a/apps/web/src/features/agents-view/views/AgentsView.tsx
+++ b/apps/web/src/features/agents-view/views/AgentsView.tsx
@@ -202,13 +202,8 @@ function AgentsWorkspace(props: { initialRoute?: AgentsRoute }) {
};
const startConversation = (start: StartConversation) => {
const id = startPendingSession({
- botId: start.botId,
+ ...start,
userId: userId(),
- prompt: start.prompt,
- attachments: start.attachments,
- modelOverride: start.modelOverride,
- repoUrl: start.repoUrl,
- repoBranch: start.repoBranch,
});
openConversation(
{ id, type: 'agent_session' },
diff --git a/apps/web/src/features/agents-view/views/NewChatPage.test.tsx b/apps/web/src/features/agents-view/views/NewChatPage.test.tsx
index e2aa5254f1..931cfb7582 100644
--- a/apps/web/src/features/agents-view/views/NewChatPage.test.tsx
+++ b/apps/web/src/features/agents-view/views/NewChatPage.test.tsx
@@ -17,6 +17,7 @@ import { NewChatPage } from './NewChatPage';
const mocks = vi.hoisted(() => ({
openSettings: vi.fn(),
+ capabilitiesPending: false,
attachments: [] as InputAttachmentData[],
recentIds: [] as string[],
recentUrls: [] as string[],
@@ -71,6 +72,35 @@ vi.mock('../queries/repository-branches', () => ({
}));
vi.mock('../components/AgentGlyph', () => ({ AgentIcon: () => <span /> }));
+vi.mock('@queries/agents/capabilities', () => ({
+ useAgentCapabilitiesQuery: (
+ target: () => { model?: string } | undefined
+ ) => ({
+ get isSuccess() {
+ return !mocks.capabilitiesPending;
+ },
+ isFetching: false,
+ get data() {
+ if (target()?.model !== 'gpt-5') return { configOptions: [] };
+ return {
+ configOptions: [
+ {
+ id: 'cursor_effort',
+ name: 'Effort',
+ category: 'thought_level',
+ type: 'select',
+ currentValue: 'low',
+ options: [
+ { value: 'low', name: 'Low' },
+ { value: 'ultra', name: 'Ultra' },
+ ],
+ },
+ ],
+ };
+ },
+ }),
+}));
+
vi.mock('@queries/agents/models', () => ({
useAgentModelsQueries: (targets: () => { harness: string }[]) => [
{
@@ -218,6 +248,7 @@ async function hoverAgent(name: string) {
describe('agent-led new conversation', () => {
let motionStyles: HTMLStyleElement;
beforeEach(() => {
+ mocks.capabilitiesPending = false;
mocks.attachments = [];
mocks.recentIds = [MACRO_CODER_BOT_ID];
mocks.recentUrls = [];
@@ -602,6 +633,7 @@ describe('agent-led new conversation', () => {
selected={macro}
loading={false}
onSelect={onSelect}
+ onSelectEffort={onSelect}
onConnect={vi.fn()}
onCreate={vi.fn()}
/>
@@ -659,6 +691,36 @@ describe('agent-led new conversation', () => {
);
expect(screen.getByTestId('drawer').hasAttribute('hidden')).toBe(true);
});
+ it('passes opaque effort and clears it with the model override after sending', async () => {
+ const send = page();
+ const models = await hoverAgent('Cursor');
+ fireEvent.keyDown(models.getByRole('menuitem', { name: /^GPT-5/ }), {
+ key: 'ArrowRight',
+ });
+ await screen.findByRole('menuitem', { name: 'Ultra' });
+ fireEvent.keyDown(screen.getByRole('menuitem', { name: 'Ultra' }), {
+ key: 'Enter',
+ });
+ await waitFor(() => expect(screen.queryByRole('menu')).toBeNull());
+ mocks.capabilitiesPending = true;
+ expect(screen.getByRole('button', { name: 'Agent' }).textContent).toContain(
+ 'GPT-5 · Ultra'
+ );
+ fireEvent.click(screen.getByRole('button', { name: 'Send' }));
+ expect(send).toHaveBeenLastCalledWith(
+ expect.objectContaining({
+ modelOverride: 'gpt-5',
+ effortOverride: { configId: 'cursor_effort', value: 'ultra' },
+ })
+ );
+ expect(
+ screen.queryByRole('button', { name: 'Reasoning effort' })
+ ).toBeNull();
+ fireEvent.click(screen.getByRole('button', { name: 'Send' }));
+ expect(send).toHaveBeenLastCalledWith(
+ expect.objectContaining({ effortOverride: undefined })
+ );
+ });
});
it('starts a conversation with an uploaded image and no text', () => {
diff --git a/apps/web/src/features/agents-view/views/NewChatPage.tsx b/apps/web/src/features/agents-view/views/NewChatPage.tsx
index c738ecbaef..802c553487 100644
--- a/apps/web/src/features/agents-view/views/NewChatPage.tsx
+++ b/apps/web/src/features/agents-view/views/NewChatPage.tsx
@@ -8,8 +8,14 @@ import {
import { useSettingsState } from '@core/constant/SettingsState';
import { useUserId } from '@core/context/user';
import { uploadFile } from '@core/util/upload';
+import { useAgentCapabilitiesQuery } from '@queries/agents/capabilities';
import type { PromptAttachment } from '@service-agent-harness/generated/schemas';
import { createMemo, createSignal } from 'solid-js';
+import {
+ type EffortChoice,
+ effortConfigOption,
+ effortLabel,
+} from '../../block-agent/state/session-config';
import { ChatComposer } from '../components/ChatComposer';
import type { AgentKind } from '../core/agent-kind';
import { defaultBranchFor } from '../core/repository';
@@ -35,6 +41,7 @@ export type StartConversation = {
repoUrl?: string;
repoBranch?: string;
modelOverride?: string;
+ effortOverride?: { configId: string; value: string };
};
/** One agent choice determines the session kind, default model, and repository context. */
@@ -104,6 +111,41 @@ export function NewChatPage(props: {
}
return modelOverride();
};
+ const capabilityTarget = () => {
+ const agent = selected();
+ const harness =
+ agent?.harness === 'macro-inmem' ? 'in-memory' : agent?.harness;
+ if (harness !== 'in-memory' && harness !== 'cursor') return undefined;
+ return {
+ harness,
+ model: composerModelOverride() ?? agent?.defaultModel,
+ } as const;
+ };
+ const capabilities = useAgentCapabilitiesQuery(capabilityTarget);
+ const effort = () =>
+ effortConfigOption(
+ capabilities.isSuccess ? capabilities.data.configOptions : []
+ );
+ const [effortSelection, setEffortSelection] = createSignal<{
+ target: string;
+ configId: string;
+ value: string;
+ name: string;
+ }>();
+ const selectedEffort = () => {
+ const selection = effortSelection();
+ return selection?.target === JSON.stringify(capabilityTarget())
+ ? selection
+ : undefined;
+ };
+ // The submenu already validated this choice. Retain it while the selected
+ // model's discovery refreshes; startup revalidates against the runtime.
+ const effortOverride = () => {
+ const selection = selectedEffort();
+ return selection
+ ? { configId: selection.configId, value: selection.value }
+ : undefined;
+ };
const coding = () => selected()?.kind === 'coder';
// The create-session API accepts explicit repositories only for Cursor.
const canSelectRepository = () => selected()?.harness === 'cursor';
@@ -167,10 +209,33 @@ export function NewChatPage(props: {
repoUrl: repo,
...(repo ? { repoBranch: repoBranch() } : {}),
...(model ? { modelOverride: model } : {}),
+ effortOverride: effortOverride(),
});
attachmentTracker.clearAttachments();
// Macro's preferred model stays; coding-agent submenu picks are one-shot.
setModelOverride(undefined);
+ setEffortSelection(undefined);
+ };
+
+ const selectAgent = (
+ agent: RosterAgent,
+ model?: string,
+ selection?: EffortChoice
+ ) => {
+ setAgentId(agent.id);
+ if (agent.id === MACRO_PERSONA_ID) {
+ if (model) preferredInmem.remember(model);
+ // Still set the override so the trigger updates when Macro was
+ // already selected (agent id unchanged would otherwise skip a render).
+ setModelOverride(model);
+ } else {
+ setModelOverride(model);
+ }
+ setEffortSelection(
+ selection
+ ? { ...selection, target: JSON.stringify(capabilityTarget()) }
+ : undefined
+ );
};
const agentSelector = () => (
@@ -179,17 +244,10 @@ export function NewChatPage(props: {
selected={selected()}
modelOverride={composerModelOverride()}
loading={props.rosterLoading}
- onSelect={(agent, model) => {
- setAgentId(agent.id);
- if (agent.id === MACRO_PERSONA_ID) {
- if (model) preferredInmem.remember(model);
- // Still set the override so the trigger updates when Macro was
- // already selected (agent id unchanged would otherwise skip a render).
- setModelOverride(model);
- return;
- }
- setModelOverride(model);
- }}
+ effortLabel={selectedEffort()?.name ?? effortLabel(effort())}
+ effortSelection={effortOverride()}
+ onSelect={selectAgent}
+ onSelectEffort={selectAgent}
onConnect={connect}
onCreate={() => props.onOpenRoster(coding() ? 'coder' : 'agent')}
/>
diff --git a/apps/web/src/features/block-agent/context/pending-session.ts b/apps/web/src/features/block-agent/context/pending-session.ts
index e743caf8bb..1b0f71a54b 100644
--- a/apps/web/src/features/block-agent/context/pending-session.ts
+++ b/apps/web/src/features/block-agent/context/pending-session.ts
@@ -29,6 +29,8 @@ import type {
} from '@service-agent-harness/generated/schemas';
import { type Accessor, createSignal } from 'solid-js';
import { v7 as uuidv7 } from 'uuid';
+import { effortConfigOption } from '../state/session-config';
+import { confirmSessionControl } from './confirm-session-control';
export type PendingSession = {
/** The session's id, once the create has made it real. */
@@ -60,6 +62,8 @@ export type StartPendingSessionOptions = {
userId?: string;
/** Model to run on instead of the persona's, set as the session is created. */
modelOverride?: string;
+ /** Opaque harness setting confirmed before the first prompt. */
+ effortOverride?: { configId: string; value: string };
/**
* Explicit GitHub repository for the managed Cursor session.
*/
@@ -105,39 +109,80 @@ export function startPendingSession(
);
return;
}
- // Normally the id this tab minted; a service that predates the field
- // mints its own, and the block adopts that one the way it always did.
+ // Normally the id this tab minted; an older service may mint its own.
const created = result.value.session.id;
void refetchSoupEntity(created, 'agentSession', { created: true });
- // The block adopts the session the moment it exists. The first prompt
- // then goes through the shared session like any other, so it is folded
- // speculatively - bubble and working line on screen at once - while
- // the control POST waits out the runtime handshake. Delivering it
- // first and adopting after left the transcript empty for that wait.
- setSessionId(created);
+ // Hold the block in preflight while selected settings are confirmed,
+ // then adopt the session before issuing the first prompt so that prompt
+ // is folded speculatively while its POST is in flight.
const prompt = options.prompt?.trim() ?? '';
- if (prompt || options.attachments?.length) {
+ if (
+ options.modelOverride ||
+ options.effortOverride ||
+ prompt ||
+ options.attachments?.length
+ ) {
const session = AgentSession.acquire(created);
try {
- const delivered = await session.issue(
- {
- type: 'prompt',
- prompt,
- ...(options.attachments?.length
- ? { attachments: options.attachments }
- : {}),
- },
- { userId: options.userId }
- );
- if (delivered.isErr()) {
- setError(
- delivered.error.map((error) => error.message).join(' ') ||
- 'The first message could not be sent.'
+ if (options.modelOverride || options.effortOverride) {
+ await session.load();
+ if (options.modelOverride) {
+ await confirmSessionControl(session, {
+ type: 'setModel',
+ model: options.modelOverride,
+ });
+ }
+ if (options.effortOverride) {
+ const snapshot = await session.snapshot();
+ const effort = effortConfigOption(
+ snapshot.metadata.configOptions
+ );
+ if (
+ effort?.id !== options.effortOverride.configId ||
+ !effort.options.some(
+ (option) => option.value === options.effortOverride?.value
+ )
+ ) {
+ throw new Error(
+ 'The selected effort is no longer available for this model.'
+ );
+ }
+ await confirmSessionControl(session, {
+ type: 'setConfigOption',
+ ...options.effortOverride,
+ });
+ }
+ }
+ setSessionId(created);
+ if (prompt || options.attachments?.length) {
+ const delivered = await session.issue(
+ {
+ type: 'prompt',
+ prompt,
+ ...(options.attachments?.length
+ ? { attachments: options.attachments }
+ : {}),
+ },
+ { userId: options.userId }
);
+ if (delivered.isErr()) {
+ setError(
+ delivered.error.map((error) => error.message).join(' ') ||
+ 'The first message could not be sent.'
+ );
+ }
}
+ } catch (error) {
+ setError(
+ error instanceof Error
+ ? error.message
+ : 'The selected settings could not be applied.'
+ );
} finally {
session.release();
}
+ } else {
+ setSessionId(created);
}
})
.catch(() =>
diff --git a/apps/web/src/features/block-agent/context/resolve-session-id.test.ts b/apps/web/src/features/block-agent/context/resolve-session-id.test.ts
index 569fad3bd7..68cb7afd6f 100644
--- a/apps/web/src/features/block-agent/context/resolve-session-id.test.ts
+++ b/apps/web/src/features/block-agent/context/resolve-session-id.test.ts
@@ -5,6 +5,7 @@
* in for one being created — resolved into the one the block consumes.
*/
+import type { AgentAction } from '@service-agent-harness/generated/schemas';
import { createRoot } from 'solid-js';
import { beforeEach, describe, expect, it, vi } from 'vitest';
@@ -12,6 +13,9 @@ const create = vi.hoisted(() => ({
resolve: undefined as ((id?: string) => void) | undefined,
reject: undefined as (() => void) | undefined,
control: vi.fn(),
+ autoConfirm: true,
+ confirm: undefined as ((error?: string) => void) | undefined,
+ release: vi.fn(),
}));
vi.mock('@service-agent-harness/client', () => ({
@@ -37,14 +41,63 @@ vi.mock('@service-agent-harness/client', () => ({
},
}));
-// The first prompt goes through the shared session so it is folded
-// speculatively; here that is just the control POST under the session's id.
vi.mock('@core/agent-session/AgentSession', () => ({
AgentSession: {
- acquire: (id: string) => ({
- issue: (action: unknown) => create.control(id, action),
- release: () => {},
- }),
+ acquire: (id: string) => {
+ let requestId: string | undefined;
+ let outcome: { kind: string; message?: string } = { kind: 'pending' };
+ let listener: (() => void) | undefined;
+ create.confirm = (error) => {
+ outcome = error
+ ? { kind: 'rejected', message: error }
+ : { kind: 'accepted' };
+ listener?.();
+ };
+ return {
+ load: async () => {},
+ issue: async (action: AgentAction) => {
+ const result = await create.control(id, action);
+ if (!result.isErr()) {
+ requestId = result.value.actionId;
+ outcome = { kind: create.autoConfirm ? 'accepted' : 'pending' };
+ }
+ return result;
+ },
+ snapshot: async () => ({
+ messages: requestId
+ ? [
+ {
+ requestId,
+ pending: false,
+ parts: [{ kind: 'control', outcome }],
+ },
+ ]
+ : [],
+ metadata: {
+ configOptions: [
+ {
+ id: 'effort',
+ name: 'Effort',
+ category: 'thought_level',
+ type: 'select',
+ currentValue: 'low',
+ options: [
+ { value: 'low', name: 'Low' },
+ { value: 'ultra', name: 'Ultra' },
+ ],
+ },
+ ],
+ },
+ }),
+ subscribe: (callback: () => void) => {
+ listener = callback;
+ return () => {
+ listener = undefined;
+ };
+ },
+ release: create.release,
+ };
+ },
},
}));
@@ -57,7 +110,12 @@ const { resolveSessionId } = await import('./resolve-session-id');
/** Let the mocked create's `.then` run. */
const flush = () => new Promise((resolve) => setTimeout(resolve, 0));
-beforeEach(() => create.control.mockReset());
+beforeEach(() => {
+ create.control.mockReset();
+ create.release.mockReset();
+ create.autoConfirm = true;
+ create.confirm = undefined;
+});
describe('a block id that is already a session', () => {
it('resolves to itself, never pending', () => {
@@ -118,9 +176,8 @@ describe('an id whose create is in flight', () => {
});
});
- // A model chosen before the session exists is what the session is created
- // on, not something switched afterwards: the first prompt is the only thing
- // sent, so it opens the session's first turn and the session gets a name.
+ // A model chosen before the session exists is sent at creation and confirmed
+ // before the first prompt, so that prompt runs on the requested model.
it('creates the session on the chosen model', async () => {
create.control.mockResolvedValue({
isErr: () => false,
@@ -147,6 +204,7 @@ describe('an id whose create is in flight', () => {
await flush();
expect(create.control.mock.calls).toEqual([
+ [placeholder, { type: 'setModel', model: 'model-2' }],
[placeholder, { type: 'prompt', prompt: 'Fix the tests' }],
]);
expect(resolved.sessionId()).toBe(placeholder);
@@ -182,6 +240,90 @@ describe('an id whose create is in flight', () => {
});
});
+ it('shows a model failure without sending the prompt on the wrong model', async () => {
+ create.control.mockResolvedValue({
+ isErr: () => true,
+ error: [{ code: 'HTTP_ERROR', message: 'Model is unavailable.' }],
+ });
+ const placeholder = startPendingSession({
+ modelOverride: 'missing',
+ prompt: 'Hello',
+ });
+ await createRoot(async (dispose) => {
+ const resolved = resolveSessionId(() => placeholder);
+ create.resolve?.('session-model-error');
+ await flush();
+ expect(resolved.error()).toBe('Model is unavailable.');
+ expect(resolved.pending()).toBe(false);
+ expect(create.control).toHaveBeenCalledTimes(1);
+ dispose();
+ });
+ });
+
+ it('waits for model and effort confirmation before sending the first prompt', async () => {
+ create.autoConfirm = false;
+ create.control.mockResolvedValue({
+ isErr: () => false,
+ value: { actionId: 'control', status: 'accepted' },
+ });
+ const placeholder = startPendingSession({
+ modelOverride: 'model-2',
+ effortOverride: { configId: 'effort', value: 'ultra' },
+ prompt: 'Hello',
+ });
+ await createRoot(async (dispose) => {
+ const resolved = resolveSessionId(() => placeholder);
+ create.resolve?.('session-confirm');
+ await flush();
+ expect(create.control.mock.calls).toEqual([
+ ['session-confirm', { type: 'setModel', model: 'model-2' }],
+ ]);
+ expect(resolved.pending()).toBe(true);
+ create.confirm?.();
+ await flush();
+ expect(create.control.mock.calls).toEqual([
+ ['session-confirm', { type: 'setModel', model: 'model-2' }],
+ [
+ 'session-confirm',
+ { type: 'setConfigOption', configId: 'effort', value: 'ultra' },
+ ],
+ ]);
+ expect(resolved.pending()).toBe(true);
+ create.confirm?.();
+ await flush();
+ expect(create.control).toHaveBeenLastCalledWith('session-confirm', {
+ type: 'prompt',
+ prompt: 'Hello',
+ });
+ expect(resolved.sessionId()).toBe('session-confirm');
+ expect(create.release).toHaveBeenCalledOnce();
+ dispose();
+ });
+ });
+
+ it('does not send the prompt when the runtime rejects an HTTP-accepted change', async () => {
+ create.autoConfirm = false;
+ create.control.mockResolvedValue({
+ isErr: () => false,
+ value: { actionId: 'control', status: 'accepted' },
+ });
+ const placeholder = startPendingSession({
+ effortOverride: { configId: 'effort', value: 'ultra' },
+ prompt: 'Hello',
+ });
+ await createRoot(async (dispose) => {
+ const resolved = resolveSessionId(() => placeholder);
+ create.resolve?.('session-reject');
+ await flush();
+ create.confirm?.('Effort is unavailable.');
+ await flush();
+ expect(resolved.error()).toBe('Effort is unavailable.');
+ expect(create.control).toHaveBeenCalledTimes(1);
+ expect(create.release).toHaveBeenCalledOnce();
+ dispose();
+ });
+ });
+
it('shows the first prompt failure', async () => {
create.control.mockResolvedValue({
isErr: () => true,
diff --git a/docs/AGENT_EFFORT.md b/docs/AGENT_EFFORT.md
index 0e7f339662..bce0e6c320 100644
--- a/docs/AGENT_EFFORT.md
+++ b/docs/AGENT_EFFORT.md
@@ -46,8 +46,12 @@ Sources checked September 21, 2026:
- `POST /agent-capabilities/discover` accepts a selected model for Cursor and
in-memory. The existing `/agent-models/load` API remains available.
-- Capability cache identity includes the harness and model. External harnesses
- expose controls after opening a session; model-specific preflight is not guessed.
+- Preflight capability cache identity includes the harness and model. A selection
+ from another target is discarded. External harnesses expose controls after
+ opening a session; model-specific preflight is not guessed.
+- Startup waits for the correlated ACP acceptance of the model, checks the
+ resulting effort choices, then confirms effort before sending the prompt.
+ HTTP queue acceptance alone is insufficient. Rejection or timeout stops startup.
- New/resumed sessions and setting changes return the complete configuration.
Clients replace their previous options, including removing unsupported controls.
- In-memory rejects unsupported models and effort values. A model change resets
@@ -85,7 +89,7 @@ an external harness result.
## Model menu interaction
-Effort is a submenu of each model in running-session selectors.
+Effort is a submenu of each model in new-chat and running-session selectors.
Discovery runs when the submenu opens, scoped to that model and harness;
the current session's advertised options take precedence for its selected model.
The trigger displays the model and selected effort together. Keyboard Right Arrow
@@ -95,4 +99,6 @@ no effort options keep ordinary model selection available.
A combined running-session selection waits for the model's correlated ACP
confirmation, validates effort against the new snapshot, then confirms effort.
A model rejection prevents the effort request. An effort rejection leaves the
-accepted model in place and reports the failure.
+accepted model in place and reports the failure. New-chat choices remain bound
+to their model while discovery refreshes, so immediately sending cannot silently
+drop a selected effort.
diff --git a/docs/AGENT_GUIDE/ai-chat.md b/docs/AGENT_GUIDE/ai-chat.md
index b042ac132c..0d282bc083 100644
--- a/docs/AGENT_GUIDE/ai-chat.md
+++ b/docs/AGENT_GUIDE/ai-chat.md
@@ -982,7 +982,13 @@ again. If the model succeeds but effort is rejected, the new model remains
selected with its confirmed effort; the error is shown and no unsupported
setting is presented as accepted.
-See [effort capabilities](../AGENT_EFFORT.md) for the harness contracts and test coverage.
+New conversations confirm selected model and effort settings before sending the
+first message. If startup reports a rejected setting or timeout, the first prompt
+has not been sent. See [effort capabilities](../AGENT_EFFORT.md) for the harness
+contracts and test coverage.
+
+Routine model/agent pickers retain model-only selection: they do not offer effort
+choices, because routine targets do not save an effort setting.
## Reading skills
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index 61e8cf661a..64df6b979a 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -1654,4 +1654,7 @@ again. If the model succeeds but effort is rejected, the new model remains
selected with its confirmed effort; the error is shown and no unsupported
setting is presented as accepted.
-See [effort capabilities](../AGENT_EFFORT.md) for the harness contracts and test coverage.
+New conversations confirm selected model and effort settings before sending the
+first message. If startup reports a rejected setting or timeout, the first prompt
+has not been sent. See [effort capabilities](../AGENT_EFFORT.md) for the harness
+contracts and test coverage.