fix: key plugin descriptors by active model · openclaw/openclaw@7ce905f
steipete
·
2026-05-10
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -58,6 +58,22 @@ describe("openclaw plugin tool context", () => {
|
58 | 58 | }); |
59 | 59 | }); |
60 | 60 | |
| 61 | +it("does not duplicate provider-qualified active model refs", () => { |
| 62 | +const result = resolveOpenClawPluginToolInputs({ |
| 63 | +options: { |
| 64 | +config: {} as never, |
| 65 | +modelProvider: "openrouter", |
| 66 | +modelId: "openrouter/auto", |
| 67 | +}, |
| 68 | +}); |
| 69 | + |
| 70 | +expect(result.context.activeModel).toStrictEqual({ |
| 71 | +provider: "openrouter", |
| 72 | +modelId: "openrouter/auto", |
| 73 | +modelRef: "openrouter/auto", |
| 74 | +}); |
| 75 | +}); |
| 76 | + |
61 | 77 | it("infers the default agent workspace when workspaceDir is omitted", () => { |
62 | 78 | const workspaceDir = path.join(process.cwd(), "tmp-main-workspace"); |
63 | 79 | const result = resolveOpenClawPluginToolInputs({ |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2,6 +2,7 @@ import type { OpenClawConfig } from "../config/types.openclaw.js";
|
2 | 2 | import { normalizeDeliveryContext } from "../utils/delivery-context.js"; |
3 | 3 | import type { GatewayMessageChannel } from "../utils/message-channel.js"; |
4 | 4 | import { resolveAgentWorkspaceDir, resolveSessionAgentIds } from "./agent-scope.js"; |
| 5 | +import { modelKey } from "./model-ref-shared.js"; |
5 | 6 | import type { ToolFsPolicy } from "./tool-fs-policy.js"; |
6 | 7 | import { resolveWorkspaceRoot } from "./workspace-dir.js"; |
7 | 8 | |
@@ -51,7 +52,7 @@ export function resolveOpenClawPluginToolInputs(params: {
|
51 | 52 | ? { |
52 | 53 | ...(modelProvider ? { provider: modelProvider } : {}), |
53 | 54 | ...(modelId ? { modelId } : {}), |
54 | | - ...(modelProvider && modelId ? { modelRef: `${modelProvider}/${modelId}` } : {}), |
| 55 | + ...(modelProvider && modelId ? { modelRef: modelKey(modelProvider, modelId) } : {}), |
55 | 56 | } |
56 | 57 | : undefined; |
57 | 58 | const deliveryContext = normalizeDeliveryContext({ |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -91,6 +91,38 @@ describe("plugin tool descriptor cache keys", () => {
|
91 | 91 | expect(firstKey).not.toBe(secondKey); |
92 | 92 | }); |
93 | 93 | |
| 94 | +it("varies descriptor keys by active model metadata", () => { |
| 95 | +const base = { |
| 96 | +pluginId: "demo", |
| 97 | +source: "/tmp/demo.js", |
| 98 | +contractToolNames: ["demo"], |
| 99 | +ctx: { |
| 100 | +workspaceDir: "/tmp/workspace", |
| 101 | +agentId: "main", |
| 102 | +activeModel: { |
| 103 | +provider: "openai", |
| 104 | +modelId: "gpt-5.4", |
| 105 | +modelRef: "openai/gpt-5.4", |
| 106 | +}, |
| 107 | +}, |
| 108 | +}; |
| 109 | + |
| 110 | +const firstKey = buildPluginToolDescriptorCacheKey(base); |
| 111 | +const secondKey = buildPluginToolDescriptorCacheKey({ |
| 112 | + ...base, |
| 113 | +ctx: { |
| 114 | + ...base.ctx, |
| 115 | +activeModel: { |
| 116 | +provider: "openrouter", |
| 117 | +modelId: "openrouter/auto", |
| 118 | +modelRef: "openrouter/auto", |
| 119 | +}, |
| 120 | +}, |
| 121 | +}); |
| 122 | + |
| 123 | +expect(firstKey).not.toBe(secondKey); |
| 124 | +}); |
| 125 | + |
94 | 126 | it("keeps descriptor keys stable across config bookkeeping writes", () => { |
95 | 127 | const firstConfig = { |
96 | 128 | id: "runtime", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -104,6 +104,7 @@ function buildDescriptorContextCacheKey(params: {
|
104 | 104 | workspaceDir: ctx.workspaceDir ?? null, |
105 | 105 | agentDir: ctx.agentDir ?? null, |
106 | 106 | agentId: ctx.agentId ?? null, |
| 107 | +activeModel: ctx.activeModel ?? null, |
107 | 108 | browser: ctx.browser ?? null, |
108 | 109 | messageChannel: ctx.messageChannel ?? null, |
109 | 110 | agentAccountId: ctx.agentAccountId ?? null, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。