Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
fix: group Antigravity models and refresh effort choices (#34518)
Brennan Benson00de405c5c0c
diff --git a/mobile/src/session/use-mobile-structured-agent-options.test.ts b/mobile/src/session/use-mobile-structured-agent-options.test.tsindex fc05245019d..8a2f6b02bb4 100644--- a/mobile/src/session/use-mobile-structured-agent-options.test.ts+++ b/mobile/src/session/use-mobile-structured-agent-options.test.ts@@ -545,6 +545,52 @@ describe('useMobileStructuredAgentOptions after a lost pick reply', () => {})})+it('joins the post-receipt menu read with an unchanged phone option stamp', async () => {+ const initial: AgentSessionOptionsResult = {+ models: [{ id: 'family', label: 'Family', isDefault: false, efforts: [], effortsKnown: false }],+ current: { model: 'family' }+ }+ const ready = deferred<AgentSessionOptionsResult>()+ let reads = 0+ const client = optionsClient(() => (++reads === 1 ? Promise.resolve(initial) : ready.promise))+ const { mutate } = recordingMutate(async () =>+ accepted({ key: 'model', value: 'family', options: { model: 'family' } }, true)+ )+ const harness = await mountOptions({+ ...BASE,+ agent: 'antigravity',+ client: client.client,+ mutate,+ optionStamp: 'family|own'+ })+ expect(descriptorFor(harness.current().optionSnapshot, 'effort')).toBeUndefined()+ await act(async () => {+ expect(await harness.current().setStructuredOption('model', 'family')).toBe(true)+ })+ expect(descriptorFor(harness.current().optionSnapshot, 'model')?.settable).toBe(true)+ await act(async () => {+ ready.resolve({+ ...initial,+ models: [+ {+ id: 'family',+ label: 'Family',+ isDefault: false,+ efforts: [+ { value: 'low', label: 'Low' },+ { value: 'high', label: 'High' }+ ]+ }+ ],+ current: { model: 'family', effort: 'low' }+ })+ })+ await settle()+ expect(currentValueOf(harness.current().optionSnapshot, 'effort')).toBe('low')+ expect(descriptorFor(harness.current().optionSnapshot, 'effort')?.settable).toBe(true)+ await harness.unmount()+})+it('phone retains a queried seed-catalog base across its fence until later metadata arrives', async () => {const catalog = deferred<AgentSessionModelCatalogResult>()let reads = 0diff --git a/src/main/acp/acp-dialects/acp-dialect.ts b/src/main/acp/acp-dialects/acp-dialect.tsindex eb32dfcef18..0af70062ba4 100644--- a/src/main/acp/acp-dialects/acp-dialect.ts+++ b/src/main/acp/acp-dialects/acp-dialect.ts@@ -107,8 +107,6 @@ export type AcpDialect = {): { sessionId: string; promptId: string; stopReason: string } | undefinedcontextWindow?(models: unknown): number | undefinedmodelEfforts?(model: ModelInfo): { efforts: AgentSessionOptionChoice[]; defaultEffort?: string }- /** The agent clamps an effort another model lacks, so unlisted models' menus are unknown, not empty. */- clampsUnlistedEffort?: true/** Claimed permission requests are never auto-approved. */request?(method: string, params: unknown): AcpRequestPresentation | undefinedsettleRequest?(method: string, params: unknown): AcpRequestSettlement | undefineddiff --git a/src/main/acp/acp-dialects/omp-dialect.ts b/src/main/acp/acp-dialects/omp-dialect.tsindex 99ea622010c..7af2b20e536 100644--- a/src/main/acp/acp-dialects/omp-dialect.ts+++ b/src/main/acp/acp-dialects/omp-dialect.ts@@ -113,8 +113,6 @@ function errorDetails(error: AcpAgentError): string | undefined {}export const OMP_ACP_DIALECT: AcpDialect = {- // OMP resolves any thinking level against the selected model (model-controls.ts setThinkingLevel).- clampsUnlistedEffort: true,normalizeToolUpdate,compactionReply,authenticationRequired: (error) => {diff --git a/src/main/acp/acp-session-option-write.ts b/src/main/acp/acp-session-option-write.tsindex 2737c053311..1063284a78e 100644--- a/src/main/acp/acp-session-option-write.ts+++ b/src/main/acp/acp-session-option-write.ts@@ -7,7 +7,14 @@ export function writeAcpSessionOption(connection: Pick<AcpStructuredConnection, 'setConfigOption' | 'setModel'>,options: AcpStructuredOptions,write: AcpOptionWrite,- bound: { agent: string; timeoutMs: number; signal?: AbortSignal; key: string; value: string }+ bound: {+ agent: string+ timeoutMs: number+ signal?: AbortSignal+ key: string+ value: string+ onUncertain?: (error: Error) => void+ }): Promise<void> {const { agent, timeoutMs, signal } = boundif (signal?.aborted) {@@ -22,20 +29,30 @@ export function writeAcpSessionOption(apply()options.appliedInput.set(bound.key, write.method === 'config' ? write.value : write.modelId)}+ let completed = falseconst applied =write.method === 'config'- ? connection- .setConfigOption(write.configId, write.value)- .then((result) => adopt(() => options.adoptConfigOptions(result.configOptions)))- : connection- .setModel(write.modelId)- .then(() => adopt(() => options.adoptModel(write.modelId)))+ ? connection.setConfigOption(write.configId, write.value).then((result) => {+ completed = true+ adopt(() => options.adoptConfigOptions(result.configOptions))+ })+ : connection.setModel(write.modelId).then(() => {+ completed = true+ adopt(() => options.adoptModel(write.modelId))+ })+ void applied.catch(() => {+ completed = true+ })return new Promise<void>((resolve, reject) => {const fail = (error: Error): void => {if (options.writeRevision === revision) {options.writeRevision += 1}settle()+ // A local deadline/abort cannot cancel an already-sent native control.+ if (!completed) {+ bound.onUncertain?.(error)+ }reject(error)}const onAbort = (): void => {diff --git a/src/main/acp/acp-structured-child.ts b/src/main/acp/acp-structured-child.tsindex 412bb82a57f..7301388b728 100644--- a/src/main/acp/acp-structured-child.ts+++ b/src/main/acp/acp-structured-child.ts@@ -1,5 +1,6 @@import type { SubmissionRejectionFact } from '../../shared/agent-session-failure'import type { StructuredAgentSessionProviderOpenResult } from '../native-chat/agent-session-wire/structured-agent-session-provider-open-contract'+import type { StructuredAgentSessionSetOptionInput } from '../native-chat/agent-session-wire/structured-agent-session-adapter'import { AcpAgentError } from './acp-errors'import { acpAuthenticationRequired, acpSignInRequiredFailure } from './acp-turn-failures'import type { AcpStructuredSession } from './acp-structured-session'@@ -34,6 +35,22 @@ export function isAcpReadySession(return session != null && session.lane !== null && session.turns !== null}+export function canSetAcpOptionWhileIdle(+ session: AcpStructuredChild | undefined,+ input: StructuredAgentSessionSetOptionInput+): boolean {+ return !!(+ session &&+ isAcpReadySession(session) &&+ session.fence === input.fence &&+ session.journalClosed === null &&+ !session.closeRequested &&+ !session.turns.running &&+ input.key === 'model' &&+ session.options.write('model', input.value)?.method === 'config'+ )+}+export function acpStartupFailure(session: AcpStructuredChild,error: unknowndiff --git a/src/main/acp/acp-structured-host-model-options.test.ts b/src/main/acp/acp-structured-host-model-options.test.tsnew file mode 100644index 00000000000..8995e818f4e--- /dev/null+++ b/src/main/acp/acp-structured-host-model-options.test.ts@@ -0,0 +1,744 @@+import { readFileSync } from 'node:fs'+import { join } from 'node:path'+import { afterEach, expect, it, onTestFinished, vi } from 'vitest'+import {+ NewSessionResponseSchema,+ ResumeSessionRequestSchema,+ SessionConfigValueIdSchema,+ SetSessionConfigOptionRequestSchema,+ SetSessionConfigOptionResponseSchema+} from './generated/acp-protocol.generated'+import { acpLaunchSpecFor } from './acp-launch-specs'+import { framesOf, launch, openHostRig, send, stop } from './acp-structured-host.test-support'+import { PROVIDER_SESSION, waitFor } from './acp-structured-adapter.test-support'+import type { AcpScriptedAgent, FakeFrame } from './acp-scripted-agent.test-support'+import {+ CALLER,+ envelope,+ hostTestState+} from '../native-chat/agent-session-wire/structured-agent-session-host-test-harness'+import {+ HOST_TEST_SESSION as SESSION,+ hostTestAttachParams+} from '../native-chat/agent-session-wire/structured-agent-session-host-test-data'+import { closeProviderTimelineRigs } from '../native-chat/agent-session-timeline/provider-timeline-assembler-test-support'+import { createAgentModelCatalogService } from '../native-chat/agent-model-catalog/agent-model-catalog-service'+import { AgentModelCatalogStore } from '../native-chat/agent-model-catalog/agent-model-catalog-store'+import type { AgentSessionRecordStore } from '../runtime/agent-session-record-store'+import { withLiveCatalogListing } from '../native-chat/agent-model-catalog/agent-model-catalog-entry'+import { AcpStructuredOptions } from './acp-structured-options'+import { readStructuredAgentSessionOptions } from '../native-chat/agent-session-wire/structured-agent-session-options-read'+import { structuredAgentSessionHandingOver } from '../native-chat/agent-session-wire/structured-agent-session-handing-over'++const recording = JSON.parse(+ readFileSync(new URL('./fixtures/antigravity-v1.4.3-options.json', import.meta.url), 'utf8')+)+const session = NewSessionResponseSchema.parse({+ ...recording.session,+ sessionId: PROVIDER_SESSION+})+const response = (key: string) => SetSessionConfigOptionResponseSchema.parse(recording[key])+const SPEC = acpLaunchSpecFor('antigravity')!+const FLASH = 'gemini-3.8-flash'+const PRO = 'gemini-3.1-pro'+afterEach(async () => {+ vi.useRealTimers()+ await closeProviderTimelineRigs()+})++async function openModels(+ settings: {+ saved?: Record<string, string>+ flat?: boolean+ noEffort?: boolean+ timeoutMs?: number+ control?: (agent: AcpScriptedAgent, frame: FakeFrame) => boolean+ } = {}+) {+ const accountHome = { variable: 'GEMINI_HOME', path: join(hostTestState().root, 'antigravity') }+ let records: AgentSessionRecordStore | undefined+ const catalog = createAgentModelCatalogService({+ store: new AgentModelCatalogStore(),+ getRecord: (id) => records?.getRecord(id) ?? undefined,+ getConversation: (id) => records?.getConversation(id) ?? undefined,+ drivesRecord: () => true,+ resolveAccountHome: async () => accountHome,+ recordWorkspacePath: async () => '/workspace/project',+ agentReadsProjectModelConfig: () => false,+ workspaceMayOverrideDefaultModel: async () => false+ })+ onTestFinished(() => catalog.stop())+ let resumed = false+ const spec = settings.flat ? { ...SPEC, permissionModeConfig: undefined } : SPEC+ const rig = await openHostRig({+ spec,+ modelCatalog: catalog,+ initialize: recording.initialize,+ deps: {+ resolveLaunch: async () => ({+ ...(await launch(() => resumed, spec)()),+ env: { GEMINI_HOME: accountHome.path }+ }),+ optionWriteTimeoutMs: settings.timeoutMs+ },+ script: (agent) => {+ let native = settings.flat ? [] : (session.configOptions ?? [])+ if (settings.noEffort) {+ native = native.filter((row) => row.category !== 'thought_level')+ }+ for (const method of ['session/new', 'session/load', 'session/resume']) {+ agent.on(method, (frame) => {+ if (method === 'session/resume') {+ expect(ResumeSessionRequestSchema.parse(frame.params).sessionId).toBe(PROVIDER_SESSION)+ }+ const configOptions = method === 'session/load' || !settings.flat ? native : undefined+ agent.reply(frame, { ...session, configOptions })+ })+ }+ agent.on('session/set_model', (frame) => agent.reply(frame, {}))+ agent.on('session/set_config_option', (frame) => {+ const { configId, value } = SetSessionConfigOptionRequestSchema.parse(frame.params)+ if (configId !== 'mode' && settings.control?.(agent, frame)) {+ return+ }+ if (configId === 'model') {+ native =+ value === PRO+ ? response('pro').configOptions+ : value === FLASH+ ? (session.configOptions ?? [])+ : response('legacy').configOptions+ } else if (configId === 'thinking_level') {+ const pro = native?.some(+ (row) => row.category === 'model' && row.type === 'select' && row.currentValue === PRO+ )+ if (pro && value === 'medium') {+ agent.fail(frame, -32602, 'Unsupported effort')+ return+ }+ native = native?.map((row) =>+ row.category === 'thought_level' && row.type === 'select'+ ? { ...row, currentValue: SessionConfigValueIdSchema.parse(value) }+ : row+ )+ }+ agent.reply(frame, { configOptions: native })+ })+ }+ })+ records = rig.store+ const attach = (fence: number | null) =>+ rig.host.attach(+ CALLER,+ hostTestAttachParams(fence, {+ provider: 'antigravity',+ agent: 'antigravity',+ accountHome,+ providerHandle: undefined,+ options: fence === null ? (settings.saved ?? { model: FLASH }) : undefined+ })+ )+ expect(await attach(null)).toMatchObject({ ok: true })+ await rig.ready()+ resumed = true+ const journal = () => rig.host.collaboratorsForTests().sessions.get(SESSION)!.journal+ const picks = (key: string, value: string) =>+ rig.host.setOption(CALLER, {+ envelope: envelope('agentSession.setOption', { key, value }),+ key,+ value+ })+ const writes = () =>+ framesOf(rig.rig.child(), 'session/set_config_option').filter(+ (frame) => SetSessionConfigOptionRequestSchema.parse(frame.params).configId !== 'mode'+ )+ const state = rig.host.collaboratorsForTests().runtimeState+ const ownership = () => ({+ tasks: rig.host['tasks']['attaching'].size,+ handles: state.acquireAborts['inFlight'].get(SESSION)?.size ?? 0,+ places: state.deliveryOrder['lanes'].get(SESSION)?.places.size ?? 0,+ lanes: state.deliveryOrder['lanes'].size+ })+ const complete = async (id: string) => {+ await waitFor(() =>+ expect(journal().submission(id)?.dispatchState).toMatch(/admitted|accepted/)+ )+ const frame = framesOf(rig.rig.child(), 'session/prompt').at(-1)!+ const turn = journal().runningTurn()?.turnId+ rig.rig.child().agent.reply(frame, { stopReason: 'end_turn' })+ await rig.rig.settle()+ await rig.host.flushStreamedEvents(SESSION)+ await waitFor(() => expect(journal().runningTurn()?.turnId).not.toBe(turn))+ expect(structuredAgentSessionHandingOver(journal()).has(id)).toBe(false)+ }+ const defer = async (path: string | false) => {+ const busy = path === 'busy' ? await send(rig.host, 'busy') : undefined+ if (busy) {+ await waitFor(() =>+ expect(journal().submission(busy)?.dispatchState).toMatch(/admitted|accepted/)+ )+ }+ if (path === 'held') {+ await journal().queuedMessages.insert({+ messageId: 'held',+ holdReason: 'send_failed',+ body: { kind: 'message', role: 'user', blocks: [{ type: 'text', text: 'held' }] }+ })+ }+ return async () => {+ if (busy) {+ await complete(busy)+ }+ if (path === 'held') {+ expect(+ await rig.host.queuedMessageSend(CALLER, {+ envelope: envelope('agentSession.queuedMessageSend', { messageId: 'held' }),+ messageId: 'held'+ })+ ).toMatchObject({ ok: true })+ await complete(journal().submissions().at(-1)!.clientMessageId)+ }+ }+ }+ const deliver = async (text: string) => {+ const id = await send(rig.host, text)+ await complete(id)+ return id+ }+ return {+ ...rig,+ catalog,+ journal,+ picks,+ writes,+ complete,+ deliver,+ attach,+ state,+ ownership,+ defer+ }+}++it.each([+ ['live', 10],+ ['live', 100],+ ['cold', 1],+ ['restart', 1],+ ['busy', 1],+ ['held', 1]+] as const)(+ 'retains Low through first Pro dispatch with bounded idle work (%s, history=%i)',+ async (path, count) => {+ const rig = await openModels()+ expect(await rig.picks('effort', 'low')).toMatchObject({ ok: true })+ await rig.deliver('apply Low')+ for (let i = 1; i < count; i++) {+ await rig.deliver(`history ${i}`)+ }+ const saved = await rig.catalog.read({+ agent: 'antigravity',+ sessionId: SESSION,+ savedOnly: true+ })+ if (saved.origin === 'unknown') {+ throw new Error('catalog missing')+ }+ expect(saved.models.find((row) => row.id === PRO)).toMatchObject({+ efforts: [],+ effortsKnown: false+ })+ const scans = vi.spyOn(rig.journal(), 'submissions')+ if (path === 'cold') {+ await rig.host.close(SESSION, 'user-close')+ }+ const wake = await rig.defer(path)+ const proWrites = rig.writes().length+ expect(await rig.picks('model', PRO)).toMatchObject({ ok: true })+ if (path === 'live') {+ await rig.host.readOptions(SESSION)+ const examined = scans.mock.results.reduce(+ (total, result) => total + (result.type === 'return' ? result.value.length : 0),+ 0+ )+ expect(examined).toBeLessThanOrEqual(100 * count)+ expect(+ rig+ .writes()+ .slice(proWrites)+ .filter(+ ({ params }) => SetSessionConfigOptionRequestSchema.parse(params).configId === 'model'+ )+ ).toHaveLength(1)+ }+ expect(rig.store.getRecord(SESSION)?.options).toEqual({ model: PRO, effort: 'low' })+ await wake()+ if (path === 'restart') {+ await rig.host.close(SESSION, 'user-close')+ expect(await rig.attach(rig.fence())).toMatchObject({ ok: true })+ await rig.ready()+ }+ const id = await rig.deliver('Pro without re-picking effort')+ expect(rig.journal().submission(id)?.options).toMatchObject({ model: PRO, effort: 'low' })+ expect(+ rig+ .writes()+ .slice(path === 'cold' || path === 'restart' ? 0 : proWrites)+ .at(-1)?.params+ ).toMatchObject({+ configId: 'thinking_level',+ value: 'low'+ })+ }+)++it.each([false, 'normal', 'live', 'busy', 'held'] as const)(+ 'attempts retained Medium after %s Pro selection and accepts an explicit Low correction',+ async (path) => {+ const rig = await openModels({ saved: { model: FLASH, effort: 'medium' } })+ expect(await rig.picks('model', FLASH)).toMatchObject({ ok: true })+ await rig.host.readOptions(SESSION)+ await rig.deliver('Flash Medium')+ const wake = await rig.defer(path)+ if (path === 'normal') {+ const target = new AcpStructuredOptions()+ target.adoptSession({ ...session, ...response('pro') })+ rig.catalog.recordLiveListing(SESSION, withLiveCatalogListing(target.read()).catalogListing)+ } else if (path) {+ rig.rig.child().agent.notify('session/update', {+ sessionId: PROVIDER_SESSION,+ update: { sessionUpdate: 'config_option_update', ...response('pro') }+ })+ await rig.rig.settle()+ await rig.host.readOptions(SESSION)+ expect(+ rig.rig.adapter['children'].sessions.get(SESSION)?.options.appliedInput.get('effort')+ ).toBe('medium')+ }+ expect(await rig.picks('model', PRO)).toMatchObject({ ok: true })+ await rig.host.readOptions(SESSION)+ expect(rig.store.getRecord(SESSION)?.options).toEqual({ model: PRO, effort: 'medium' })+ const before = framesOf(rig.rig.child(), 'session/prompt').length+ const id = await send(rig.host, 'retained Medium')+ if (path === 'busy' || path === 'held') {+ expect(rig.journal().submission(id)?.options).toEqual({ model: PRO, effort: 'medium' })+ await rig.rig.settle()+ expect(framesOf(rig.rig.child(), 'session/prompt')).toHaveLength(before)+ }+ await wake()+ await waitFor(() =>+ expect(rig.journal().submission(id)).toMatchObject({+ options: { model: PRO, effort: 'medium' },+ dispatchState: 'rejected',+ rejection: { kind: 'providerRejected' }+ })+ )+ await waitFor(() =>+ expect(structuredAgentSessionHandingOver(rig.journal()).has(id)).toBe(false)+ )+ expect(rig.writes().at(-1)?.params).toMatchObject({+ configId: 'thinking_level',+ value: 'medium'+ })+ expect(rig.store.getRecord(SESSION)?.options).toEqual({ model: PRO, effort: 'medium' })+ expect(framesOf(rig.rig.child(), 'session/prompt')).toHaveLength(+ before + (path === 'held' ? 1 : 0)+ )+ expect(+ framesOf(rig.rig.child(), 'session/prompt').some(({ params }) =>+ JSON.stringify(params).includes('retained Medium')+ )+ ).toBe(false)+ expect(await rig.picks('effort', 'low')).toMatchObject({ ok: true })+ const corrected = await rig.deliver('supported Low')+ expect(rig.journal().submission(corrected)?.options).toEqual({ model: PRO, effort: 'low' })+ expect(rig.writes().at(-1)?.params).toMatchObject({ configId: 'thinking_level', value: 'low' })+ }+)++it.each([false, true])(+ 'retains the same rejected model pick through actual Send (idle control=%s)',+ async (idle) => {+ const options = { model: 'opaque/rejected-model', effort: 'low' }+ const request = { sessionId: PROVIDER_SESSION, configId: 'model', value: options.model }+ const rig = await openModels({+ saved: { model: FLASH, effort: options.effort },+ control: (agent, frame) => {+ agent.fail(frame, -32602, 'Model unavailable')+ return true+ }+ })+ if (!idle) {+ vi.spyOn(rig.rig.adapter, 'canSetOptionWhileIdle').mockReturnValue(false)+ }+ expect(await rig.picks('model', options.model)).toMatchObject({ ok: true, value: { options } })+ await rig.host.readOptions(SESSION)+ expect(rig.writes()).toHaveLength(idle ? 1 : 0)+ await waitFor(() =>+ expect(rig.ownership()).toEqual({ tasks: 0, handles: 0, places: 0, lanes: 0 })+ )+ expect(rig.store.getRecord(SESSION)?.options).toEqual(options)+ const id = await send(rig.host, 'same rejected selection')+ await waitFor(() =>+ expect(rig.journal().submission(id)).toMatchObject({+ options,+ dispatchState: 'rejected',+ rejection: { kind: 'providerRejected' }+ })+ )+ await waitFor(() =>+ expect(structuredAgentSessionHandingOver(rig.journal()).has(id)).toBe(false)+ )+ expect(+ rig.writes().map(({ params }) => SetSessionConfigOptionRequestSchema.parse(params))+ ).toEqual(Array.from({ length: idle ? 2 : 1 }, () => request))+ expect(rig.store.getRecord(SESSION)?.options).toEqual(options)+ expect(framesOf(rig.rig.child(), 'session/prompt')).toHaveLength(0)+ }+)++it.each([10, 100, 'Send', 'rejection'] as const)(+ 'coalesces unanswered picks and settles captured FIFO delivery (%s)',+ async (count) => {+ let held: FakeFrame | undefined+ const rig = await openModels({+ saved: { model: FLASH, effort: 'low' },+ control: (_agent, frame) => {+ if (!held) {+ held = frame+ return true+ }+ return false+ }+ })+ const begins = vi.spyOn(rig.state.acquireAborts, 'begin')+ const places = vi.spyOn(rig.state.deliveryOrder, 'reserve')+ let receipted = false+ const receipt = rig.picks('model', PRO).then((result) => {+ receipted = true+ return result+ })+ await waitFor(() => expect(held).toBeDefined())+ await waitFor(() => expect(receipted).toBe(true))+ expect(await receipt).toMatchObject({ ok: true })+ const readingUnderLane = vi.spyOn(rig.rig.adapter, 'readOptions')+ const framesBeforeRead = rig.rig.child().agent.frames.length+ let readDone = false+ const reading = Promise.all([+ rig.host.readOptions(SESSION),+ rig.host.readOptions(SESSION)+ ]).then(([answer, phone]) => {+ for (const result of [answer, phone]) {+ expect(result.current).toMatchObject({ model: FLASH, effort: 'low' })+ }+ readDone = true+ return answer+ })+ await rig.rig.settle()+ expect(readingUnderLane).not.toHaveBeenCalled()+ expect(rig.rig.child().agent.frames).toHaveLength(framesBeforeRead)+ for (let i = 1; i < (typeof count === 'string' ? 4 : count); i++) {+ expect(await rig.picks('model', i % 2 ? FLASH : PRO)).toMatchObject({ ok: true })+ expect(rig.store.getRecord(SESSION)?.options).toEqual({+ model: i % 2 ? FLASH : PRO,+ effort: 'low'+ })+ }+ await rig.rig.settle()+ expect(rig.ownership()).toEqual({ tasks: 1, handles: 1, places: 1, lanes: 1 })+ expect([begins.mock.calls.length, places.mock.calls.length, rig.writes().length]).toEqual([+ 1, 1, 1+ ])+ const first = typeof count === 'string' ? await send(rig.host, 'captured Flash') : null+ if (first) {+ await rig.picks('model', PRO)+ }+ const second = first ? await send(rig.host, 'captured Pro') : null+ if (second) {+ await rig.picks('model', FLASH)+ }+ expect(readDone).toBe(false)+ expect(framesOf(rig.rig.child(), 'session/prompt')).toHaveLength(0)+ if (count === 'rejection') {+ rig.rig.child().agent.fail(held!, -32602, 'Optional model rejected')+ } else {+ rig.rig.child().agent.reply(held!, response('pro'))+ }+ const answer = await reading+ if (first && second) {+ for (const [id, model] of [+ [first, FLASH],+ [second, PRO]+ ] as const) {+ expect(rig.journal().submission(id)?.options).toEqual({ model, effort: 'low' })+ await rig.complete(id)+ }+ expect(+ rig.rig+ .child()+ .agent.frames.filter(+ (frame) => rig.writes().includes(frame) || frame.method === 'session/prompt'+ )+ .map(({ method, params }) => ({ method, params }))+ ).toMatchObject([+ { method: 'session/set_config_option', params: { configId: 'model', value: PRO } },+ { method: 'session/set_config_option', params: { configId: 'model', value: FLASH } },+ {+ method: 'session/set_config_option',+ params: { configId: 'thinking_level', value: 'low' }+ },+ {+ method: 'session/prompt',+ params: { prompt: [{ type: 'text', text: 'captured Flash' }] }+ },+ { method: 'session/set_config_option', params: { configId: 'model', value: PRO } },+ {+ method: 'session/set_config_option',+ params: { configId: 'thinking_level', value: 'low' }+ },+ { method: 'session/prompt', params: { prompt: [{ type: 'text', text: 'captured Pro' }] } }+ ])+ } else {+ expect(framesOf(rig.rig.child(), 'session/prompt')).toHaveLength(0)+ expect(answer.current.model).toBe(FLASH)+ expect(+ answer.models.find((row) => row.id === FLASH)?.efforts.map((row) => row.value)+ ).toEqual(['low', 'medium', 'high'])+ expect(+ rig.writes().map(({ params }) => SetSessionConfigOptionRequestSchema.parse(params).value)+ ).toEqual([PRO, FLASH])+ }+ await waitFor(() =>+ expect(rig.ownership()).toEqual({ tasks: 0, handles: 0, places: 0, lanes: 0 })+ )+ }+)++it.each(['Stop', 'deadline', 'child close', 'unproven close'] as const)(+ 'retires an uncertain producer on %s without sending on its old channel',+ async (ending) => {+ let holding = false+ const rig = await openModels({+ timeoutMs: 100,+ control: (_agent, frame) =>+ holding && SetSessionConfigOptionRequestSchema.parse(frame.params).configId === 'model'+ })+ await rig.deliver('history before uncertainty')+ const priorWrites = rig.writes().length+ holding = true+ if (ending === 'deadline' || ending === 'unproven close') {+ vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] })+ }+ await rig.picks('model', PRO)+ await waitFor(() => expect(rig.writes()).toHaveLength(priorWrites + 1))+ const child = rig.rig.child()+ const native = rig.rig.adapter['children'].sessions.get(SESSION)!+ if (ending === 'unproven close') {+ child.proveClose = async () => false+ }+ const handles = rig.store.getRecord(SESSION)?.providerHandleChain.map(({ handle }) => handle)+ expect(handles?.length).toBeGreaterThan(0)+ const pending = rig.writes()[priorWrites]!+ await rig.picks('model', FLASH)+ await rig.picks('model', PRO)+ const reading = rig.host.readOptions(SESSION).then(+ (answer) => ({ answer }),+ (error: unknown) => ({ error })+ )+ const id = await send(rig.host, 'accepted while outstanding')+ if (ending === 'Stop') {+ await stop(rig.host)+ } else if (ending === 'deadline' || ending === 'unproven close') {+ await vi.advanceTimersByTimeAsync(100)+ } else {+ child.exit()+ }+ vi.useRealTimers()+ await waitFor(() => expect(child.exited).toBe(ending !== 'unproven close'))+ const readResult = await reading+ if (ending === 'unproven close') {+ expect(readResult).toMatchObject({+ error: { message: expect.stringContaining('no live antigravity child') }+ })+ }+ await rig.rig.settle()+ expect(framesOf(child, 'session/prompt')).toHaveLength(1)+ expect(await rig.messages()).toContain('history before uncertainty')+ expect(rig.store.getRecord(SESSION)?.options?.model).toBe(PRO)+ expect(rig.store.getRecord(SESSION)?.providerHandleChain.map(({ handle }) => handle)).toEqual(+ handles+ )+ await waitFor(() => expect(rig.journal().submission(id)?.dispatchState).toBe('rejected'))+ expect(rig.rig.spawned.filter((step) => step === 'spawn')).toHaveLength(1)+ if (ending === 'child close') {+ expect(await rig.attach(rig.fence())).toMatchObject({ ok: true })+ await rig.ready()+ await rig.picks('model', FLASH)+ await waitFor(() => expect(rig.writes()).toHaveLength(1))+ const completion = rig.state.deliveryOrder.optionsReady(SESSION)+ const latest = rig.host.readOptions(SESSION)+ child.agent.reply(pending, response('pro'))+ await rig.rig.settle()+ expect(rig.state.deliveryOrder.optionsReady(SESSION)).toBe(completion)+ expect(rig.ownership()).toEqual({ tasks: 1, handles: 1, places: 1, lanes: 1 })+ rig.rig.child().agent.reply(rig.writes()[0]!, { configOptions: session.configOptions })+ expect((await latest).current.model).toBe(FLASH)+ await rig.deliver('resumed history')+ } else {+ child.agent.reply(pending, response('pro'))+ }+ await waitFor(() =>+ expect(rig.ownership()).toEqual({ tasks: 0, handles: 0, places: 0, lanes: 0 })+ )+ if (ending === 'unproven close') {+ expect(rig.rig.adapter['children'].sessions.get(SESSION)).toBe(native)+ expect(native.journalClosed).not.toBeNull()+ child.exit()+ }+ await expect(rig.host.close(SESSION, 'user-close')).resolves.toBeUndefined()+ }+)++it.each([+ {+ flat: false,+ model: 'gemini-3.8-flash-medium',+ shown: 'gemini-3.8-flash-medium',+ noEffort: false+ },+ {+ flat: true,+ model: 'gemini-3.8-flash-medium',+ shown: 'gemini-3.8-flash-medium',+ noEffort: false+ },+ { flat: false, model: PRO, shown: PRO, noEffort: true }+])(+ 'reads the target before prompt and delivers exact $model (flat=$flat, noEffort=$noEffort)',+ async ({ flat, model, shown, noEffort }) => {+ const rig = await openModels({ flat, noEffort })+ await rig.picks('model', model)+ const answer = await rig.host.readOptions(SESSION)+ expect(answer.current.model).toBe(shown)+ expect(framesOf(rig.rig.child(), 'session/prompt')).toHaveLength(0)+ if (noEffort) {+ expect(answer.models.find((row) => row.id === PRO)?.efforts.map((row) => row.value)).toEqual([+ 'low',+ 'high'+ ])+ }+ await rig.deliver('saved identity')+ expect(rig.store.getRecord(SESSION)?.options?.model).toBe(model)+ expect(+ framesOf(rig.rig.child(), flat ? 'session/set_model' : 'session/set_config_option').some(+ ({ params }) =>+ flat+ ? JSON.stringify(params).includes(model)+ : SetSessionConfigOptionRequestSchema.parse(params).value === model+ )+ ).toBe(true)+ if (!flat && model === 'gemini-3.8-flash-medium') {+ const before = rig+ .writes()+ .filter(+ ({ params }) => SetSessionConfigOptionRequestSchema.parse(params).configId === 'model'+ ).length+ for (const configOptions of [+ response('pro').configOptions,+ [],+ response('legacy').configOptions+ ]) {+ rig.rig.child().agent.notify('session/update', {+ sessionId: PROVIDER_SESSION,+ update: { sessionUpdate: 'config_option_update', configOptions }+ })+ await rig.rig.settle()+ await rig.deliver('same successful raw input after observation')+ }+ expect(+ rig+ .writes()+ .filter(+ ({ params }) => SetSessionConfigOptionRequestSchema.parse(params).configId === 'model'+ )+ ).toHaveLength(before)+ }+ }+)++it.each(['new cycle', 'replacement', 'rest'] as const)(+ 'joins once then reads current state after %s without native read work',+ async (transition) => {+ const rig = await openModels({ control: () => true })+ await rig.picks('model', PRO)+ await waitFor(() => expect(rig.writes()).toHaveLength(1))+ const old = rig.rig.child()+ const base = rig.host['mutationContext']()+ const entered = Promise.withResolvers<void>()+ const continueRead = Promise.withResolvers<void>()+ let entries = 0+ let inLane = false+ const readOptions = rig.rig.adapter.readOptions.bind(rig.rig.adapter)+ const observed = vi.spyOn(rig.rig.adapter, 'readOptions').mockImplementation((input) => {+ expect(inLane).toBe(true)+ return readOptions(input)+ })+ const reading = readStructuredAgentSessionOptions(+ {+ ...base,+ serialize: async <T>(id: string, task: () => Promise<T>): Promise<T> => {+ if (++entries === 2) {+ entered.resolve()+ await continueRead.promise+ }+ return base.serialize(id, async () => {+ inLane = true+ try {+ return await task()+ } finally {+ inLane = false+ }+ })+ }+ },+ SESSION,+ { readsWithoutModel: true }+ )+ await rig.rig.settle()+ expect(observed).not.toHaveBeenCalled()+ old.agent.reply(rig.writes()[0]!, response('pro'))+ await entered.promise+ if (transition === 'new cycle') {+ await rig.picks('model', FLASH)+ await waitFor(() => expect(rig.writes()).toHaveLength(2))+ } else {+ await rig.host.close(SESSION, 'user-close')+ if (transition === 'replacement') {+ expect(await rig.attach(rig.fence())).toMatchObject({ ok: true })+ await rig.ready()+ expect(rig.rig.child()).not.toBe(old)+ }+ }+ const child = rig.host.collaboratorsForTests().sessions.get(SESSION)?.child+ const frames = rig.rig.child().agent.frames.length+ continueRead.resolve()+ const answer = await reading+ expect(entries).toBe(2)+ expect(rig.rig.child().agent.frames).toHaveLength(frames)+ if (transition === 'rest') {+ expect(observed).not.toHaveBeenCalled()+ } else {+ expect(observed).toHaveBeenCalledExactlyOnceWith({ sessionId: SESSION, fence: child!.fence })+ expect(+ answer.models.find((row) => row.id === (transition === 'new cycle' ? FLASH : PRO))+ ).toMatchObject({ efforts: [], effortsKnown: false })+ }+ if (transition === 'new cycle') {+ expect(rig.state.deliveryOrder.optionsReady(SESSION)).toBeDefined()+ rig.rig.child().agent.reply(rig.writes()[1]!, { configOptions: session.configOptions })+ }+ await waitFor(() =>+ expect(rig.ownership()).toEqual({ tasks: 0, handles: 0, places: 0, lanes: 0 })+ )+ }+)diff --git a/src/main/acp/acp-structured-host-option-hang.test.ts b/src/main/acp/acp-structured-host-option-hang.test.tsindex 088f146ae67..54a025398da 100644--- a/src/main/acp/acp-structured-host-option-hang.test.ts+++ b/src/main/acp/acp-structured-host-option-hang.test.ts@@ -7,13 +7,7 @@ import {} from '../native-chat/agent-session-wire/structured-agent-session-host-test-harness'import { HOST_TEST_SESSION as SESSION } from '../native-chat/agent-session-wire/structured-agent-session-host-test-data'import { GROK_CONFIG_OPTIONS, waitFor } from './acp-structured-adapter.test-support'-import {- framesOf,- hello,- openAttachedHostRig,- send,- stop-} from './acp-structured-host.test-support'+import { framesOf, hello, openAttachedHostRig, send } from './acp-structured-host.test-support'import type { StructuredAgentSessionHost } from '../native-chat/agent-session-wire/structured-agent-session-host'import { STOP_NOTE_CANCELLATION_REQUESTED } from '../native-chat/agent-session-wire/structured-agent-session-turn-stop-notes'@@ -32,6 +26,7 @@ describe('a Grok model pick Grok never answers during send', () => {const { rig, host, rows } = await openAttachedHostRig({script: (agent) => agent.on('session/set_config_option', () => {})})+ vi.spyOn(rig.adapter, 'canSetOptionWhileIdle').mockReturnValue(false)expect(await pick(host, 'grok-4.6')).toMatchObject({ ok: true })await send(host, 'hello')await waitFor(() => expect(framesOf(rig.child(), 'session/set_config_option')).toHaveLength(1))@@ -62,6 +57,7 @@ describe('a Grok model pick Grok never answers during send', () => {const { rig, host } = await openAttachedHostRig({script: (agent) => agent.on('session/set_config_option', () => {})})+ vi.spyOn(rig.adapter, 'canSetOptionWhileIdle').mockReturnValue(false)expect(await pick(host, 'grok-4.6')).toMatchObject({ ok: true })const dispatch = vi.spyOn(rig.adapter, 'dispatch')const sending = await host.send(CALLER, {@@ -96,17 +92,20 @@ describe('a Grok model pick Grok never answers during send', () => {})})- it('re-establishes opening A after uncertain B without adopting B’s late reply', async () => {- const { rig, host, store, fence } = await openAttachedHostRig({+ it('retires an unanswered dispatch control and retains the saved model and conversation', async () => {+ const { rig, host, store } = await openAttachedHostRig({optionWriteTimeoutMs: 100,script: (agent) => agent.on('session/set_config_option', () => {})})+ vi.spyOn(rig.adapter, 'canSetOptionWhileIdle').mockReturnValue(false)vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout'] })expect(await pick(host, 'grok-4.6')).toMatchObject({ ok: true })const savedModel = store.getRecord(SESSION)?.options?.modelexpect(savedModel).toBe('grok-4.6')await send(host, 'hello')await waitFor(() => expect(framesOf(rig.child(), 'session/set_config_option')).toHaveLength(1))+ const child = rig.child()+ const [old] = framesOf(child, 'session/set_config_option')await vi.advanceTimersByTimeAsync(100)await waitFor(() =>expect(@@ -114,55 +113,24 @@ describe('a Grok model pick Grok never answers during send', () => {).toBe('rejected'))vi.useRealTimers()+ await waitFor(() => expect(child.exited).toBe(true))expect(framesOf(rig.child(), 'session/prompt')).toEqual([])await expect(host.readOptions(SESSION)).resolves.toMatchObject({current: { model: savedModel }})- const restore = rig.adapter.dispatch({- sessionId: SESSION,- fence: fence(),- clientMessageId: 'restore-A',- executionOptions: { model: 'grok-4.7' },- body: { kind: 'message', role: 'user', blocks: [{ type: 'text', text: 'A again' }] }- })- await waitFor(() => expect(framesOf(rig.child(), 'session/set_config_option')).toHaveLength(2))- const [old, current] = framesOf(rig.child(), 'session/set_config_option')- rig.child().agent.reply(current!, { configOptions: GROK_CONFIG_OPTIONS })- await restore- expect(framesOf(rig.child(), 'session/set_config_option')).toHaveLength(2)- expect([old?.params, current?.params]).toEqual([- { sessionId: expect.any(String), configId: 'model', value: 'grok-4.6' },- { sessionId: expect.any(String), configId: 'model', value: 'grok-4.7' }- ])- expect(framesOf(rig.child(), 'session/prompt')).toHaveLength(1)rig.child().agent.reply(old!, {configOptions: GROK_CONFIG_OPTIONS.map((option) =>- option.id === 'model' ? { ...option, currentValue: 'grok-4.6' } : option+ option.id === 'model' ? { ...option, currentValue: 'grok-4.7' } : option)})await rig.settle()+ expect(framesOf(child, 'session/prompt')).toHaveLength(0)expect(- (await rig.adapter.readOptions({ sessionId: SESSION, fence: fence() })).current.model- ).toBe('grok-4.7')+ host.collaboratorsForTests().sessions.get(SESSION)?.journal.submissions()[0]?.dispatchState+ ).toBe('rejected')expect((await host.readOptions(SESSION)).current.model).toBe(savedModel)expect(store.getRecord(SESSION)?.options?.model).toBe(savedModel)+ expect(store.getRecord(SESSION)?.providerHandleChain.length).toBeGreaterThan(0)await host.close(SESSION, 'user-close')})})--describe('a saved Grok pick', () => {- it.each(['Stop', 'Close'] as const)(- 'never contacts Grok or holds %s behind a setter',- async (ending) => {- const { rig, host, store } = await openAttachedHostRig({- script: (agent) => agent.on('session/set_config_option', () => {})- })- await expect(pick(host, 'grok-4.6')).resolves.toMatchObject({ ok: true })- expect(store.getRecord(SESSION)?.options?.model).toBe('grok-4.6')- expect(framesOf(rig.child(), 'session/set_config_option')).toEqual([])- const ended = ending === 'Stop' ? stop(host) : host.close(SESSION, 'user-close')- await ended- await host.close(SESSION, 'user-close')- }- )-})diff --git a/src/main/acp/acp-structured-options.test.ts b/src/main/acp/acp-structured-options.test.tsindex 2d848e08a68..5ea94fc6cfd 100644--- a/src/main/acp/acp-structured-options.test.ts+++ b/src/main/acp/acp-structured-options.test.ts@@ -1,6 +1,7 @@import { readFileSync } from 'node:fs'import { describe, expect, it, vi } from 'vitest'import { AcpStructuredOptions, readAcpLiveOptions } from './acp-structured-options'+import { writeAcpSessionOption } from './acp-session-option-write'import { grokModelEfforts } from './acp-dialects/grok-model-catalog'import { GROK_ACP_DIALECT } from './acp-dialects/grok-dialect'import { OMP_ACP_DIALECT } from './acp-dialects/omp-dialect'@@ -107,38 +108,71 @@ describe('ACP session options', () => {})- it('keeps the session’s picks out of the catalog facts', () => {- // OpenCode refuses an effort the selected model lacks, so another model's empty menu stays strict.- const options = new AcpStructuredOptions(OPENCODE_ACP_DIALECT)- options.adoptSession({ configOptions })- const { models, current } = options.read()- // Current values supply an effort menu, never a catalog default.- expect(models).toEqual([- { id: 'model-a', label: 'Model A', isDefault: false, efforts: [] },- {- id: 'model-b',- label: 'Model B',- isDefault: false,- efforts: [- { value: 'low', label: 'Low' },- { value: 'high', label: 'High' }- ]+ it.each([OPENCODE_ACP_DIALECT, OMP_ACP_DIALECT])(+ 'keeps native menus and observations separate from applied inputs',+ async (dialect) => {+ const options = new AcpStructuredOptions(dialect)+ options.adoptSession({+ configOptions,+ models: { currentModelId: 'legacy', availableModels: [] }+ })+ const { models, current } = options.read()+ // Current values supply an effort menu, never a catalog default.+ expect(models).toEqual([+ { id: 'model-a', label: 'Model A', isDefault: false, efforts: [], effortsKnown: false },+ {+ id: 'model-b',+ label: 'Model B',+ isDefault: false,+ efforts: [+ { value: 'low', label: 'Low' },+ { value: 'high', label: 'High' }+ ]+ }+ ])+ expect(current).toEqual({ model: 'model-b', effort: 'high', confirmed: ['model', 'effort'] })+ options.notePick('model')+ options.adoptModel('')+ options.adoptConfigOptions(null)+ options.adoptConfigOptions(undefined)+ expect(options.reported()).toEqual({ model: 'model-b', effort: 'high' })+ options.adoptConfigOptions(configOptions)+ expect([...options.appliedInput]).toEqual([])+ await writeAcpSessionOption(+ {+ setConfigOption: async () => ({ configOptions }),+ setModel: async () => ({})+ },+ options,+ options.write('model', 'raw/retired')!,+ {+ agent: 'test',+ key: 'model',+ value: 'raw/retired',+ timeoutMs: 1000+ }+ )+ expect([...options.appliedInput]).toEqual([['model', 'raw/retired']])+ const reports = [+ { model: 'model-a' },+ { model: 'model-b', effort: 'high' },+ {},+ { model: 'model-b', effort: 'high' }+ ]+ for (const [index, next] of [+ [{ ...configOptions[0]!, currentValue: 'model-a' }],+ configOptions,+ [],+ configOptions+ ].entries()) {+ options.adoptConfigOptions(next)+ expect([...options.appliedInput]).toEqual([['model', 'raw/retired']])+ expect(options.reported()).toEqual(reports[index])}- ])- expect(current).toEqual({ model: 'model-b', effort: 'high', confirmed: ['model', 'effort'] })- })-- it('leaves another model’s menu unknown for an agent that clamps unlisted efforts', () => {- const options = new AcpStructuredOptions(OMP_ACP_DIALECT)- options.adoptSession({ configOptions })- expect(options.read().models[0]).toEqual({- id: 'model-a',- label: 'Model A',- isDefault: false,- efforts: [],- effortsKnown: false- })- })+ options.adoptSession({ configOptions })+ expect([...options.appliedInput]).toEqual([])+ }+ )it('reads each model’s own menu where the agent advertises one', () => {const options = new AcpStructuredOptions(GROK_ACP_DIALECT)diff --git a/src/main/acp/acp-structured-options.ts b/src/main/acp/acp-structured-options.tsindex ed4c7603165..172314ca7b4 100644--- a/src/main/acp/acp-structured-options.ts+++ b/src/main/acp/acp-structured-options.ts@@ -51,7 +51,7 @@ export class AcpStructuredOptions {constructor(private readonly dialect: Pick<AcpDialect,- 'modelEfforts' | 'clampsUnlistedEffort' | 'withheldCommands' | 'effortChangesModel'+ 'modelEfforts' | 'withheldCommands' | 'effortChangesModel'> = {}) {}@@ -162,18 +162,20 @@ export class AcpStructuredOptions {const models: AgentSessionModelOption[] = listed.map((model) => {const info = this.models?.availableModels.find((entry) => entry.modelId === model.id)const advertised = info ? this.dialect.modelEfforts?.(info) : undefined- // A clamping agent's session menu says nothing about another model's menu: unknown, not none.+ // A current-session menu supplies no negative evidence about an unobserved model.const sessionMenu =model.id === currentModel? { efforts: sessionEfforts }- : this.dialect.clampsUnlistedEffort && effortOption && !advertised+ : (modelOption || effortOption) && !advertised? { efforts: [], effortsKnown: false as const }: { efforts: [] }return {...model,isDefault: false,// Fall back to the running session's menu when the advertised menu is empty.- ...(advertised && advertised.efforts.length > 0 ? advertised : sessionMenu)+ ...(advertised && (advertised.efforts.length > 0 || model.id !== currentModel)+ ? advertised+ : sessionMenu)}})const confirmed = [...(currentModel ? ['model'] : []), ...(effortOption ? ['effort'] : [])]diff --git a/src/main/acp/acp-structured-session-adapter.test.ts b/src/main/acp/acp-structured-session-adapter.test.tsindex f21e4b17e49..5d6c18b406d 100644--- a/src/main/acp/acp-structured-session-adapter.test.ts+++ b/src/main/acp/acp-structured-session-adapter.test.ts@@ -1,3 +1,9 @@+import { readFileSync } from 'node:fs'+import { acpLaunchSpecFor } from './acp-launch-specs'+import {+ NewSessionResponseSchema,+ SessionNotificationSchema+} from './generated/acp-protocol.generated'import { afterEach, describe, expect, it } from 'vitest'import { readAgentJournalTurn } from '../../shared/agent-session-turn-record'import {@@ -5,7 +11,6 @@ import {SESSION} from '../native-chat/agent-session-timeline/provider-timeline-assembler-test-support'import { AgentSessionAcquisitionRootExitObservedError } from '../native-chat/agent-session-wire/structured-agent-session-adapter'-import { acpLaunchSpecFor } from './acp-launch-specs'import { GENERIC_ACP_DIALECT } from './acp-dialects/acp-dialect'import { OPENCODE_ACP_DIALECT } from './acp-dialects/opencode-dialect'import { OMP_ACP_DIALECT } from './acp-dialects/omp-dialect'@@ -436,6 +441,46 @@ describe('ACP structured session adapter: turns', () => {})+ it('keeps recorded OpenCode startup identity inert when its own model arrives later', async () => {+ const startup = NewSessionResponseSchema.parse(+ JSON.parse(+ readFileSync(new URL('./fixtures/opencode-v2-start-options.json', import.meta.url), 'utf8')+ )+ )+ const frames = readFileSync(+ new URL('./fixtures/opencode-v2-reopen.jsonl', import.meta.url),+ 'utf8'+ )+ .trim()+ .split('\n')+ .map((line) => JSON.parse(line))+ const late = SessionNotificationSchema.parse(frames[1].message.params)+ const rig = await openAcpAdapterRig({+ spec: acpLaunchSpecFor('opencode2')!,+ script: (agent) =>+ agent.on('session/new', (frame) =>+ agent.reply(frame, { ...startup, sessionId: PROVIDER_SESSION })+ )+ })+ await rig.acquire()+ rig.child().agent.notify('session/update', { ...late, sessionId: PROVIDER_SESSION })+ await waitFor(() =>+ expect(rig.lifecycle.at(-1)).toMatchObject({+ type: 'options-reported',+ reportedOptions: { model: 'opencode/big-pickle' }+ })+ )+ await rig.adapter.dispatch({+ sessionId: SESSION,+ fence: 1,+ clientMessageId: 'own-model',+ body: hello,+ executionOptions: {}+ })+ await rig.frame('session/prompt')+ expect(rig.sent('session/set_config_option')).toHaveLength(0)+ })+it("sends Grok's prompt identity only to an agent whose dialect echoes it", async () => {const rig = await openAcpAdapterRig({deps: { spec: { ...GROK, dialect: GENERIC_ACP_DIALECT } }diff --git a/src/main/acp/acp-structured-session-adapter.ts b/src/main/acp/acp-structured-session-adapter.tsindex e3728476b0f..94b8a31bf87 100644--- a/src/main/acp/acp-structured-session-adapter.ts+++ b/src/main/acp/acp-structured-session-adapter.ts@@ -9,10 +9,10 @@ import {AgentSessionPreSpawnError,isAgentSessionPreSpawnError,type AgentSessionAcquisition,- type AgentSessionDispatchOutcome,+ type AgentSessionDispatchOutcome as DispatchOutcome,type StructuredAgentSessionAcquireInput,- type StructuredAgentSessionAdapter,- type StructuredAgentSessionSetOptionInput+ type StructuredAgentSessionAdapter as SessionAdapter,+ type StructuredAgentSessionSetOptionInput as SetOptionInput} from '../native-chat/agent-session-wire/structured-agent-session-adapter'import { withObservedProviderExit } from '../native-chat/agent-session-wire/structured-agent-session-failure-text'import { acpAgentName } from './acp-structured-agent-definitions'@@ -33,13 +33,13 @@ import {import { readAcpLiveOptions } from './acp-structured-options'import { writeAcpSessionOption } from './acp-session-option-write'import { stopAcpChildren, acpChildStopCapabilities } from './acp-structured-child-stop'-import { acpStartupFailure, isAcpReadySession } from './acp-structured-child'+import * as childState from './acp-structured-child'import { AcpStructuredChildren } from './acp-structured-child-lifecycle'import { AcpConversationCopies } from './acp-conversation-copies'import { AcpTextTasks } from './acp-text-task'import { supportsAcpStructuredLocation } from './acp-structured-location-support'-export class AcpStructuredSessionAdapter implements StructuredAgentSessionAdapter {+export class AcpStructuredSessionAdapter implements SessionAdapter {readonly atRestCommands: AcpStructuredSessionAdapterDeps['atRestCommands']private readonly children: AcpStructuredChildrenprivate readonly copies: AcpConversationCopies@@ -51,10 +51,10 @@ export class AcpStructuredSessionAdapter implements StructuredAgentSessionAdaptethis.textTasks = new AcpTextTasks(deps)}- generateText: NonNullable<StructuredAgentSessionAdapter['generateText']> = (input) =>+ generateText: NonNullable<SessionAdapter['generateText']> = (input) =>this.textTasks.generate(input)- copyConversation: NonNullable<StructuredAgentSessionAdapter['copyConversation']> = (input) =>+ copyConversation: NonNullable<SessionAdapter['copyConversation']> = (input) =>this.copies.copy(input)supportsLocation = (location: AgentSessionExecutionLocation): boolean => {@@ -146,7 +146,7 @@ export class AcpStructuredSessionAdapter implements StructuredAgentSessionAdapte}}- open: NonNullable<StructuredAgentSessionAdapter['open']> = async (input) => {+ open: NonNullable<SessionAdapter['open']> = async (input) => {const child = this.children.sessions.get(input.sessionId)if (!child ||@@ -159,7 +159,7 @@ export class AcpStructuredSessionAdapter implements StructuredAgentSessionAdaptetry {return await child.open(input.signal)} catch (error) {- const failure = acpStartupFailure(child, error)+ const failure = childState.acpStartupFailure(child, error)if (failure) {const refusal = new AgentSessionAcquisitionRefusal(`${acpAgentName(child.spec.agent)} requires sign-in`,@@ -171,9 +171,7 @@ export class AcpStructuredSessionAdapter implements StructuredAgentSessionAdapte}}- async dispatch(- input: Parameters<StructuredAgentSessionAdapter['dispatch']>[0]- ): Promise<AgentSessionDispatchOutcome> {+ async dispatch(input: Parameters<SessionAdapter['dispatch']>[0]): Promise<DispatchOutcome> {const lost = this.children.sessions.get(input.sessionId)if (lost && lost.journalClosed !== null) {// Protocol loss prevents dispatch even before exit is proven.@@ -214,10 +212,10 @@ export class AcpStructuredSessionAdapter implements StructuredAgentSessionAdaptereturn { state: 'admitted' }}- compact: NonNullable<StructuredAgentSessionAdapter['compact']> = async (input) =>+ compact: NonNullable<SessionAdapter['compact']> = async (input) =>this.live(input.sessionId).turns.compact(input.command)- cancelTurn: StructuredAgentSessionAdapter['cancelTurn'] = async (input) => {+ cancelTurn: SessionAdapter['cancelTurn'] = async (input) => {const session = this.live(input.sessionId)// Refuse a stale named turn; a handover with no journal turn can stop the in-flight prompt.const liveTurnId = input.resolveLiveTurnId?.() ?? session.lane.openTurnId@@ -234,15 +232,15 @@ export class AcpStructuredSessionAdapter implements StructuredAgentSessionAdapteawaitStoppedRequestEnd = async (sessionId: string, stoppedAt: number): Promise<void> => {const session = this.children.sessions.get(sessionId)- if (session && isAcpReadySession(session)) {+ if (session && childState.isAcpReadySession(session)) {await awaitAcpTurnEnd(session, stoppedAt, this.stopGraceMs())}}- answerPrompt: StructuredAgentSessionAdapter['answerPrompt'] = (input) =>+ answerPrompt: SessionAdapter['answerPrompt'] = (input) =>this.live(input.sessionId).prompts.answer(input)- async setOption(input: StructuredAgentSessionSetOptionInput) {+ async setOption(input: SetOptionInput) {const session = this.live(input.sessionId)const write = session.options.write(input.key, input.value)if (!write) {@@ -257,25 +255,31 @@ export class AcpStructuredSessionAdapter implements StructuredAgentSessionAdaptevalue: input.value,agent: session.spec.agent,timeoutMs: this.deps.optionWriteTimeoutMs ?? ACP_OPTION_WRITE_TIMEOUT_MS,- ...(input.signal ? { signal: input.signal } : {})+ ...(input.signal ? { signal: input.signal } : {}),+ onUncertain: (error) => this.children.connectionLost(session, error)})return session.options.reported()}+ canSetOptionWhileIdle = (input: SetOptionInput): boolean =>+ childState.canSetAcpOptionWhileIdle(this.children.sessions.get(input.sessionId), input)+readOptions = async (input: { sessionId: string; fence: number }) =>readAcpLiveOptions(this.live(input.sessionId), this.deps.spec.permissionModeConfig?.values)readCommands = (sessionId: string) => {const session = this.children.sessions.get(sessionId)- return session && isAcpReadySession(session) ? session.options.readCommands() : undefined+ return session && childState.isAcpReadySession(session)+ ? session.options.readCommands()+ : undefined}- capturePendingOutput: StructuredAgentSessionAdapter['capturePendingOutput'] = (input) =>+ capturePendingOutput: SessionAdapter['capturePendingOutput'] = (input) =>this.children.capturePendingOutput?.(input)holdsDispatch = (sessionId: string): boolean => {const session = this.children.sessions.get(sessionId)- return session ? isAcpReadySession(session) && session.turns.running : false+ return session ? childState.isAcpReadySession(session) && session.turns.running : false}holdsLiveProviderProcess = (sessionId: string, generation: string): boolean => {@@ -294,9 +298,8 @@ export class AcpStructuredSessionAdapter implements StructuredAgentSessionAdapteheldSends = (sessionId: string): ReadonlySet<string> | undefined =>this.children.sessions.get(sessionId)?.turns?.heldSends- stopBackgroundTasks: NonNullable<StructuredAgentSessionAdapter['stopBackgroundTasks']> = (- input- ) => stopAcpChildren(this.live(input.sessionId), input.fence, input.taskIds, input.acknowledge)+ stopBackgroundTasks: NonNullable<SessionAdapter['stopBackgroundTasks']> = (input) =>+ stopAcpChildren(this.live(input.sessionId), input.fence, input.taskIds, input.acknowledge)backgroundTaskStops = (sessionId: string) =>acpChildStopCapabilities(this.children.sessions.get(sessionId))@@ -319,7 +322,7 @@ export class AcpStructuredSessionAdapter implements StructuredAgentSessionAdapteprivate live(sessionId: string): AcpStructuredSession {const session = this.children.sessions.get(sessionId)- if (!session || !isAcpReadySession(session) || session.journalClosed !== null) {+ if (!session || !childState.isAcpReadySession(session) || session.journalClosed !== null) {throw new Error(`no live ${this.deps.spec.agent} child owns ${sessionId}`)}return sessiondiff --git a/src/main/acp/fixtures/antigravity-v1.4.3-options.json b/src/main/acp/fixtures/antigravity-v1.4.3-options.jsonnew file mode 100644index 00000000000..b55aa7d6fcc--- /dev/null+++ b/src/main/acp/fixtures/antigravity-v1.4.3-options.json@@ -0,0 +1,537 @@+{+ "initialize": {+ "protocolVersion": 1,+ "agentCapabilities": {+ "loadSession": true,+ "promptCapabilities": {+ "image": true,+ "audio": true,+ "embeddedContext": true+ },+ "mcpCapabilities": {+ "http": true,+ "sse": true+ },+ "sessionCapabilities": {+ "list": {},+ "resume": {}+ },+ "auth": {+ "logout": {}+ },+ "_meta": {+ "antigravity": {+ "tier": true,+ "systemPrompt": {+ "append": true+ }+ }+ }+ },+ "authMethods": [+ {+ "id": "oauth-personal",+ "name": "Log in with Google",+ "description": "Log in with your Google account"+ },+ {+ "id": "oauth-business",+ "name": "Log in with Gemini Enterprise",+ "description": "Log in with your Gemini Enterprise account"+ },+ {+ "id": "gemini-api-key",+ "name": "Gemini API key",+ "description": "Use an API key with Gemini Developer API"+ },+ {+ "id": "agent-platform",+ "name": "Gemini Enterprise Agent Platform",+ "description": "Use Gemini Enterprise Agent Platform (formerly Vertex AI) with Application Default Credentials or an API key"+ }+ ],+ "agentInfo": {+ "name": "antigravity-acp",+ "title": "Google Antigravity",+ "version": "1.4.3"+ }+ },+ "session": {+ "sessionId": "session-1",+ "modes": {+ "currentModeId": "default",+ "availableModes": [+ {+ "id": "default",+ "name": "Default",+ "description": "Default permission prompt flow"+ },+ {+ "id": "auto_edit",+ "name": "Auto Edit",+ "description": "Auto-approve file edit tools"+ },+ {+ "id": "yolo",+ "name": "YOLO",+ "description": "Auto-approve all tools"+ }+ ]+ },+ "configOptions": [+ {+ "currentValue": "gemini-3.8-flash",+ "options": [+ {+ "value": "gemini-3.8-flash",+ "name": "Gemini 3.8 Flash"+ },+ {+ "value": "gemini-3.7-flash",+ "name": "Gemini 3.7 Flash"+ },+ {+ "value": "gemini-3.6-flash",+ "name": "Gemini 3.6 Flash"+ },+ {+ "value": "gemini-3.5-flash",+ "name": "Gemini 3.5 Flash"+ },+ {+ "value": "gemini-3.1-pro",+ "name": "Gemini 3.1 Pro"+ }+ ],+ "id": "model",+ "name": "Model",+ "category": "model",+ "type": "select"+ },+ {+ "currentValue": "high",+ "options": [+ {+ "value": "low",+ "name": "Low"+ },+ {+ "value": "medium",+ "name": "Medium"+ },+ {+ "value": "high",+ "name": "High"+ }+ ],+ "id": "thinking_level",+ "name": "Thinking Level",+ "category": "thought_level",+ "type": "select"+ },+ {+ "currentValue": "default",+ "options": [+ {+ "value": "default",+ "name": "Default",+ "description": "Default permission prompt flow"+ },+ {+ "value": "auto_edit",+ "name": "Auto Edit",+ "description": "Auto-approve file edit tools"+ },+ {+ "value": "yolo",+ "name": "YOLO",+ "description": "Auto-approve all tools"+ }+ ],+ "id": "mode",+ "name": "Session Mode",+ "category": "mode",+ "type": "select"+ }+ ],+ "models": {+ "availableModels": [+ {+ "modelId": "gemini-3.8-flash-high",+ "name": "Gemini 3.8 Flash (High)",+ "description": "Gemini 3.8 Flash model with high thinking level"+ },+ {+ "modelId": "gemini-3.8-flash-medium",+ "name": "Gemini 3.8 Flash (Medium)",+ "description": "Gemini 3.8 Flash model with medium thinking level"+ },+ {+ "modelId": "gemini-3.8-flash-low",+ "name": "Gemini 3.8 Flash (Low)",+ "description": "Gemini 3.8 Flash model with low thinking level"+ },+ {+ "modelId": "gemini-3.7-flash-high",+ "name": "Gemini 3.7 Flash (High)",+ "description": "Gemini 3.7 Flash model with high thinking level"+ },+ {+ "modelId": "gemini-3.7-flash-medium",+ "name": "Gemini 3.7 Flash (Medium)",+ "description": "Gemini 3.7 Flash model with medium thinking level"+ },+ {+ "modelId": "gemini-3.7-flash-low",+ "name": "Gemini 3.7 Flash (Low)",+ "description": "Gemini 3.7 Flash model with low thinking level"+ },+ {+ "modelId": "gemini-3.6-flash-high",+ "name": "Gemini 3.6 Flash (High)",+ "description": "Gemini 3.6 Flash model with high thinking level"+ },+ {+ "modelId": "gemini-3.6-flash-medium",+ "name": "Gemini 3.6 Flash (Medium)",+ "description": "Gemini 3.6 Flash model with medium thinking level"+ },+ {+ "modelId": "gemini-3.6-flash-low",+ "name": "Gemini 3.6 Flash (Low)",+ "description": "Gemini 3.6 Flash model with low thinking level"+ },+ {+ "modelId": "gemini-3.5-flash-high",+ "name": "Gemini 3.5 Flash (High)",+ "description": "Gemini 3.5 Flash model with high thinking level"+ },+ {+ "modelId": "gemini-3.5-flash-medium",+ "name": "Gemini 3.5 Flash (Medium)",+ "description": "Gemini 3.5 Flash model with medium thinking level"+ },+ {+ "modelId": "gemini-3.5-flash-low",+ "name": "Gemini 3.5 Flash (Low)",+ "description": "Gemini 3.5 Flash model with low thinking level"+ },+ {+ "modelId": "gemini-3.1-pro-high",+ "name": "Gemini 3.1 Pro (High)",+ "description": "Gemini 3.1 Pro model with high thinking level"+ },+ {+ "modelId": "gemini-3.1-pro-low",+ "name": "Gemini 3.1 Pro (Low)",+ "description": "Gemini 3.1 Pro model with low thinking level"+ }+ ],+ "currentModelId": "gemini-3.8-flash-high"+ }+ },+ "low": {+ "configOptions": [+ {+ "currentValue": "gemini-3.8-flash",+ "options": [+ {+ "value": "gemini-3.8-flash",+ "name": "Gemini 3.8 Flash"+ },+ {+ "value": "gemini-3.7-flash",+ "name": "Gemini 3.7 Flash"+ },+ {+ "value": "gemini-3.6-flash",+ "name": "Gemini 3.6 Flash"+ },+ {+ "value": "gemini-3.5-flash",+ "name": "Gemini 3.5 Flash"+ },+ {+ "value": "gemini-3.1-pro",+ "name": "Gemini 3.1 Pro"+ }+ ],+ "id": "model",+ "name": "Model",+ "category": "model",+ "type": "select"+ },+ {+ "currentValue": "low",+ "options": [+ {+ "value": "low",+ "name": "Low"+ },+ {+ "value": "medium",+ "name": "Medium"+ },+ {+ "value": "high",+ "name": "High"+ }+ ],+ "id": "thinking_level",+ "name": "Thinking Level",+ "category": "thought_level",+ "type": "select"+ },+ {+ "currentValue": "default",+ "options": [+ {+ "value": "default",+ "name": "Default",+ "description": "Default permission prompt flow"+ },+ {+ "value": "auto_edit",+ "name": "Auto Edit",+ "description": "Auto-approve file edit tools"+ },+ {+ "value": "yolo",+ "name": "YOLO",+ "description": "Auto-approve all tools"+ }+ ],+ "id": "mode",+ "name": "Session Mode",+ "category": "mode",+ "type": "select"+ }+ ]+ },+ "pro": {+ "configOptions": [+ {+ "currentValue": "gemini-3.1-pro",+ "options": [+ {+ "value": "gemini-3.8-flash",+ "name": "Gemini 3.8 Flash"+ },+ {+ "value": "gemini-3.7-flash",+ "name": "Gemini 3.7 Flash"+ },+ {+ "value": "gemini-3.6-flash",+ "name": "Gemini 3.6 Flash"+ },+ {+ "value": "gemini-3.5-flash",+ "name": "Gemini 3.5 Flash"+ },+ {+ "value": "gemini-3.1-pro",+ "name": "Gemini 3.1 Pro"+ }+ ],+ "id": "model",+ "name": "Model",+ "category": "model",+ "type": "select"+ },+ {+ "currentValue": "low",+ "options": [+ {+ "value": "low",+ "name": "Low"+ },+ {+ "value": "high",+ "name": "High"+ }+ ],+ "id": "thinking_level",+ "name": "Thinking Level",+ "category": "thought_level",+ "type": "select"+ },+ {+ "currentValue": "default",+ "options": [+ {+ "value": "default",+ "name": "Default",+ "description": "Default permission prompt flow"+ },+ {+ "value": "auto_edit",+ "name": "Auto Edit",+ "description": "Auto-approve file edit tools"+ },+ {+ "value": "yolo",+ "name": "YOLO",+ "description": "Auto-approve all tools"+ }+ ],+ "id": "mode",+ "name": "Session Mode",+ "category": "mode",+ "type": "select"+ }+ ]+ },+ "high": {+ "configOptions": [+ {+ "currentValue": "gemini-3.1-pro",+ "options": [+ {+ "value": "gemini-3.8-flash",+ "name": "Gemini 3.8 Flash"+ },+ {+ "value": "gemini-3.7-flash",+ "name": "Gemini 3.7 Flash"+ },+ {+ "value": "gemini-3.6-flash",+ "name": "Gemini 3.6 Flash"+ },+ {+ "value": "gemini-3.5-flash",+ "name": "Gemini 3.5 Flash"+ },+ {+ "value": "gemini-3.1-pro",+ "name": "Gemini 3.1 Pro"+ }+ ],+ "id": "model",+ "name": "Model",+ "category": "model",+ "type": "select"+ },+ {+ "currentValue": "high",+ "options": [+ {+ "value": "low",+ "name": "Low"+ },+ {+ "value": "high",+ "name": "High"+ }+ ],+ "id": "thinking_level",+ "name": "Thinking Level",+ "category": "thought_level",+ "type": "select"+ },+ {+ "currentValue": "default",+ "options": [+ {+ "value": "default",+ "name": "Default",+ "description": "Default permission prompt flow"+ },+ {+ "value": "auto_edit",+ "name": "Auto Edit",+ "description": "Auto-approve file edit tools"+ },+ {+ "value": "yolo",+ "name": "YOLO",+ "description": "Auto-approve all tools"+ }+ ],+ "id": "mode",+ "name": "Session Mode",+ "category": "mode",+ "type": "select"+ }+ ]+ },+ "legacy": {+ "configOptions": [+ {+ "currentValue": "gemini-3.8-flash",+ "options": [+ {+ "value": "gemini-3.8-flash",+ "name": "Gemini 3.8 Flash"+ },+ {+ "value": "gemini-3.7-flash",+ "name": "Gemini 3.7 Flash"+ },+ {+ "value": "gemini-3.6-flash",+ "name": "Gemini 3.6 Flash"+ },+ {+ "value": "gemini-3.5-flash",+ "name": "Gemini 3.5 Flash"+ },+ {+ "value": "gemini-3.1-pro",+ "name": "Gemini 3.1 Pro"+ }+ ],+ "id": "model",+ "name": "Model",+ "category": "model",+ "type": "select"+ },+ {+ "currentValue": "medium",+ "options": [+ {+ "value": "low",+ "name": "Low"+ },+ {+ "value": "medium",+ "name": "Medium"+ },+ {+ "value": "high",+ "name": "High"+ }+ ],+ "id": "thinking_level",+ "name": "Thinking Level",+ "category": "thought_level",+ "type": "select"+ },+ {+ "currentValue": "default",+ "options": [+ {+ "value": "default",+ "name": "Default",+ "description": "Default permission prompt flow"+ },+ {+ "value": "auto_edit",+ "name": "Auto Edit",+ "description": "Auto-approve file edit tools"+ },+ {+ "value": "yolo",+ "name": "YOLO",+ "description": "Auto-approve all tools"+ }+ ],+ "id": "mode",+ "name": "Session Mode",+ "category": "mode",+ "type": "select"+ }+ ]+ }+}diff --git a/src/main/acp/fixtures/opencode-v2-start-options.json b/src/main/acp/fixtures/opencode-v2-start-options.jsonnew file mode 100644index 00000000000..a76e12a71e1--- /dev/null+++ b/src/main/acp/fixtures/opencode-v2-start-options.json@@ -0,0 +1,499 @@+{+ "sessionId": "ses_eeda46a79ffedz4yHR5GrxQyR6",+ "configOptions": [+ {+ "id": "model",+ "name": "Model",+ "category": "model",+ "type": "select",+ "currentValue": "opencode/fledge-alpha-free",+ "options": [+ {+ "value": "opencode/big-pickle",+ "name": "opencode/Big Pickle"+ },+ {+ "value": "opencode/claude-fable-5",+ "name": "opencode/Claude Fable 5"+ },+ {+ "value": "opencode/claude-fable-5-1",+ "name": "opencode/Claude Fable 5.1"+ },+ {+ "value": "opencode/claude-haiku-4-5",+ "name": "opencode/Claude Haiku 4.5"+ },+ {+ "value": "opencode/claude-opus-4-5",+ "name": "opencode/Claude Opus 4.5"+ },+ {+ "value": "opencode/claude-opus-4-6",+ "name": "opencode/Claude Opus 4.6"+ },+ {+ "value": "opencode/claude-opus-4-7",+ "name": "opencode/Claude Opus 4.7"+ },+ {+ "value": "opencode/claude-opus-4-8",+ "name": "opencode/Claude Opus 4.8"+ },+ {+ "value": "opencode/claude-opus-5",+ "name": "opencode/Claude Opus 5"+ },+ {+ "value": "opencode/claude-opus-5-5",+ "name": "opencode/Claude Opus 5.5"+ },+ {+ "value": "opencode/claude-sonnet-4",+ "name": "opencode/Claude Sonnet 4"+ },+ {+ "value": "opencode/claude-sonnet-4-5",+ "name": "opencode/Claude Sonnet 4.5"+ },+ {+ "value": "opencode/claude-sonnet-4-6",+ "name": "opencode/Claude Sonnet 4.6"+ },+ {+ "value": "opencode/claude-sonnet-5",+ "name": "opencode/Claude Sonnet 5"+ },+ {+ "value": "opencode/claude-sonnet-5-5",+ "name": "opencode/Claude Sonnet 5.5"+ },+ {+ "value": "opencode/deepseek-v4-flash",+ "name": "opencode/DeepSeek V4 Flash"+ },+ {+ "value": "opencode/deepseek-v4-flash-vision-exp",+ "name": "opencode/DeepSeek V4 Flash Vision Exp"+ },+ {+ "value": "opencode/deepseek-v4-pro",+ "name": "opencode/DeepSeek V4 Pro"+ },+ {+ "value": "opencode/deepseek-v4.1-flash",+ "name": "opencode/DeepSeek V4.1 Flash"+ },+ {+ "value": "opencode/fledge-alpha-free",+ "name": "opencode/Fledge Alpha Free"+ },+ {+ "value": "opencode/gemini-3-flash",+ "name": "opencode/Gemini 3 Flash"+ },+ {+ "value": "opencode/gemini-3.1-pro",+ "name": "opencode/Gemini 3.1 Pro Preview"+ },+ {+ "value": "opencode/gemini-3.5-flash",+ "name": "opencode/Gemini 3.5 Flash"+ },+ {+ "value": "opencode/gemini-3.5-flash-lite",+ "name": "opencode/Gemini 3.5 Flash Lite"+ },+ {+ "value": "opencode/gemini-3.6-flash",+ "name": "opencode/Gemini 3.6 Flash"+ },+ {+ "value": "opencode/gemini-3.7-flash",+ "name": "opencode/Gemini 3.7 Flash"+ },+ {+ "value": "opencode/gemini-3.8-flash",+ "name": "opencode/Gemini 3.8 Flash"+ },+ {+ "value": "opencode/glm-5",+ "name": "opencode/GLM-5"+ },+ {+ "value": "opencode/glm-5.1",+ "name": "opencode/GLM-5.1"+ },+ {+ "value": "opencode/glm-5.2",+ "name": "opencode/GLM-5.2"+ },+ {+ "value": "opencode/glm-5.3",+ "name": "opencode/GLM-5.3"+ },+ {+ "value": "opencode/glm-5.3-flash",+ "name": "opencode/GLM-5.3-Flash"+ },+ {+ "value": "opencode/gpt-5",+ "name": "opencode/GPT-5"+ },+ {+ "value": "opencode/gpt-5-codex",+ "name": "opencode/GPT-5 Codex"+ },+ {+ "value": "opencode/gpt-5-nano",+ "name": "opencode/GPT-5 Nano"+ },+ {+ "value": "opencode/gpt-5.1",+ "name": "opencode/GPT-5.1"+ },+ {+ "value": "opencode/gpt-5.1-codex",+ "name": "opencode/GPT-5.1 Codex"+ },+ {+ "value": "opencode/gpt-5.1-codex-max",+ "name": "opencode/GPT-5.1 Codex Max"+ },+ {+ "value": "opencode/gpt-5.1-codex-mini",+ "name": "opencode/GPT-5.1 Codex Mini"+ },+ {+ "value": "opencode/gpt-5.2",+ "name": "opencode/GPT-5.2"+ },+ {+ "value": "opencode/gpt-5.2-codex",+ "name": "opencode/GPT-5.2 Codex"+ },+ {+ "value": "opencode/gpt-5.3-codex",+ "name": "opencode/GPT-5.3 Codex"+ },+ {+ "value": "opencode/gpt-5.3-codex-spark",+ "name": "opencode/GPT-5.3 Codex Spark"+ },+ {+ "value": "opencode/gpt-5.4",+ "name": "opencode/GPT-5.4"+ },+ {+ "value": "opencode/gpt-5.4-mini",+ "name": "opencode/GPT-5.4 Mini"+ },+ {+ "value": "opencode/gpt-5.4-nano",+ "name": "opencode/GPT-5.4 Nano"+ },+ {+ "value": "opencode/gpt-5.4-pro",+ "name": "opencode/GPT-5.4 Pro"+ },+ {+ "value": "opencode/gpt-5.5",+ "name": "opencode/GPT-5.5"+ },+ {+ "value": "opencode/gpt-5.5-pro",+ "name": "opencode/GPT-5.5 Pro"+ },+ {+ "value": "opencode/gpt-5.6-luna",+ "name": "opencode/GPT-5.6 Luna"+ },+ {+ "value": "opencode/gpt-5.6-sol",+ "name": "opencode/GPT-5.6 Sol"+ },+ {+ "value": "opencode/gpt-5.6-terra",+ "name": "opencode/GPT-5.6 Terra"+ },+ {+ "value": "opencode/gpt-6-astra",+ "name": "opencode/GPT-6 Astra"+ },+ {+ "value": "opencode/gpt-6-luna",+ "name": "opencode/GPT-6 Luna"+ },+ {+ "value": "opencode/gpt-6-sol",+ "name": "opencode/GPT-6 Sol"+ },+ {+ "value": "opencode/gpt-6.1-sol",+ "name": "opencode/GPT-6.1 Sol"+ },+ {+ "value": "opencode/grok-4.5",+ "name": "opencode/Grok 4.5"+ },+ {+ "value": "opencode/grok-4.6",+ "name": "opencode/Grok 4.6"+ },+ {+ "value": "opencode/grok-4.7",+ "name": "opencode/Grok 4.7"+ },+ {+ "value": "opencode/grok-build-0.1",+ "name": "opencode/Grok Build 0.1"+ },+ {+ "value": "opencode/kimi-k2.5",+ "name": "opencode/Kimi K2.5"+ },+ {+ "value": "opencode/kimi-k2.6",+ "name": "opencode/Kimi K2.6"+ },+ {+ "value": "opencode/kimi-k2.7-code",+ "name": "opencode/Kimi K2.7 Code"+ },+ {+ "value": "opencode/kimi-k3",+ "name": "opencode/Kimi K3"+ },+ {+ "value": "opencode/ling-3.0-flash-fin-free",+ "name": "opencode/Ling 3.0 Flash Fin Free"+ },+ {+ "value": "opencode/ling-3.1-flash-free",+ "name": "opencode/Ling 3.1 Flash Free"+ },+ {+ "value": "opencode/longcat-2.5-preview-free",+ "name": "opencode/LongCat 2.5 Preview Free"+ },+ {+ "value": "opencode/mimo-v2.6-flash-free",+ "name": "opencode/MiMo-V2.6-Flash Free"+ },+ {+ "value": "opencode/minimax-m2.5",+ "name": "opencode/MiniMax-M2.5"+ },+ {+ "value": "opencode/minimax-m2.7",+ "name": "opencode/MiniMax-M2.7"+ },+ {+ "value": "opencode/minimax-m3",+ "name": "opencode/MiniMax-M3"+ },+ {+ "value": "opencode/muse-spark-1.2",+ "name": "opencode/Muse Spark 1.2"+ },+ {+ "value": "opencode/muse-spark-1.3",+ "name": "opencode/Muse Spark 1.3"+ },+ {+ "value": "opencode/muse-spark-1.3-contributor-free",+ "name": "opencode/Muse Spark 1.3 Free"+ },+ {+ "value": "opencode/nemotron-3-ultra-free",+ "name": "opencode/Nemotron 3 Ultra Free"+ },+ {+ "value": "opencode/nemotron-3.5-lightning-free",+ "name": "opencode/Nemotron 3.5 Lightning Free"+ },+ {+ "value": "opencode/qwen3.5-plus",+ "name": "opencode/Qwen3.5 Plus"+ },+ {+ "value": "opencode/qwen3.6-plus",+ "name": "opencode/Qwen3.6 Plus"+ },+ {+ "value": "opencode/qwen3.8-flash",+ "name": "opencode/Qwen3.8 Flash"+ },+ {+ "value": "opencode/qwen3.8-max",+ "name": "opencode/Qwen3.8 Max"+ },+ {+ "value": "opencode/space-bunny-free",+ "name": "opencode/Space Bunny Free"+ },+ {+ "value": "opencode-go/deepseek-v4-flash",+ "name": "opencode-go/DeepSeek V4 Flash"+ },+ {+ "value": "opencode-go/deepseek-v4-flash-vision-exp",+ "name": "opencode-go/DeepSeek V4 Flash Vision Exp"+ },+ {+ "value": "opencode-go/deepseek-v4-pro",+ "name": "opencode-go/DeepSeek V4 Pro (New)"+ },+ {+ "value": "opencode-go/deepseek-v4.1-flash",+ "name": "opencode-go/DeepSeek V4.1 Flash"+ },+ {+ "value": "opencode-go/glm-5.2",+ "name": "opencode-go/GLM-5.2"+ },+ {+ "value": "opencode-go/glm-5.3",+ "name": "opencode-go/GLM-5.3"+ },+ {+ "value": "opencode-go/glm-5.3-flash",+ "name": "opencode-go/GLM-5.3-Flash"+ },+ {+ "value": "opencode-go/gpt-5.6-luna",+ "name": "opencode-go/GPT-5.6 Luna"+ },+ {+ "value": "opencode-go/gpt-6-luna",+ "name": "opencode-go/GPT-6 Luna"+ },+ {+ "value": "opencode-go/grok-4.6",+ "name": "opencode-go/Grok 4.6"+ },+ {+ "value": "opencode-go/grok-4.7",+ "name": "opencode-go/Grok 4.7"+ },+ {+ "value": "opencode-go/hy3",+ "name": "opencode-go/Hy3"+ },+ {+ "value": "opencode-go/hy4-preview",+ "name": "opencode-go/Hy4 preview"+ },+ {+ "value": "opencode-go/kimi-k2.7-code",+ "name": "opencode-go/Kimi K2.7 Code"+ },+ {+ "value": "opencode-go/kimi-k3",+ "name": "opencode-go/Kimi K3"+ },+ {+ "value": "opencode-go/longcat-2.5-preview-free",+ "name": "opencode-go/LongCat 2.5 Preview Free"+ },+ {+ "value": "opencode-go/longcat-2.0",+ "name": "opencode-go/LongCat-2.0"+ },+ {+ "value": "opencode-go/mimo-v2.5",+ "name": "opencode-go/MiMo V2.5"+ },+ {+ "value": "opencode-go/mimo-v2.5-pro",+ "name": "opencode-go/MiMo V2.5 Pro"+ },+ {+ "value": "opencode-go/mimo-v2.6-flash",+ "name": "opencode-go/MiMo-V2.6-Flash"+ },+ {+ "value": "opencode-go/mimo-v2.6-pro",+ "name": "opencode-go/MiMo-V2.6-Pro"+ },+ {+ "value": "opencode-go/minimax-m2.7",+ "name": "opencode-go/MiniMax-M2.7"+ },+ {+ "value": "opencode-go/minimax-m3",+ "name": "opencode-go/MiniMax-M3"+ },+ {+ "value": "opencode-go/muse-spark-1.2-contributor",+ "name": "opencode-go/Muse Spark 1.2 Contributor"+ },+ {+ "value": "opencode-go/muse-spark-1.3-contributor",+ "name": "opencode-go/Muse Spark 1.3 Contributor"+ },+ {+ "value": "opencode-go/qwen3.7-plus",+ "name": "opencode-go/Qwen3.7 Plus"+ },+ {+ "value": "opencode-go/qwen3.8-flash",+ "name": "opencode-go/Qwen3.8 Flash"+ },+ {+ "value": "opencode-go/qwen3.8-max",+ "name": "opencode-go/Qwen3.8 Max"+ },+ {+ "value": "opencode-go/space-bunny",+ "name": "opencode-go/Space Bunny"+ }+ ]+ },+ {+ "id": "effort",+ "name": "Effort",+ "description": "Available effort levels for this model",+ "category": "thought_level",+ "type": "select",+ "currentValue": "default",+ "options": [+ {+ "value": "low",+ "name": "Low"+ },+ {+ "value": "high",+ "name": "High"+ },+ {+ "value": "max",+ "name": "Max"+ },+ {+ "value": "default",+ "name": "Default"+ }+ ]+ },+ {+ "id": "mode",+ "name": "Session Mode",+ "category": "mode",+ "type": "select",+ "currentValue": "build",+ "options": [+ {+ "value": "build",+ "name": "Build",+ "description": "The default agent. Executes tools based on configured permissions."+ },+ {+ "value": "plan",+ "name": "Plan",+ "description": "Read-only agent for exploring the codebase and planning work before implementation."+ }+ ]+ }+ ]+}diff --git a/src/main/antigravity/antigravity-acp-runtime.ts b/src/main/antigravity/antigravity-acp-runtime.tsindex 66d098301c3..8be1a388cd2 100644--- a/src/main/antigravity/antigravity-acp-runtime.ts+++ b/src/main/antigravity/antigravity-acp-runtime.ts@@ -1,10 +1,10 @@-// No upstream checksums are published; pin each verified archive and executable.+// Pin the official registry archives and each executable verified inside them.import { join } from 'node:path'import type { ManagedRuntime, ManagedRuntimePin } from '../node-runtime/managed-runtime-release'import { probeAntigravityAcpServer } from './antigravity-acp-runtime-probe'-const VERSION = '1.3.0'+const VERSION = '1.4.3'const RELEASES = 'https://dl.google.com/agy-extensions/releases'const COMMAND = 'agy_acp_server.par'// The server finds its harness beside itself.@@ -21,40 +21,40 @@ type Pinned = {}const PINNED: Record<string, Pinned> = {'darwin-arm64': {- path: 'macos/agy-acp-server-1.3.0-darwin-arm64.zip',- archive: '7cd97045f7b4fe81175a107cdf16f9c51484e3c78a5162cae415338bb6aa5b88',- archiveBytes: 111456962,- server: 'cb1f0725183ed922079ed6cd1d2422b4d8be44c5fb60be3e9a43d8d04f99a18e',- serverBytes: 278535456,- harness: 'b04b00662c1821b953a409d43626b86d1229130eeb2078b4e1304c06199aa481',- harnessBytes: 118611392+ path: 'macos/agy-acp-server-1.4.3-darwin-arm64.zip',+ archive: 'c57db0a9b8b712daa9c3c17cdb990a61842ea569f279e8bd79d7aa85a303b20b',+ archiveBytes: 114147623,+ server: '1251927db3e21f3d693fd042d6890d82f65eb00587e97f1f3d8f0d798e7f0954',+ serverBytes: 282446160,+ harness: '9e8fdc6e20a3262ca0a771850ca4a8414ca839a642cc964ec5c547cc2c33c200',+ harnessBytes: 122957936},'darwin-x64': {- path: 'macos/agy-acp-server-1.3.0-darwin-x86_64.zip',- archive: 'bb23956b89984bf5d354af2c3725e6c57f0cc1b7228e77a0e91c9c2bc1d47646',- archiveBytes: 117245544,- server: 'f31bd5797eeb225a5efa12e24573f1f4eb157ec00698dd6a2cda6f0d924705cf',- serverBytes: 282840688,- harness: 'd724f49b2c9e440c5d37925b1da203fc204c17dd9c662df45094c641f9806bc6',- harnessBytes: 124175392+ path: 'macos/agy-acp-server-1.4.3-darwin-x86_64.zip',+ archive: '9392dbbdad7f0663dbfb5a0bf641297b0cf80d2ee9cd2d49a616bbbc7378731d',+ archiveBytes: 119801100,+ server: 'd51eea5bdb2c5fa2ca37c21bafcbba1eb89fb6b287489b0c2795c64f3b96ee33',+ serverBytes: 286653712,+ harness: '0c000ad3f4c1ded5fc72b23a8c5816205a09e6d8f0957c9ea548221273e0efd9',+ harnessBytes: 127612208},'linux-x64': {- path: 'linux/agy-acp-server-1.3.0-linux-x86_64.zip',- archive: '9fb60956af0a9d76220a4db91ca9ac88e2a2372ad68f985ab5fceace6b825b96',- archiveBytes: 333727150,- server: 'cf6feaebdacfc2255dcfc8883db99b15de8554698554e2a1e78e5ccec1c68a20',- serverBytes: 926533965,- harness: '63042ca43fc7a69600683920f7706689b82cf8aecefe21dc18cf35e99c9dde4d',- harnessBytes: 130388040+ path: 'linux/agy-acp-server-1.4.3-linux-x86_64.zip',+ archive: '0634ce5306ba92c932945455e7a83fda78e2d99c33fa8aa6ee0566206a382714',+ archiveBytes: 336846435,+ server: '7e06ec4aab6dcff53911a16c124692bc95c8848b2a1fd3220be6f67dbe7efafb',+ serverBytes: 927707135,+ harness: '55b2d1d8206d3f38353cdba3c5c5d087cd718241b90500bce4f8009f64495285',+ harnessBytes: 133926136},'linux-arm64': {- path: 'linux/agy-acp-server-1.3.0-linux-arm64.zip',- archive: '500b0bc0fb858e88f4df404d4cedf80bf9298c178291e39e383d6c50b111cbdf',- archiveBytes: 321690363,- server: '03ea51ff7a60cb1b44e65da40fdb35f1f457db7950d1651d9e86945c8aa584c6',- serverBytes: 930848992,- harness: '7fe676f1234889900800bad3ca50fb9b55f1e16ee4cb82b789f84ae5145fd582',- harnessBytes: 123224968+ path: 'linux/agy-acp-server-1.4.3-linux-arm64.zip',+ archive: '05c153443b0b1175151c760eeddea538950bc9843e317d54786a1f03670182bc',+ archiveBytes: 322887047,+ server: '6db15569878613d9abe47f9841a3e039322b0c599c752510ff27381c9532ff21',+ serverBytes: 932662106,+ harness: 'd898fa05e31d502b0b2df5a8565463c2cec0a06a7a65285d49b1ea79c3fc42b3',+ harnessBytes: 127512832}}diff --git a/src/main/native-chat/agent-session-wire/structured-agent-session-adapter-router.ts b/src/main/native-chat/agent-session-wire/structured-agent-session-adapter-router.tsindex 9751fe523fa..696de1c086d 100644--- a/src/main/native-chat/agent-session-wire/structured-agent-session-adapter-router.ts+++ b/src/main/native-chat/agent-session-wire/structured-agent-session-adapter-router.ts@@ -171,6 +171,8 @@ export class StructuredAgentSessionAdapterRouter implements StructuredAgentSessisetOption: StructuredAgentSessionAdapter['setOption'] = (input) =>this.owner(input.sessionId).setOption(input)+ canSetOptionWhileIdle: StructuredAgentSessionAdapter['canSetOptionWhileIdle'] = (input) =>+ this.liveOwnerOrNull(input.sessionId)?.canSetOptionWhileIdle?.(input) === truereadAppliedInputOptions: StructuredAgentSessionAdapter['readAppliedInputOptions'] = (input) =>this.liveOwnerOrNull(input.sessionId)?.readAppliedInputOptions?.(input) ?? nulldiff --git a/src/main/native-chat/agent-session-wire/structured-agent-session-adapter.ts b/src/main/native-chat/agent-session-wire/structured-agent-session-adapter.tsindex 97bfc41746d..3cd45001fcc 100644--- a/src/main/native-chat/agent-session-wire/structured-agent-session-adapter.ts+++ b/src/main/native-chat/agent-session-wire/structured-agent-session-adapter.ts@@ -277,6 +277,8 @@ export type StructuredAgentSessionAdapter = StructuredAgentSessionAdapterStop &setOption(input: StructuredAgentSessionSetOptionInput): Promise<void | Readonly<Record<string, string>>>+ /** Opt in only when setOption can update idle metadata without a provider turn. */+ canSetOptionWhileIdle?(input: StructuredAgentSessionSetOptionInput): boolean/** Applied inputs for this exact child; observations never decide message admission. */readAppliedInputOptions?(input: {sessionId: stringdiff --git a/src/main/native-chat/agent-session-wire/structured-agent-session-delivery-order.ts b/src/main/native-chat/agent-session-wire/structured-agent-session-delivery-order.tsindex 382b41a197e..183e3e62912 100644--- a/src/main/native-chat/agent-session-wire/structured-agent-session-delivery-order.ts+++ b/src/main/native-chat/agent-session-wire/structured-agent-session-delivery-order.ts@@ -1,16 +1,25 @@import type { AgentJournalSubmission } from '../../../shared/agent-session-journal-types'import { isQueuedAgentJournalSubmission } from '../../../shared/agent-session-queued-submission'+import type { StructuredAgentSessionProviderChild } from './structured-agent-session-host-types'export type StructuredAgentSessionDeliveryPlace = {before: Promise<void>release: () => void}+type OptionsCycle = StructuredAgentSessionDeliveryPlace & {+ child: StructuredAgentSessionProviderChild+ signal: AbortSignal+ ready: Promise<void>+ demand: 'refresh' | 'idle' | 'sealed'+}+type Lane = {tail: Promise<void>places: Set<StructuredAgentSessionDeliveryPlace>sends: Map<string, StructuredAgentSessionDeliveryPlace>active: Set<string>+ options?: OptionsCycle}/** One delivery order; active handovers retain their place through settlement. */@@ -20,6 +29,9 @@ export class StructuredAgentSessionDeliveryOrder {reconcile(sessionId: string, submissions: readonly AgentJournalSubmission[]): void {const queued = submissions.filter(isQueuedAgentJournalSubmission)const lane = this.lanes.get(sessionId)+ if (lane?.options && (queued.length > 0 || lane.active.size > 0)) {+ lane.options.demand = 'sealed'+ }const ids = new Set(queued.map((submission) => submission.clientMessageId))for (const [id, place] of lane?.sends ?? []) {if (!ids.has(id) && !lane?.active.has(id)) {@@ -62,6 +74,46 @@ export class StructuredAgentSessionDeliveryOrder {return place}+ joinOptions(sessionId: string, child: StructuredAgentSessionProviderChild): boolean {+ const cycle = this.lanes.get(sessionId)?.options+ if (!cycle || cycle.child !== child || cycle.signal.aborted) {+ return false+ }+ if (cycle.demand !== 'sealed') {+ cycle.demand = 'refresh'+ }+ return true+ }++ /** One optional producer shares the send order and the prepared readers' completion. */+ reserveOptions(+ sessionId: string,+ child: StructuredAgentSessionProviderChild,+ signal: AbortSignal+ ): OptionsCycle {+ const place = this.reserve(sessionId)+ const lane = this.lanes.get(sessionId)!+ const cycle: OptionsCycle = {+ child,+ signal,+ before: place.before,+ ready: lane.tail,+ demand: 'refresh',+ release: () => {+ if (lane.options === cycle) {+ lane.options = undefined+ }+ place.release()+ }+ }+ lane.options = cycle+ return cycle+ }++ optionsReady(sessionId: string): Promise<void> | undefined {+ return this.lanes.get(sessionId)?.options?.ready+ }+beforeSend(sessionId: string, messageId: string): Promise<void> {return this.lanes.get(sessionId)?.sends.get(messageId)?.before ?? Promise.resolve()}diff --git a/src/main/native-chat/agent-session-wire/structured-agent-session-host-mutation-wiring.ts b/src/main/native-chat/agent-session-wire/structured-agent-session-host-mutation-wiring.tsindex 8fe95459227..f6ae8c867d7 100644--- a/src/main/native-chat/agent-session-wire/structured-agent-session-host-mutation-wiring.ts+++ b/src/main/native-chat/agent-session-wire/structured-agent-session-host-mutation-wiring.ts@@ -20,6 +20,9 @@ type Inputs = {runtimeState: StructuredAgentSessionHostRuntimeStateattachContext: () => StructuredAgentSessionAttachContextserialize: StructuredAgentSessionMutationContext['serialize']+ trackProviderOperation: NonNullable<+ StructuredAgentSessionMutationContext['trackProviderOperation']+ >now: () => number}@@ -51,6 +54,7 @@ export function createStructuredAgentSessionHostMutationContext(startFlights: input.runtimeState.startFlights,startupAttempts: input.runtimeState.startupAttempts,deliveryOrder: input.runtimeState.deliveryOrder,+ trackProviderOperation: input.trackProviderOperation,joinChildClose: (sessionId) =>agentStart.joinClosingStructuredAgentSessionChild(input.attachContext(), sessionId),wakeDelivery: (sessionId) => input.conversationDelivery.loop.wake(sessionId),diff --git a/src/main/native-chat/agent-session-wire/structured-agent-session-host-mutations.ts b/src/main/native-chat/agent-session-wire/structured-agent-session-host-mutations.tsindex 95479eab140..4ec4b8c9b1a 100644--- a/src/main/native-chat/agent-session-wire/structured-agent-session-host-mutations.ts+++ b/src/main/native-chat/agent-session-wire/structured-agent-session-host-mutations.ts@@ -56,6 +56,7 @@ import {type StructuredAgentSessionOptionsReader} from './structured-agent-session-options-read'import { settleStructuredAgentSessionLateDispatch } from './structured-agent-session-late-dispatch'+import { confirmIdleStructuredAgentSessionOption } from './structured-agent-session-idle-option'export function sendStructuredAgentSessionTurn(context: StructuredAgentSessionMutationContext,@@ -233,7 +234,13 @@ export async function setStructuredAgentSessionOption({...plan,conversationWrite: true,- run: (ctx) => recordStructuredAgentSessionOptionIntent(context.deps, ctx, params)+ run: async (ctx) => {+ const picked = await recordStructuredAgentSessionOptionIntent(context.deps, ctx, params)+ if (picked.ok) {+ confirmIdleStructuredAgentSessionOption(context, ctx, params)+ }+ return picked+ }},openForWrite(context, params.envelope))diff --git a/src/main/native-chat/agent-session-wire/structured-agent-session-host.ts b/src/main/native-chat/agent-session-wire/structured-agent-session-host.tsindex 0d91fe94820..ce8916f826f 100644--- a/src/main/native-chat/agent-session-wire/structured-agent-session-host.ts+++ b/src/main/native-chat/agent-session-wire/structured-agent-session-host.ts@@ -23,7 +23,7 @@ import { structuredAgentSessionMutationDelegates } from './structured-agent-sessimport { flushStructuredAgentSessionHost } from './structured-agent-session-host-teardown'import type * as HostTypes from './structured-agent-session-host-types'import { StructuredAgentSessionEventRecovery } from './structured-agent-session-event-recovery'-import { StructuredAgentSessionBackgroundTaskChannel } from './structured-agent-session-background-task-channel'+import { StructuredAgentSessionBackgroundTaskChannel as BackgroundTasks } from './structured-agent-session-background-task-channel'import { StructuredAgentSessionClientDelivery } from './structured-agent-session-client-delivery'import { StructuredAgentSessionConversations } from './structured-agent-session-conversations'import * as resume from './structured-agent-session-restart-resume-host'@@ -72,14 +72,14 @@ export class StructuredAgentSessionHost {private readonly lifetime: lifetime.StructuredAgentSessionConversationLifetimeprivate readonly conversationDelivery: conversation.StructuredAgentSessionConversationDeliveryprivate readonly eventRecovery: StructuredAgentSessionEventRecovery- private readonly backgroundTasks: StructuredAgentSessionBackgroundTaskChannel+ private readonly backgroundTasks: BackgroundTasksreadonly restartResume: resume.StructuredAgentSessionRestartResumeconstructor(readonly deps: HostTypes.StructuredAgentSessionHostDeps) {// Collaborators share a logger wrapper that cannot fail the operation it reports.this.deps = deps = sessionLogger.withNeverThrowingLogger(deps)this.clientDelivery.watchAtRestCommands(deps.adapter)- this.backgroundTasks = new StructuredAgentSessionBackgroundTaskChannel(+ this.backgroundTasks = new BackgroundTasks(deps,this.sessions,this.subscribers,@@ -278,6 +278,7 @@ export class StructuredAgentSessionHost {queued: this.queued,runtimeState: this.runtimeState,attachContext: () => this.attachContext(),+ trackProviderOperation: (operation) => this.tasks.trackAttach(operation),serialize: (sessionId, task) => this.serialize(sessionId, task),now: () => this.now()})@@ -311,8 +312,7 @@ export class StructuredAgentSessionHost {/** Read the store; idle-released chats have no session-map entry. */handoffStatus = (sessionId: string) => structuredAgentSessionOwnerStatus(this.deps, sessionId)- history: StructuredAgentSessionBackgroundTaskChannel['history'] = (...args) =>- this.backgroundTasks.history(...args)+ history: BackgroundTasks['history'] = (...args) => this.backgroundTasks.history(...args)readonly continuationContext: ReturnType<typeof contextReader>@@ -321,7 +321,7 @@ export class StructuredAgentSessionHost {(await this.lifetime.conversation(sessionId)).journal.snapshot()currentWork = this.clientDelivery.readCurrentWork- readCurrentRequests: StructuredAgentSessionBackgroundTaskChannel['currentRequests'] = (...args) =>+ readCurrentRequests: BackgroundTasks['currentRequests'] = (...args) =>this.backgroundTasks.currentRequests(...args)observeJournalPublications = this.clientDelivery.observeJournalPublicationsdiff --git a/src/main/native-chat/agent-session-wire/structured-agent-session-idle-option.ts b/src/main/native-chat/agent-session-wire/structured-agent-session-idle-option.tsnew file mode 100644index 00000000000..cfff83c4412--- /dev/null+++ b/src/main/native-chat/agent-session-wire/structured-agent-session-idle-option.ts@@ -0,0 +1,125 @@+import { waitForPromiseWithSignal } from '../../../shared/abort-signal-reason'+import type { StructuredAgentSessionMutationContext } from './structured-agent-session-mutation-context'+import type { AgentSessionTurnContext } from './structured-agent-session-turns'+import { contextStructuredAgentSessionCurrentWork } from './structured-agent-session-current-work'+import { structuredAgentSessionSendBlock } from './structured-agent-session-send-preparation'++/** Reserve under admission; provider work and its readback never hold that lane. */+export function confirmIdleStructuredAgentSessionOption(+ context: StructuredAgentSessionMutationContext,+ ctx: AgentSessionTurnContext,+ input: { key: string; value: string }+): void {+ const { sessionId, fence } = ctx+ const { adapter, store } = context.deps+ const child = context.sessions.get(sessionId)?.child+ const eligible = (value: string): boolean => {+ const record = store.getRecord(sessionId)+ const work = contextStructuredAgentSessionCurrentWork(ctx)+ return !!(+ child &&+ context.sessions.get(sessionId)?.child === child &&+ child.phase === 'ready' &&+ !child.close &&+ child.fence === fence &&+ record?.lease.claimStatus === 'live' &&+ record.lease.runtimeFence === fence &&+ record.options?.[input.key] === value &&+ !structuredAgentSessionSendBlock(record) &&+ adapter.canSetOptionWhileIdle?.({ sessionId, fence, key: input.key, value }) === true &&+ !work.working() &&+ !work.hasActionablePrompt() &&+ !context.childWorkOpen(sessionId) &&+ !ctx.journal.queuedMessages.awaitReopenMark()+ )+ }+ if (!eligible(input.value) || !child || context.deliveryOrder.joinOptions(sessionId, child)) {+ return+ }+ const operation = context.acquireAborts.begin(+ sessionId,+ false,+ false,+ () => context.sessions.get(sessionId)?.child === child+ )+ const cycle = context.deliveryOrder.reserveOptions(sessionId, child, operation.signal)+ let finished = false+ const finish = (): void => {+ if (!finished) {+ finished = true+ operation.end()+ cycle.release()+ context.wakeDelivery(sessionId)+ }+ }+ const run = async (): Promise<void> => {+ try {+ await waitForPromiseWithSignal(cycle.before, operation.signal)+ let confirmed: string | undefined+ for (;;) {+ const pending = await context.serialize(sessionId, async () => {+ if (+ !operation.signal.aborted &&+ confirmed !== undefined &&+ eligible(confirmed) &&+ cycle.demand !== 'refresh'+ ) {+ ctx.publish()+ }+ const value = store.getRecord(sessionId)?.options?.[input.key]+ if (+ operation.signal.aborted ||+ cycle.demand !== 'refresh' ||+ value === undefined ||+ !eligible(value)+ ) {+ // Completion and the last claim are atomic with subsequent picks.+ finish()+ return null+ }+ cycle.demand = 'idle'+ return {+ value,+ written: adapter.setOption({+ sessionId,+ fence,+ key: input.key,+ value,+ signal: operation.signal+ })+ }+ })+ if (!pending) {+ return+ }+ confirmed = undefined+ try {+ await pending.written+ confirmed = pending.value+ } catch (error) {+ if (!operation.signal.aborted) {+ ctx.logger.warn('confirming idle session metadata failed', {+ scope: 'idle-option',+ sessionId,+ error+ })+ }+ }+ }+ } catch (error) {+ if (!operation.signal.aborted) {+ ctx.logger.warn('confirming idle session metadata failed', {+ scope: 'idle-option',+ sessionId,+ error+ })+ }+ } finally {+ if (!finished) {+ await context.serialize(sessionId, async () => finish())+ }+ }+ }+ const pending = run()+ context.trackProviderOperation?.(pending)+}diff --git a/src/main/native-chat/agent-session-wire/structured-agent-session-mutation-context.ts b/src/main/native-chat/agent-session-wire/structured-agent-session-mutation-context.tsindex 10ce8024b88..fb51feb722f 100644--- a/src/main/native-chat/agent-session-wire/structured-agent-session-mutation-context.ts+++ b/src/main/native-chat/agent-session-wire/structured-agent-session-mutation-context.ts@@ -48,6 +48,7 @@ export type StructuredAgentSessionMutationContext = {startFlights: Pick<StructuredAgentSessionStartFlights, 'get'>startupAttempts: Pick<StructuredAgentSessionStartupAttempts, 'readiness'>deliveryOrder: StructuredAgentSessionDeliveryOrder+ trackProviderOperation?: <T>(operation: Promise<T>) => Promise<T>/** Join without starting a child, inside existing serialization. */joinChildClose: (sessionId: string) => Promise<AgentSessionMutationSessionPreparation>wakeDelivery: (sessionId: string) => voiddiff --git a/src/main/native-chat/agent-session-wire/structured-agent-session-options-deadline.test.ts b/src/main/native-chat/agent-session-wire/structured-agent-session-options-deadline.test.tsindex 528796e659e..2ca9fd5432a 100644--- a/src/main/native-chat/agent-session-wire/structured-agent-session-options-deadline.test.ts+++ b/src/main/native-chat/agent-session-wire/structured-agent-session-options-deadline.test.ts@@ -19,7 +19,7 @@ function restingJournal() {}}-it('bounds legacy saved-scope preparation without changing saved Auto', async () => {+it('keeps one legacy deadline across an optional join and current resting read', async () => {vi.useFakeTimers()const args = Promise.withResolvers<string[]>()const resolving = vi.fn(() => args.promise)@@ -49,11 +49,14 @@ it('bounds legacy saved-scope preparation without changing saved Auto', async ()})}})+ const completion = Promise.withResolvers<void>()+ const optionsReady = vi.fn(() => completion.promise)+ let child: { phase: 'ready'; fence: number } | null = { phase: 'ready', fence: 1 }const resting = { child: null, params: { provider: 'claude' }, journal: restingJournal() }// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: the full read only uses these context members.const context = {deps: {- adapter: {},+ adapter: { readOptions: async () => ({ models: [], current: {} }) },agents: claudeAndCodexAgents(),store: {getConversation: () => {@@ -64,8 +67,9 @@ it('bounds legacy saved-scope preparation without changing saved Auto', async ()},modelCatalog: catalog},+ deliveryOrder: { optionsReady },serialize: (_id: string, task: () => Promise<unknown>) => task(),- openConversation: async () => resting,+ openConversation: async () => ({ ...resting, child }),conversation: async () => resting} as unknown as StructuredAgentSessionMutationContexttry {@@ -73,14 +77,21 @@ it('bounds legacy saved-scope preparation without changing saved Auto', async ()readsWithoutModel: false})await vi.advanceTimersByTimeAsync(0)+ expect(resolving).not.toHaveBeenCalled()+ await vi.advanceTimersByTimeAsync(10_000)+ child = null+ completion.resolve()+ await vi.advanceTimersByTimeAsync(0)+ expect(optionsReady).toHaveBeenCalledExactlyOnceWith(SESSION)expect(resolving).toHaveBeenCalledOnce()- await vi.advanceTimersByTimeAsync(30_001)+ await vi.advanceTimersByTimeAsync(20_001)await expect(answer).resolves.toMatchObject({ current: { permissionMode: 'auto' } })expect(resolving).toHaveBeenCalledOnce()args.resolve([])await vi.advanceTimersByTimeAsync(0)expect(environment).not.toHaveBeenCalled()} finally {+ completion.resolve()args.resolve([])catalog.stop()vi.useRealTimers()diff --git a/src/main/native-chat/agent-session-wire/structured-agent-session-options-read.ts b/src/main/native-chat/agent-session-wire/structured-agent-session-options-read.tsindex fb3f6aa8c34..baf1c799b2e 100644--- a/src/main/native-chat/agent-session-wire/structured-agent-session-options-read.ts+++ b/src/main/native-chat/agent-session-wire/structured-agent-session-options-read.ts@@ -31,7 +31,8 @@ export async function readStructuredAgentSessionOptions(context: Pick<StructuredAgentSessionMutationContext,'deps' | 'serialize' | 'openConversation' | 'conversation'- >,+ > &+ Partial<Pick<StructuredAgentSessionMutationContext, 'deliveryOrder'>>,sessionId: string,reader: StructuredAgentSessionOptionsReader): Promise<AgentSessionOptionsResult> {@@ -39,24 +40,34 @@ export async function readStructuredAgentSessionOptions(? reader: { ...reader, deadline: reader.deadline ?? Date.now() + AGENT_MODEL_CATALOG_PICKER_WAIT_MS }const { adapter, agents, store } = context.deps- const started = await context.serialize(sessionId, async () => {- const session = await context.openConversation(sessionId).catch((error: unknown) => {- throw journalOpenReadRefusal(error, context.deps.logger, sessionId)+ const readCurrent = (allowJoin: boolean) =>+ context.serialize(sessionId, async () => {+ const session = await context.openConversation(sessionId).catch((error: unknown) => {+ throw journalOpenReadRefusal(error, context.deps.logger, sessionId)+ })+ const child = session?.child+ if (!child || child.phase === 'starting') {+ return { kind: 'rest' as const }+ }+ if (!adapter.readOptions) {+ throw new Error('structured_agent_session_options_unsupported')+ }+ const pending = allowJoin ? context.deliveryOrder?.optionsReady(sessionId) : undefined+ if (pending) {+ return { kind: 'pending' as const, pending }+ }+ return {+ kind: 'live' as const,+ session,+ child,+ options: await adapter.readOptions({ sessionId, fence: child.fence })+ }})- const child = session?.child- if (!child || child.phase === 'starting') {- return { kind: 'rest' as const }- }- if (!adapter.readOptions) {- throw new Error('structured_agent_session_options_unsupported')- }- return {- kind: 'live' as const,- session,- child,- options: await adapter.readOptions({ sessionId, fence: child.fence })- }- })+ let started = await readCurrent(true)+ if (started.kind === 'pending') {+ await started.pending.catch(() => undefined)+ started = await readCurrent(false)+ }const live: StructuredAgentSessionLiveOptions | null =started.kind === 'live' ? started.options : nulllet rested: RestingOptions | undefineddiff --git a/src/renderer/src/components/native-chat/use-structured-agent-session-options.test-fixture.tsx b/src/renderer/src/components/native-chat/use-structured-agent-session-options.test-fixture.tsxindex e04f4554e12..41dc078f2c7 100644--- a/src/renderer/src/components/native-chat/use-structured-agent-session-options.test-fixture.tsx+++ b/src/renderer/src/components/native-chat/use-structured-agent-session-options.test-fixture.tsx@@ -12,7 +12,7 @@ type OptionsFixtureMocks = {enqueue: Mockpick: Mocktarget: RuntimeClientTarget- agent: 'codex' | 'claude'+ agent: 'codex' | 'claude' | 'antigravity'hold: Mock<(sessionId: string,@@ -159,7 +159,7 @@ type RenderProps = {hidden?: booleanlaunchSeedOptions?: Record<string, string>worktree?: string- agent?: 'claude' | 'codex'+ agent?: 'claude' | 'codex' | 'antigravity'providerStarting?: booleanpaired?: boolean}diff --git a/src/renderer/src/components/native-chat/use-structured-agent-session-options.test.tsx b/src/renderer/src/components/native-chat/use-structured-agent-session-options.test.tsxindex 309db5fbd0d..b4bf557179d 100644--- a/src/renderer/src/components/native-chat/use-structured-agent-session-options.test.tsx+++ b/src/renderer/src/components/native-chat/use-structured-agent-session-options.test.tsx@@ -21,6 +21,7 @@ import {SEED,tick} from './use-structured-agent-session-options.test-fixture'+import type { AgentSessionOptionsResult } from '../../../../shared/agent-session-wire'import { act, waitFor } from '@testing-library/react'import { beforeEach, describe, expect, it } from 'vitest'@@ -45,6 +46,64 @@ describe('useStructuredAgentSessionOptions', () => {resetHostModelCatalogSnapshotsForTests()})+ it('keeps the latest dependent menu after same-stamp receipts and an older delayed answer', async () => {+ const menu = (model: string, effort?: string): AgentSessionOptionsResult => ({+ models: ['family', 'newer'].map((id) => ({+ id,+ label: id,+ isDefault: false,+ effortsKnown: id === model && !!effort ? undefined : (false as const),+ efforts:+ id === model && effort ? [effort, 'off'].map((value) => ({ value, label: value })) : []+ })),+ current: { model, ...(effort ? { effort } : {}) }+ })+ const initial = menu('family')+ const older = Promise.withResolvers<AgentSessionOptionsResult>()+ const latest = Promise.withResolvers<AgentSessionOptionsResult>()+ let reads = 0+ answer({+ options: () =>+ [Promise.resolve(initial), older.promise, latest.promise][reads++] ?? latest.promise+ })+ const { mutate, calls } = mutateWith(async () => null)+ calls+ .mockResolvedValueOnce({ options: { model: 'family' } })+ .mockResolvedValue({ options: { model: 'newer' } })+ const { result, rerender, unmount } = renderOptions(+ { ...REOPENED, agent: 'antigravity' },+ mutate+ )+ await waitFor(() => expect(currentValue(result.current.optionSnapshot, 'model')).toBe('family'))+ expect(descriptor(result.current.optionSnapshot, 'effort')).toBeUndefined()+ await act(async () => {+ expect(await result.current.setStructuredOption('model', 'family')).toBe(true)+ })+ await waitFor(() => expect(reads).toBe(2))+ await act(async () => {+ expect(await result.current.setStructuredOption('model', 'newer')).toBe(true)+ })+ expect(descriptor(result.current.optionSnapshot, 'model')?.settable).toBe(true)+ expect(descriptor(result.current.optionSnapshot, 'effort')).toBeUndefined()+ // Returning to the view starts a current reader while the superseded response is still in flight.+ rerender({ ...REOPENED, agent: 'antigravity', hidden: true })+ rerender({ ...REOPENED, agent: 'antigravity' })+ await waitFor(() => expect(reads).toBe(3))+ await act(async () => latest.resolve(menu('newer', 'high')))+ await waitFor(() => expect(currentValue(result.current.optionSnapshot, 'effort')).toBe('high'))+ await act(async () => older.resolve(menu('family', 'low')))+ expect(currentValue(result.current.optionSnapshot, 'model')).toBe('newer')+ expect(descriptor(result.current.optionSnapshot, 'effort')).toMatchObject({+ settable: true,+ kind: {+ type: 'select',+ currentValue: 'high',+ choices: [{ value: 'high' }, { value: 'off' }]+ }+ })+ unmount()+ })+it('retains a queried seed-catalog base through same-session attach and later metadata', async () => {mocks.coherentCatalog = truelet landCatalog = (_value: unknown): void => {}