fix(gateway): invalidate tool inventory on channel registry changes · openclaw/openclaw@e20f755
steipete
·
2026-04-27
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2,6 +2,9 @@ export { listAgentIds, resolveSessionAgentId } from "../../agents/agent-scope.js
|
2 | 2 | export { resolveEffectiveToolInventory } from "../../agents/tools-effective-inventory.js"; |
3 | 3 | export { resolveReplyToMode } from "../../auto-reply/reply/reply-threading.js"; |
4 | 4 | export { loadConfig } from "../../config/config.js"; |
5 | | -export { getActivePluginRegistryVersion } from "../../plugins/runtime.js"; |
| 5 | +export { |
| 6 | +getActivePluginChannelRegistryVersion, |
| 7 | +getActivePluginRegistryVersion, |
| 8 | +} from "../../plugins/runtime.js"; |
6 | 9 | export { deliveryContextFromSession } from "../../utils/delivery-context.shared.js"; |
7 | 10 | export { loadSessionEntry, resolveSessionModelRef } from "../session-utils.js"; |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -29,6 +29,7 @@ const runtimeMocks = vi.hoisted(() => ({
|
29 | 29 | model: "gpt-4.1", |
30 | 30 | }, |
31 | 31 | })), |
| 32 | +getActivePluginChannelRegistryVersion: vi.fn(() => 1), |
32 | 33 | getActivePluginRegistryVersion: vi.fn(() => 1), |
33 | 34 | resolveEffectiveToolInventory: vi.fn(() => ({ |
34 | 35 | agentId: "main", |
@@ -80,6 +81,7 @@ describe("tools.effective handler", () => {
|
80 | 81 | vi.clearAllMocks(); |
81 | 82 | __testing.resetToolsEffectiveCacheForTest(); |
82 | 83 | __testing.resetToolsEffectiveNowForTest(); |
| 84 | +runtimeMocks.getActivePluginChannelRegistryVersion.mockReturnValue(1); |
83 | 85 | runtimeMocks.getActivePluginRegistryVersion.mockReturnValue(1); |
84 | 86 | }); |
85 | 87 | |
@@ -182,6 +184,18 @@ describe("tools.effective handler", () => {
|
182 | 184 | expect((second.respond.mock.calls[0] as RespondCall | undefined)?.[0]).toBe(true); |
183 | 185 | }); |
184 | 186 | |
| 187 | +it("invalidates the cache when only the channel registry version changes", async () => { |
| 188 | +const first = createInvokeParams({ sessionKey: "main:abc" }); |
| 189 | +await first.invoke(); |
| 190 | + |
| 191 | +runtimeMocks.getActivePluginChannelRegistryVersion.mockReturnValue(2); |
| 192 | +const second = createInvokeParams({ sessionKey: "main:abc" }); |
| 193 | +await second.invoke(); |
| 194 | + |
| 195 | +expect(runtimeMocks.resolveEffectiveToolInventory).toHaveBeenCalledTimes(2); |
| 196 | +expect((second.respond.mock.calls[0] as RespondCall | undefined)?.[0]).toBe(true); |
| 197 | +}); |
| 198 | + |
185 | 199 | it("coalesces identical cache misses while inventory resolution is pending", async () => { |
186 | 200 | const first = createInvokeParams({ sessionKey: "main:abc" }); |
187 | 201 | const second = createInvokeParams({ sessionKey: "main:abc" }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -11,6 +11,7 @@ import {
|
11 | 11 | } from "../protocol/index.js"; |
12 | 12 | import { |
13 | 13 | deliveryContextFromSession, |
| 14 | +getActivePluginChannelRegistryVersion, |
14 | 15 | getActivePluginRegistryVersion, |
15 | 16 | listAgentIds, |
16 | 17 | loadConfig, |
@@ -108,6 +109,7 @@ function buildToolsEffectiveCacheKey(params: {
|
108 | 109 | v: 1, |
109 | 110 | config: configFingerprint(context.cfg), |
110 | 111 | pluginRegistry: getActivePluginRegistryVersion(), |
| 112 | +channelRegistry: getActivePluginChannelRegistryVersion(), |
111 | 113 | sessionKey: params.sessionKey, |
112 | 114 | agentId: context.agentId, |
113 | 115 | senderIsOwner: context.senderIsOwner, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。