Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Accept Copilot Auto when the session leaves the model currentValue unset. (#4044)

BISWAJIT MANDALa55540c3fa55
diff --git a/docs/verification/copilot-engine.md b/docs/verification/copilot-engine.md
index b297c0a2a1..7fdc62789a 100644
--- a/docs/verification/copilot-engine.md
+++ b/docs/verification/copilot-engine.md
@@ -25,7 +25,9 @@ client; the cwd matches when quoted, resolved, or (on Windows) in another
case, and the test's workspace.yaml uses Copilot CLI 1.0.105's own fields. Only Copilot's discovery closes stdin and waits up to two seconds for
the agent to exit before killing it; a custom ACP agent is killed at once, and
an agent that ignores EOF is still stopped once the wait is over. The tests also cover the model applied over ACP and never on argv,
-a model switch between turns, a `session/request_permission` shown as an
+a model switch between turns, a turn on Auto when the session leaves the model
+`currentValue` unset (Copilot CLI 1.0.105) followed by an explicit model that
+still has to be confirmed, a `session/request_permission` shown as an
approval card and answered with the person's choice, the fallback to Auto with a notice when the plan
no longer offers a saved model, and a missing login reported as a sign-in step.
They also check that `COPILOT_ALLOW_ALL` and a server-wide `GITHUB_TOKEN` never
diff --git a/server/drivers/acp/copilot.test.ts b/server/drivers/acp/copilot.test.ts
index b8e3569ecf..584b4501b6 100644
--- a/server/drivers/acp/copilot.test.ts
+++ b/server/drivers/acp/copilot.test.ts
@@ -266,6 +266,16 @@ describe("GitHub Copilot ACP driver", () => {
expect(readFileSync(answer, "utf8")).toBe("reject");
});
+ it("runs Auto when the session leaves the model currentValue unset, then still confirms an explicit model", async () => {
+ const { instance, recorder } = await create({ FAKE_ACP_OMIT_MODEL_VALUE: "auto" });
+ for (const model of ["auto", "claude-haiku-4.5"]) {
+ const { turnId } = await instance.adapter.sendTurn({ threadId: "copilot-auto", text: `on ${model}`, model, approvalMode: "ask" });
+ await recorder.until((event) => event.type === "turn.completed" && event.turnId === turnId);
+ }
+ expect(prompts().map((entry) => entry.model)).toEqual(["auto", "claude-haiku-4.5"]);
+ expect(recorder.events.some((event) => event.type === "runtime.error")).toBe(false);
+ });
+
it("switches models between turns of one conversation", async () => {
const { instance, recorder } = await create();
for (const model of ["gpt-5.6-luna", "claude-haiku-4.5"]) {
diff --git a/server/drivers/acp/copilot.ts b/server/drivers/acp/copilot.ts
index 1a6986f3a5..cec3dd1018 100644
--- a/server/drivers/acp/copilot.ts
+++ b/server/drivers/acp/copilot.ts
@@ -1,8 +1,9 @@
// GitHub Copilot CLI over ACP (`copilot --acp --stdio`), billed to the signed-in Copilot plan.
// Copilot CLI 1.0.103 advertises its models as the `model` config option, each with `_meta.copilotUsage`
// (the premium-request multiplier), and per-model effort as `reasoning_effort`; session/set_config_option
-// validates and confirms both. Its own `allow_all` option stays at its `off` default: the ACP broker answers
-// every permission request.
+// validates and confirms both. CLI 1.0.105 leaves that option's currentValue unset once the session is on
+// Auto (the stored id stays `auto`; the picker may show Copilot Fusion and an autoTier instead). Its own
+// `allow_all` option stays at its `off` default: the ACP broker answers every permission request.
import { createHash } from "node:crypto";
import { readFile, realpath, rm } from "node:fs/promises";
import { homedir } from "node:os";
@@ -206,7 +207,7 @@ const SUPPORT: AcpSupport = {
// Every fleet has this instance, and any `copilot` on PATH (VS Code's shim included) would otherwise be started
// at launch: the catalog comes from the startup cache and refreshes when the engine is picked.
resolveModelsOnCreate: false,
- selectModel: { configId: "model" },
+ selectModel: { configId: "model", unsetIds: [AUTO] },
modelVariants: true,
fallbackModel: (sessionConfig, catalogDefault) => {
const offered = offeredModels(sessionConfig, "model");
diff --git a/server/drivers/acp/core.ts b/server/drivers/acp/core.ts
index 69312f2301..b3b6c40077 100644
--- a/server/drivers/acp/core.ts
+++ b/server/drivers/acp/core.ts
@@ -1454,7 +1454,7 @@ export function createAcpDriver(support: AcpSupport): ProviderDriver<AcpConfig>
const imageBlocks = support.images === true && runtimeAcceptsImages
? await readAcpImageBlocks(turn.images ?? [])
: [];
- if (support.modelVariants && cliTurn.model && !modelControls.usesAgentDefault() && modelControls.modelOf(session.sessionConfigResult) !== cliTurn.model) {
+ if (support.modelVariants && !modelControls.confirms(cliTurn.model)) {
throw new Error(`${support.displayName} changed model before the prompt`);
}
if (variant !== undefined && requestedVariantOption().currentValue !== variant) {
diff --git a/server/drivers/acp/session-model-controls.test.ts b/server/drivers/acp/session-model-controls.test.ts
index 75a9d7c57d..8a7656d91b 100644
--- a/server/drivers/acp/session-model-controls.test.ts
+++ b/server/drivers/acp/session-model-controls.test.ts
@@ -81,6 +81,25 @@ describe("ACP session model controls", () => {
await expect(controls.select(request, "s", 100)).rejects.toThrow("did not switch to two");
});
+ it("accepts an unset currentValue only for an id the driver names", async () => {
+ let state: any;
+ const modelOption = (currentValue?: string) => ({ configOptions: [{ id: "model", type: "select", ...(currentValue === undefined ? {} : { currentValue }),
+ options: [{ value: "auto", name: "Auto" }, { value: "one", name: "One" }] }] });
+ const controlsFor = (model: string) => new SessionModelControls({
+ selection: { configId: "model", unsetIds: ["auto"] }, variants: false, displayName: "GitHub Copilot",
+ model: () => model, reportedModel: () => model, state: () => state, store: (value) => { state = value; }, report: () => {},
+ });
+ const unset = modelOption();
+ controlsFor("auto").receive(modelOption("one"), true);
+ await expect(controlsFor("auto").select(async (_method, _params, _timeout, receive) => { receive?.(unset); return unset; }, "s", 100)).resolves.toBe("auto");
+ expect(controlsFor("auto").confirms("auto")).toBe(true);
+ expect(controlsFor("one").confirms("one")).toBe(false);
+ controlsFor("one").receive(modelOption("one"), true);
+ await expect(controlsFor("auto").select(async (_method, _params, _timeout, receive) => { receive?.(modelOption("one")); return modelOption("one"); }, "s", 100)).rejects.toThrow("did not switch to auto (still one)");
+ controlsFor("one").receive(modelOption(), true);
+ await expect(controlsFor("one").select(async () => ({}), "s", 100)).rejects.toThrow("did not switch to one (still unknown)");
+ });
+
it("clears the previous native session's settings when a new session has none", () => {
const { controls, state } = fixture();
controls.receive(modern("two"), true);
diff --git a/server/drivers/acp/session-model-controls.ts b/server/drivers/acp/session-model-controls.ts
index 8d64d2b845..c6f43caf41 100644
--- a/server/drivers/acp/session-model-controls.ts
+++ b/server/drivers/acp/session-model-controls.ts
@@ -10,6 +10,8 @@ export interface AcpModelSelection {
agentDefault?: string;
/** Accept ACP's legacy models state and session/set_model when no model config option exists. */
allowLegacy?: boolean;
+ /** Ids a successful set confirms by leaving `currentValue` unset. Every other id still needs the string. */
+ unsetIds?: readonly string[];
}
interface ModelControlsInput {
@@ -59,6 +61,12 @@ export class SessionModelControls {
});
}
+ confirms(model: string | undefined): boolean {
+ if (!model || this.usesAgentDefault()) return true;
+ const selected = this.modelOf(this.input.state());
+ return selected === model || (selected === null && this.input.selection?.unsetIds?.includes(model) === true);
+ }
+
variant(value: string | undefined): NonNullable<ReturnType<typeof acpVariantOption>> {
if (!this.input.variants) throw new Error(`${this.input.displayName} does not support model variants`);
const option = acpVariantOption(this.input.state());
@@ -91,10 +99,10 @@ export class SessionModelControls {
(response) => this.receive(response));
}
selected = this.modelOf(this.input.state());
- if (selected !== wanted) {
+ if (!this.confirms(wanted)) {
throw new Error(`${this.input.displayName} did not switch to ${wanted} (still ${selected ?? "unknown"})`);
}
- return selected;
+ return selected ?? wanted ?? null;
}
}
diff --git a/server/testing/fake-acp-cli.ts b/server/testing/fake-acp-cli.ts
index cfa7cc0966..ac41c5eaa7 100755
--- a/server/testing/fake-acp-cli.ts
+++ b/server/testing/fake-acp-cli.ts
@@ -42,6 +42,8 @@
// FAKE_ACP_MODELS_LIST=auto-only Cursor CLI 2026.10.22: `models` lists only `auto`
// FAKE_ACP_VERBOSE_FAIL_ONCE marker path: the first `models --verbose` fails, like a new OpenCode home's first run
// FAKE_ACP_MODEL_STICKS set_config_option succeeds but keeps the old model
+// FAKE_ACP_OMIT_MODEL_VALUE when the live model equals this id, the model option has no currentValue
+// (Copilot CLI 1.0.105 does this for auto)
// FAKE_ACP_EXIT_ON_MODEL the process exits when set_config_option selects this model
// FAKE_ACP_VARIANTS JSON map model -> {id?, currentValue?, options} of ACP select values
// FAKE_ACP_CONFIG_UPDATES JSON [{after, sessionId?, configOptions, replay?}] emitted after the named response
@@ -138,7 +140,7 @@ const configOptions = () => {
name: "Model",
category: "model",
type: "select",
- currentValue: currentModel,
+ ...(process.env.FAKE_ACP_OMIT_MODEL_VALUE === currentModel ? {} : { currentValue: currentModel }),
options: models.map((value) => ({ value, name: value })),
},
] : []),