fix(acp): custom models now reach the agent instead of failing to open (#19313)
Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
a0ea721c47
commit
19a67ef521
3 files changed
+50
No files matched your search
@@ -1752,4 +1752,41 @@ describe("AcpSessionRuntime", () => {
|
||||
Effect.ensuring(Effect.sync(() => NodeFS.rmSync(tempDir, { recursive: true, force: true }))),
|
||||
);
|
||||
});
|
||||
|
||||
it.effect("sends configured custom models the agent does not advertise", () => {
|
||||
const tempDir = NodeFS.mkdtempSync(NodePath.join(NodeOS.tmpdir(), "acp-runtime-"));
|
||||
const requestLogPath = NodePath.join(tempDir, "requests.ndjson");
|
||||
return Effect.gen(function* () {
|
||||
const runtime = yield* AcpSessionRuntime.AcpSessionRuntime;
|
||||
yield* runtime.start();
|
||||
|
||||
yield* runtime.setModel("cline-free/custom-model");
|
||||
const error = yield* runtime.setModel("unconfigured/model").pipe(Effect.flip);
|
||||
expect(error._tag).toBe("AcpRequestError");
|
||||
|
||||
const sentModels = NodeFS.readFileSync(requestLogPath, "utf8")
|
||||
.trim()
|
||||
.split("\n")
|
||||
.filter((line) => line.length > 0)
|
||||
.map((line) => JSON.parse(line) as { method?: string; params?: { value?: unknown } })
|
||||
.filter((message) => message.method === "session/set_config_option")
|
||||
.map((message) => message.params?.value);
|
||||
expect(sentModels).toEqual(["cline-free/custom-model"]);
|
||||
}).pipe(
|
||||
Effect.provide(
|
||||
AcpSessionRuntime.layer({
|
||||
...mockRuntimeOptions,
|
||||
spawn: {
|
||||
command: mockAgentCommand,
|
||||
args: mockAgentArgs,
|
||||
env: { T3_ACP_REQUEST_LOG_PATH: requestLogPath },
|
||||
},
|
||||
customModels: ["cline-free/custom-model"],
|
||||
}),
|
||||
),
|
||||
Effect.scoped,
|
||||
Effect.provide(NodeServices.layer),
|
||||
Effect.ensuring(Effect.sync(() => NodeFS.rmSync(tempDir, { recursive: true, force: true }))),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
makeCopilotSubagentRouting,
|
||||
} from "./copilotAcp.ts";
|
||||
import { defaultInstanceIdForDriver, ProviderDriverKind } from "@t3tools/contracts";
|
||||
import { readCustomModelEntries } from "@t3tools/shared/model";
|
||||
import { AcpRegistrySettings } from "../settings.ts";
|
||||
import * as HostProcess from "@t3tools/shared/HostProcess";
|
||||
import { resolveSelfInvocation, type SelfInvocation } from "@t3tools/shared/nodeRuntime";
|
||||
@@ -168,6 +169,9 @@ function makeAcpRegistryRuntime(
|
||||
env: { ...resolved.spawn.env, ...processEnvironment },
|
||||
},
|
||||
...(options.settings.authMethodId ? { authMethodId: options.settings.authMethodId } : {}),
|
||||
customModels: readCustomModelEntries(options.settings.customModels).map(
|
||||
(entry) => entry.slug,
|
||||
),
|
||||
}),
|
||||
);
|
||||
return yield* Effect.service(AcpSessionRuntime.AcpSessionRuntime).pipe(
|
||||
|
||||
@@ -155,6 +155,12 @@ export interface AcpSessionRuntimeOptions {
|
||||
readonly onTermination?: (error: EffectAcpErrors.AcpError) => Effect.Effect<void>;
|
||||
readonly onOutgoingResponseFailure?: EffectAcpClient.AcpClientOptions["onOutgoingResponseFailure"];
|
||||
readonly onOutgoingResponse?: EffectAcpClient.AcpClientOptions["onOutgoingResponse"];
|
||||
/**
|
||||
* Model ids the user configured for this instance. The model config option
|
||||
* accepts them even when the agent does not advertise them, and the agent
|
||||
* validates them instead.
|
||||
*/
|
||||
readonly customModels?: ReadonlyArray<string>;
|
||||
}
|
||||
|
||||
export interface AcpSessionRequestLogEvent {
|
||||
@@ -1977,6 +1983,9 @@ export const make = (
|
||||
if (allowedValues.includes(value)) {
|
||||
return;
|
||||
}
|
||||
if (configOption.category === "model" && options.customModels?.includes(value)) {
|
||||
return;
|
||||
}
|
||||
return yield* new EffectAcpErrors.AcpRequestError({
|
||||
code: -32602,
|
||||
errorMessage: `Invalid value ${formatConfigOptionValue(value)} for session config option "${configOption.id}": expected one of ${allowedValues.join(", ")}`,
|
||||
|
||||
Reference in new issue
Block a user