@nexus-cortex/core 4.79.0 → 4.81.0
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.
- package/dist/middleware/HelperModelMiddleware.d.ts +9 -4
- package/dist/middleware/HelperModelMiddleware.d.ts.map +1 -1
- package/dist/middleware/HelperModelMiddleware.js +141 -291
- package/dist/middleware/HelperModelMiddleware.js.map +1 -1
- package/dist/middleware/helpers/adapters/ChatCompletionsAPIHelperAdapter.d.ts.map +1 -1
- package/dist/middleware/helpers/adapters/ChatCompletionsAPIHelperAdapter.js +10 -2
- package/dist/middleware/helpers/adapters/ChatCompletionsAPIHelperAdapter.js.map +1 -1
- package/dist/middleware/helpers/adapters/GenerateContentAPIHelperAdapter.d.ts +7 -0
- package/dist/middleware/helpers/adapters/GenerateContentAPIHelperAdapter.d.ts.map +1 -1
- package/dist/middleware/helpers/adapters/GenerateContentAPIHelperAdapter.js +13 -0
- package/dist/middleware/helpers/adapters/GenerateContentAPIHelperAdapter.js.map +1 -1
- package/dist/middleware/helpers/adapters/GoogleGenAPIHelperAdapter.d.ts +8 -0
- package/dist/middleware/helpers/adapters/GoogleGenAPIHelperAdapter.d.ts.map +1 -1
- package/dist/middleware/helpers/adapters/GoogleGenAPIHelperAdapter.js +25 -0
- package/dist/middleware/helpers/adapters/GoogleGenAPIHelperAdapter.js.map +1 -1
- package/dist/middleware/helpers/adapters/ResponsesAPIHelperAdapter.d.ts +6 -0
- package/dist/middleware/helpers/adapters/ResponsesAPIHelperAdapter.d.ts.map +1 -1
- package/dist/middleware/helpers/adapters/ResponsesAPIHelperAdapter.js +19 -0
- package/dist/middleware/helpers/adapters/ResponsesAPIHelperAdapter.js.map +1 -1
- package/dist/orchestrator/CortexOrchestrator.d.ts.map +1 -1
- package/dist/orchestrator/CortexOrchestrator.js +20 -1
- package/dist/orchestrator/CortexOrchestrator.js.map +1 -1
- package/dist/training/DecisionPriorInjector.d.ts +9 -0
- package/dist/training/DecisionPriorInjector.d.ts.map +1 -1
- package/dist/training/DecisionPriorInjector.js +24 -0
- package/dist/training/DecisionPriorInjector.js.map +1 -1
- package/dist/training/DecisionStore.d.ts +24 -0
- package/dist/training/DecisionStore.d.ts.map +1 -1
- package/dist/training/DecisionStore.js +24 -0
- package/dist/training/DecisionStore.js.map +1 -1
- package/package.json +3 -3
|
@@ -233,6 +233,15 @@ export declare class HelperModelMiddleware {
|
|
|
233
233
|
maxOutputTokens?: number;
|
|
234
234
|
helperModelId?: string;
|
|
235
235
|
}): Promise<string>;
|
|
236
|
+
/**
|
|
237
|
+
* Shared reactive-mentorship guidance generator (item-11a frame migration, 2026-08-27).
|
|
238
|
+
* Every generator builds a PLAIN body and routes through the item-11a helper frame
|
|
239
|
+
* (frameHelperPrompt: persona + verbatim-grounding rule + output budget), then generate()
|
|
240
|
+
* (RAW — the rewrap fix). No legacy <thinking> framing, no extractThinkingContent — the
|
|
241
|
+
* helper's output is plain guidance delivered as attributed user-role text (item 11c).
|
|
242
|
+
* Reasoning is disabled per the DeepSeek helper card (reasoning.defaultEffort:'none').
|
|
243
|
+
*/
|
|
244
|
+
private generateGuidance;
|
|
236
245
|
generateErrorGuidance(context: {
|
|
237
246
|
toolName: string;
|
|
238
247
|
toolUseId: string;
|
|
@@ -282,10 +291,6 @@ export declare class HelperModelMiddleware {
|
|
|
282
291
|
* Build keyword-specific prompt
|
|
283
292
|
*/
|
|
284
293
|
private buildKeywordPrompt;
|
|
285
|
-
/**
|
|
286
|
-
* Extract thinking content from response
|
|
287
|
-
*/
|
|
288
|
-
private extractThinkingContent;
|
|
289
294
|
/**
|
|
290
295
|
* Generate periodic review guidance (Phase 2)
|
|
291
296
|
* Triggered every N turns for strategic check-in
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HelperModelMiddleware.d.ts","sourceRoot":"","sources":["../../src/middleware/HelperModelMiddleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,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,EAAE,KAAK,CAAC;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,OAAO,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC,CAAC;QAC5E,eAAe,EAAE,MAAM,CAAC;QACxB,aAAa,EAAE,OAAO,EAAE,CAAC;QACzB,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,GAAG,OAAO,CAAC,MAAM,CAAC;IA0BnB;;;;OAIG;IACG,+BAA+B,CAAC,OAAO,EAAE;QAC7C,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,EAAE,OAAO,EAAE,CAAC;QACzB,SAAS,EAAE,MAAM,EAAE,CAAC;QACpB,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB,GAAG,OAAO,CAAC,MAAM,CAAC;CAiCpB"}
|
|
@@ -417,11 +417,12 @@ export class HelperModelMiddleware {
|
|
|
417
417
|
* Select helper model based on main model provider
|
|
418
418
|
*/
|
|
419
419
|
selectHelperModel(provider) {
|
|
420
|
-
// Last-resort default =
|
|
421
|
-
// (
|
|
422
|
-
//
|
|
423
|
-
//
|
|
424
|
-
|
|
420
|
+
// Last-resort default = deepseek-v4-flash. SINGLE-PROVIDER congruence: the
|
|
421
|
+
// shipped harness (and the TB2 bench container) runs one provider key; a
|
|
422
|
+
// Gemma/CF default would force the user to enter a 2nd API key before the
|
|
423
|
+
// helper works. deepseek-v4-flash is cheap, large-context, and reuses the
|
|
424
|
+
// main DeepSeek key for the text-only helper role (compaction/mentorship).
|
|
425
|
+
return HELPER_MODEL_REGISTRY[provider.toLowerCase()] || 'deepseek-v4-flash';
|
|
425
426
|
}
|
|
426
427
|
/**
|
|
427
428
|
* Get ModelConfig for a helper/mentorship model by ID
|
|
@@ -651,6 +652,12 @@ export class HelperModelMiddleware {
|
|
|
651
652
|
displayName: 'DeepSeek V4 Flash',
|
|
652
653
|
provider: 'deepseek',
|
|
653
654
|
family: 'deepseek-v4',
|
|
655
|
+
// DISABLE thinking for the HELPER role — deepseek-v4-* is dual-mode (thinking on by
|
|
656
|
+
// default); helper tasks (compaction/guidance/summaries) need no reasoning, and leaving
|
|
657
|
+
// it on starves message.content (all budget → reasoning_content). The ChatCompletions
|
|
658
|
+
// helper adapter forwards defaultEffort as `reasoning_effort` (DeepSeek OpenAI-format
|
|
659
|
+
// toggle: 'none' disables thinking).
|
|
660
|
+
reasoning: { supported: true, defaultEffort: 'none' },
|
|
654
661
|
api: {
|
|
655
662
|
pattern: 'chat/completions',
|
|
656
663
|
endpoint: 'https://api.deepseek.com/chat/completions',
|
|
@@ -942,47 +949,46 @@ Produce the FULL updated CORTEX.md. Rules, in priority order:
|
|
|
942
949
|
// strip accidental fences
|
|
943
950
|
return out.replace(/^```[a-z]*\n/, '').replace(/\n```\s*$/, '').trim();
|
|
944
951
|
}
|
|
952
|
+
/**
|
|
953
|
+
* Shared reactive-mentorship guidance generator (item-11a frame migration, 2026-08-27).
|
|
954
|
+
* Every generator builds a PLAIN body and routes through the item-11a helper frame
|
|
955
|
+
* (frameHelperPrompt: persona + verbatim-grounding rule + output budget), then generate()
|
|
956
|
+
* (RAW — the rewrap fix). No legacy <thinking> framing, no extractThinkingContent — the
|
|
957
|
+
* helper's output is plain guidance delivered as attributed user-role text (item 11c).
|
|
958
|
+
* Reasoning is disabled per the DeepSeek helper card (reasoning.defaultEffort:'none').
|
|
959
|
+
*/
|
|
960
|
+
async generateGuidance(spec, body, helperModelId) {
|
|
961
|
+
const modelId = helperModelId || 'deepseek-v4-flash';
|
|
962
|
+
const helperConfig = this.getHelperModelConfig(modelId);
|
|
963
|
+
const adapter = this.helperAdapterRegistry.getAdapterForModel(helperConfig);
|
|
964
|
+
const prompt = frameHelperPrompt(spec, body);
|
|
965
|
+
const messages = [{ role: 'user', content: prompt }];
|
|
966
|
+
const out = await adapter.generate(messages, helperConfig, spec.outputBudgetTokens);
|
|
967
|
+
return (out || '').replace(/^```[a-z]*\n/, '').replace(/\n```\s*$/, '').trim();
|
|
968
|
+
}
|
|
945
969
|
async generateErrorGuidance(context) {
|
|
946
|
-
// Format error for display
|
|
947
970
|
const errorText = typeof context.error === 'string'
|
|
948
971
|
? context.error
|
|
949
972
|
: JSON.stringify(context.error, null, 2);
|
|
950
|
-
// Format recent history for context
|
|
951
973
|
const historyContext = this.formatRecentHistory(context.recentHistory);
|
|
952
|
-
|
|
953
|
-
const prompt = `You are an AI mentor analyzing a tool execution error. Provide concise, actionable guidance.
|
|
974
|
+
const body = `A tool call just failed.
|
|
954
975
|
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
**Error**: ${errorText}
|
|
976
|
+
Tool: ${context.toolName}
|
|
977
|
+
Error: ${errorText}
|
|
958
978
|
|
|
959
|
-
|
|
979
|
+
Recent actions:
|
|
960
980
|
${historyContext}
|
|
961
981
|
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
const helperModelId = context.helperModelId || 'grok-4-1-fast-non-reasoning'; // Default to grok-beta for mentorship
|
|
973
|
-
const helperConfig = this.getHelperModelConfig(helperModelId);
|
|
974
|
-
// Get appropriate adapter for helper model
|
|
975
|
-
const adapter = this.helperAdapterRegistry.getAdapterForModel(helperConfig);
|
|
976
|
-
// Convert prompt to HelperCanonicalMessage format
|
|
977
|
-
const messages = [{
|
|
978
|
-
role: 'user',
|
|
979
|
-
content: prompt
|
|
980
|
-
}];
|
|
981
|
-
// Make API call via adapter (using compact method as it does single-turn generation)
|
|
982
|
-
// We use targetTokens=500 for concise guidance
|
|
983
|
-
const result = await adapter.compact(messages, helperConfig, 500);
|
|
984
|
-
// Extract thinking content from the response
|
|
985
|
-
return this.extractThinkingContent(result.summary);
|
|
982
|
+
Give concise, actionable guidance in plain text with these labeled parts:
|
|
983
|
+
- Error analysis (what went wrong, 1-2 sentences)
|
|
984
|
+
- Immediate fix (2-3 concrete steps)
|
|
985
|
+
- Why this works (brief)`;
|
|
986
|
+
return this.generateGuidance({
|
|
987
|
+
surface: 'error-guidance',
|
|
988
|
+
persona: 'You are an AI coding mentor analyzing a tool execution error.',
|
|
989
|
+
task: 'Diagnose the failure and give the immediate next steps to fix it.',
|
|
990
|
+
outputBudgetTokens: 500,
|
|
991
|
+
}, body, context.helperModelId);
|
|
986
992
|
}
|
|
987
993
|
/**
|
|
988
994
|
* Generate a concise session title from the first user message.
|
|
@@ -1039,23 +1045,14 @@ PREDICTION: <prediction>`;
|
|
|
1039
1045
|
*/
|
|
1040
1046
|
async generateKeywordGuidance(context) {
|
|
1041
1047
|
const historyContext = this.formatRecentHistory(context.recentHistory);
|
|
1042
|
-
|
|
1043
|
-
const
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
const messages = [{
|
|
1051
|
-
role: 'user',
|
|
1052
|
-
content: prompt
|
|
1053
|
-
}];
|
|
1054
|
-
// Get guidance (use higher token limit for keyword-based analysis)
|
|
1055
|
-
const targetTokens = context.keyword === '@ultrathink' ? 1000 : 500;
|
|
1056
|
-
const result = await adapter.compact(messages, helperConfig, targetTokens);
|
|
1057
|
-
// Extract thinking content
|
|
1058
|
-
return this.extractThinkingContent(result.summary);
|
|
1048
|
+
const body = this.buildKeywordPrompt(context.keyword, historyContext);
|
|
1049
|
+
const budget = context.keyword === '@ultrathink' ? 1000 : 500;
|
|
1050
|
+
return this.generateGuidance({
|
|
1051
|
+
surface: `keyword:${context.keyword}`,
|
|
1052
|
+
persona: 'You are an AI coding mentor giving on-demand strategic guidance.',
|
|
1053
|
+
task: 'Answer the user\'s keyword request directly and concisely.',
|
|
1054
|
+
outputBudgetTokens: budget,
|
|
1055
|
+
}, body, context.helperModelId);
|
|
1059
1056
|
}
|
|
1060
1057
|
/**
|
|
1061
1058
|
* Format recent history for mentorship context
|
|
@@ -1089,63 +1086,31 @@ PREDICTION: <prediction>`;
|
|
|
1089
1086
|
* Build keyword-specific prompt
|
|
1090
1087
|
*/
|
|
1091
1088
|
buildKeywordPrompt(keyword, historyContext) {
|
|
1092
|
-
const
|
|
1093
|
-
'@ultrathink': `
|
|
1094
|
-
|
|
1095
|
-
**Recent Context**:
|
|
1089
|
+
const bodies = {
|
|
1090
|
+
'@ultrathink': `Recent context:
|
|
1096
1091
|
${historyContext}
|
|
1097
1092
|
|
|
1098
|
-
The user requested @ultrathink
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
2. [Option 2: Approach and trade-offs]
|
|
1105
|
-
3. [Option 3: Approach and trade-offs]
|
|
1106
|
-
**Recommended Approach**: [Which option and why - 2-3 sentences]
|
|
1107
|
-
**Next Steps**: [Concrete actions to take]
|
|
1108
|
-
</thinking>`,
|
|
1109
|
-
'@analyze': `You are an AI mentor providing efficiency assessment.
|
|
1110
|
-
|
|
1111
|
-
**Recent Context**:
|
|
1093
|
+
The user requested @ultrathink — give deep strategic guidance in plain text with these labeled parts:
|
|
1094
|
+
- Current situation (2-3 sentences)
|
|
1095
|
+
- Strategy options (3 options, each with its trade-offs)
|
|
1096
|
+
- Recommended approach (which option and why)
|
|
1097
|
+
- Next steps (concrete actions to take)`,
|
|
1098
|
+
'@analyze': `Recent context:
|
|
1112
1099
|
${historyContext}
|
|
1113
1100
|
|
|
1114
|
-
The user requested @analyze
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
**Quick Wins**: [Immediate improvements to try]
|
|
1120
|
-
</thinking>`,
|
|
1121
|
-
'@rethink': `You are an AI mentor challenging current assumptions.
|
|
1122
|
-
|
|
1123
|
-
**Recent Context**:
|
|
1101
|
+
The user requested @analyze — give a quick efficiency assessment in plain text with these labeled parts:
|
|
1102
|
+
- What worked (2-3 points)
|
|
1103
|
+
- What could improve (2-3 points)
|
|
1104
|
+
- Quick wins (immediate improvements to try)`,
|
|
1105
|
+
'@rethink': `Recent context:
|
|
1124
1106
|
${historyContext}
|
|
1125
1107
|
|
|
1126
|
-
The user requested @rethink
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
**Alternative Perspectives**: [Different ways to think about this]
|
|
1131
|
-
**Recommended Shift**: [New approach to try and why]
|
|
1132
|
-
</thinking>`
|
|
1108
|
+
The user requested @rethink — reconsider from first principles in plain text with these labeled parts:
|
|
1109
|
+
- Current assumptions (2-3 points)
|
|
1110
|
+
- Alternative perspectives (different ways to think about this)
|
|
1111
|
+
- Recommended shift (new approach to try and why)`
|
|
1133
1112
|
};
|
|
1134
|
-
|
|
1135
|
-
const prompt = keywordPrompts[keyword];
|
|
1136
|
-
return prompt !== undefined ? prompt : keywordPrompts['@analyze'];
|
|
1137
|
-
}
|
|
1138
|
-
/**
|
|
1139
|
-
* Extract thinking content from response
|
|
1140
|
-
*/
|
|
1141
|
-
extractThinkingContent(response) {
|
|
1142
|
-
// Look for <thinking>...</thinking> tags
|
|
1143
|
-
const thinkingMatch = response.match(/<thinking>([\s\S]*?)<\/thinking>/);
|
|
1144
|
-
if (thinkingMatch && thinkingMatch[1]) {
|
|
1145
|
-
return thinkingMatch[1].trim();
|
|
1146
|
-
}
|
|
1147
|
-
// If no tags, return the response as-is
|
|
1148
|
-
return response;
|
|
1113
|
+
return bodies[keyword] ?? bodies['@analyze'];
|
|
1149
1114
|
}
|
|
1150
1115
|
// ============================================================
|
|
1151
1116
|
// Phase 2 Mentorship Features
|
|
@@ -1155,73 +1120,42 @@ The user requested @rethink - reconsider from first principles:
|
|
|
1155
1120
|
* Triggered every N turns for strategic check-in
|
|
1156
1121
|
*/
|
|
1157
1122
|
async generatePeriodicReview(context) {
|
|
1158
|
-
|
|
1159
|
-
const prompt = context.includeStrategicAdvice
|
|
1123
|
+
const body = context.includeStrategicAdvice
|
|
1160
1124
|
? this.buildStrategicReviewPrompt(context)
|
|
1161
1125
|
: this.buildSummaryReviewPrompt(context);
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
const messages = [{
|
|
1169
|
-
role: 'user',
|
|
1170
|
-
content: prompt
|
|
1171
|
-
}];
|
|
1172
|
-
// Get guidance (strategic reviews get more tokens)
|
|
1173
|
-
const targetTokens = context.includeStrategicAdvice ? 800 : 400;
|
|
1174
|
-
const result = await adapter.compact(messages, helperConfig, targetTokens);
|
|
1175
|
-
// Extract thinking content
|
|
1176
|
-
return this.extractThinkingContent(result.summary);
|
|
1126
|
+
return this.generateGuidance({
|
|
1127
|
+
surface: 'periodic-review',
|
|
1128
|
+
persona: 'You are an AI coding mentor doing a periodic check-in.',
|
|
1129
|
+
task: 'Review recent progress and keep the work on track.',
|
|
1130
|
+
outputBudgetTokens: context.includeStrategicAdvice ? 800 : 400,
|
|
1131
|
+
}, body, context.helperModelId);
|
|
1177
1132
|
}
|
|
1178
1133
|
/**
|
|
1179
1134
|
* Build strategic review prompt (comprehensive)
|
|
1180
1135
|
*/
|
|
1181
1136
|
buildStrategicReviewPrompt(context) {
|
|
1182
1137
|
const historyContext = this.formatRecentHistory(context.recentHistory);
|
|
1183
|
-
return `
|
|
1184
|
-
|
|
1185
|
-
**Current Turn**: ${context.turnNumber}
|
|
1186
|
-
**Conversation Snapshot** (last 5 messages):
|
|
1138
|
+
return `Current turn: ${context.turnNumber}
|
|
1139
|
+
Conversation snapshot (last 5 messages):
|
|
1187
1140
|
${historyContext}
|
|
1188
1141
|
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
**Progress Summary**: [What's been accomplished in recent turns - 2-3 sentences]
|
|
1195
|
-
|
|
1196
|
-
**Current Trajectory**: [Is the approach effective? Any concerns?]
|
|
1197
|
-
|
|
1198
|
-
**Strategic Recommendations**:
|
|
1199
|
-
- [Recommendation 1]
|
|
1200
|
-
- [Recommendation 2]
|
|
1201
|
-
|
|
1202
|
-
**Watch Out For**: [Potential issues to monitor]
|
|
1203
|
-
</thinking>
|
|
1204
|
-
|
|
1205
|
-
Be concise but insightful. Focus on maintaining momentum.`;
|
|
1142
|
+
Give a strategic review in plain text with these labeled parts:
|
|
1143
|
+
- Progress summary (what's been accomplished in recent turns, 2-3 sentences)
|
|
1144
|
+
- Current trajectory (is the approach effective? any concerns?)
|
|
1145
|
+
- Strategic recommendations (2 bullets)
|
|
1146
|
+
- Watch out for (potential issues to monitor)`;
|
|
1206
1147
|
}
|
|
1207
1148
|
/**
|
|
1208
1149
|
* Build summary review prompt (lightweight)
|
|
1209
1150
|
*/
|
|
1210
1151
|
buildSummaryReviewPrompt(context) {
|
|
1211
1152
|
const historyContext = this.formatRecentHistory(context.recentHistory.slice(-3));
|
|
1212
|
-
return `
|
|
1153
|
+
return `Turn: ${context.turnNumber}
|
|
1154
|
+
Recent: ${historyContext}
|
|
1213
1155
|
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
<thinking>
|
|
1218
|
-
**Progress Check (Turn ${context.turnNumber})**
|
|
1219
|
-
|
|
1220
|
-
**Summary**: [What's been done - 1-2 sentences]
|
|
1221
|
-
**Status**: [On track / Needs adjustment / Going well]
|
|
1222
|
-
</thinking>
|
|
1223
|
-
|
|
1224
|
-
Very brief - just a quick check-in.`;
|
|
1156
|
+
Give a brief progress check in plain text with:
|
|
1157
|
+
- Summary (what's been done, 1-2 sentences)
|
|
1158
|
+
- Status (on track / needs adjustment / going well)`;
|
|
1225
1159
|
}
|
|
1226
1160
|
/**
|
|
1227
1161
|
* Generate pattern detection guidance (Phase 2)
|
|
@@ -1229,45 +1163,24 @@ Very brief - just a quick check-in.`;
|
|
|
1229
1163
|
*/
|
|
1230
1164
|
async generatePatternDetectionGuidance(context) {
|
|
1231
1165
|
const historyContext = this.formatRecentHistory(context.recentHistory);
|
|
1232
|
-
const
|
|
1166
|
+
const body = `A repeated error pattern is blocking progress.
|
|
1233
1167
|
|
|
1234
|
-
|
|
1235
|
-
|
|
1168
|
+
Pattern: ${context.errorPattern}
|
|
1169
|
+
Occurrences: ${context.occurrences} times
|
|
1236
1170
|
|
|
1237
|
-
|
|
1171
|
+
Recent context:
|
|
1238
1172
|
${historyContext}
|
|
1239
1173
|
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
3. [Third step to verify success]
|
|
1251
|
-
|
|
1252
|
-
**Alternative Strategy**: [Completely different approach to consider]
|
|
1253
|
-
</thinking>
|
|
1254
|
-
|
|
1255
|
-
Focus on helping break out of the repeated failure loop.`;
|
|
1256
|
-
// Get helper model configuration
|
|
1257
|
-
const helperModelId = context.helperModelId || 'grok-4-1-fast-non-reasoning';
|
|
1258
|
-
const helperConfig = this.getHelperModelConfig(helperModelId);
|
|
1259
|
-
// Get appropriate adapter
|
|
1260
|
-
const adapter = this.helperAdapterRegistry.getAdapterForModel(helperConfig);
|
|
1261
|
-
// Convert to message format
|
|
1262
|
-
const messages = [{
|
|
1263
|
-
role: 'user',
|
|
1264
|
-
content: prompt
|
|
1265
|
-
}];
|
|
1266
|
-
// Get guidance
|
|
1267
|
-
const targetTokens = 600;
|
|
1268
|
-
const result = await adapter.compact(messages, helperConfig, targetTokens);
|
|
1269
|
-
// Extract thinking content
|
|
1270
|
-
return this.extractThinkingContent(result.summary);
|
|
1174
|
+
Give pattern-breaking guidance in plain text with these labeled parts:
|
|
1175
|
+
- Why this keeps happening (root cause, 2-3 sentences)
|
|
1176
|
+
- Breaking the pattern (3 concrete steps: a different approach, how to avoid the error, how to verify success)
|
|
1177
|
+
- Alternative strategy (one completely different approach)`;
|
|
1178
|
+
return this.generateGuidance({
|
|
1179
|
+
surface: 'pattern-detection',
|
|
1180
|
+
persona: 'You are an AI coding mentor helping an agent break out of a repeated failure loop.',
|
|
1181
|
+
task: 'Diagnose why the error keeps recurring and give concrete, different next steps.',
|
|
1182
|
+
outputBudgetTokens: 600,
|
|
1183
|
+
}, body, context.helperModelId);
|
|
1271
1184
|
}
|
|
1272
1185
|
/**
|
|
1273
1186
|
* Generate interleaved thinking assistance (Phase 2)
|
|
@@ -1275,46 +1188,24 @@ Focus on helping break out of the repeated failure loop.`;
|
|
|
1275
1188
|
*/
|
|
1276
1189
|
async generateInterleavedThinking(context) {
|
|
1277
1190
|
const historyContext = this.formatRecentHistory(context.recentHistory);
|
|
1278
|
-
const
|
|
1191
|
+
const body = `Help think through this problem before acting.
|
|
1279
1192
|
|
|
1280
|
-
|
|
1193
|
+
User request: ${context.userMessage}
|
|
1281
1194
|
|
|
1282
|
-
|
|
1195
|
+
Recent context:
|
|
1283
1196
|
${historyContext}
|
|
1284
1197
|
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
**Approach**: [Suggested reasoning path to solve this]
|
|
1298
|
-
|
|
1299
|
-
**First Step**: [Concrete action to start with]
|
|
1300
|
-
</thinking>
|
|
1301
|
-
|
|
1302
|
-
Help the model reason through the problem step by step.`;
|
|
1303
|
-
// Get helper model configuration
|
|
1304
|
-
const helperModelId = context.helperModelId || 'grok-4-1-fast-non-reasoning';
|
|
1305
|
-
const helperConfig = this.getHelperModelConfig(helperModelId);
|
|
1306
|
-
// Get appropriate adapter
|
|
1307
|
-
const adapter = this.helperAdapterRegistry.getAdapterForModel(helperConfig);
|
|
1308
|
-
// Convert to message format
|
|
1309
|
-
const messages = [{
|
|
1310
|
-
role: 'user',
|
|
1311
|
-
content: prompt
|
|
1312
|
-
}];
|
|
1313
|
-
// Get guidance
|
|
1314
|
-
const targetTokens = 500;
|
|
1315
|
-
const result = await adapter.compact(messages, helperConfig, targetTokens);
|
|
1316
|
-
// Extract thinking content
|
|
1317
|
-
return this.extractThinkingContent(result.summary);
|
|
1198
|
+
Give thinking assistance in plain text with these labeled parts:
|
|
1199
|
+
- Problem understanding (restate the core challenge, 2 sentences)
|
|
1200
|
+
- Key considerations (3 important factors)
|
|
1201
|
+
- Approach (suggested reasoning path)
|
|
1202
|
+
- First step (concrete action to start with)`;
|
|
1203
|
+
return this.generateGuidance({
|
|
1204
|
+
surface: 'interleaved-thinking',
|
|
1205
|
+
persona: 'You are an AI coding mentor helping a model reason through a problem step by step.',
|
|
1206
|
+
task: 'Map the problem and suggest a concrete first step.',
|
|
1207
|
+
outputBudgetTokens: 500,
|
|
1208
|
+
}, body, context.helperModelId);
|
|
1318
1209
|
}
|
|
1319
1210
|
/**
|
|
1320
1211
|
* Generate interleaved continuation thinking (between tool iterations)
|
|
@@ -1325,33 +1216,21 @@ Help the model reason through the problem step by step.`;
|
|
|
1325
1216
|
const toolResultsSummary = context.toolResults
|
|
1326
1217
|
.map(r => `- ${r.toolName}: ${r.isError ? 'FAILED — ' : ''}${r.summary}`)
|
|
1327
1218
|
.join('\n');
|
|
1328
|
-
const
|
|
1329
|
-
Be concise — 2-3 sentences max. Think out loud about what just happened and what to do next.
|
|
1330
|
-
Do NOT use headers, bullet points, or structured formatting. Write naturally, like stream of consciousness.
|
|
1331
|
-
|
|
1332
|
-
Tool call iteration ${context.iterationNumber} just completed.
|
|
1219
|
+
const body = `Tool call iteration ${context.iterationNumber} just completed.
|
|
1333
1220
|
|
|
1334
1221
|
Tool results:
|
|
1335
1222
|
${toolResultsSummary}
|
|
1336
1223
|
|
|
1337
1224
|
Original user request: ${context.userMessage}
|
|
1338
1225
|
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
role: 'user',
|
|
1348
|
-
content: prompt
|
|
1349
|
-
}];
|
|
1350
|
-
// Short target — this is a subtle nudge, not a lecture
|
|
1351
|
-
const targetTokens = 150;
|
|
1352
|
-
const result = await adapter.compact(messages, helperConfig, targetTokens);
|
|
1353
|
-
// Extract thinking content
|
|
1354
|
-
return this.extractThinkingContent(result.summary);
|
|
1226
|
+
Write a brief reflection (2-3 sentences max) on what just happened and what to do next. Write naturally, like stream of consciousness — no headers, bullets, or structured formatting.`;
|
|
1227
|
+
return this.generateGuidance({
|
|
1228
|
+
surface: 'interleaved-continuation',
|
|
1229
|
+
persona: 'You are the inner monologue of an AI assistant between tool calls.',
|
|
1230
|
+
task: 'Reflect briefly and naturally on the last result and the next move.',
|
|
1231
|
+
outputBudgetTokens: 150,
|
|
1232
|
+
grounding: false,
|
|
1233
|
+
}, body, context.helperModelId);
|
|
1355
1234
|
}
|
|
1356
1235
|
/**
|
|
1357
1236
|
* Generate Active Discovery guidance (Phase 2)
|
|
@@ -1363,57 +1242,28 @@ Provide a brief reflection:`;
|
|
|
1363
1242
|
const filesReadList = context.filesRead.length > 0
|
|
1364
1243
|
? context.filesRead.join('\n- ')
|
|
1365
1244
|
: 'None yet';
|
|
1366
|
-
const
|
|
1367
|
-
|
|
1368
|
-
**Core Rule**: NEVER infer how code works from documentation, imports, or comments alone. ALWAYS verify by reading the actual source.
|
|
1245
|
+
const body = `Core rule: NEVER infer how code works from documentation, imports, or comments alone — ALWAYS verify by reading the actual source.
|
|
1369
1246
|
|
|
1370
|
-
|
|
1247
|
+
User request: ${context.userMessage}
|
|
1371
1248
|
|
|
1372
|
-
|
|
1249
|
+
Files already read:
|
|
1373
1250
|
- ${filesReadList}
|
|
1374
1251
|
|
|
1375
|
-
|
|
1252
|
+
Recent context:
|
|
1376
1253
|
${historyContext}
|
|
1377
1254
|
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
- [File 3 — why it's needed]
|
|
1391
|
-
|
|
1392
|
-
**Anti-pattern warning**: Do NOT:
|
|
1393
|
-
- Infer behavior from documentation or file names
|
|
1394
|
-
- Cite line numbers in files you haven't read
|
|
1395
|
-
- Say "this likely calls..." without verifying
|
|
1396
|
-
- Use CLAUDE.md or system message context as a substitute for reading source
|
|
1397
|
-
|
|
1398
|
-
**Research plan**: [Specific files to read and what to look for in each]
|
|
1399
|
-
</thinking>
|
|
1400
|
-
|
|
1401
|
-
Focus on tracing the complete dependency chain — imports, function calls, type references. Every claim must cite a specific file and line that was actually read.`;
|
|
1402
|
-
// Get helper model configuration
|
|
1403
|
-
const helperModelId = context.helperModelId || 'grok-4-1-fast-non-reasoning';
|
|
1404
|
-
const helperConfig = this.getHelperModelConfig(helperModelId);
|
|
1405
|
-
// Get appropriate adapter
|
|
1406
|
-
const adapter = this.helperAdapterRegistry.getAdapterForModel(helperConfig);
|
|
1407
|
-
// Convert to message format
|
|
1408
|
-
const messages = [{
|
|
1409
|
-
role: 'user',
|
|
1410
|
-
content: prompt
|
|
1411
|
-
}];
|
|
1412
|
-
// Get guidance (slightly more tokens for detailed file analysis)
|
|
1413
|
-
const targetTokens = 600;
|
|
1414
|
-
const result = await adapter.compact(messages, helperConfig, targetTokens);
|
|
1415
|
-
// Extract thinking content
|
|
1416
|
-
return this.extractThinkingContent(result.summary);
|
|
1255
|
+
Give Active Discovery guidance in plain text with these labeled parts:
|
|
1256
|
+
- What needs investigation (the core question or system)
|
|
1257
|
+
- Files read so far (are they sufficient?)
|
|
1258
|
+
- Critical gaps — files that MUST be read (each with why: the import, function call, or type reference that leads there)
|
|
1259
|
+
- Research plan (specific files to read and what to look for in each)
|
|
1260
|
+
Anti-patterns to avoid: inferring behavior from docs or file names; citing line numbers in unread files; "this likely calls…" without verifying; using CLAUDE.md/system context as a substitute for reading source. Trace the complete dependency chain; every claim must cite a specific file and line actually read.`;
|
|
1261
|
+
return this.generateGuidance({
|
|
1262
|
+
surface: 'active-discovery',
|
|
1263
|
+
persona: 'You are an AI research-methodology advisor enforcing the Active Discovery methodology.',
|
|
1264
|
+
task: 'Identify exactly which source files must be read to answer accurately.',
|
|
1265
|
+
outputBudgetTokens: 600,
|
|
1266
|
+
}, body, context.helperModelId);
|
|
1417
1267
|
}
|
|
1418
1268
|
}
|
|
1419
1269
|
//# sourceMappingURL=HelperModelMiddleware.js.map
|