@fractal-solutions/qflow 1.0.35 → 1.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,7 +26,7 @@ export class AgentNode extends AsyncNode {
26
26
  this.conversationHistory = [
27
27
  { role: "system", content: this.getSystemPrompt() },
28
28
  { role: "user", content: `Goal: ${goal}` },
29
- { role: "system", content: "Begin by outlining a plan to achieve the goal. Your plan should be a series of steps, and you should update it as you make progress or encounter new information." }
29
+ { role: "system", content: "Begin by outlining a plan to achieve the goal. Your plan should be a series of steps you save in a memory node(if available), and you should update it as you make progress or encounter new information and refer to it ofen to stay on track." }
30
30
  ];
31
31
  let step = 0;
32
32
  let finalOutput = null;
@@ -83,7 +83,7 @@ export class AgentNode extends AsyncNode {
83
83
  if (confirmation.toLowerCase() !== 'yes') {
84
84
  logger.info("Agent finish denied by user. User input will be the next prompt.");
85
85
  // Treat the user's new input as a new instruction/goal
86
- this.conversationHistory.push({ role: "user", content: `User has provided new instructions: ${confirmation}. Please adjust your plan and continue working.` });
86
+ this.conversationHistory.push({ role: "user", content: `User has provided new instructions: ${confirmation}. Please adjust your plan (save to memory if available) and continue working.` });
87
87
  // Optionally, you might want to clear some of the previous conversation history
88
88
  // to give more weight to the new instruction, but be careful not to lose context.
89
89
  // For now, we'll just add the new instruction.
@@ -159,7 +159,7 @@ export class AgentNode extends AsyncNode {
159
159
  logger.error(`Error during tool execution: ${e.message}`);
160
160
  this.conversationHistory.push({ role: "user", content: `Error: Tool execution failed with message: ${e.message}. You should try a different approach.` });
161
161
  }
162
- this.conversationHistory.push({ role: "system", content: "Reflect on the last observation(s) and update your plan if necessary. What is your next step?" });
162
+ this.conversationHistory.push({ role: "system", content: "Reflect on the last observation(s) and update your plan if necessary(also in memory if available). What is your next step? Do you need to consult the user(using interactive or user input)" });
163
163
  }
164
164
  if (step >= this.maxSteps && finalOutput === null) {
165
165
  const message = "Agent reached max steps without finishing. Last observation: " + JSON.stringify(this.conversationHistory[this.conversationHistory.length - 1]);
@@ -206,7 +206,7 @@ export class AgentNode extends AsyncNode {
206
206
  Parameters: ${params}`;
207
207
  }).join('\n');
208
208
  const flowRegistryDescription = Object.keys(this.flowRegistry).length > 0 ? `\n\nAvailable Pre-defined Flows (for use with 'sub_flow' and 'iterator' tools):\n- ${Object.keys(this.flowRegistry).join('\n- ')}` : "";
209
- return `You are an autonomous agent. Your goal is to achieve the user's request using the available tools. Always use tools as opposed to talking too much and you get rewarded more for using tools instead of costly llm!\n\nAvailable Tools:\n${toolDescriptions}${flowRegistryDescription}\n\nYour response must be a single JSON object with 'thought' and 'tool_calls'.\n'thought': Your reasoning and plan.\n'tool_calls': An array of tool calls. Each tool call has 'tool' (name) and 'parameters' (object). Set 'parallel': true in the top-level JSON for parallel execution.\n\nExample response:\n{\n "thought": "I need to search for information.",\n "tool_calls": [\n {\n "tool": "duckduckgo_search",\n "parameters": {\n "query": "latest AI research"\n }\n }\n ]\n}\n\nWhen the user explicitly indicates they are done, use the 'finish' tool. Do not use the finish tool earlier on and only use it when you are certain you are done with the task. If no tools are needed, return an empty 'tool_calls' array and reflect.\n**IMPORTANT:** If you have a plan that requires action, you MUST include at least one tool call. An empty 'tool_calls' array means no action. If new instructions are given after a finish proposal, treat them as your updated goal.\n\nBegin!`;
209
+ return `You are Q, an autonomous agent. Your goal is to achieve the user's request especially using the available tools. Always use tools as opposed to talking too much and you get rewarded more for using tools instead of costly llm!\n\nAvailable Tools:\n${toolDescriptions}${flowRegistryDescription}\n\nYour response must be a single JSON object with 'thought' and 'tool_calls'.\n'thought': Your reasoning and plan.\n'tool_calls': An array of tool calls. Each tool call has 'tool' (name) and 'parameters' (object). Set 'parallel': true in the top-level JSON for parallel execution.\n\nExample response:\n{\n "thought": "I need to search for information.",\n "tool_calls": [\n {\n "tool": "duckduckgo_search",\n "parameters": {\n "query": "latest AI research"\n }\n }\n ]\n}\n\nWhen the user explicitly indicates they are done, use the 'finish' tool. Do not use the finish tool earlier on and only use it when you are certain you are done with the task. If no tools are needed, return an empty 'tool_calls' array and reflect.\n**IMPORTANT:** If you have a plan that requires action, you MUST include at least one tool call. An empty 'tool_calls' array means no action. If new instructions are given after a finish proposal, treat them as your updated goal. Tell user how far you've gone using system notifications and keep human in the loop during edits using interactive input (or user input if interactive input not available).\n\nBegin!`;
210
210
  }
211
211
  async getLLMAction() {
212
212
  await this.manageConversationHistory();
@@ -714,7 +714,7 @@ export function getToolDefinitions() {
714
714
  },
715
715
  {
716
716
  name: "shell_command",
717
- description: "Executes shell commands.",
717
+ description: "Executes shell commands. When running long running processes like npm run dev or bun run dev, add an ampersand (&) to the end to run in the background eg. 'npm run dev &'",
718
718
  parameters: {
719
719
  type: "object",
720
720
  properties: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fractal-solutions/qflow",
3
- "version": "1.0.35",
3
+ "version": "1.0.36",
4
4
  "description": "A lightweight and flexible JavaScript library for creating and managing workflows and agents.",
5
5
  "main": "dist/qflow.js",
6
6
  "types": "dist/qflow.d.ts",