@mcpc-tech/core 0.2.7-beta.1 → 0.2.7-beta.2

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.
Files changed (2) hide show
  1. package/index.mjs +56 -20
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -1059,7 +1059,7 @@ var SystemPrompts = {
1059
1059
  4. **Collect feedback** from each action result
1060
1060
  5. **Decide** next step:
1061
1061
  - **proceed**: More work needed
1062
- - **complete**: Question answered
1062
+ - **complete**: Question answered (do NOT provide action field)
1063
1063
  - **retry**: Current action failed
1064
1064
  6. **Provide** parameter object matching action name
1065
1065
  7. **Continue** until complete
@@ -1068,9 +1068,16 @@ var SystemPrompts = {
1068
1068
  \`\`\`json
1069
1069
  {
1070
1070
  "action": "tool_name",
1071
- "decision": "proceed|retry|complete",
1071
+ "decision": "proceed|retry",
1072
1072
  "tool_name": { /* tool parameters */ }
1073
1073
  }
1074
+ \`\`\`
1075
+
1076
+ **When task is complete:**
1077
+ \`\`\`json
1078
+ {
1079
+ "decision": "complete"
1080
+ }
1074
1081
  \`\`\``,
1075
1082
  /**
1076
1083
  * Workflow execution system prompt
@@ -1110,14 +1117,22 @@ var SystemPrompts = {
1110
1117
  - Continue until question answered
1111
1118
 
1112
1119
  ## JSON Response Format
1120
+ **During execution:**
1113
1121
  \`\`\`json
1114
1122
  {
1115
1123
  "action": "tool_name",
1116
- "decision": "proceed|retry|complete",
1124
+ "decision": "proceed|retry",
1117
1125
  "tool_name": { /* tool parameters */ }
1118
1126
  }
1119
1127
  \`\`\`
1120
1128
 
1129
+ **When task is complete (do NOT include action):**
1130
+ \`\`\`json
1131
+ {
1132
+ "decision": "complete"
1133
+ }
1134
+ \`\`\`
1135
+
1121
1136
  ## Available Tools
1122
1137
  {toolList}`,
