Skip to content

Commit a8395fe

Browse files
authored
Switch from per-charm tools to top-level run/read/inspect tools (commontoolsinc#2072)
* Switch from per-charm tools to top-level run/read/inspect tools * Fix tool schemas/parameter declarations * Append schema LUT to the system prompt Makes this a 1:1 comparison against old version * Lint + format * Fix test case
1 parent 6c198d5 commit a8395fe

File tree

3 files changed

+351
-239
lines changed

3 files changed

+351
-239
lines changed

packages/patterns/chatbot.tsx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -328,21 +328,23 @@ export default recipe<ChatInput, ChatOutput>(
328328
return attachments;
329329
});
330330

331-
// Derive tools from attachments (including auto-attached recent charm)
331+
// Surface attached charms so the LLM can use read/run/schema helpers.
332332
const dynamicTools = computed(() => {
333-
const tools: Record<string, any> = {};
333+
const attached: Record<string, any> = {};
334334

335335
for (const attachment of attachmentsWithRecent || []) {
336-
if (attachment.type === "mention" && attachment.charm) {
337-
const charmName = attachment.charm[NAME] || "Charm";
338-
tools[charmName] = {
339-
charm: attachment.charm,
340-
description: `Handlers from ${charmName}`,
341-
};
342-
}
336+
if (attachment.type !== "mention" || !attachment.charm) continue;
337+
const charmName = attachment.charm[NAME] || "Charm";
338+
attached[charmName] = {
339+
charm: attachment.charm,
340+
description:
341+
`Attached charm ${charmName}. Use schema("${charmName}") to ` +
342+
`inspect it, then read("${charmName}/path") or ` +
343+
`run("${charmName}/handler").`,
344+
};
343345
}
344346

345-
return tools;
347+
return attached;
346348
});
347349

348350
const attachmentTools = {
@@ -354,7 +356,8 @@ export default recipe<ChatInput, ChatOutput>(
354356
}),
355357
},
356358
listAttachments: {
357-
description: "List all attachments in the attachments array.",
359+
description:
360+
"List attachment names to use with schema(), read(), and run().",
358361
handler: listAttachments({ allAttachments: attachmentsWithRecent }),
359362
},
360363
listMentionable: {

0 commit comments

Comments
 (0)