@oh-my-pi/pi-agent-core 18.18.0 → 18.18.1

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.
@@ -205,6 +205,8 @@ export declare const AUTO_HANDOFF_THRESHOLD_FOCUS: string;
205
205
  export interface SummaryOptions {
206
206
  promptOverride?: string;
207
207
  extraContext?: string[];
208
+ /** Additional summary context fetched only when a compaction request consumes it. */
209
+ loadExtraContext?: () => Promise<string[] | undefined>;
208
210
  remoteEndpoint?: string;
209
211
  /** Stable system-prompt segments from the live turn, preserved for provider cache reuse. */
210
212
  remoteSystemPrompt?: string[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@oh-my-pi/pi-agent-core",
4
- "version": "18.18.0",
4
+ "version": "18.18.1",
5
5
  "description": "General-purpose agent with transport abstraction, state management, and attachment support",
6
6
  "homepage": "https://omp.sh",
7
7
  "author": {
@@ -38,16 +38,16 @@
38
38
  "fmt": "oxfmt --no-error-on-unmatched-pattern 'src/**/*.{ts,tsx}' '{test,bench,examples,scripts}/**/*.ts' '*.ts'"
39
39
  },
40
40
  "dependencies": {
41
- "@oh-my-pi/pi-ai": "18.18.0",
42
- "@oh-my-pi/pi-catalog": "18.18.0",
43
- "@oh-my-pi/pi-natives": "18.18.0",
44
- "@oh-my-pi/pi-utils": "18.18.0",
45
- "@oh-my-pi/pi-wire": "18.18.0",
46
- "@oh-my-pi/snapcompact": "18.18.0",
41
+ "@oh-my-pi/pi-ai": "18.18.1",
42
+ "@oh-my-pi/pi-catalog": "18.18.1",
43
+ "@oh-my-pi/pi-natives": "18.18.1",
44
+ "@oh-my-pi/pi-utils": "18.18.1",
45
+ "@oh-my-pi/pi-wire": "18.18.1",
46
+ "@oh-my-pi/snapcompact": "18.18.1",
47
47
  "@opentelemetry/api": "^1.9.1"
48
48
  },
49
49
  "devDependencies": {
50
- "@oh-my-pi/omptype": "18.18.0",
50
+ "@oh-my-pi/omptype": "18.18.1",
51
51
  "@opentelemetry/context-async-hooks": "2.9.0",
52
52
  "@opentelemetry/sdk-trace-base": "2.9.0",
53
53
  "@types/bun": "^1.3.14"
@@ -691,6 +691,8 @@ function shouldRetryHandoffWithAutoToolChoice(response: AssistantMessage): boole
691
691
  export interface SummaryOptions {
692
692
  promptOverride?: string;
693
693
  extraContext?: string[];
694
+ /** Additional summary context fetched only when a compaction request consumes it. */
695
+ loadExtraContext?: () => Promise<string[] | undefined>;
694
696
  remoteEndpoint?: string;
695
697
  /** Stable system-prompt segments from the live turn, preserved for provider cache reuse. */
696
698
  remoteSystemPrompt?: string[];
@@ -1781,6 +1783,14 @@ export async function compact(
1781
1783
  // an outer retry loop multiplies with the inner one (see SummaryOptions).
1782
1784
  oneshotRetry: options?.oneshotRetry,
1783
1785
  };
1786
+ let extraContextLoaded = false;
1787
+ const ensureExtraContext = async (): Promise<void> => {
1788
+ if (extraContextLoaded || !options?.loadExtraContext) return;
1789
+ const context = await options.loadExtraContext();
1790
+ signal?.throwIfAborted();
1791
+ if (context?.length) summaryOptions.extraContext = [...(summaryOptions.extraContext ?? []), ...context];
1792
+ extraContextLoaded = true;
1793
+ };
1784
1794
 
1785
1795
  // An archive keeps the reasoning policy of the model it was rendered for;
1786
1796
  // Claude refuses inputs that reproduce reasoning (issue #6093), so a
@@ -2214,6 +2224,7 @@ export async function compact(
2214
2224
  ].filter(files => files.after >= filesDueBefore);
2215
2225
  if (carried.length > 0) nativeRetainedFiles = carried;
2216
2226
  }
2227
+ await ensureExtraContext();
2217
2228
  try {
2218
2229
  // The live turn's own system prompt, wire tools and transformed
2219
2230
  // history when the host can build them: kept thinking remains valid
@@ -2274,6 +2285,7 @@ export async function compact(
2274
2285
  if (!usedRemoteCompaction && nativeCompactionError !== undefined && !summaryOptions.remoteEndpoint) {
2275
2286
  throw new NativeCompactionError(nativeCompactionError);
2276
2287
  }
2288
+ if (!usedRemoteCompaction && nativeSummary === undefined) await ensureExtraContext();
2277
2289
 
2278
2290
  // Generate summaries (can be parallel if both needed) and merge into one
2279
2291
  let summary: string;
@@ -2332,11 +2344,7 @@ export async function compact(
2332
2344
 
2333
2345
  const shortSummary = usedRemoteCompaction
2334
2346
  ? "Remote compaction"
2335
- : await generateShortSummary(recentMessages, summary, model, reserveTokens, apiKey, signal, {
2336
- ...summaryOptions,
2337
- extraContext: options?.extraContext,
2338
- thinkingLevel: options?.thinkingLevel,
2339
- });
2347
+ : await generateShortSummary(recentMessages, summary, model, reserveTokens, apiKey, signal, summaryOptions);
2340
2348
 
2341
2349
  // Compute file lists and append to summary
2342
2350
  const { readFiles, modifiedFiles } = snapcompact.computeFileLists(fileOps);