























@@ -65,6 +65,7 @@ type SelectModelOptions = {
6565providerOverride?: string;
6666};
6767isGmailHook?: boolean;
68+agentId?: string;
6869};
69707071function parseModelRef(raw: string): { provider: string; model: string } | { error: string } {
@@ -126,6 +127,7 @@ async function selectModel(options: SelectModelOptions = {}) {
126127sessionEntry: options.sessionEntry ?? {},
127128payload: options.payload ?? defaultPayload(),
128129isGmailHook: options.isGmailHook ?? false,
130+agentId: options.agentId,
129131});
130132}
131133@@ -401,6 +403,94 @@ describe("cron model formatting and precedence edge cases", () => {
401403});
402404});
403405406+describe("CLI runtime compatibility", () => {
407+it("keeps the canonical Anthropic provider when a per-agent Claude CLI runtime is configured", async () => {
408+await expectSelectedModel(
409+{
410+cfg: {
411+agents: {
412+defaults: {
413+model: "anthropic/claude-opus-4-6",
414+},
415+list: [
416+{
417+id: "scheduler",
418+agentRuntime: { id: "claude-cli" },
419+},
420+],
421+},
422+},
423+agentId: "scheduler",
424+},
425+{ provider: "anthropic", model: "claude-opus-4-6" },
426+);
427+});
428+429+it("keeps an OpenAI payload override on OpenAI when per-agent Claude CLI is configured", async () => {
430+await expectSelectedModel(
431+{
432+cfg: {
433+agents: {
434+defaults: {
435+model: "anthropic/claude-opus-4-6",
436+},
437+list: [
438+{
439+id: "scheduler",
440+agentRuntime: { id: "claude-cli" },
441+},
442+],
443+},
444+},
445+agentId: "scheduler",
446+payload: {
447+kind: "agentTurn",
448+message: DEFAULT_MESSAGE,
449+model: "openai/gpt-4.1-mini",
450+},
451+},
452+{ provider: "openai", model: "gpt-4.1-mini" },
453+);
454+});
455+456+it("keeps the canonical Anthropic provider when a default Claude CLI runtime is configured", async () => {
457+await expectSelectedModel(
458+{
459+cfg: {
460+agents: {
461+defaults: {
462+model: "anthropic/claude-opus-4-6",
463+agentRuntime: { id: "claude-cli" },
464+},
465+},
466+},
467+},
468+{ provider: "anthropic", model: "claude-opus-4-6" },
469+);
470+});
471+472+it("keeps an OpenAI payload override on OpenAI when default Claude CLI is configured", async () => {
473+await expectSelectedModel(
474+{
475+cfg: {
476+agents: {
477+defaults: {
478+model: "anthropic/claude-opus-4-6",
479+agentRuntime: { id: "claude-cli" },
480+},
481+},
482+},
483+payload: {
484+kind: "agentTurn",
485+message: DEFAULT_MESSAGE,
486+model: "openai/gpt-4.1-mini",
487+},
488+},
489+{ provider: "openai", model: "gpt-4.1-mini" },
490+);
491+});
492+});
493+404494describe("stored session overrides", () => {
405495it("stored modelOverride/providerOverride are applied", async () => {
406496await expectSelectedModel(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。