Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

perf(cindy-tools): 插件花名册只注入 ghost_list 描述 (#1321)

Dash284e379b781a
diff --git a/packages/cindy-tools/src/__tests__/ghostMcp.test.ts b/packages/cindy-tools/src/__tests__/ghostMcp.test.ts
index 664adb24ac..2fb6b07bad 100644
--- a/packages/cindy-tools/src/__tests__/ghostMcp.test.ts
+++ b/packages/cindy-tools/src/__tests__/ghostMcp.test.ts
@@ -1099,6 +1099,38 @@ describe("formatGhostRoster(花名册快照:语义召回数据源)", () => {
);
expect(many.split("\n")).toHaveLength(1 + 16); // 标题 + 上限 16 条
});
+
+ /**
+ * 花名册只许进 ghost_list 一处。两件工具的描述都在 system prompt 的固定
+ * 前缀里,拼两遍等于整份已装插件清单在上下文出现两次。
+ */
+ it("只注入 ghost_list 描述;ghost_call 描述不带花名册", () => {
+ const server = createCindyGhostsMcpServer(
+ fakeDeps({
+ getRosterItems: () => [
+ {
+ id: "art",
+ name: "画图",
+ command: "画图",
+ description: "画图与改图。",
+ },
+ ],
+ }),
+ ) as unknown as {
+ _registeredTools: Record<string, { description?: string } | undefined>;
+ };
+
+ const listDesc = server._registeredTools.ghost_list?.description ?? "";
+ const callDesc = server._registeredTools.ghost_call?.description ?? "";
+
+ expect(listDesc).toContain("【本机插件清单");
+ expect(listDesc).toContain("- 画图(id: art,指令 $画图):画图与改图。");
+
+ expect(callDesc).not.toContain("【本机插件清单");
+ expect(callDesc).not.toContain("id: art");
+ // ghost_call 仍保留自身基线描述(去重不等于把描述删空)。
+ expect(callDesc).toContain("调用某个插件(Ghost)提供的工具。");
+ });
});
describe("cindy · 卡槽③(xdt_card_id 提升 + agentToolUseId 提取)", () => {
diff --git a/packages/cindy-tools/src/ghost/mcpServer.ts b/packages/cindy-tools/src/ghost/mcpServer.ts
index de5ae48401..ed42b921c2 100644
--- a/packages/cindy-tools/src/ghost/mcpServer.ts
+++ b/packages/cindy-tools/src/ghost/mcpServer.ts
@@ -732,17 +732,21 @@ export function createCindyGhostsMcpServer(
version: "1.0.0",
});
- // 花名册快照:装配时取一次,拼进两件工具的描述(语义召回的数据源;
+ // 花名册快照:装配时取一次,只拼进 ghost_list 的描述(语义召回的数据源;
// 会话内恒定,缓存安全)。无花名册 dep / 空清单 = 描述保持基线。
+ //
+ // 只拼一处:两件工具的描述都进 system prompt 固定前缀,同一份花名册拼两遍
+ // 等于让整份已装插件清单在上下文里出现两次(12 个插件实测约 1.5k 字符/份)。
+ // ghost_call 的调用前提是已知 ghost_id + tool,那必然来自 ghost_list 的描述
+ // 或返回值(D_GHOST_CALL 首行已写明这点),再挂一份花名册对路由没有增量作用。
const roster = formatGhostRoster(deps.getRosterItems?.() ?? []);
const dGhostList = roster ? `${D_GHOST_LIST}\n\n${roster}` : D_GHOST_LIST;
- const dGhostCall = roster ? `${D_GHOST_CALL}\n\n${roster}` : D_GHOST_CALL;
server.tool("ghost_list", dGhostList, {}, async () => handleGhostList(deps));
server.tool(
"ghost_call",
- dGhostCall,
+ D_GHOST_CALL,
{
ghost_id: z.string().describe("目标插件 id(来自 ghost_list)"),
tool: z.string().describe("工具名(来自 ghost_list 该插件的 tools)"),