1123
1138
  /**
@@ -1152,9 +1167,12 @@ You MUST respond with a JSON object for workflow execution:
1152
1167
 
1153
1168
  **For Step Execution (Subsequent Calls):**
1154
1169
  - action: "{toolName}"
1155
- - decision: "proceed" (advance), "retry" (retry), or "complete" (finish - sampling mode only)
1170
+ - decision: "proceed" (advance), "retry" (retry)
1156
1171
  - [step parameters]: Tool-specific parameters you autonomously determine for current step
1157
1172
 
1173
+ **When Workflow is Complete (do NOT include action):**
1174
+ - decision: "complete"
1175
+
1158
1176
  **\u{1F3AF} AGENTIC WORKFLOW CONSTRAINTS:**
1159
1177
  - Response must be pure JSON demonstrating autonomous decision-making within workflow structure
1160
1178
  - Invalid JSON indicates failure in agentic workflow reasoning
@@ -2097,7 +2115,7 @@ var BaseSamplingExecutor = class {
2097
2115
  role: "user",
2098
2116
  content: {
2099
2117
  type: "text",
2100
- text: 'Return ONE AND ONLY ONE raw JSON object (no code fences, explanations, or multiple objects). The JSON MUST include action and decision. Example: {"action":"<tool>","decision":"proceed|complete","<tool>":{}}'
2118
+ text: 'Return ONE AND ONLY ONE raw JSON object (no code fences, explanations, or multiple objects). During execution provide: {"action":"<tool>","decision":"proceed|retry","<tool>":{}}. When complete provide: {"decision":"complete"}'
2101
2119
  }
2102
2120
  }
2103
2121
  ];
@@ -2157,7 +2175,18 @@ var BaseSamplingExecutor = class {
2157
2175
  role: "user",
2158
2176
  content: {
2159
2177
  type: "text",
2160
- text: 'Required fields missing: action or decision. Return ONLY raw JSON, no code fences or explanations. Example: {"action":"<tool>","decision":"proceed|complete","<tool>":{}}'
2178
+ text: 'Required fields missing. During execution provide: {"action":"<tool>","decision":"proceed|retry","<tool>":{}}. When complete provide: {"decision":"complete"}'
2179
+ }
2180
+ });
2181
+ if (iterationSpan) endSpan(iterationSpan);
2182
+ continue;
2183
+ }
2184
+ if (parsedData["decision"] === "complete" && action) {
2185
+ this.conversationHistory.push({
2186
+ role: "user",
2187
+ content: {
2188
+ type: "text",
2189
+ text: 'Invalid: Cannot have both "decision":"complete" and "action" field. When complete, only provide {"decision":"complete"}.'
2161
2190
  }
2162
2191
  });
2163
2192
  if (iterationSpan) endSpan(iterationSpan);
@@ -2445,12 +2474,16 @@ var SamplingExecutor = class extends BaseSamplingExecutor {
2445
2474
  const toolCallData = parsedData;
2446
2475
  const isComplete = toolCallData.decision === "complete";
2447
2476
  const actionName = toolCallData.action;
2448
- if (isComplete && actionName && actionName !== "complete") {
2449
- this.logger.debug({
2450
- message: "Decision is 'complete' with action present, treating as 'proceed'",
2451
- action: actionName
2452
- });
2453
- toolCallData.decision = "proceed";
2477
+ if (isComplete && actionName) {
2478
+ return {
2479
+ content: [
2480
+ {
2481
+ type: "text",
2482
+ text: 'Invalid: Cannot have both "decision":"complete" and "action" field. When complete, only provide {"decision":"complete"}. When executing, provide {"action":"<tool>","decision":"proceed|retry","<tool>":{}}.'
2483
+ }
2484
+ ],
2485
+ isError: true
2486
+ };
2454
2487
  }
2455
2488
  if (toolCallData.decision === "complete") {
2456
2489
  return await this.createCompletionResult("Task completed", parentSpan);
@@ -2499,8 +2532,7 @@ ${JSON.stringify(context2, null, 2)}`;
2499
2532
  ## Current Task
2500
2533
  You will now use agentic sampling to complete the following task: "${userRequest}"${contextInfo}
2501
2534
 
2502
- When you need to use a tool, specify the tool name in 'action' and provide tool-specific parameters as additional properties.
2503
- When the task is complete, use "action": "complete".`;
2535
+ When you need to use a tool, specify the tool name in 'action' and provide tool-specific parameters as additional properties.`;
2504
2536
  return this.injectJsonInstruction({
2505
2537
  prompt: basePrompt + taskPrompt,
2506
2538
  schema: agenticSchema
@@ -3074,12 +3106,16 @@ var WorkflowSamplingExecutor = class extends BaseSamplingExecutor {
3074
3106
  const toolCallData = parsedData;
3075
3107
  const isComplete = toolCallData.decision === "complete";
3076
3108
  const actionName = toolCallData.action;
3077
- if (isComplete && actionName && actionName !== "complete") {
3078
- this.logger.debug({
3079
- message: "Decision is 'complete' with action present, treating as 'proceed'",
3080
- action: actionName
3081
- });
3082
- toolCallData.decision = "proceed";
3109
+ if (isComplete && actionName) {
3110
+ return {
3111
+ content: [
3112
+ {
3113
+ type: "text",
3114
+ text: 'Invalid: Cannot have both "decision":"complete" and "action" field. When complete, only provide {"decision":"complete"}. When executing, provide {"action":"<tool>","decision":"proceed|retry","<tool>":{}}.'
3115
+ }
3116
+ ],
3117
+ isError: true
3118
+ };
3083
3119
  }
3084
3120
  if (toolCallData.decision === "complete") {
3085
3121
  return await this.createCompletionResult("Task completed", parentSpan);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpc-tech/core",
3
- "version": "0.2.7-beta.1",
3
+ "version": "0.2.7-beta.2",
4
4
  "homepage": "https://jsr.io/@mcpc/core",
5
5
  "type": "module",
6
6
  "dependencies": {