Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,56 @@ describe("AcpRegistryAdapterV2", () => {
},
);

// Mistral Vibe 3.1 keeps a renamed model's old ID as a catalog alias and
// resolves it in session/set_config_option, so the agent judges a stored
// name it no longer lists.
it.effect.each([
{ name: "resolves", stored: "mistral-large-4-0-3", resolvedTo: "mistral-large-4-0" },
{ name: "rejects", stored: "missing", resolvedTo: undefined },
{ name: "keeps default", stored: "default", resolvedTo: "mistral-medium-latest" },
] as const)("lets Mistral Vibe judge an unlisted stored model: $name", (testCase) => {
const vibeModel = (currentValue: string) => ({
...modelOption("model", currentValue),
options: ["mistral-large-4-0", "mistral-medium-latest"].map((value) => ({
value,
name: value,
})),
});
return Effect.gen(function* () {
const { configurations } = yield* openWithStoredPicks({
agentId: "mistral-vibe",
setup: { configOptions: [vibeModel("mistral-medium-latest")] },
storedModel: testCase.stored,
...(testCase.resolvedTo === undefined ? { rejectedModel: testCase.stored } : {}),
pickFrames:
testCase.stored === "default"
? []
: [
outbound("session/set_config_option", {
sessionId: "agent-session",
configId: "model",
value: testCase.stored,
}),
testCase.resolvedTo === undefined
? {
type: "emit_inbound",
frame: {
kind: "response",
method: "session/set_config_option",
error: { code: -32602, message: `Unknown model: ${testCase.stored}` },
},
}
: answer("session/set_config_option", {
configOptions: [vibeModel(testCase.resolvedTo)],
}),
],
});
if (testCase.resolvedTo !== undefined) {
assert.equal(configurations[0]?.currentModelId, testCase.resolvedTo);
}
}).pipe(Effect.provide(layerTest));
});

// regression: #19519 models come from session model state, not a hardcoded list
it.effect("keeps unadvertised default and auto selections agent-controlled", () =>
Effect.gen(function* () {
Expand Down
6 changes: 5 additions & 1 deletion packages/provider-acp-registry/src/server/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,11 @@ export const makeAcpRegistryAdapterV2 = Effect.fn("makeAcpRegistryAdapterV2")(fu
),
),
}),
...(isVibe ? { registerExtensions: registerMistralVibeAcpExtensions } : {}),
// Vibe (v3.1.4) resolves the old ID it keeps as an alias after a model rename and refuses an
// unknown model with invalid params.
...(isVibe
? { registerExtensions: registerMistralVibeAcpExtensions, resolvesUnlistedModels: true }
: {}),
...(isClaude
? {
followAgentWorkState: true,
Expand Down
26 changes: 20 additions & 6 deletions packages/provider-acp/src/server/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,12 @@ export interface AcpAdapterV2Flavor {
ChildProcessSpawner.ChildProcessSpawner | SecureRandom.SecureRandom | Scope.Scope
>;
readonly customModels?: ReadonlyArray<string>;
/**
* The agent resolves a model its model option does not list, such as the old ID it keeps as an
* alias after a rename, and refuses an unknown one with invalid params. An unlisted explicit
* model is then written for the agent to judge, and the session runs the model it reports.
*/
readonly resolvesUnlistedModels?: boolean;
/** The agent may run another model than session/new reports, so the model is always written. */
readonly alwaysSetModel?: boolean;
/** Values the client shows for options a new session's selection leaves unset. */
Expand Down Expand Up @@ -8070,6 +8076,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
)
return;
const option = findModelConfigOption(yield* runtime.getConfigOptions);
if (option !== undefined && flavor.resolvesUnlistedModels === true) return;
const models = (yield* Ref.get(activeSessionSetup))?.sessionSetupResult.models;
const available =
option?.type === "select"
Expand Down Expand Up @@ -8118,18 +8125,25 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
const modelOption = findModelConfigOption(yield* runtime.getConfigOptions);
const modelState = startResult.sessionSetupResult.models;
if (modelOption?.type === "select") {
if (
isCustomModel ||
flattenSelectChoices(modelOption.options).some(
(choice) => choice.value === requestedModel,
)
) {
const isListed = flattenSelectChoices(modelOption.options).some(
(choice) => choice.value === requestedModel,
);
if (isCustomModel || isListed) {
yield* runtime
.setConfigOption(modelOption.id, requestedModel, {
resendCurrentValue: flavor.alwaysSetModel === true,
})
.pipe(Effect.mapError(rejectedModel));
appliedModel = requestedModel;
} else if (
flavor.resolvesUnlistedModels === true &&
requestedModel !== "default" &&
requestedModel !== "auto"
) {
// The model option's current value then names the model the agent resolved.
yield* runtime
.setConfigOption(modelOption.id, requestedModel, { allowUnlistedValue: true })
.pipe(Effect.mapError(rejectedModel));
}
} else if (
modelState != null &&
Expand Down
Loading