Skip to content

Commit 570e2db

Browse files
authored
fix(plugins): isolate cached tool runtime siblings
1 parent 53990d5 commit 570e2db

2 files changed

Lines changed: 35 additions & 2 deletions

File tree

‎src/plugins/tools.optional.test.ts‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,6 +2061,39 @@ describe("resolvePluginTools optional tools", () => {
20612061
expect(factory).toHaveBeenCalledTimes(2);
20622062
});
20632063

2064+
it("executes cached healthy tools when a runtime sibling is malformed", async () => {
2065+
const factory = vi.fn(() => [
2066+
createMalformedTool("fuzz_move_angles"),
2067+
{
2068+
...makeTool("mockplugin_status"),
2069+
async execute() {
2070+
return { content: [{ type: "text", text: "mock-status-ok" }] };
2071+
},
2072+
},
2073+
]);
2074+
setRegistry([
2075+
{
2076+
pluginId: "fuzzplugin",
2077+
optional: false,
2078+
source: "/tmp/fuzzplugin.js",
2079+
names: ["mockplugin_status"],
2080+
factory,
2081+
},
2082+
]);
2083+
2084+
const first = resolvePluginTools(createResolveToolsParams());
2085+
const second = resolvePluginTools(createResolveToolsParams());
2086+
const statusTool = second.find((tool) => tool.name === "mockplugin_status");
2087+
2088+
expectResolvedToolNames(first, ["mockplugin_status"]);
2089+
expectResolvedToolNames(second, ["mockplugin_status"]);
2090+
expect(factory).toHaveBeenCalledTimes(1);
2091+
await expect(statusTool?.execute("call", {}, undefined)).resolves.toEqual({
2092+
content: [{ type: "text", text: "mock-status-ok" }],
2093+
});
2094+
expect(factory).toHaveBeenCalledTimes(2);
2095+
});
2096+
20642097
it("reuses cached plugin tool descriptors across session identity changes", async () => {
20652098
const factory = vi.fn((rawCtx: unknown) => {
20662099
const ctx = rawCtx as { sessionId?: string };

‎src/plugins/tools.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,10 +692,10 @@ function createCachedDescriptorPluginTool(params: {
692692
for (const toolRaw of listRaw) {
693693
const malformedReason = describeMalformedPluginTool(toolRaw);
694694
if (malformedReason) {
695-
throw new Error(`plugin tool is malformed (${pluginId}): ${malformedReason}`);
695+
continue;
696696
}
697697
const runtimeTool = toolRaw as AnyAgentTool;
698-
if (normalizeToolName(runtimeTool.name) === requestedToolName) {
698+
if (normalizeToolName(readPluginToolName(runtimeTool)) === requestedToolName) {
699699
return runtimeTool;
700700
}
701701
}

0 commit comments

Comments
 (0)