@project-ava-supernova/core 0.2.91 → 0.2.93

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.
@@ -503,6 +503,30 @@ export declare class Agent {
503
503
  private maybeExplorationBudgetNudge;
504
504
  /** Get current context usage for a set of messages. */
505
505
  getContextUsage(messages: Message[]): ContextUsage;
506
+ /**
507
+ * Would the next turn compress this context? The same gate runInner uses
508
+ * (70% of the window, capped at 400K, and at least six messages), exposed
509
+ * so a host can compact BETWEEN turns and persist the boundary — see
510
+ * Conversation.applyCompaction. Compacting in the host, before the turn,
511
+ * is what stops the every-turn re-summarising: the agent's own in-turn
512
+ * pass stays as the emergency net for one enormous turn.
513
+ */
514
+ shouldCompact(messages: Message[]): boolean;
515
+ /**
516
+ * Compact a context and ALSO return the boundary a Conversation can keep:
517
+ * what replaced the head (middle), the note for the system prompt, and
518
+ * where in the input the verbatim tail starts. `result` is the compacted
519
+ * context exactly as compressContext would return it.
520
+ */
521
+ compact(messages: Message[], onEvent: AgentEventHandler, signal?: AbortSignal): Promise<{
522
+ result: Message[];
523
+ compaction: {
524
+ middle: Message[];
525
+ systemNote: string;
526
+ keptFromContext: number;
527
+ } | null;
528
+ }>;
529
+ private lastCompaction;
506
530
  /** Manually compress context — triggered by user clicking the context bar. */
507
531
  manualCompress(messages: Message[], onEvent: AgentEventHandler, signal?: AbortSignal): Promise<Message[]>;
508
532
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/agent/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAqC,MAAM,uBAAuB,CAAC;AAEzF,OAAO,KAAK,EACV,OAAO,EACP,gBAAgB,EAChB,QAAQ,EACR,eAAe,EACf,UAAU,EAEX,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AA+B9D,OAAO,KAAK,EAAE,UAAU,EA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9C;;;;OAIG;IACH,OAAO,CAAC,cAAc;CAoDvB"}
@@ -1702,7 +1702,10 @@ export class Agent {
1702
1702
  });
1703
1703
  onEvent({
1704
1704
  type: 'error',
1705
- error: Object.assign(new Error(`Context compressed: ${dropped} older messages summarised to memory. Continuing your current task.`), { code: 'context_compressed' }),
1705
+ error: Object.assign(
1706
+ // Truncation, not compression: the summary failed and these were
1707
+ // dropped. Saying "summarised" here hid a real failure for months.
1708
+ new Error(`Context trimmed: the summary could not be made, so ${dropped} older messages were dropped from my working view (they are still in the transcript). Continuing your current task.`), { code: 'context_compressed' }),
1706
1709
  });
1707
1710
  }
1708
1711
  // ── Sanitize messages for model compatibility ──────────────────────────
