@fractal-solutions/qflow 1.0.36 → 1.0.37

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 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." }
29
+ { role: "system", content: "You are now at the 'Understand & Explore' phase. Analyze the user's request and the directory/codebase, then formulate a plan." }
30
30
  ];
31
31
  let step = 0;
32
32
  let finalOutput = null;
@@ -66,7 +66,7 @@ export class AgentNode extends AsyncNode {
66
66
  this.conversationHistory.push({ role: "assistant", content: JSON.stringify({ thought, tool_calls: toolCalls, parallel }) });
67
67
  // If no tool calls, continue the loop to allow the LLM to re-evaluate
68
68
  if (toolCalls.length === 0) {
69
- this.conversationHistory.push({ role: "system", content: "No tools were called. Reflect on your plan and provide the next step." });
69
+ this.conversationHistory.push({ role: "system", content: "Your last step resulted in no action. Re-evaluate your plan. If you are stuck, consider using a different tool or asking the user for clarification with the 'interactive_input'tool." });
70
70
  continue;
71
71
  }
72
72
  // Handle finish tool
@@ -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(also in memory if available). What is your next step? Do you need to consult the user(using interactive or user input)" });
162
+ this.conversationHistory.push({ role: "system", content: "You have just received an observation from your tools. Analyze the result and proceed to the next step in your plan. If the observation was an error, you must adjust your plan to fix the error." });
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,22 @@ 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 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!`;
209
+ return `You are a senior Expert Computer User and AI software engineer. Your primary directive is to solve tasks by
210
+ effectively and impactfully using the tools available to you. You must operate with a professional software
211
+ engineering mindset by following a structured, non-negotiable workflow for every task:
212
+
213
+
214
+ Understand & Explore: Use commands (like glob, read, write, append, grep etc) to analyze the existing
215
+ directory/codebase/task. You must understand the context before you act.
216
+ Plan: Create a detailed, step-by-step plan. Present this plan in your 'thought'.
217
+ Execute: Execute the plan using the available tools.
218
+ Verify: After making changes, you MUST run tests to verify correctness of tool use.
219
+
220
+
221
+ Your response MUST be a single JSON object with 'thought' and 'tool_calls'. The 'thought'
222
+ field must contain your reasoning and current step in the plan. Do not add notes outside
223
+ the JSON structure. If you have a plan, you MUST include at least one tool call. An empty
224
+ 'tool_calls' array means you are thinking or waiting for user input.`;
210
225
  }
211
226
  async getLLMAction() {
212
227
  await this.manageConversationHistory();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fractal-solutions/qflow",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
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",