fix: keep metadata reuse scoped to agent turns · openclaw/openclaw@bfceb0d
shakkernerd
·
2026-05-17
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -20,7 +20,6 @@ import {
|
20 | 20 | import { formatErrorMessage } from "../infra/errors.js"; |
21 | 21 | import { buildOutboundSessionContext } from "../infra/outbound/session-context.js"; |
22 | 22 | import { createSubsystemLogger } from "../logging/subsystem.js"; |
23 | | -import { setCurrentPluginMetadataSnapshot } from "../plugins/current-plugin-metadata-snapshot.js"; |
24 | 23 | import { loadManifestMetadataSnapshot } from "../plugins/manifest-contract-eligibility.js"; |
25 | 24 | import { |
26 | 25 | isSubagentSessionKey, |
@@ -403,11 +402,6 @@ async function prepareAgentCommandExecution(
|
403 | 402 | workspaceDir, |
404 | 403 | env: process.env, |
405 | 404 | }); |
406 | | -setCurrentPluginMetadataSnapshot(manifestMetadataSnapshot, { |
407 | | -config: cfg, |
408 | | -env: process.env, |
409 | | - workspaceDir, |
410 | | -}); |
411 | 405 | const manifestPlugins = manifestMetadataSnapshot.plugins; |
412 | 406 | const configuredModel = resolveConfiguredModelRef({ |
413 | 407 | cfg, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -134,6 +134,8 @@ export function inferUniqueProviderFromConfiguredModels(
|
134 | 134 | manifestPlugins: params.manifestPlugins, |
135 | 135 | }); |
136 | 136 | if ( |
| 137 | +modelId === model || |
| 138 | +normalizeLowercaseStringOrEmpty(modelId) === normalized || |
137 | 139 | normalizedModelId === model || |
138 | 140 | normalizeLowercaseStringOrEmpty(normalizedModelId) === normalized |
139 | 141 | ) { |
@@ -604,7 +606,9 @@ export function resolveConfiguredModelRef(
|
604 | 606 | manifestPlugins: params.manifestPlugins, |
605 | 607 | }); |
606 | 608 | if (inferredProvider) { |
607 | | -return { provider: inferredProvider, model: trimmed }; |
| 609 | +return normalizeModelRef(inferredProvider, trimmed, { |
| 610 | +manifestPlugins: params.manifestPlugins, |
| 611 | +}); |
608 | 612 | } |
609 | 613 | |
610 | 614 | const safeTrimmed = sanitizeModelWarningValue(trimmed); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -695,6 +695,25 @@ describe("model-selection", () => {
|
695 | 695 | ).toBe("qwen-dashscope"); |
696 | 696 | }); |
697 | 697 | |
| 698 | +it("infers provider from raw configured ids when manifest policies add prefixes", () => { |
| 699 | +const cfg = { |
| 700 | +models: { |
| 701 | +providers: { |
| 702 | +nvidia: { |
| 703 | +models: [{ id: "llama-fast" }], |
| 704 | +}, |
| 705 | +}, |
| 706 | +}, |
| 707 | +} as unknown as OpenClawConfig; |
| 708 | + |
| 709 | +expect( |
| 710 | +inferUniqueProviderFromConfiguredModels({ |
| 711 | + cfg, |
| 712 | +model: "llama-fast", |
| 713 | +}), |
| 714 | +).toBe("nvidia"); |
| 715 | +}); |
| 716 | + |
698 | 717 | it("infers Google provider from canonicalized configured provider catalogs", () => { |
699 | 718 | const cfg = { |
700 | 719 | models: { |
@@ -1655,6 +1674,34 @@ describe("model-selection", () => {
|
1655 | 1674 | } |
1656 | 1675 | }); |
1657 | 1676 | |
| 1677 | +it("normalizes bare configured default model strings with manifest policies", () => { |
| 1678 | +const cfg = { |
| 1679 | +agents: { |
| 1680 | +defaults: { |
| 1681 | +model: { primary: "llama-fast" }, |
| 1682 | +}, |
| 1683 | +}, |
| 1684 | +models: { |
| 1685 | +providers: { |
| 1686 | +nvidia: { |
| 1687 | +models: [{ id: "llama-fast" }], |
| 1688 | +}, |
| 1689 | +}, |
| 1690 | +}, |
| 1691 | +} as unknown as OpenClawConfig; |
| 1692 | + |
| 1693 | +const result = resolveConfiguredModelRef({ |
| 1694 | + cfg, |
| 1695 | +defaultProvider: "openai", |
| 1696 | +defaultModel: "gpt-5.4", |
| 1697 | +}); |
| 1698 | + |
| 1699 | +expect(result).toEqual({ |
| 1700 | +provider: "nvidia", |
| 1701 | +model: "nvidia/llama-fast", |
| 1702 | +}); |
| 1703 | +}); |
| 1704 | + |
1658 | 1705 | it("prefers slash-form aliases for configured default models", () => { |
1659 | 1706 | const cfg = { |
1660 | 1707 | agents: { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。