mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
fix: keep metadata reuse scoped to agent turns
This commit is contained in:
@@ -20,7 +20,6 @@ import {
|
||||
import { formatErrorMessage } from "../infra/errors.js";
|
||||
import { buildOutboundSessionContext } from "../infra/outbound/session-context.js";
|
||||
import { createSubsystemLogger } from "../logging/subsystem.js";
|
||||
import { setCurrentPluginMetadataSnapshot } from "../plugins/current-plugin-metadata-snapshot.js";
|
||||
import { loadManifestMetadataSnapshot } from "../plugins/manifest-contract-eligibility.js";
|
||||
import {
|
||||
isSubagentSessionKey,
|
||||
@@ -403,11 +402,6 @@ async function prepareAgentCommandExecution(
|
||||
workspaceDir,
|
||||
env: process.env,
|
||||
});
|
||||
setCurrentPluginMetadataSnapshot(manifestMetadataSnapshot, {
|
||||
config: cfg,
|
||||
env: process.env,
|
||||
workspaceDir,
|
||||
});
|
||||
const manifestPlugins = manifestMetadataSnapshot.plugins;
|
||||
const configuredModel = resolveConfiguredModelRef({
|
||||
cfg,
|
||||
|
||||
@@ -134,6 +134,8 @@ export function inferUniqueProviderFromConfiguredModels(
|
||||
manifestPlugins: params.manifestPlugins,
|
||||
});
|
||||
if (
|
||||
modelId === model ||
|
||||
normalizeLowercaseStringOrEmpty(modelId) === normalized ||
|
||||
normalizedModelId === model ||
|
||||
normalizeLowercaseStringOrEmpty(normalizedModelId) === normalized
|
||||
) {
|
||||
@@ -604,7 +606,9 @@ export function resolveConfiguredModelRef(
|
||||
manifestPlugins: params.manifestPlugins,
|
||||
});
|
||||
if (inferredProvider) {
|
||||
return { provider: inferredProvider, model: trimmed };
|
||||
return normalizeModelRef(inferredProvider, trimmed, {
|
||||
manifestPlugins: params.manifestPlugins,
|
||||
});
|
||||
}
|
||||
|
||||
const safeTrimmed = sanitizeModelWarningValue(trimmed);
|
||||
|
||||
@@ -695,6 +695,25 @@ describe("model-selection", () => {
|
||||
).toBe("qwen-dashscope");
|
||||
});
|
||||
|
||||
it("infers provider from raw configured ids when manifest policies add prefixes", () => {
|
||||
const cfg = {
|
||||
models: {
|
||||
providers: {
|
||||
nvidia: {
|
||||
models: [{ id: "llama-fast" }],
|
||||
},
|
||||
},
|
||||
},
|
||||
} as unknown as OpenClawConfig;
|
||||
|
||||
expect(
|
||||
inferUniqueProviderFromConfiguredModels({
|
||||
cfg,
|
||||
model: "llama-fast",
|
||||
}),
|
||||
).toBe("nvidia");
|
||||
});
|
||||
|
||||
it("infers Google provider from canonicalized configured provider catalogs", () => {
|
||||
const cfg = {
|
||||
models: {
|
||||
@@ -1655,6 +1674,34 @@ describe("model-selection", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("normalizes bare configured default model strings with manifest policies", () => {
|
||||
const cfg = {
|
||||
agents: {
|
||||
defaults: {
|
||||
model: { primary: "llama-fast" },
|
||||
},
|
||||
},
|
||||
models: {
|
||||
providers: {
|
||||
nvidia: {
|
||||
models: [{ id: "llama-fast" }],
|
||||
},
|
||||
},
|
||||
},
|
||||
} as unknown as OpenClawConfig;
|
||||
|
||||
const result = resolveConfiguredModelRef({
|
||||
cfg,
|
||||
defaultProvider: "openai",
|
||||
defaultModel: "gpt-5.4",
|
||||
});
|
||||
|
||||
expect(result).toEqual({
|
||||
provider: "nvidia",
|
||||
model: "nvidia/llama-fast",
|
||||
});
|
||||
});
|
||||
|
||||
it("prefers slash-form aliases for configured default models", () => {
|
||||
const cfg = {
|
||||
agents: {
|
||||
|
||||
Reference in New Issue
Block a user