mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 16:40:49 +00:00
fix: migrate agent runtime config
This commit is contained in:
@@ -122,7 +122,7 @@ describe("anthropic cli migration", () => {
|
||||
primary: "anthropic/claude-opus-4-7",
|
||||
fallbacks: ["anthropic/claude-opus-4-6", "openai/gpt-5.2"],
|
||||
},
|
||||
embeddedHarness: { runtime: "claude-cli" },
|
||||
agentRuntime: { id: "claude-cli" },
|
||||
models: {
|
||||
"anthropic/claude-opus-4-7": { alias: "Opus" },
|
||||
"anthropic/claude-sonnet-4-6": {},
|
||||
@@ -153,7 +153,7 @@ describe("anthropic cli migration", () => {
|
||||
expect(result.configPatch).toEqual({
|
||||
agents: {
|
||||
defaults: {
|
||||
embeddedHarness: { runtime: "claude-cli" },
|
||||
agentRuntime: { id: "claude-cli" },
|
||||
models: {
|
||||
"openai/gpt-5.2": {},
|
||||
"anthropic/claude-opus-4-7": {},
|
||||
@@ -184,7 +184,7 @@ describe("anthropic cli migration", () => {
|
||||
agents: {
|
||||
defaults: {
|
||||
model: { primary: "anthropic/claude-opus-4-7" },
|
||||
embeddedHarness: { runtime: "claude-cli" },
|
||||
agentRuntime: { id: "claude-cli" },
|
||||
models: {
|
||||
"anthropic/claude-opus-4-7": {},
|
||||
"anthropic/claude-sonnet-4-6": {},
|
||||
@@ -325,7 +325,7 @@ describe("anthropic cli migration", () => {
|
||||
primary: "anthropic/claude-opus-4-7",
|
||||
fallbacks: ["anthropic/claude-opus-4-6", "openai/gpt-5.2"],
|
||||
},
|
||||
embeddedHarness: { runtime: "claude-cli" },
|
||||
agentRuntime: { id: "claude-cli" },
|
||||
models: {
|
||||
"anthropic/claude-opus-4-7": { alias: "Opus" },
|
||||
"anthropic/claude-opus-4-6": { alias: "Opus" },
|
||||
|
||||
@@ -12,9 +12,9 @@ import { CLAUDE_CLI_BACKEND_ID, CLAUDE_CLI_DEFAULT_ALLOWLIST_REFS } from "./cli-
|
||||
|
||||
type AgentDefaultsModel = NonNullable<NonNullable<OpenClawConfig["agents"]>["defaults"]>["model"];
|
||||
type AgentDefaultsModels = NonNullable<NonNullable<OpenClawConfig["agents"]>["defaults"]>["models"];
|
||||
type AgentDefaultsEmbeddedHarness = NonNullable<
|
||||
type AgentDefaultsRuntimePolicy = NonNullable<
|
||||
NonNullable<OpenClawConfig["agents"]>["defaults"]
|
||||
>["embeddedHarness"];
|
||||
>["agentRuntime"];
|
||||
type ClaudeCliCredential = NonNullable<ReturnType<typeof readClaudeCliCredentialsForSetup>>;
|
||||
|
||||
function toAnthropicModelRef(raw: string): string | null {
|
||||
@@ -125,16 +125,14 @@ function seedClaudeCliAllowlist(
|
||||
return next;
|
||||
}
|
||||
|
||||
function selectClaudeCliRuntime(
|
||||
embeddedHarness: AgentDefaultsEmbeddedHarness | undefined,
|
||||
): AgentDefaultsEmbeddedHarness {
|
||||
const currentRuntime = embeddedHarness?.runtime?.trim();
|
||||
function selectClaudeCliRuntime(agentRuntime: AgentDefaultsRuntimePolicy | undefined) {
|
||||
const currentRuntime = agentRuntime?.id?.trim();
|
||||
if (currentRuntime && currentRuntime !== "auto") {
|
||||
return embeddedHarness;
|
||||
return agentRuntime;
|
||||
}
|
||||
return {
|
||||
...embeddedHarness,
|
||||
runtime: CLAUDE_CLI_BACKEND_ID,
|
||||
...agentRuntime,
|
||||
id: CLAUDE_CLI_BACKEND_ID,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -198,7 +196,7 @@ export function buildAnthropicCliMigrationResult(
|
||||
agents: {
|
||||
defaults: {
|
||||
...(rewrittenModel.changed ? { model: rewrittenModel.value } : {}),
|
||||
embeddedHarness: selectClaudeCliRuntime(defaults?.embeddedHarness),
|
||||
agentRuntime: selectClaudeCliRuntime(defaults?.agentRuntime),
|
||||
models: nextModels,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -140,7 +140,7 @@ function isAnthropicCacheRetentionTarget(
|
||||
}
|
||||
|
||||
function usesClaudeCliModelSelection(config: OpenClawConfig): boolean {
|
||||
if (config.agents?.defaults?.embeddedHarness?.runtime === CLAUDE_CLI_BACKEND_ID) {
|
||||
if (config.agents?.defaults?.agentRuntime?.id === CLAUDE_CLI_BACKEND_ID) {
|
||||
return true;
|
||||
}
|
||||
const primary = resolveModelPrimaryValue(
|
||||
|
||||
@@ -176,7 +176,7 @@ describe("anthropic provider replay hooks", () => {
|
||||
},
|
||||
agents: {
|
||||
defaults: {
|
||||
embeddedHarness: { runtime: "claude-cli" },
|
||||
agentRuntime: { id: "claude-cli" },
|
||||
model: { primary: "anthropic/claude-opus-4-7" },
|
||||
models: {
|
||||
"anthropic/claude-opus-4-7": {},
|
||||
|
||||
@@ -196,6 +196,12 @@ function buildDiscordModelPickerCurrentModel(
|
||||
return `${defaultProvider}/${defaultModel}`;
|
||||
}
|
||||
|
||||
function resolveConfiguredAgentRuntimeId(value: {
|
||||
agentRuntime?: { id?: unknown };
|
||||
}): string | undefined {
|
||||
return normalizeOptionalString(value.agentRuntime?.id);
|
||||
}
|
||||
|
||||
function buildDiscordModelPickerAllowedModelRefs(
|
||||
data: Awaited<ReturnType<typeof loadDiscordModelPickerData>>,
|
||||
): Set<string> {
|
||||
@@ -386,15 +392,15 @@ function resolveDiscordModelPickerCurrentRuntime(params: {
|
||||
// Fall through to configured defaults when the session store is unavailable.
|
||||
}
|
||||
|
||||
const agentRuntime = normalizeOptionalString(
|
||||
const agentRuntime = resolveConfiguredAgentRuntimeId(
|
||||
params.cfg.agents?.list?.find(
|
||||
(entry) => normalizeOptionalString(entry.id) === params.route.agentId,
|
||||
)?.embeddedHarness?.runtime,
|
||||
) ?? {},
|
||||
);
|
||||
if (agentRuntime) {
|
||||
return agentRuntime;
|
||||
}
|
||||
return normalizeOptionalString(params.cfg.agents?.defaults?.embeddedHarness?.runtime) ?? "auto";
|
||||
return resolveConfiguredAgentRuntimeId(params.cfg.agents?.defaults ?? {}) ?? "auto";
|
||||
}
|
||||
|
||||
export async function replyWithDiscordModelPickerProviders(params: {
|
||||
|
||||
@@ -85,7 +85,7 @@ export function buildGoogleGeminiCliProvider(): ProviderPlugin {
|
||||
configPatch: {
|
||||
agents: {
|
||||
defaults: {
|
||||
embeddedHarness: { runtime: PROVIDER_ID },
|
||||
agentRuntime: { id: PROVIDER_ID },
|
||||
models: {
|
||||
[DEFAULT_MODEL]: {},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user