From 768d0a656b2a82e3033b95830052771b805defc4 Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Wed, 11 Nov 2026 12:58:37 -0800 Subject: [PATCH 1/3] fix(cloud): --effort and --tag take effect for cloud workspaces (SUPER-3306) --tag: the CLI refused it for cloud workspaces, and cloudWorkspace.create had no tags input. create now takes and returns tags; the CLI sends them. --effort: a cloud agent opened as a chat lost its effort in host-service, whose chat launch had no effort field and refused chat for an effort. The chat runtime has taken effortId since #9410; host-service now passes it. --- .../create/createCloudWorkspace.test.ts | 10 +++ .../workspaces/create/createCloudWorkspace.ts | 2 +- .../sandbox-self-seed/sandbox-self-seed.ts | 1 + .../src/trpc/router/agents/agents.test.ts | 15 ++-- .../src/trpc/router/agents/agents.ts | 1 - .../router/sessions/create-chat-session.ts | 1 + .../trpc/router/sessions/session-service.ts | 2 + .../src/trpc/router/sessions/sessions.test.ts | 23 +++++- .../cloud-workspace/cloud-workspace.test.ts | 76 +++++++++++++++++++ .../router/cloud-workspace/cloud-workspace.ts | 5 +- 10 files changed, 125 insertions(+), 11 deletions(-) diff --git a/packages/cli/src/commands/workspaces/create/createCloudWorkspace.test.ts b/packages/cli/src/commands/workspaces/create/createCloudWorkspace.test.ts index 79ef8c79a8b..653d65f687f 100644 --- a/packages/cli/src/commands/workspaces/create/createCloudWorkspace.test.ts +++ b/packages/cli/src/commands/workspaces/create/createCloudWorkspace.test.ts @@ -69,6 +69,16 @@ test("sends --base-branch as the branch the cloud workspace starts from", async expect(calls.createInput).toMatchObject({ branch: "main" }); }); +test("sends --tag to the cloud", async () => { + const { api, calls } = recordingApi(); + await createCloudWorkspace({ + api, + organizationId: "org", + options: { tag: ["fleet", "migration"] }, + }); + expect(calls.createInput).toMatchObject({ tags: ["fleet", "migration"] }); +}); + test("returns the cloud workspace's desktop and web links", async () => { const { api } = recordingApi(); const result = await createCloudWorkspace({ diff --git a/packages/cli/src/commands/workspaces/create/createCloudWorkspace.ts b/packages/cli/src/commands/workspaces/create/createCloudWorkspace.ts index b70befc6d6b..90dcef54779 100644 --- a/packages/cli/src/commands/workspaces/create/createCloudWorkspace.ts +++ b/packages/cli/src/commands/workspaces/create/createCloudWorkspace.ts @@ -49,7 +49,6 @@ export async function createCloudWorkspace(args: { ["--pr", options.pr], ["--task", options.task], ["--skip-branch-prefix", options.skipBranchPrefix || undefined], - ["--tag", options.tag?.length ? options.tag : undefined], ["--command", options.command], ] as const) { if (value !== undefined) { @@ -115,6 +114,7 @@ export async function createCloudWorkspace(args: { ...(options.effort ? { effort: options.effort } : {}), ...(options.machineSize ? { machineSize: options.machineSize } : {}), ...(attachmentFileIds.length > 0 ? { attachmentFileIds } : {}), + ...(options.tag?.length ? { tags: options.tag } : {}), }) .catch(rethrowWithLocationHint); diff --git a/packages/host-service/src/runtime/sandbox-self-seed/sandbox-self-seed.ts b/packages/host-service/src/runtime/sandbox-self-seed/sandbox-self-seed.ts index 6b217c2ad7e..086139b78dd 100644 --- a/packages/host-service/src/runtime/sandbox-self-seed/sandbox-self-seed.ts +++ b/packages/host-service/src/runtime/sandbox-self-seed/sandbox-self-seed.ts @@ -388,6 +388,7 @@ export async function launchSandboxAgentOnce( agent, prompt, model, + effort, mode, ...(attachmentIds?.length ? { attachmentIds } : {}), }, diff --git a/packages/host-service/src/trpc/router/agents/agents.test.ts b/packages/host-service/src/trpc/router/agents/agents.test.ts index 4a46ded1116..7924e4013c7 100644 --- a/packages/host-service/src/trpc/router/agents/agents.test.ts +++ b/packages/host-service/src/trpc/router/agents/agents.test.ts @@ -1174,19 +1174,20 @@ describe("continuationTarget", () => { const db = createTestDb(); seedClaude(db); const launch = { workspaceId, agent: "claude", prompt: "go" }; - - expect( - chatLaunchTarget(db, { ...launch, surface: "chat", mode: "plan" }), - ).toEqual({ + const claudeChat = { harness: "claude-acp", label: "Claude", agentConfigId: "00000000-0000-0000-0000-00000000000a", attachments: [], - }); - expect(chatLaunchTarget(db, launch)).toBeNull(); + }; + + expect( + chatLaunchTarget(db, { ...launch, surface: "chat", mode: "plan" }), + ).toEqual(claudeChat); expect( chatLaunchTarget(db, { ...launch, surface: "chat", effort: "high" }), - ).toBeNull(); + ).toEqual(claudeChat); + expect(chatLaunchTarget(db, launch)).toBeNull(); }); it("chats as a custom agent that runs the claude or codex CLI", () => { diff --git a/packages/host-service/src/trpc/router/agents/agents.ts b/packages/host-service/src/trpc/router/agents/agents.ts index 713bf39fa48..0606cc22c38 100644 --- a/packages/host-service/src/trpc/router/agents/agents.ts +++ b/packages/host-service/src/trpc/router/agents/agents.ts @@ -673,7 +673,6 @@ export function chatLaunchTarget( } | null { if ( input.surface !== "chat" || - input.effort || input.resumeSessionId || input.forkSessionId ) { diff --git a/packages/host-service/src/trpc/router/sessions/create-chat-session.ts b/packages/host-service/src/trpc/router/sessions/create-chat-session.ts index d485bf981d6..601fd827e12 100644 --- a/packages/host-service/src/trpc/router/sessions/create-chat-session.ts +++ b/packages/host-service/src/trpc/router/sessions/create-chat-session.ts @@ -31,6 +31,7 @@ export function createChatSession( : {}), terminalId, ...(input.model ? { modelId: input.model } : {}), + ...(input.effort ? { effortId: input.effort } : {}), ...(input.mode ? { modeId: input.mode } : {}), ...(input.resumeSessionId ? { resume: { harnessSessionId: input.resumeSessionId } } diff --git a/packages/host-service/src/trpc/router/sessions/session-service.ts b/packages/host-service/src/trpc/router/sessions/session-service.ts index 08c789a8cfd..16d780251ba 100644 --- a/packages/host-service/src/trpc/router/sessions/session-service.ts +++ b/packages/host-service/src/trpc/router/sessions/session-service.ts @@ -17,6 +17,7 @@ export const createChatSessionSchema = z agent: z.string().min(1), prompt: z.string().default(""), model: z.string().min(1).optional(), + effort: z.string().min(1).optional(), mode: z.string().min(1).optional(), resumeSessionId: z.string().min(1).optional(), continueSessionId: z.string().min(1).optional(), @@ -126,6 +127,7 @@ export async function createChatSessionInWorkspace( if ( input.continueSessionId && !input.model && + !input.effort && !input.mode && !input.attachmentIds?.length ) { diff --git a/packages/host-service/src/trpc/router/sessions/sessions.test.ts b/packages/host-service/src/trpc/router/sessions/sessions.test.ts index 98496cbc6d0..097bea12de0 100644 --- a/packages/host-service/src/trpc/router/sessions/sessions.test.ts +++ b/packages/host-service/src/trpc/router/sessions/sessions.test.ts @@ -5,6 +5,7 @@ import { type ChatRuntime, FakeHarness, type HarnessFactoryOptions, + type HarnessStartOptions, } from "@superset/chat-runtime"; import { createTestRuntime, waitFor } from "@superset/chat-runtime/testing"; import { eq } from "drizzle-orm"; @@ -23,12 +24,14 @@ let runtime: ChatRuntime; let db: HostDb; let startDead: boolean; let launches: HarnessFactoryOptions[]; +let starts: HarnessStartOptions[]; let caller: ReturnType; let ctx: HostServiceContext; beforeEach(() => { startDead = false; launches = []; + starts = []; const sqlite = new Database(":memory:"); db = drizzle(sqlite, { schema }) as unknown as HostDb; migrate(db as never, { @@ -77,7 +80,7 @@ beforeEach(() => { "claude-acp", (options: HarnessFactoryOptions) => { launches.push(options); - return new FakeHarness({ + const harness = new FakeHarness({ start: [ { kind: "session", @@ -91,6 +94,12 @@ beforeEach(() => { ], turns: [[], []], }); + const start = harness.start.bind(harness); + harness.start = (startOptions) => { + starts.push(startOptions); + return start(startOptions); + }; + return harness; }, ], ]), @@ -207,6 +216,18 @@ describe("sessions router", () => { ).toHaveLength(1); }); + test("starts the agent at the reasoning effort the caller asked for", async () => { + const created = await createChatSessionInWorkspace(ctx, { + workspaceId: WORKSPACE, + agent: "claude", + prompt: "go", + effort: "high", + }); + expect(created.kind).toBe("chat"); + await waitFor(() => starts.length > 0); + expect(starts[0]?.effortId).toBe("high"); + }); + test("launches under the terminal id a cloud launch was promised", async () => { const terminalId = crypto.randomUUID(); const created = await createChatSessionInWorkspace( diff --git a/packages/trpc/src/router/cloud-workspace/cloud-workspace.test.ts b/packages/trpc/src/router/cloud-workspace/cloud-workspace.test.ts index 4f83221de63..ca235e08cdf 100644 --- a/packages/trpc/src/router/cloud-workspace/cloud-workspace.test.ts +++ b/packages/trpc/src/router/cloud-workspace/cloud-workspace.test.ts @@ -1,11 +1,17 @@ import { beforeEach, describe, expect, test } from "bun:test"; import { db } from "@superset/db/client"; import { stub } from "../../../test/stub"; +import * as attachments from "../../lib/attachments"; import * as plan from "../../lib/billing/plan"; import * as guards from "../../lib/cloud-guards"; +import * as githubUser from "../../lib/github-user"; import * as realtime from "../../lib/realtime"; import * as sandbox from "../../lib/sandbox"; +import * as userSettings from "../../lib/user-settings"; +import * as workspaceAccess from "../../lib/workspace-access"; import * as access from "./access"; +import * as activity from "./activity"; +import * as jobs from "./jobs"; import * as meter from "./meter"; import * as wake from "./wake"; @@ -22,13 +28,41 @@ let running = false; let boxVcpus = 8; let restartedWith: string[] = []; +const ENVIRONMENT_ID = "5e6f7a8b-9c0d-4e1f-8a2b-3c4d5e6f7a8b"; +let inserted: unknown[] = []; +let queuedJobs: { launch?: { surface?: string; effort?: string } }[] = []; + stub(db.query.cloudWorkspaces, { findFirst: async () => ROW }); +stub(db.query.environments, { + findFirst: async () => ({ id: ENVIRONMENT_ID, scope: "organization" }), +}); +stub(db.query.users, { + findFirst: async () => ({ id: "user-1", name: "Ana", image: null }), +}); stub(db, { update: () => ({ set: (values: Record) => ({ where: () => ({ returning: async () => [{ ...ROW, ...values }] }), }), }), + insert: () => ({ + values: (values: Record | unknown[]) => { + inserted.push(values); + return Object.assign(Promise.resolve(), { + returning: async () => [{ ...ROW, ...values }], + }); + }, + }), +}); +stub(githubUser, { githubUserTokenFor: async () => null }); +stub(attachments, { anchorAttachments: async () => {} }); +stub(activity, { recordCloudWorkspaceActivity: async () => {} }); +stub(workspaceAccess, { pushWorkspaceAccess: () => {} }); +stub(userSettings, { acpChatEnabled: async () => true }); +stub(jobs, { + publishCloudWorkspaceJob: async (job: { body: (typeof queuedJobs)[0] }) => { + queuedJobs.push(job.body); + }, }); stub(guards, { assertMember: async () => {}, @@ -56,6 +90,12 @@ stub(sandbox, { running, vcpus: boxVcpus, }), + environmentRepositoryRows: async () => [ + { id: "repo-1", defaultBranch: "main" }, + ], + primaryRepository: (rows: unknown[]) => rows[0], + recordWorkspaceRepositories: async () => {}, + workspaceBranchName: () => "paradev/ws-1", }); stub(wake, { restartCloudWorkspace: async (row: { machineSize: string }) => { @@ -90,6 +130,42 @@ beforeEach(() => { running = false; boxVcpus = 8; restartedWith = []; + inserted = []; + queuedJobs = []; +}); + +describe("cloudWorkspace.create", () => { + const create = (input: Record) => + caller.cloudWorkspace.create({ + organizationId: "1a2b3c4d-5e6f-4a7b-8c9d-0e1f2a3b4c5d", + environmentId: ENVIRONMENT_ID, + machineSize: "xlarge", + ...input, + } as never); + + test("files the new workspace under the caller's tags", async () => { + const row = await create({ tags: ["Fleet", "migration"] }); + expect(inserted).toContainEqual([ + expect.objectContaining({ tag: "fleet", createdByUserId: "user-1" }), + expect.objectContaining({ tag: "migration", createdByUserId: "user-1" }), + ]); + expect(row.tags).toEqual(["fleet", "migration"]); + }); + + test("opens a chat that carries the agent's effort and mode to the box", async () => { + const row = await create({ + agent: "claude", + prompt: "Fix the build", + effort: "high", + mode: "plan", + }); + expect(queuedJobs[0]?.launch).toMatchObject({ + surface: "chat", + effort: "high", + mode: "plan", + }); + expect(row.initialLaunch).toMatchObject({ surface: "chat" }); + }); }); describe("cloudWorkspace.setMachineSize", () => { diff --git a/packages/trpc/src/router/cloud-workspace/cloud-workspace.ts b/packages/trpc/src/router/cloud-workspace/cloud-workspace.ts index f826101b710..f56e8914045 100644 --- a/packages/trpc/src/router/cloud-workspace/cloud-workspace.ts +++ b/packages/trpc/src/router/cloud-workspace/cloud-workspace.ts @@ -404,6 +404,8 @@ export const cloudWorkspaceRouter = { taskIds: z.array(z.string().uuid()).max(10).optional(), /** A size the organization offers (see `machineSizes`); omitted = its default. */ machineSize: z.enum(MACHINE_SIZES).optional(), + /** The caller's own tags, as `setTags` files them. */ + tags: workspaceTagsInputSchema.optional(), /** * A workspace that moves into the new one, in place of an agent: * the move `workspaceMove.begin` recorded. The new workspace starts @@ -464,6 +466,7 @@ export const cloudWorkspaceRouter = { taskIds: input.taskIds, attachmentFileIds: input.attachmentFileIds, machineSize: input.machineSize, + tags: input.tags, chat: !!input.agent && (await acpChatEnabled(ctx.principal.userId)), ...(input.agent ? { @@ -519,7 +522,7 @@ export const cloudWorkspaceRouter = { ? { userId: creator.id, name: creator.name, image: creator.image } : null, presence: NO_PRESENCE, - tags: [] as string[], + tags: input.tags ?? [], /** Chats of a moving workspace that could not move, and stay where they were. */ skippedChats, }; From 46176085a96cb355af9428841149bbe34859156e Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Wed, 11 Nov 2026 13:15:54 -0800 Subject: [PATCH 2/3] fix(cloud): address review on #9638 - docs: a cloud workspace refuses --branch and cuts its branch from --base-branch - tags: reject control characters, which Postgres cannot store; a NUL tag failed the tag insert after the workspace row existed and left it stuck in provisioning - chat: log when the agent does not take the requested reasoning effort --- apps/docs/content/docs/cli/cli-reference.mdx | 10 +++++----- .../chat-runtime/src/harness/acp/acpAdapter.ts | 18 +++++++++++++----- packages/shared/src/workspace-tags.test.ts | 7 +++++++ packages/shared/src/workspace-tags.ts | 9 +++++++++ 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/apps/docs/content/docs/cli/cli-reference.mdx b/apps/docs/content/docs/cli/cli-reference.mdx index 8bf14d36101..674a70a0c28 100644 --- a/apps/docs/content/docs/cli/cli-reference.mdx +++ b/apps/docs/content/docs/cli/cli-reference.mdx @@ -790,10 +790,10 @@ project id when the host does not know the project's name. { flag: "--session", description: "Create a project-less session (a managed scratch folder) on a host. Mutually exclusive with `--project`." }, { flag: "--name ", description: "Workspace name. Required when `--project` is set; optional for sessions." }, { flag: "--checkout ", description: "Use the shared project checkout or a separate worktree (default). Requires `--project`." }, - { flag: "--branch ", description: "Workspace branch. On a host, required unless `--pr`, `--task`, or `--checkout local` is set. For a cloud workspace, the base branch (default: the repository's default branch)." }, + { flag: "--branch ", description: "Workspace branch. On a host, required unless `--pr`, `--task`, or `--checkout local` is set. Not accepted for a cloud workspace, which always works on a new branch of its own; use `--base-branch`." }, { flag: "--pr ", description: "Pull request number. Checks out the verified PR head." }, { flag: "--task ", description: "Task ID to link. When `--branch` is omitted, the task's provider branch name (e.g. Linear's) is used verbatim." }, - { flag: "--base-branch ", description: "Branch to fork from when `--branch` does not exist. Defaults to the project default branch." }, + { flag: "--base-branch ", description: "On a host, the branch to fork from when `--branch` does not exist (default: the project default branch). For a cloud workspace, the branch its new branch is cut from (default: the repository's default branch)." }, { flag: "--skip-branch-prefix", description: "Use `--branch` exactly as given instead of namespacing it under the project branch prefix." }, { flag: "--host ", description: "Target host machineId, or `cloud`. Mutually exclusive with `--local`. Without either, creates in the cloud if your account has cloud workspaces, else on this machine." }, { flag: "--local", description: "Target this machine. Mutually exclusive with `--host`." }, @@ -830,9 +830,9 @@ requires either `--project ` or `--session`; omitting both is an error. Without `--host` or `--local`, the command creates a [cloud workspace](/cloud-workspaces) if your account has cloud workspaces. A cloud workspace takes no project: it starts from an -environment, and Paradev creates a new working branch from `--branch`. `--project`, -`--session`, `--checkout`, `--pr`, `--task`, `--base-branch`, `--skip-branch-prefix`, -`--tag`, and `--command` are rejected for a cloud workspace. `--attachment` needs `--agent`: +environment, and Paradev creates a new working branch from `--base-branch` (default: the +repository's default branch). `--project`, `--session`, `--checkout`, `--branch`, `--pr`, +`--task`, `--skip-branch-prefix`, and `--command` are rejected for a cloud workspace. `--attachment` needs `--agent`: the files go to the agent through Paradev's storage, up to 200 MB each and 10 at a time. The command returns while the workspace is still provisioning. diff --git a/packages/chat-runtime/src/harness/acp/acpAdapter.ts b/packages/chat-runtime/src/harness/acp/acpAdapter.ts index 7c94ecfd894..e69e2116d1e 100644 --- a/packages/chat-runtime/src/harness/acp/acpAdapter.ts +++ b/packages/chat-runtime/src/harness/acp/acpAdapter.ts @@ -2028,11 +2028,19 @@ export class AcpAdapter implements HarnessAdapter { const model = this.applyStartSelection("model", wanted.modelId); const { effortId } = wanted; // The effort levels on offer belong to the model, so they are only known once it is set. - const effort = model.then((modelId) => - effortId && (modelId || !wanted.modelId) - ? this.applyStartSelection("thought_level", effortId) - : undefined, - ); + const effort = model + .then((modelId) => + effortId && (modelId || !wanted.modelId) + ? this.applyStartSelection("thought_level", effortId) + : undefined, + ) + .then((taken) => { + if (effortId && !taken) + console.warn( + `[acp] the agent did not take reasoning effort "${effortId}"; it runs at its default`, + ); + return taken; + }); this.trackSelection(effort); // Fast mode also belongs to the model. It waits for effort too: a refused // setting rolls back every option to before it was sent. diff --git a/packages/shared/src/workspace-tags.test.ts b/packages/shared/src/workspace-tags.test.ts index ad4ab0718bb..13a60651d76 100644 --- a/packages/shared/src/workspace-tags.test.ts +++ b/packages/shared/src/workspace-tags.test.ts @@ -95,6 +95,13 @@ describe("workspaceTagInputSchema", () => { ).success, ).toBe(false); }); + + test("rejects control characters, which the database cannot store", () => { + expect(workspaceTagInputSchema.safeParse("ok\u0000tag").success).toBe( + false, + ); + expect(workspaceTagInputSchema.safeParse("ok\ttag").success).toBe(false); + }); }); describe("workspaceTagsInputSchema", () => { diff --git a/packages/shared/src/workspace-tags.ts b/packages/shared/src/workspace-tags.ts index 684aa32694a..efa0d3d2ac7 100644 --- a/packages/shared/src/workspace-tags.ts +++ b/packages/shared/src/workspace-tags.ts @@ -65,6 +65,9 @@ export function normalizeWorkspaceTags( return [...unique].sort(); } +// biome-ignore lint/suspicious/noControlCharactersInRegex: matching them is the point. +const CONTROL_CHARACTER = /[\u0000-\u001f\u007f]/; + /** Router-boundary schema for one tag; parses to its stored normalized form. */ export const workspaceTagInputSchema = z .string() @@ -75,6 +78,12 @@ export const workspaceTagInputSchema = z message: `Tag must be 1-${WORKSPACE_TAG_MAX_LENGTH} characters after trimming`, }); } + if (CONTROL_CHARACTER.test(tag)) { + ctx.addIssue({ + code: "custom", + message: "Tag must not contain control characters", + }); + } }) .transform((tag) => normalizeWorkspaceTag(tag) as string); From 2c89dcfcb4481805ad0ec89ff408f924f19559a3 Mon Sep 17 00:00:00 2001 From: superset-home <338338640+superset-home@users.noreply.github.com> Date: Wed, 11 Nov 2026 21:31:19 +0000 Subject: [PATCH 3/3] fix(chat-runtime): warn about a skipped start effort on every start path The warning lived in applyConfigSelections, which the start path skips when the agent lists no config options before the grace period ends. Warn once the start selections settle instead, so that path is covered. --- .../src/harness/acp/acpAdapter.test.ts | 22 +++++++++++++- .../src/harness/acp/acpAdapter.ts | 30 ++++++++----------- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts b/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts index 062fedc6033..0e96eeb6e60 100644 --- a/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts +++ b/packages/chat-runtime/src/harness/acp/acpAdapter.test.ts @@ -1,4 +1,4 @@ -import { describe, expect, it, jest } from "bun:test"; +import { describe, expect, it, jest, spyOn } from "bun:test"; import { spawn } from "node:child_process"; import type { ChatSelections } from "@superset/chat/core"; import type { Item } from "@superset/chat/protocol"; @@ -5937,6 +5937,26 @@ describe("AcpAdapter config options", () => { await adapter.dispose(); }); + it("warns when the agent lists no options in time to take the start effort", async () => { + const warn = spyOn(console, "warn").mockImplementation(() => {}); + const agent = new FakeAcpAgent(); + agent.protocolVersion = 1; + const { adapter } = startAdapter( + agent, + undefined, + { effortId: "high" }, + { startOptionsGraceMs: 1 }, + ); + + expect(await adapter.startSelections()).toEqual({}); + expect(warn).toHaveBeenCalledWith( + '[acp] the agent did not take reasoning effort "high"; it runs at its default', + ); + + warn.mockRestore(); + await adapter.dispose(); + }); + it("leaves the model alone when the start model is not offered", async () => { const agent = new FakeAcpAgent(); agent.protocolVersion = 1; diff --git a/packages/chat-runtime/src/harness/acp/acpAdapter.ts b/packages/chat-runtime/src/harness/acp/acpAdapter.ts index e69e2116d1e..a4336275641 100644 --- a/packages/chat-runtime/src/harness/acp/acpAdapter.ts +++ b/packages/chat-runtime/src/harness/acp/acpAdapter.ts @@ -2028,19 +2028,11 @@ export class AcpAdapter implements HarnessAdapter { const model = this.applyStartSelection("model", wanted.modelId); const { effortId } = wanted; // The effort levels on offer belong to the model, so they are only known once it is set. - const effort = model - .then((modelId) => - effortId && (modelId || !wanted.modelId) - ? this.applyStartSelection("thought_level", effortId) - : undefined, - ) - .then((taken) => { - if (effortId && !taken) - console.warn( - `[acp] the agent did not take reasoning effort "${effortId}"; it runs at its default`, - ); - return taken; - }); + const effort = model.then((modelId) => + effortId && (modelId || !wanted.modelId) + ? this.applyStartSelection("thought_level", effortId) + : undefined, + ); this.trackSelection(effort); // Fast mode also belongs to the model. It waits for effort too: a refused // setting rolls back every option to before it was sent. @@ -2096,7 +2088,7 @@ export class AcpAdapter implements HarnessAdapter { ...(startOptions.fast ? { fast: startOptions.fast } : {}), ...(modeId && !this.options.clientApprovalModes ? { modeId } : {}), }; - const configured = + const configured: Promise = this.configOptions.length > 0 ? this.applyConfigSelections(wanted) : Object.keys(wanted).length > 0 @@ -2122,12 +2114,16 @@ export class AcpAdapter implements HarnessAdapter { taken ? modeId : undefined, ); } - void Promise.all([configured, sessionMode]).then(([taken, takenMode]) => + void Promise.all([configured, sessionMode]).then(([taken, takenMode]) => { + if (wanted.effortId && !taken.effortId) + console.warn( + `[acp] the agent did not take reasoning effort "${wanted.effortId}"; it runs at its default`, + ); this.settleStartSelections({ ...taken, ...(takenMode ? { modeId: takenMode } : {}), - }), - ); + }); + }); } /** The start model, effort and mode the agent took. */