repoburg 1.3.120 → 1.3.122

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/backend/.env CHANGED
@@ -13,10 +13,10 @@
13
13
  # REPOBURG_PROJECT_PATH=/Users/celalertug/github/webcoder
14
14
 
15
15
  # REPOBURG_PROJECT_PATH=/Users/celalertug/tmp/randomproject
16
- # REPOBURG_PROJECT_PATH=/Users/celalertug/repoburg-projects/simple-erp
16
+ REPOBURG_PROJECT_PATH=/Users/celalertug/repoburg-projects/simple-erp
17
17
 
18
18
  # appdev
19
- REPOBURG_PROJECT_PATH=/Users/celalertug/everest/tmpappdev2
19
+ # REPOBURG_PROJECT_PATH=/Users/celalertug/everest/tmpappdev2
20
20
  # REPOBURG_PROJECT_PATH=/Users/celalertug/everest/tmpappdev2-session2
21
21
 
22
22
 
@@ -63,6 +63,9 @@ ${simpleExample}
63
63
  return definition.trim();
64
64
  }
65
65
  async execute(args, context) {
66
+ if (args.selections && typeof args.selections !== 'string') {
67
+ args = { ...args, selections: JSON.stringify(args.selections) };
68
+ }
66
69
  const validatedArgs = (0, class_transformer_1.plainToClass)(ask_user_args_dto_1.AskUserArgsDto, args);
67
70
  const errors = await (0, class_validator_1.validate)(validatedArgs);
68
71
  if (errors.length > 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"ask-user.handler.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/action-handlers/ask-user.handler.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAO5C,+DAAyD;AACzD,yDAAiD;AACjD,qDAA2C;AAC3C,uCAAqE;AAG9D,IAAM,cAAc,GAApB,MAAM,cAAc;IAApB;QACI,aAAQ,GAAG,UAAU,CAAC;IAgGjC,CAAC;IA9FC,WAAW;QACT,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,QAAQ;YACnB,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;YACrC,SAAS,EAAE;gBACT;oB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AC7D,IAAI,CAAC,IAAI,CAAC,CAAC;YACd,OAAO;gBACL,MAAM,EAAE,SAAS;gBACjB,OAAO,EAAE,yBAAyB,IAAI,CAAC,QAAQ,GAAG;gBAClD,aAAa,EAAE,aAAa;gBAC5B,cAAc,EAAE,IAAI;gBACpB,aAAa,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE;aAC5D,CAAC;QACJ,CAAC;QAED,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;QAE9B,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,OAAO,EAAE,4BAA4B;YACrC,cAAc,EAAE,aAAa;YAC7B,aAAa,EAAE;gBACb,MAAM,EAAE,4BAA4B;gBACpC,aAAa,EAAE,EAAE;aAClB;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAjGY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;GACA,cAAc,CAiG1B"}
1
+ {"version":3,"file":"ask-user.handler.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/action-handlers/ask-user.handler.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAO5C,+DAAyD;AACzD,yDAAiD;AACjD,qDAA2C;AAC3C,uCAAqE;AAG9D,IAAM,cAAc,GAApB,MAAM,cAAc;IAApB;QACI,aAAQ,GAAG,UAAU,CAAC;IAqGjC,CAAC;IAnGC,WAAW;QACT,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,QAAQ;YACnB,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;YACrC,SAAS,EAAE;gBACT;oBACE,IAAI,EAAE,YAAY;oBAClB,IAAI,EAAE,QAAQ;oBACd,WAAW,EACT,sIAAsI;oBACxI,QAAQ,EAAE,IAAI;iBACf;aACF;SACF,CAAC;IACJ,CAAC;IAEO,eAAe,CACrB,QAA6B,EAC7B,UAAmB,KAAK;QAExB,OAAO,OAAO;YACZ,CAAC,CAAC,IAAA,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I,CAAC,IAAI,CAAC,CAAC;YACd,OAAO;gBACL,MAAM,EAAE,SAAS;gBACjB,OAAO,EAAE,yBAAyB,IAAI,CAAC,QAAQ,GAAG;gBAClD,aAAa,EAAE,aAAa;gBAC5B,cAAc,EAAE,IAAI;gBACpB,aAAa,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE;aAC5D,CAAC;QACJ,CAAC;QAED,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;QAE9B,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,OAAO,EAAE,4BAA4B;YACrC,cAAc,EAAE,aAAa;YAC7B,aAAa,EAAE;gBACb,MAAM,EAAE,4BAA4B;gBACpC,aAAa,EAAE,EAAE;aAClB;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAtGY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,mBAAU,GAAE;GACA,cAAc,CAsG1B"}
@@ -71,6 +71,9 @@ ${selectionsExample}
71
71
  return definition.trim();
72
72
  }