@@ -2902,8 +2905,8 @@ export class Agent {
2902
2905
  const n = (this.repeatedToolFailures.get(failKey) ?? 0) + 1;
2903
2906
  this.repeatedToolFailures.set(failKey, n);
2904
2907
  if (n >= 3) {
2905
- output = `${result.output}
2906
-
2908
+ output = `${result.output}
2909
+
2907
2910
  [This is attempt ${n} of \`${toolCall.function.name}\` with identical arguments, and it has failed the same way every time. Do NOT call it again with these arguments — nothing has changed, so nothing will. Tell the user plainly what failed and what the error said, and either change the approach or ask them how they want to proceed.]`;
2908
2911
  }
2909
2912
  }
@@ -3118,6 +3121,30 @@ export class Agent {
3118
3121
  const limit = this.model.contextWindow;
3119
3122
  return { used, limit, percent: Math.round((used / limit) * 100) };
3120
3123
  }
3124
+ /**
3125
+ * Would the next turn compress this context? The same gate runInner uses
3126
+ * (70% of the window, capped at 400K, and at least six messages), exposed
3127
+ * so a host can compact BETWEEN turns and persist the boundary — see
3128
+ * Conversation.applyCompaction. Compacting in the host, before the turn,
3129
+ * is what stops the every-turn re-summarising: the agent's own in-turn
3130
+ * pass stays as the emergency net for one enormous turn.
3131
+ */
3132
+ shouldCompact(messages) {
3133
+ const maxInputTokens = Math.min(Math.floor(this.model.contextWindow * 0.7), 400_000);
3134
+ return this.estimateTokenCount(messages) > maxInputTokens && messages.length >= 6;
3135
+ }
3136
+ /**
3137
+ * Compact a context and ALSO return the boundary a Conversation can keep:
3138
+ * what replaced the head (middle), the note for the system prompt, and
3139
+ * where in the input the verbatim tail starts. `result` is the compacted
3140
+ * context exactly as compressContext would return it.
3141
+ */
3142
+ async compact(messages, onEvent, signal) {
3143
+ this.lastCompaction = null;
3144
+ const result = await this.compressContext(messages, onEvent, signal);
3145
+ return { result, compaction: this.lastCompaction };
3146
+ }
3147
+ lastCompaction = null;
3121
3148
  /** Manually compress context — triggered by user clicking the context bar. */
3122
3149
  async manualCompress(messages, onEvent, signal) {
3123
3150
  return this.compressContext(messages, onEvent, signal);
@@ -3160,34 +3187,55 @@ export class Agent {
3160
3187
  // outputs remain in the persisted transcript and are retrievable via
3161
3188
  // conversation_recall — the backstop, not the summary, is the place for
3162
3189
  // exact tool detail.
3163
- const transcript = toCompress
3164
- .map((m) => {
3165
- const text = getTextContent(m.content);
3166
- return `[${m.role}]: ${text || '(no text)'}`;
3167
- })
3168
- .join('\n');
3169
- const compressionPrompt = `You are a conversation summarizer preparing a handoff for an AI agent that will continue the work. The agent will have zero memory of this transcript except for what you produce, so your summary must be structured and decision-focused, not narrative.
3170
-
3171
- Produce your output in EXACTLY this format:
3172
-
3173
- CURRENT_TASK: <one sentence describing what the agent was actively working on at the end of the transcript. This is the single most important field — the agent uses it to decide what to do next. If multiple tasks were interleaved, pick the one that was most recently in flight.>
3174
-
3175
- LAST_STEP: <one sentence describing the most recent concrete action the agent completed. Example: "Wrote src/components/HabitTracker.tsx with Tauri invoke calls for get_habit_logs."</ >
3176
-
3177
- NEXT_STEP: <one sentence describing what the agent should do next to continue the task. Example: "Fix the missing habitId argument being passed to get_habit_logs in App.tsx." >
3178
-
3179
- BLOCKERS: <any active blockers the agent needs to know about. Write "none" if there are none.>
3180
-
3181
- SUMMARY:
3182
- <Free-form bullet-point summary of everything else worth preserving: key decisions, file paths, function names, tool results, errors and how they were resolved, technical context. Be thorough but concise. Do NOT repeat what you put in the structured fields above.>
3183
-
3184
- Rules:
3185
- - Every field above is MANDATORY. If you can't extract a value for one, write "unclear" but never omit the field.
3186
- - No pleasantries, no meta-commentary, no "Here's the summary" preamble.
3187
- - Use plain text in the structured fields — no markdown, no bullet points, no multi-line values.
3188
- - Keep the CURRENT_TASK, LAST_STEP, NEXT_STEP fields to a single sentence each.
3189
-
3190
- TRANSCRIPT:
3190
+ //
3191
+ // CHUNKED (19 Sep 2026). This used to send the whole compress zone in one
3192
+ // request. At the 400K threshold that is a ~400K-token prompt, which
3193
+ // fails or times out on most models — and the failure was swallowed, so
3194
+ // auto-compression silently never happened and the turn fell through to
3195
+ // truncation, which dropped 115 messages and called it "summarised". Now
3196
+ // the zone is summarised in pieces of at most CHUNK_TOKENS, each into
3197
+ // working notes, and the notes are folded into the one structured
3198
+ // continuation header. A zone that fits in one piece takes one call.
3199
+ const CHUNK_TOKENS = 60_000;
3200
+ const chunks = [];
3201
+ let cur = [];
3202
+ let curTokens = 0;
3203
+ for (const m of toCompress) {
3204
+ const line = `[${m.role}]: ${getTextContent(m.content) || '(no text)'}`;
3205
+ const t = Agent.estimateTextTokens(line);
3206
+ if (cur.length && curTokens + t > CHUNK_TOKENS) {
3207
+ chunks.push(cur.join('\n'));
3208
+ cur = [];
3209
+ curTokens = 0;
3210
+ }
3211
+ cur.push(line);
3212
+ curTokens += t;
3213
+ }
3214
+ if (cur.length)
3215
+ chunks.push(cur.join('\n'));
3216
+ const notesPrompt = (part, total, text) => `You are summarising part ${part} of ${total} of a long transcript between a user and an AI agent, as working notes for a later handoff summary. Capture, as concise bullet points: decisions made, files and functions named, tool results and errors and how they were resolved, what the user asked for in their own words, and what was in flight at the end of this part. No preamble, no narrative.\n\nTRANSCRIPT PART ${part}/${total}:\n${text}`;
3217
+ const compressionPromptFor = (transcript) => `You are a conversation summarizer preparing a handoff for an AI agent that will continue the work. The agent will have zero memory of this transcript except for what you produce, so your summary must be structured and decision-focused, not narrative.
3218
+
3219
+ Produce your output in EXACTLY this format:
3220
+
3221
+ CURRENT_TASK: <one sentence describing what the agent was actively working on at the end of the transcript. This is the single most important field — the agent uses it to decide what to do next. If multiple tasks were interleaved, pick the one that was most recently in flight.>
3222
+
3223
+ LAST_STEP: <one sentence describing the most recent concrete action the agent completed. Example: "Wrote src/components/HabitTracker.tsx with Tauri invoke calls for get_habit_logs."</ >
3224
+
3225
+ NEXT_STEP: <one sentence describing what the agent should do next to continue the task. Example: "Fix the missing habitId argument being passed to get_habit_logs in App.tsx." >
3226
+
3227
+ BLOCKERS: <any active blockers the agent needs to know about. Write "none" if there are none.>
3228
+
3229
+ SUMMARY:
3230
+ <Free-form bullet-point summary of everything else worth preserving: key decisions, file paths, function names, tool results, errors and how they were resolved, technical context. Be thorough but concise. Do NOT repeat what you put in the structured fields above.>
3231
+
3232
+ Rules:
3233
+ - Every field above is MANDATORY. If you can't extract a value for one, write "unclear" but never omit the field.
3234
+ - No pleasantries, no meta-commentary, no "Here's the summary" preamble.
3235
+ - Use plain text in the structured fields — no markdown, no bullet points, no multi-line values.
3236
+ - Keep the CURRENT_TASK, LAST_STEP, NEXT_STEP fields to a single sentence each.
3237
+
3238
+ TRANSCRIPT:
3191
3239
  ${transcript}`;
3192
3240
  // Scale the summary budget to how much is being compressed. A flat cap
3193
3241
  // under-summarises a large zone — 1500 tokens for a 300K-token compress
@@ -3197,18 +3245,18 @@ ${transcript}`;
3197
3245
  // meant to shrink.
3198
3246
  const compressedTokens = this.estimateTokenCount(toCompress);
3199
3247
  const summaryBudget = Math.min(4000, Math.max(1500, Math.floor(compressedTokens / 12)));
3200
- try {
3248
+ const complete = async (prompt, maxTokens) => {
3201
3249
  const response = await this.provider.createCompletion({
3202
3250
  model: this.model.id,
3203
3251
  messages: [
3204
3252
  { role: 'system', content: 'You are a precise conversation summarizer.' },
3205
- { role: 'user', content: compressionPrompt },
3253
+ { role: 'user', content: prompt },
3206
3254
  ],
3207
3255
  // Compression is a real cost the turn incurred, so it belongs to the
3208
3256
  // turn. Leaving it untagged would quietly understate what a long
3209
3257
  // conversation actually costs to answer.
3210
3258
  turnId: this.runTurnId,
3211
- max_tokens: summaryBudget,
3259
+ max_tokens: maxTokens,
3212
3260
  temperature: 0.2,
3213
3261
  }, signal);
3214
3262
  // Meter the compression call. It's a heavy-model completion the same
@@ -3217,7 +3265,24 @@ ${transcript}`;
3217
3265
  model: this.model.id,
3218
3266
  rawTokens: extractUsage(response.usage),
3219
3267
  });
3220
- const summary = response.choices?.[0]?.message?.content || '';
3268
+ return response.choices?.[0]?.message?.content || '';
3269
+ };
3270
+ try {
3271
+ let summary;
3272
+ if (chunks.length <= 1) {
3273
+ summary = await complete(compressionPromptFor(chunks[0] ?? ''), summaryBudget);
3274
+ }
3275
+ else {
3276
+ logger.info(`[agent] compression: summarising ${chunks.length} chunks of ≤${CHUNK_TOKENS} tokens`);
3277
+ const notes = [];
3278
+ for (let i = 0; i < chunks.length; i++) {
3279
+ const n = await complete(notesPrompt(i + 1, chunks.length, chunks[i]), 1500);
3280
+ if (!n)
3281
+ throw new Error(`Empty notes for chunk ${i + 1}/${chunks.length}`);
3282
+ notes.push(`--- part ${i + 1}/${chunks.length} ---\n${n}`);
3283
+ }
3284
+ summary = await complete(compressionPromptFor(notes.join('\n\n')), summaryBudget);
3285
+ }
3221
3286
  if (!summary)
3222
3287
  throw new Error('Empty compression response');
3223
3288
  // Memory policy: see notes at the earlier compression site. The
@@ -3295,6 +3360,9 @@ ${transcript}`;
3295
3360
  const result = enrichedSystem
3296
3361
  ? [enrichedSystem, ...middle, ...fixedTail]
3297
3362
  : [...middle, ...fixedTail];
3363
+ // The boundary, for a host that keeps its transcript and compacts only
3364
+ // the model's view: the tail starts KEEP_RECENT from the end of the input.
3365
+ this.lastCompaction = { middle, systemNote: pinnedNote, keptFromContext: messages.length - KEEP_RECENT };
3298
3366
  const originalTokens = this.estimateTokenCount(messages);
3299
3367
  const compressedTokens = this.estimateTokenCount(result);
3300
3368
  onEvent({ type: 'context_compression_end', originalTokens, compressedTokens });
@@ -3306,8 +3374,11 @@ ${transcript}`;
3306
3374
  });
3307
3375
  return result;
3308
3376
  }
3309
- catch {
3310
- // Compression failed — fall back silently (caller will truncate if needed)
3377
+ catch (err) {
3378
+ // Compression failed — fall back (the caller truncates if it must). Not
3379
+ // silently any more: a swallowed failure here is how "auto never
3380
+ // compresses" went undiagnosed.
3381
+ logger.warn(`[agent] compression FAILED (${toCompress.length} messages, ~${compressedTokens} tokens, ${chunks.length} chunk(s)): ${err instanceof Error ? err.message : String(err)}`);
3311
3382
  onEvent({ type: 'context_compression_end', originalTokens: 0, compressedTokens: 0 });
3312
3383
  return messages;
3313
3384
  }