mirror of
https://github.com/agentclientprotocol/claude-agent-acp.git
synced 2026-11-29 20:52:58 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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<ReturnType<typeof getSessionMessages>>);
|
||||
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<void>();
|
||||
scriptTurns(async function* (options) {
|
||||
|
||||
@@ -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) };
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user