mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-30 19:32:27 +00:00
fix: summarize plugin tool descriptions in catalog
This commit is contained in:
@@ -19,7 +19,12 @@ const pluginToolMetaState = new Map<string, { pluginId: string; optional: boolea
|
||||
vi.mock("../../plugins/tools.js", () => ({
|
||||
resolvePluginTools: vi.fn(() => [
|
||||
{ name: "voice_call", label: "voice_call", description: "Plugin calling tool" },
|
||||
{ name: "matrix_room", label: "matrix_room", description: "Matrix room helper" },
|
||||
{
|
||||
name: "matrix_room",
|
||||
label: "matrix_room",
|
||||
displaySummary: "Summarized Matrix room helper.",
|
||||
description: "Matrix room helper\n\nACTIONS:\n- join\n- leave",
|
||||
},
|
||||
]),
|
||||
getPluginToolMeta: vi.fn((tool: { name: string }) => pluginToolMetaState.get(tool.name)),
|
||||
}));
|
||||
@@ -119,6 +124,29 @@ describe("tools.catalog handler", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("summarizes plugin tool descriptions the same way as the effective inventory", async () => {
|
||||
const { respond, invoke } = createInvokeParams({});
|
||||
await invoke();
|
||||
const call = respond.mock.calls[0] as RespondCall | undefined;
|
||||
expect(call?.[0]).toBe(true);
|
||||
const payload = call?.[1] as
|
||||
| {
|
||||
groups: Array<{
|
||||
source: "core" | "plugin";
|
||||
tools: Array<{
|
||||
id: string;
|
||||
description: string;
|
||||
}>;
|
||||
}>;
|
||||
}
|
||||
| undefined;
|
||||
const matrixRoom = (payload?.groups ?? [])
|
||||
.filter((group) => group.source === "plugin")
|
||||
.flatMap((group) => group.tools)
|
||||
.find((tool) => tool.id === "matrix_room");
|
||||
expect(matrixRoom?.description).toBe("Summarized Matrix room helper.");
|
||||
});
|
||||
|
||||
it("opts plugin tool catalog loads into gateway subagent binding", async () => {
|
||||
const { invoke } = createInvokeParams({});
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
PROFILE_OPTIONS,
|
||||
resolveCoreToolProfiles,
|
||||
} from "../../agents/tool-catalog.js";
|
||||
import { summarizeToolDescriptionText } from "../../agents/tool-description-summary.js";
|
||||
import { loadConfig } from "../../config/config.js";
|
||||
import { getPluginToolMeta, resolvePluginTools } from "../../plugins/tools.js";
|
||||
import {
|
||||
@@ -105,10 +106,10 @@ function buildPluginGroups(params: {
|
||||
existing.tools.push({
|
||||
id: tool.name,
|
||||
label: typeof tool.label === "string" && tool.label.trim() ? tool.label.trim() : tool.name,
|
||||
description:
|
||||
typeof tool.description === "string" && tool.description.trim()
|
||||
? tool.description.trim()
|
||||
: "Plugin tool",
|
||||
description: summarizeToolDescriptionText({
|
||||
rawDescription: typeof tool.description === "string" ? tool.description : undefined,
|
||||
displaySummary: tool.displaySummary,
|
||||
}),
|
||||
source: "plugin",
|
||||
pluginId,
|
||||
optional: meta?.optional,
|
||||
|
||||
Reference in New Issue
Block a user