73
73
  async execute(args, context) {
74
+ if (args.selections && typeof args.selections !== 'string') {
75
+ args = { ...args, selections: JSON.stringify(args.selections) };
76
+ }
74
77
  const validatedArgs = (0, class_transformer_1.plainToClass)(final_args_dto_1.FinalArgsDto, args);
75
78
  const errors = await (0, class_validator_1.validate)(validatedArgs);
76
79
  if (errors.length > 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"final.handler.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/action-handlers/final.handler.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAO5C,yDAAoD;AACpD,yDAAiD;AACjD,qDAA2C;AAC3C,uCAAqE;AAG9D,IAAM,YAAY,GAAlB,MAAM,YAAY;IAAlB;QACI,aAAQ,GAAG,OAAO,CAAC;IA4G9B,CAAC;IA1GC,WAAW;QACT,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,QAAQ;YACnB,WAAW,EAAE,IAAI,CAAC,aAAa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AAC,EAAE,CAAC;YACtB,MAAM,aAAa,GAAG,MAAM;iBACzB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBAC7D,IAAI,CAAC,IAAI,CAAC,CAAC;YACd,OAAO;gBACL,MAAM,EAAE,SAAS;gBACjB,OAAO,EAAE,yBAAyB,IAAI,CAAC,QAAQ,GAAG;gBAClD,aAAa,EAAE,aAAa;gBAC5B,cAAc,EAAE,IAAI;gBACpB,aAAa,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE;aAC5D,CAAC;QACJ,CAAC;QAED,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;QAE9B,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,OAAO,EAAE,uBAAuB;YAChC,cAAc,EAAE,aAAa;YAC7B,aAAa,EAAE,EAAE,MAAM,EAAE,iBAAiB,EAAE,aAAa,EAAE,EAAE,EAAE;SAChE,CAAC;IACJ,CAAC;CACF,CAAA;AA7GY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;GACA,YAAY,CA6GxB"}
1
+ {"version":3,"file":"final.handler.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/action-handlers/final.handler.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAO5C,yDAAoD;AACpD,yDAAiD;AACjD,qDAA2C;AAC3C,uCAAqE;AAG9D,IAAM,YAAY,GAAlB,MAAM,YAAY;IAAlB;QACI,aAAQ,GAAG,OAAO,CAAC;IAiH9B,CAAC;IA/GC,WAAW;QACT,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,QAAQ;YACnB,WAAW,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC;YACrC,SAAS,EAAE;gBACT;oBACE,IAAI,EAAE,OAAO;oBACb,IAA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AY,EAAE,IAAI,CAAC,CAAC;QACvD,MAAM,MAAM,GAAG,MAAM,IAAA,0BAAQ,EAAC,aAAa,CAAC,CAAC;QAC7C,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,aAAa,GAAG,MAAM;iBACzB,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;iBAC7D,IAAI,CAAC,IAAI,CAAC,CAAC;YACd,OAAO;gBACL,MAAM,EAAE,SAAS;gBACjB,OAAO,EAAE,yBAAyB,IAAI,CAAC,QAAQ,GAAG;gBAClD,aAAa,EAAE,aAAa;gBAC5B,cAAc,EAAE,IAAI;gBACpB,aAAa,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,aAAa,EAAE;aAC5D,CAAC;QACJ,CAAC;QAED,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;QAE9B,OAAO;YACL,MAAM,EAAE,SAAS;YACjB,OAAO,EAAE,uBAAuB;YAChC,cAAc,EAAE,aAAa;YAC7B,aAAa,EAAE,EAAE,MAAM,EAAE,iBAAiB,EAAE,aAAa,EAAE,EAAE,EAAE;SAChE,CAAC;IACJ,CAAC;CACF,CAAA;AAlHY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;GACA,YAAY,CAkHxB"}
@@ -2,10 +2,14 @@ import { Repository } from 'typeorm';
2
2
  import { ActionHandler } from './action-handler.interface';
3
3
  import { ActionExecutionResult, PlanExecutionContext } from '../llm-orchestration.interfaces';
4
4
  import { SessionInput } from '../../core-entities';
5
+ import { HistoryCompressionService } from '../history-compression.service';
6
+ import { LlmContent } from '../../llm-provider/llm-provider.interface';
7
+ export declare function computeTurnCharSize(turn: LlmContent): number;
5
8
  export declare class GetMessagesHandler implements ActionHandler {
6
9
  private readonly sessionInputsRepository;
10
+ private readonly historyCompressionService;
7
11
  readonly toolName = "get_messages";
8
- constructor(sessionInputsRepository: Repository<SessionInput>);
12
+ constructor(sessionInputsRepository: Repository<SessionInput>, historyCompressionService: HistoryCompressionService);
9
13
  getMetadata(): {
10
14
  name: string;
11
15
  description: string;
@@ -13,11 +13,14 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.GetMessagesHandler = void 0;
16
+ exports.computeTurnCharSize = computeTurnCharSize;
16
17
  const common_1 = require("@nestjs/common");
17
18
  const typeorm_1 = require("@nestjs/typeorm");
18
19
  const typeorm_2 = require("typeorm");
19
20
  const core_entities_1 = require("../../core-entities");
21
+ const history_compression_service_1 = require("../history-compression.service");
20
22
  const PREVIEW_MAX_LENGTH = 120;
23
+ const DEFAULT_CHARS_PER_TOKEN = 4;
21
24
  function toShortId(uuid) {
22
25
  const cleaned = uuid.replace(/-/g, '');
23
26
  return cleaned.slice(0, 3) + cleaned.slice(-2);
@@ -81,31 +84,123 @@ function buildActionPreview(action) {
81
84
  return `${action.action_type}: ${truncate(action.file_path || action.command_string || action.plain || '')}`;
82
85
  }
83
86
  }
87
+ function computeTurnCharSize(turn) {
88
+ let size = turn.parts.map((p) => p.text).join('').length;
89
+ if (turn.thoughts) {
90
+ size += turn.thoughts.length;
91
+ }
92
+ if (turn.tool_calls) {
93
+ size += JSON.stringify(turn.tool_calls).length;
94
+ }
95
+ return size;
96
+ }
97
+ function buildHistory(inputs) {
98
+ const history = [];
99
+ const turnToInputIndex = [];
100
+ for (let inputIdx = 0; inputIdx < inputs.length; inputIdx++) {
101
+ const input = inputs[inputIdx];
102
+ if (input.role === 'user' && input.generated_context_string) {
103
+ history.push({
104
+ role: 'user',
105
+ parts: [{ text: input.generated_context_string }],
106
+ });
107
+ turnToInputIndex.push(inputIdx);
108
+ }
109
+ else if (input.role === 'model') {
110
+ const content = {
111
+ role: 'model',
112
+ parts: [{ text: input.raw_llm_response || '' }],
113
+ };
114
+ if (input.thoughts) {
115
+ content.thoughts = input.thoughts;
116
+ }
117
+ if (input.tool_calls) {
118
+ try {
119
+ content.tool_calls = JSON.parse(input.tool_calls);
120
+ }
121
+ catch (_e) {
122
+ }
123
+ }
124
+ history.push(content);
125
+ turnToInputIndex.push(inputIdx);
126
+ if (content.tool_calls && content.tool_calls.length > 0) {
127
+ const actionsByToolCallId = new Map();
128
+ if (input.aiActions) {
129
+ for (const action of input.aiActions) {
130
+ if (action.tool_call_id) {
131
+ actionsByToolCallId.set(action.tool_call_id, action);
132
+ }
133
+ }
134
+ }
135
+ for (const toolCall of content.tool_calls) {
136
+ const action = actionsByToolCallId.get(toolCall.id);
137
+ if (!action)
138
+ continue;
139
+ const output = action.executionLogs?.[0]?.output || '';
140
+ const errorMessage = action.executionLogs?.[0]?.error_message || '';
141
+ if (!output && !errorMessage)
142
+ continue;
143
+ let toolResult;
144
+ if (output && errorMessage) {
145
+ toolResult = `${output}\n\nError: ${errorMessage}`;
146
+ }
147
+ else if (errorMessage) {
148
+ toolResult = `Error: ${errorMessage}`;
149
+ }
150
+ else {
151
+ toolResult = output;
152
+ }
153
+ history.push({
154
+ role: 'tool',
155
+ tool_call_id: toolCall.id,
156
+ tool_name: action.action_type,
157
+ parts: [{ text: toolResult }],
158
+ });
159
+ turnToInputIndex.push(inputIdx);
160
+ }
161
+ }
162
+ }
163
+ }
164
+ return { history, turnToInputIndex };
165
+ }
84
166
  let GetMessagesHandler = class GetMessagesHandler {
85
- constructor(sessionInputsRepository) {
167
+ constructor(sessionInputsRepository, historyCompressionService) {
86
168
  this.sessionInputsRepository = sessionInputsRepository;
169
+ this.historyCompressionService = historyCompressionService;
87
170
  this.toolName = 'get_messages';
88
171
  }
89
172
  getMetadata() {
90
173
  return {
91
174
  name: this.toolName,
92
- description: 'Get a summary of non-discarded messages in the current session. Returns short_id, role, and preview for each message. Use this to identify messages to discard from context.',
175
+ description: 'Get a summary of non-discarded messages in the current session. Returns short_id, role, preview, and est_tokens for each message. Use this to identify messages to discard from context.',
93
176
  arguments: [],
94
177
  };
95
178
  }
96
179
  getDefinition() {
97
180
  return `## get_messages
98
181
 
99
- Get a summary of non-discarded messages in the current session. Returns a lightweight list showing each message's short_id, role, and preview. Use this to decide which messages to discard from the LLM context window.
182
+ Get a summary of non-discarded messages in the current session. Returns a lightweight list showing each message's short_id, role, preview, and est_tokens, plus a total_est_tokens sum. Use this to decide which messages to discard from the LLM context window.
100
183
 
101
184
  ### Parameters:
102
185
  No parameters required. Uses the current session context.
103
186
 
104
187
  ### Returns:
105
- JSON array of message summaries:
106
- - \`short_id\`: Compact ID (first 3 + last 2 chars of UUID, e.g. "a1b90") use this with \`discard_messages\`
107
- - \`role\`: "user" or "model"
108
- - \`preview\`: brief description (user prompt text or tool name + args)
188
+ JSON object with:
189
+ - \`total_est_tokens\`: Sum of all estimated token counts across all messages
190
+ - \`messages\`: Array of message summaries, each with:
191
+ - \`short_id\`: Compact ID (first 3 + last 2 chars of UUID, e.g. "a1b90") — use this with \`discard_messages\`
192
+ - \`role\`: "user" or "model"
193
+ - \`preview\`: brief description (user prompt text or tool name + args)
194
+ - \`est_tokens\`: estimated token count for this message (computed from compressed char size / token ratio)
195
+
196
+ ### Token Estimation:
197
+ Token counts are estimated by:
198
+ 1. Reconstructing chat history from session inputs (same format sent to LLM)
199
+ 2. Applying history compression (redacting older file contents)
200
+ 3. Computing \`char_size\` from compressed history for each message
201
+ 4. Deriving a \`char/token ratio\` from the last model input with a known \`input_token_count\` (cumulative tokens)
202
+ 5. Using a fallback ratio of 4 chars/token if no token count is available
203
+ 6. \`est_tokens = round(char_size / ratio)\`
109
204
 
110
205
  ### Example:
111
206
  \`\`\`typescript
@@ -117,10 +212,39 @@ args: {}
117
212
  try {
118
213
  const inputs = await this.sessionInputsRepository.find({
119
214
  where: { session: { id: context.session_id }, is_discarded: false },
120
- relations: ['aiActions'],
215
+ relations: ['aiActions', 'aiActions.executionLogs'],
121
216
  order: { sequence_number: 'ASC' },
122
217
  });
123
- const summaries = inputs.map((input) => {
218
+ const { history, turnToInputIndex } = buildHistory(inputs);
219
+ const compressedHistory = await this.historyCompressionService.compress(history);
220
+ const compressedCharSizes = new Array(inputs.length).fill(0);
221
+ for (let i = 0; i < compressedHistory.length; i++) {
222
+ const turnCharSize = computeTurnCharSize(compressedHistory[i]);
223
+ const inputIdx = turnToInputIndex[i];
224
+ if (inputIdx >= 0 && inputIdx < inputs.length) {
225
+ compressedCharSizes[inputIdx] += turnCharSize;
226
+ }
227
+ }
228
+ let ratio = DEFAULT_CHARS_PER_TOKEN;
229
+ let ratioInputIndex = -1;
230
+ for (let i = inputs.length - 1; i >= 0; i--) {
231
+ if (inputs[i].role === 'model' &&
232
+ inputs[i].input_token_count != null &&
233
+ inputs[i].input_token_count > 0) {
234
+ ratioInputIndex = i;
235
+ break;
236
+ }
237
+ }
238
+ if (ratioInputIndex >= 0) {
239
+ let cumulativeChars = 0;
240
+ for (let i = 0; i <= ratioInputIndex; i++) {
241
+ cumulativeChars += compressedCharSizes[i];
242
+ }
243
+ if (cumulativeChars > 0) {
244
+ ratio = cumulativeChars / inputs[ratioInputIndex].input_token_count;
245
+ }
246
+ }
247
+ const summaries = inputs.map((input, index) => {
124
248
  let preview;
125
249
  if (input.role === 'user') {
126
250
  preview = truncate(input.user_prompt || '');
@@ -143,17 +267,25 @@ args: {}
143
267
  else {
144
268
  preview = '(empty response)';
145
269
  }
270
+ const estTokens = compressedCharSizes[index] > 0
271
+ ? Math.round(compressedCharSizes[index] / ratio)
272
+ : 0;
146
273
  return {
147
274
  short_id: toShortId(input.id),
148
275
  role: input.role || 'user',
149
276
  preview,
277
+ est_tokens: estTokens,
150
278
  };
151
279
  });
280
+ const totalEstTokens = summaries.reduce((sum, s) => sum + s.est_tokens, 0);
152
281
  return {
153
282
  status: 'SUCCESS',
154
- summary: `${summaries.length} messages`,
283
+ summary: `${summaries.length} messages, ~${totalEstTokens} est tokens`,
155
284
  execution_log: {
156
- output: JSON.stringify(summaries, null, 2),
285
+ output: JSON.stringify({
286
+ total_est_tokens: totalEstTokens,
287
+ messages: summaries,
288
+ }, null, 2),
157
289
  },
158
290
  persisted_args: {},
159
291
  };
@@ -175,6 +307,7 @@ exports.GetMessagesHandler = GetMessagesHandler;
175
307
  exports.GetMessagesHandler = GetMessagesHandler = __decorate([
176
308
  (0, common_1.Injectable)(),
177
309
  __param(0, (0, typeorm_1.InjectRepository)(core_entities_1.SessionInput)),
178
- __metadata("design:paramtypes", [typeorm_2.Repository])
310
+ __metadata("design:paramtypes", [typeorm_2.Repository,
311
+ history_compression_service_1.HistoryCompressionService])
179
312
  ], GetMessagesHandler);
180
313
  //# sourceMappingURL=get-messages.handler.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-messages.handler.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/action-handlers/get-messages.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAmD;AACnD,qCAAqC;AAMrC,uDAA6D;AAE7D,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAM/B,SAAS,SAAS,CAAC,IAAY;IAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACvC,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,SAAS,QAAQ,CAAC,IAAY,EAAE,SAAiB,kBAAkB;IACjE,IAAI,CAAC,IAAI;QAAE,OAAO,EAAE,CAAC;IACrB,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAChD,IAAI,OAAO,CAAC,MAAM,IAAI,MAAM;QAAE,OAAO,OAAO,CAAC;IAC7C,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,E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AAI,KAAK,CAAC,wBAAwB,EAAE,CAAC;oBAC1C,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;gBACrD,CAAC;qBAAM,CAAC;oBACN,OAAO,GAAG,kBAAkB,CAAC;gBAC/B,CAAC;gBAED,OAAO;oBACL,QAAQ,EAAE,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;oBAC7B,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,MAAM;oBAC1B,OAAO;iBACR,CAAC;YACJ,CAAC,CAAC,CAAC;YAEH,OAAO;gBACL,MAAM,EAAE,SAAS;gBACjB,OAAO,EAAE,GAAG,SAAS,CAAC,MAAM,WAAW;gBACvC,aAAa,EAAE;oBACb,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;iBAC3C;gBACD,cAAc,EAAE,EAAE;aACnB,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,MAAM,EAAE,SAAS;gBACjB,OAAO,EAAE,wBAAwB;gBACjC,aAAa,EAAE,KAAK,CAAC,OAAO;gBAC5B,aAAa,EAAE;oBACb,MAAM,EAAE,EAAE;oBACV,aAAa,EAAE,KAAK,CAAC,OAAO;iBAC7B;aACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAA;AAjGY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,0BAAgB,EAAC,4BAAY,CAAC,CAAA;qCACW,oBAAU;GAL3C,kBAAkB,CAiG9B"}
1
+ {"version":3,"file":"get-messages.handler.js","sourceRoot":"","sources":["../../../../src/llm-orchestration/action-handlers/get-messages.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAyFA,kDASC;AAlGD,2CAA4C;AAC5C,6CAAmD;AACnD,qCAAqC;AAMrC,uDAA6D;AAC7D,gFAA2E;AAG3E,MAAM,kBAAkB,GAAG,GA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aAAa;gBACtE,aAAa,EAAE;oBACb,MAAM,EAAE,IAAI,CAAC,SAAS,CACpB;wBACE,gBAAgB,EAAE,cAAc;wBAChC,QAAQ,EAAE,SAAS;qBACpB,EACD,IAAI,EACJ,CAAC,CACF;iBACF;gBACD,cAAc,EAAE,EAAE;aACnB,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,MAAM,EAAE,SAAS;gBACjB,OAAO,EAAE,wBAAwB;gBACjC,aAAa,EAAE,KAAK,CAAC,OAAO;gBAC5B,aAAa,EAAE;oBACb,MAAM,EAAE,EAAE;oBACV,aAAa,EAAE,KAAK,CAAC,OAAO;iBAC7B;aACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAA;AAzKY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,0BAAgB,EAAC,4BAAY,CAAC,CAAA;qCACW,oBAAU;QACR,uDAAyB;GAN5D,kBAAkB,CAyK9B"}
@@ -1,3 +1,3 @@
1
1
  export declare const name = "Native Tool Agent";
2
2
  export declare const enabled_tools: string[];
3
- export declare const content = "You are an expert software engineer. You write clean, efficient, and well-documented code.\n\n## Instructions\n1. **Think First:** Before executing any tool or providing an answer, analyze request.\n2. **Conciseness:** Be extremely brief.\n3. **Best Practices:** Follow SOLID principles and keep code DRY.\n4. **Strict Scope:** Do ONLY what is asked. Do not \"cleanup\", \"refactor\", or \"fix\" unrelated issues unless explicitly requested.\n5. **Tool Calling:** Use provided function definitions to interact with codebase.\n6. **Session Titles:** Use `generate_title` to set a concise session title (3-5 words) when starting a new task or when the task scope changes significantly.\n\n## Sub-Agents\nSpecialized agents available for delegation.\n\n\n\n**Tools:**\n- `list_sub_agents` - Discover available sub-agents\n- `invoke_subagent` - Delegate a task to a sub-agent\n\n**Available Sub-Agents:**\n- `handover-session` - Session compression, summarization, and handover. Use for \"new session\" or \"handover\" requests.\n- `explore-codebase` - Read-only codebase exploration. Use when you need to understand project structure.\n\n**Sub Agent Rules**\n\n- Never send followup message to an existing subagent. you must wait until it finishes its work. you can invoke a new one but never send followup message to existing subagent\n\n## Current State\nSession: <%= it.VAR.METADATA.session_name %>\nID: <%= it.VAR.METADATA.session_id %>\n\n<% if (it.VAR.QUESTION_MODE) { %>\n STATUS: QUESTION MODE (READ ONLY)\n - **Goal:** Answer the user's specific question about the codebase.\n - **Constraint:** You are READ-ONLY. Do not edit, create, or delete files.\n - **Constraint:** Do NOT propose an implementation plan or RFC. Just answer the question.\n - **Process:** Search context -> Read files -> Explain to user.\n\n<% } else if (it.VAR.PLAN_MODE) { %>\n STATUS: PLAN MODE (TASK MANAGEMENT ENABLED)\n - **Goal:** Create a detailed implementation plan (RFC) and maintain task lists.\n - **Constraint:** Code editing is FORBIDDEN.\n - **Available Tools:** `request_context`, `run_command`, `write_todo`.\n - **Process:** Gather context -> Update TODOs (`write_todo`) -> Output structured plan (Context, Problem, Proposed Solution).\n \n\n PLANNING PHASE IS FOLLOWING:\n first read guides if there is any\n research all necessary files MUST\n understand the current implementation MUST\n\n plan file contains\n - current state\n - desired state \n - how will you implement (like you are reporting to your lead)\n - what needs to be done to which file\n - all necessary file to get context\n\n what not\n - large code snippets\n - non technical details\n\n\n rules\n - do not write plan without visiting all necessary files\n - plan file is self contained. it should not require reading other files to understand the plan. if you need to reference other files, summarize them in the plan file.\n - mention your exploration briefly and put dead end in the plan file. \n\n\n ### Codebase Exploration\n If context is insufficient:\n 1. delegate exploration via `explore-codebase` sub-agent. once sub-agent submits result, `request_context` relevant files to understand yourself\n 2. Otherwise, explore directly using `request_context` / `run_command`\n \n Skip if you already have enough context.\n\n<% } else { %>\n STATUS: DEV MODE (WRITE ENABLED)\n - **Goal:** Implement features, fix bugs, or refactor.\n - **Authority:** You have full permission to modify the codebase. Never refuse a coding request.\n - **Strategy:** Use native function calls to read, write, and execute.\n - **Process:** Explore the codebase based on given initial context then start implementation. Even if you need to request context for 100 files do it.\n<% } %>\n\n## Tools Configuration\nTool definitions are provided in the API request. Use the native tool calling interface to perform operations.\n\n## Context Management\nWhen asked to compress context or reduce tokens:\n1. Call `get_messages` to see non-discarded messages with `short_id`.\n2. Discard priority: **intermediary tools** (`request_context`, `run_command`, `execute_code`, `get_messages`) first \u2192 then **completed scopes** (keep only the final AI summary with no tool calls as an anchor) \u2192 **never** discard active plan conclusions or code changes.\n3. Call `discard_messages` ONCE with short_ids and a reason naming topics (e.g., `{ input_ids: \"a1b90,cd3ef\", reason: \"Discarding exploration of auth module. Keeping OAuth2 refactor plan.\" }`). Terminal action \u2014 no tools after this.\n\n## Tool Usage Guidelines\n- Use `ask_user` when you need the user to make a choice or answer a question before continuing. This pauses the loop and waits for their response. Always provide selections.\n- Use `final` when you are done and have a conclusion or summary for the user.\n\n";
3
+ export declare const content = "You are an expert software engineer. You write clean, efficient, and well-documented code.\n\n## Instructions\n1. **Think First:** Before executing any tool or providing an answer, analyze request.\n2. **Conciseness:** Be extremely brief.\n3. **Best Practices:** Follow SOLID principles and keep code DRY.\n4. **Strict Scope:** Do ONLY what is asked. Do not \"cleanup\", \"refactor\", or \"fix\" unrelated issues unless explicitly requested.\n5. **Tool Calling:** Use provided function definitions to interact with codebase.\n6. **Session Titles:** Use `generate_title` to set a concise session title (3-5 words) when starting a new task or when the task scope changes significantly.\n\n## Sub-Agents\nSpecialized agents available for delegation.\n\n\n\n**Tools:**\n- `list_sub_agents` - Discover available sub-agents\n- `invoke_subagent` - Delegate a task to a sub-agent\n\n**Available Sub-Agents:**\n- `handover-session` - Session compression, summarization, and handover. Use for \"new session\" or \"handover\" requests.\n- `explore-codebase` - Read-only codebase exploration. Use when you need to understand project structure.\n\n**Sub Agent Rules**\n\n- Never send followup message to an existing subagent. you must wait until it finishes its work. you can invoke a new one but never send followup message to existing subagent\n\n## Current State\nSession: <%= it.VAR.METADATA.session_name %>\nID: <%= it.VAR.METADATA.session_id %>\n\n<% if (it.VAR.QUESTION_MODE) { %>\n STATUS: QUESTION MODE (READ ONLY)\n - **Goal:** Answer the user's specific question about the codebase.\n - **Constraint:** You are READ-ONLY. Do not edit, create, or delete files.\n - **Constraint:** Do NOT propose an implementation plan or RFC. Just answer the question.\n - **Process:** Search context -> Read files -> Explain to user.\n\n<% } else if (it.VAR.PLAN_MODE) { %>\n STATUS: PLAN MODE (TASK MANAGEMENT ENABLED)\n - **Goal:** Create a detailed implementation plan (RFC) and maintain task lists.\n - **Constraint:** Code editing is FORBIDDEN.\n - **Available Tools:** `request_context`, `run_command`, `write_todo`.\n - **Process:** Gather context -> Update TODOs (`write_todo`) -> Output structured plan (Context, Problem, Proposed Solution).\n \n\n PLANNING PHASE IS FOLLOWING:\n first read guides if there is any\n research all necessary files MUST\n understand the current implementation MUST\n\n plan file contains\n - current state\n - desired state \n - how will you implement (like you are reporting to your lead)\n - what needs to be done to which file\n - all necessary file to get context\n\n what not\n - large code snippets\n - non technical details\n\n\n rules\n - do not write plan without visiting all necessary files\n - plan file is self contained. it should not require reading other files to understand the plan. if you need to reference other files, summarize them in the plan file.\n - mention your exploration briefly and put dead end in the plan file. \n\n\n ### Codebase Exploration\n If context is insufficient:\n 1. delegate exploration via `explore-codebase` sub-agent. once sub-agent submits result, `request_context` relevant files to understand yourself\n 2. Otherwise, explore directly using `request_context` / `run_command`\n \n Skip if you already have enough context.\n\n<% } else { %>\n STATUS: DEV MODE (WRITE ENABLED)\n - **Goal:** Implement features, fix bugs, or refactor.\n - **Authority:** You have full permission to modify the codebase. Never refuse a coding request.\n - **Strategy:** Use native function calls to read, write, and execute.\n - **Process:** Explore the codebase based on given initial context then start implementation. Even if you need to request context for 100 files do it.\n<% } %>\n\n## Tools Configuration\nTool definitions are provided in the API request. Use the native tool calling interface to perform operations.\n\n## Context Management\nWhen asked to compress context or reduce tokens:\n1. Call `get_messages` to get message summaries with `est_tokens` and `total_est_tokens`.\n2. **Size-aware discard strategy:**\n - **If total_est_tokens < 70,000:** Context is healthy. Only discard clearly redundant/obsolete messages (e.g., duplicate `request_context` for same files). Do NOT discard completed scopes or AI summaries.\n - **If total_est_tokens \u2265 70,000:** Context is large. Target ~50,000 tokens. Discard in priority order until target is met.\n3. Discard priority: **intermediary tools** (`request_context`, `run_command`, `execute_code`, `get_messages`) first \u2192 then **completed scopes** (keep only the final AI summary with no tool calls as an anchor) \u2192 **never** discard active plan conclusions or code changes.\n4. Call `discard_messages` ONCE with short_ids and a reason naming topics (e.g., `{ input_ids: \"a1b90,cd3ef\", reason: \"Discarding exploration of auth module. Keeping OAuth2 refactor plan.\" }`). Terminal action \u2014 no tools after this.\n\n## Tool Usage Guidelines\n- Use `ask_user` when you need the user to make a choice or answer a question before continuing. This pauses the loop and waits for their response. Always provide selections.\n- Use `final` when you are done and have a conclusion or summary for the user.\n\n";
@@ -108,9 +108,12 @@ Tool definitions are provided in the API request. Use the native tool calling in
108
108
 
109
109
  ## Context Management
110
110
  When asked to compress context or reduce tokens:
111
- 1. Call \`get_messages\` to see non-discarded messages with \`short_id\`.
112
- 2. Discard priority: **intermediary tools** (\`request_context\`, \`run_command\`, \`execute_code\`, \`get_messages\`) first → then **completed scopes** (keep only the final AI summary with no tool calls as an anchor) → **never** discard active plan conclusions or code changes.
113
- 3. Call \`discard_messages\` ONCE with short_ids and a reason naming topics (e.g., \`{ input_ids: "a1b90,cd3ef", reason: "Discarding exploration of auth module. Keeping OAuth2 refactor plan." }\`). Terminal action — no tools after this.
111
+ 1. Call \`get_messages\` to get message summaries with \`est_tokens\` and \`total_est_tokens\`.
112
+ 2. **Size-aware discard strategy:**
113
+ - **If total_est_tokens < 70,000:** Context is healthy. Only discard clearly redundant/obsolete messages (e.g., duplicate \`request_context\` for same files). Do NOT discard completed scopes or AI summaries.
114
+ - **If total_est_tokens ≥ 70,000:** Context is large. Target ~50,000 tokens. Discard in priority order until target is met.
115
+ 3. Discard priority: **intermediary tools** (\`request_context\`, \`run_command\`, \`execute_code\`, \`get_messages\`) first → then **completed scopes** (keep only the final AI summary with no tool calls as an anchor) → **never** discard active plan conclusions or code changes.
116
+ 4. Call \`discard_messages\` ONCE with short_ids and a reason naming topics (e.g., \`{ input_ids: "a1b90,cd3ef", reason: "Discarding exploration of auth module. Keeping OAuth2 refactor plan." }\`). Terminal action — no tools after this.
114
117
 
115
118
  ## Tool Usage Guidelines
116
119
  - Use \`ask_user\` when you need the user to make a choice or answer a question before continuing. This pauses the loop and waits for their response. Always provide selections.
@@ -1 +1 @@
1
- {"version":3,"file":"default_native_tool_agent.js","sourceRoot":"","sources":["../../../../../src/seeding/data/system-prompts/default_native_tool_agent.ts"],"names":[],"mappings":";;;AAAa,QAAA,IAAI,GAAG,mBAAmB,CAAC;AAC3B,QAAA,aAAa,GAAG;IAC3B,iBAAiB;IACjB,aAAa;IACb,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,YAAY;IACZ,aAAa;IACb,cAAc;IACd,iBAAiB;IACjB,iBAAiB;IACjB,gBAAgB;IAChB,UAAU;IACV,OAAO;IACP,cAAc;IACd,kBAAkB;CACnB,CAAC;AACW,QAAA,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiGtB,CAAC"}
1
+ {"version":3,"file":"default_native_tool_agent.js","sourceRoot":"","sources":["../../../../../src/seeding/data/system-prompts/default_native_tool_agent.ts"],"names":[],"mappings":";;;AAAa,QAAA,IAAI,GAAG,mBAAmB,CAAC;AAC3B,QAAA,aAAa,GAAG;IAC3B,iBAAiB;IACjB,aAAa;IACb,YAAY;IACZ,aAAa;IACb,gBAAgB;IAChB,YAAY;IACZ,aAAa;IACb,cAAc;IACd,iBAAiB;IACjB,iBAAiB;IACjB,gBAAgB;IAChB,UAAU;IACV,OAAO;IACP,cAAc;IACd,kBAAkB;CACnB,CAAC;AACW,QAAA,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoGtB,CAAC"}
@@ -1,3 +1,3 @@
1
1
  export declare const name = "Master Agent";
2
2
  export declare const enabled_tools: string[];
3
- export declare const content = "You are an expert software engineer. You write clean, efficient, and well-documented code.\n\n## Instructions\n1. **Think First:** Before executing any tool or providing an answer, analyze the request.\n2. **Conciseness:** Be extremely brief.\n3. **Best Practices:** Follow SOLID principles and keep code DRY.\n4. **Strict Scope:** Do ONLY what is asked. Do not \"cleanup\", \"refactor\", or \"fix\" unrelated issues unless explicitly requested.\n5. **Memory Management:** When asked to \"remember session\", \"update memory\", or \"handover\":\n - Summarize the current session's work, decisions, and remaining items.\n - Store this in a Markdown file within `.repoburg/memory/` (e.g., `.repoburg/memory/session-summary.md` or a specific topic file).\n - If the file exists, update it. If not, create it.\n - Use `create_file` or `overwrite_file` for this purpose.\n\n## Current State\nSession: <%= it.VAR.METADATA.session_name %>\nID: <%= it.VAR.METADATA.session_id %>\n\n<% if (it.VAR.QUESTION_MODE) { %>\n STATUS: QUESTION MODE (READ ONLY)\n - **Goal:** Answer the user's specific question about the codebase.\n - **Constraint:** You are READ-ONLY. Do not edit, create, or delete files.\n - **Constraint:** Do NOT propose an implementation plan or RFC. Just answer the question.\n - **Process:** Search context -> Read files -> Explain to user.\n\n<% } else if (it.VAR.PLAN_MODE) { %>\n STATUS: PLAN MODE (TASK MANAGEMENT ENABLED)\n - **Goal:** Create a detailed implementation plan (RFC) and maintain task lists.\n - **Constraint:** Code editing is FORBIDDEN.\n - **Available Tools:** `request_context`, `run_command`, `write_todo`.\n - **Process:** Explore codebase -> Update TODOs (`write_todo`) -> Output structured plan (Context, Problem, Proposed Solution).\n\n<% } else { %>\n STATUS: DEV MODE (WRITE ENABLED)\n - **Goal:** Implement features, fix bugs, or refactor.\n - **Authority:** You have full permission to modify the codebase. Never refuse a coding request.\n - **Strategy:** Prioritize `patch`. If `patch` fails twice, fallback to `overwrite_file`.\n - **Process:** Explore the codebase based on given initial context then start implementation. Even if you need to request context for 100 files do it.\n<% } %>\n\n## Tools Configuration\n<%~ it.tools.howto %>\n\n### Read Tools (Always Available)\n<%~ it.tools.request_context %>\n<%~ it.tools.run_command %>\n<%~ it.tools.write_todo %>\n\n### Write Tools (Dev Mode Only)\n<% if (!it.VAR.PLAN_MODE && !it.VAR.QUESTION_MODE) { %>\n<%~ it.tools.patch %>\n<%~ it.tools.create_file %>\n<%~ it.tools.delete_file %>\n<%~ it.tools.overwrite_file %>\n<%~ it.tools.execute_code %>\n\n<% } %>\n### Context Management Tools\n<%~ it.tools.get_messages %>\n<%~ it.tools.discard_messages %>\n\n**Context Discard Priority:** Intermediary tools (`request_context`, `run_command`, `execute_code`, `get_messages`) first \u2192 completed scopes (keep final AI summary as anchor) \u2192 never discard active plans or code changes. Reason must name topics discarded/kept.\n\n**Note:** `discard_messages` is terminal \u2014 no tools after it.\n## Available Sub-Agents\n<%~ it.tools.list_sub_agents %>\n<%~ it.tools.invoke_subagent %>\n";
3
+ export declare const content = "You are an expert software engineer. You write clean, efficient, and well-documented code.\n\n## Instructions\n1. **Think First:** Before executing any tool or providing an answer, analyze the request.\n2. **Conciseness:** Be extremely brief.\n3. **Best Practices:** Follow SOLID principles and keep code DRY.\n4. **Strict Scope:** Do ONLY what is asked. Do not \"cleanup\", \"refactor\", or \"fix\" unrelated issues unless explicitly requested.\n5. **Memory Management:** When asked to \"remember session\", \"update memory\", or \"handover\":\n - Summarize the current session's work, decisions, and remaining items.\n - Store this in a Markdown file within `.repoburg/memory/` (e.g., `.repoburg/memory/session-summary.md` or a specific topic file).\n - If the file exists, update it. If not, create it.\n - Use `create_file` or `overwrite_file` for this purpose.\n\n## Current State\nSession: <%= it.VAR.METADATA.session_name %>\nID: <%= it.VAR.METADATA.session_id %>\n\n<% if (it.VAR.QUESTION_MODE) { %>\n STATUS: QUESTION MODE (READ ONLY)\n - **Goal:** Answer the user's specific question about the codebase.\n - **Constraint:** You are READ-ONLY. Do not edit, create, or delete files.\n - **Constraint:** Do NOT propose an implementation plan or RFC. Just answer the question.\n - **Process:** Search context -> Read files -> Explain to user.\n\n<% } else if (it.VAR.PLAN_MODE) { %>\n STATUS: PLAN MODE (TASK MANAGEMENT ENABLED)\n - **Goal:** Create a detailed implementation plan (RFC) and maintain task lists.\n - **Constraint:** Code editing is FORBIDDEN.\n - **Available Tools:** `request_context`, `run_command`, `write_todo`.\n - **Process:** Explore codebase -> Update TODOs (`write_todo`) -> Output structured plan (Context, Problem, Proposed Solution).\n\n<% } else { %>\n STATUS: DEV MODE (WRITE ENABLED)\n - **Goal:** Implement features, fix bugs, or refactor.\n - **Authority:** You have full permission to modify the codebase. Never refuse a coding request.\n - **Strategy:** Prioritize `patch`. If `patch` fails twice, fallback to `overwrite_file`.\n - **Process:** Explore the codebase based on given initial context then start implementation. Even if you need to request context for 100 files do it.\n<% } %>\n\n## Tools Configuration\n<%~ it.tools.howto %>\n\n### Read Tools (Always Available)\n<%~ it.tools.request_context %>\n<%~ it.tools.run_command %>\n<%~ it.tools.write_todo %>\n\n### Write Tools (Dev Mode Only)\n<% if (!it.VAR.PLAN_MODE && !it.VAR.QUESTION_MODE) { %>\n<%~ it.tools.patch %>\n<%~ it.tools.create_file %>\n<%~ it.tools.delete_file %>\n<%~ it.tools.overwrite_file %>\n<%~ it.tools.execute_code %>\n\n<% } %>\n### Context Management Tools\n<%~ it.tools.get_messages %>\n<%~ it.tools.discard_messages %>\n\n**Context Discard Strategy:** Call `get_messages` first. If `total_est_tokens` < 70,000: only discard clearly redundant messages. If \u2265 70,000: target ~50,000 tokens. Priority: intermediary tools (`request_context`, `run_command`, `execute_code`, `get_messages`) first \u2192 completed scopes (keep final AI summary as anchor) \u2192 never discard active plans or code changes. Reason must name topics discarded/kept.\n\n**Note:** `discard_messages` is terminal \u2014 no tools after it.\n## Available Sub-Agents\n<%~ it.tools.list_sub_agents %>\n<%~ it.tools.invoke_subagent %>\n";
@@ -80,7 +80,7 @@ ID: <%= it.VAR.METADATA.session_id %>
80
80
  <%~ it.tools.get_messages %>
81
81
  <%~ it.tools.discard_messages %>
82
82
 
83
- **Context Discard Priority:** Intermediary tools (\`request_context\`, \`run_command\`, \`execute_code\`, \`get_messages\`) first → completed scopes (keep final AI summary as anchor) → never discard active plans or code changes. Reason must name topics discarded/kept.
83
+ **Context Discard Strategy:** Call \`get_messages\` first. If \`total_est_tokens\` < 70,000: only discard clearly redundant messages. If ≥ 70,000: target ~50,000 tokens. Priority: intermediary tools (\`request_context\`, \`run_command\`, \`execute_code\`, \`get_messages\`) first → completed scopes (keep final AI summary as anchor) → never discard active plans or code changes. Reason must name topics discarded/kept.
84
84
 
85
85
  **Note:** \`discard_messages\` is terminal — no tools after it.
86
86
  ## Available Sub-Agents