AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
fix(chat): chat loads skills when it needs them and creates the folder first (#16392)
Hazem Adelad4f160c2832
diff --git a/packages/core/shared/package.json b/packages/core/shared/package.jsonindex 5b5ab0e7c1e..f44241c9587 100644--- a/packages/core/shared/package.json+++ b/packages/core/shared/package.json@@ -1,6 +1,6 @@{"name": "@activepieces/shared",- "version": "0.200.0",+ "version": "0.200.1","type": "commonjs","sideEffects": false,"main": "./dist/src/index.js",diff --git a/packages/core/shared/src/lib/ee/agent/tool-skills.ts b/packages/core/shared/src/lib/ee/agent/tool-skills.tsindex ba16a71bce0..744945a0f96 100644--- a/packages/core/shared/src/lib/ee/agent/tool-skills.ts+++ b/packages/core/shared/src/lib/ee/agent/tool-skills.ts@@ -51,7 +51,7 @@ function renderSkillsNote({ surface }: { surface: SkillSurface }): string {const lines = [`\n\n${SKILLS_NOTE_HEADING}`,`Only a few tools are attached to you directly. Every other tool named in these instructions or listed below is real and reachable, but calling it by its own name fails: call \`${LAZY_TOOL_NAME}\` with its name as \`tool\` and its arguments as \`input\`, e.g. \`${LAZY_TOOL_NAME}({ "tool": "ap_validate_flow", "input": { "flowId": "..." } })\`.`,- `Never guess a tool's arguments. Load every skill the work needs in one \`${LOAD_SKILL_NAME}\` call, which returns each playbook and the input schema of every tool in it, or fetch one tool's schema with \`${GET_TOOL_SCHEMA_NAME}\`. A loaded skill stays in the conversation, so do not load it again.`,+ `Never guess a tool's arguments. Load the skills the work in front of you needs, together in one \`${LOAD_SKILL_NAME}\` call, and load another when the work reaches it. Each returns its playbook and the input schema of every tool in it. Or fetch one tool's schema with \`${GET_TOOL_SCHEMA_NAME}\`. A loaded skill stays in the conversation, so do not load it again.`,'If a call is rejected for its input, fix it from the schema in the error and retry once.',]return surface === 'CHAT' ? [...lines, '', 'Skills:', renderSkillIndex()].join('\n') : lines.join('\n')diff --git a/packages/server/api/src/app/mcp/tools/mcp-utils.ts b/packages/server/api/src/app/mcp/tools/mcp-utils.tsindex 21358dff172..1082f09fb07 100644--- a/packages/server/api/src/app/mcp/tools/mcp-utils.ts+++ b/packages/server/api/src/app/mcp/tools/mcp-utils.ts@@ -657,7 +657,7 @@ function extractOptionsArray(options: unknown): Array<{ label: string, value: unconst RESOLVE_TIMEOUT_MS = 30_000-const FOLDER_NAME_SCHEMA = z.string().trim().min(1).max(255).optional().describe('Name of an existing folder to place it in. For a solution of several flows and tables, create the folder once with ap_create_folder, then pass the same folderName to each of them.')+const FOLDER_NAME_SCHEMA = z.string().trim().min(1).max(255).optional().describe('Name of an existing folder to place it in. For a solution of several flows and tables, create the folder with ap_create_folder in an earlier step than the calls that use it (never in the same step, they run at once), then pass the same folderName to each of them.')async function executePropertyResolution({ pieceName, pieceVersion, actionOrTriggerName, propertyName, auth, input, searchValue, projectId, platformId, log }: {pieceName: stringdiff --git a/packages/server/worker/src/lib/execute/jobs/ee/agent/tools/skill-tools.ts b/packages/server/worker/src/lib/execute/jobs/ee/agent/tools/skill-tools.tsindex 0f9f0ed66b4..45f114a65ed 100644--- a/packages/server/worker/src/lib/execute/jobs/ee/agent/tools/skill-tools.ts+++ b/packages/server/worker/src/lib/execute/jobs/ee/agent/tools/skill-tools.ts@@ -73,9 +73,9 @@ function createSkillTools({ registry, surface, guides, onSkillLoaded, canAffordPconst loadSkillTool: ToolSet = firstSkill === undefined ? {} : {[LOAD_SKILL_NAME]: tool({- description: 'Load skills before that kind of work (silent, internal). Pass every skill the task needs in one call. Returns each playbook and the input schema of every tool in it, which you then run with ap_lazy_tool.',+ description: 'Load skills before that kind of work (silent, internal). A loaded playbook stays in the conversation and is re-read on every later step, so load only the skills the work in front of you needs right now, together in one call, and load another when the work reaches it. Returns each playbook and the input schema of every tool in it, which you then run with ap_lazy_tool.',inputSchema: z.object({- skills: z.array(z.enum([firstSkill, ...otherSkills])).min(1).describe('Every skill this task needs, loaded together'),+ skills: z.array(z.enum([firstSkill, ...otherSkills])).min(1).describe('The skills the work in front of you needs now, loaded together'),}),execute: async ({ skills: skillNames }) => {const playbooks = await Promise.all([...new Set(skillNames)].map(async (skillName) => {