From 6db2e6ae20157435cb6f7d1e620d206e7d97d2cd Mon Sep 17 00:00:00 2001 From: Ben Brandt Date: Mon, 9 Nov 2026 22:33:29 +0100 Subject: [PATCH] fix(v2): list a resumed Fable session's model as `fable` Ports #1548 to the v2 agent: sessionModels applies aliasResumedModelRow before the allowlist and model selection, as ClaudeAcpAgent.createSession does, so a resumed Fable 5.2 session offers `fable` as a new one does. Co-Authored-By: Claude --- src/tests/acp-v2.test.ts | 47 ++++++++++++++++++++++++++++++++++++++++ src/v2/setup.ts | 12 ++++++---- 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/src/tests/acp-v2.test.ts b/src/tests/acp-v2.test.ts index c1147828..e65cd964 100644 --- a/src/tests/acp-v2.test.ts +++ b/src/tests/acp-v2.test.ts @@ -741,6 +741,53 @@ describe("ACP v2 sessions", () => { }); }); + it("offers a resumed Fable 5.2 session's model as `fable`, as a new session lists it", async () => { + // On resume, the CLI lists the transcript's Fable row under its id, with no `fable` row. + const row = (value: string, resolvedModel: string, displayName: string) => ({ + value, + resolvedModel, + displayName, + description: "", + }); + sdk.initializationResult = async () => ({ + models: [ + row("default", "claude-opus-5-5", "Default (recommended)"), + row("claude-fable-5-2", "claude-fable-5-2", "Fable 5.2"), + ], + }); + const setModel = vi.fn(sdkDefaults.setModel); + sdk.setModel = setModel; + scriptTurns(); + let model: unknown; + const client = v2Client(); + await client.app.connectWith(connectRouter(), async (agent) => { + await initializeV2(agent); + const { sessionId } = await agent.request(v2.methods.agent.session.new, { cwd }); + await agent.request(v2.methods.agent.session.close, { sessionId }); + vi.mocked(getSessionMessages).mockResolvedValueOnce([ + transcriptEntry("assistant", randomUUID(), { + id: "msg_fable", + role: "assistant", + model: "claude-fable-5-2", + content: [{ type: "text", text: "ok" }], + }), + ] as unknown as Awaited>); + const resumed = await agent.request(v2.methods.agent.session.resume, { + sessionId, + cwd, + replayFrom: { type: "start" }, + }); + model = resumed.configOptions?.find((option) => option.configId === "model"); + await client.authUpdate(1); + }); + + expect(model).toMatchObject({ + currentValue: "fable", + options: [{ value: "default" }, { value: "fable", name: "Fable 5.2" }], + }); + expect(setModel).not.toHaveBeenCalled(); + }); + it("keeps the running turn of the active session that a resume gives other MCP servers", async () => { const release = Promise.withResolvers(); scriptTurns(async function* (options) { diff --git a/src/v2/setup.ts b/src/v2/setup.ts index 04107b74..9db1c9f3 100644 --- a/src/v2/setup.ts +++ b/src/v2/setup.ts @@ -20,6 +20,7 @@ import { withAirMeta, } from "../air-extension.js"; import { + aliasResumedModelRow, applyAvailableModelsAllowlist, getAvailableModels, type SessionModelState, @@ -45,7 +46,8 @@ export function withClientHooks( } /** - * The models of a session, as the v1 core picks them: the SDK's models + * The models of a session, as the v1 core picks them: the SDK's models, with + * a resumed session's model row under its family alias (`aliasResumedModelRow`), * narrowed by the settings' `availableModels` allowlist and then by the * provider (`narrow`), with the current model from `ANTHROPIC_MODEL`, the * settings' `model`, or the transcript of a resumed session @@ -69,14 +71,16 @@ export async function sessionModels( allowlistedModelInfo: ModelInfo | undefined; }> { const { availableModels, modelOverrides } = settings.getSettings(); + // A resumed Fable 5.2 session lists Fable 5.2 as `fable`, as a new session does. + const listed = aliasResumedModelRow(sdkModels, resumed?.model); const allowed = Array.isArray(availableModels) ? applyAvailableModelsAllowlist( - sdkModels, + listed, availableModels, modelOverrides, settings.getManagedDeniedModels(), ) - : sdkModels; + : listed; const narrowed = narrow(allowed); const models = await getAvailableModels( query, @@ -89,7 +93,7 @@ export async function sessionModels( resumed?.model, narrowedByProvider, ); - return { models, ...withCurrentModelInfo(narrowed, sdkModels, models.currentModelId) }; + return { models, ...withCurrentModelInfo(narrowed, listed, models.currentModelId) }; } /**