@matthewfl/pi-contemplator 0.1.6 → 0.1.7
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/package.json +5 -5
- package/src/agents/contemplator/agent.ts +6 -29
- package/src/agents/contemplator/prompts.ts +1 -1
- package/src/commands/contemplator-view.ts +1 -1
- package/src/commands/settings.ts +1 -3
- package/src/commands/status.ts +1 -1
- package/src/config.ts +0 -3
- package/src/hooks/consolidation-trigger.ts +2 -1
- package/src/runtime.ts +2 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matthewfl/pi-contemplator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "A Pi extension that keeps long-running agentic sessions on track with background memory, contemplation, and structural review.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"@earendil-works/pi-tui": "*"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@earendil-works/pi-agent-core": "^0.84.
|
|
54
|
-
"@earendil-works/pi-ai": "^0.84.
|
|
55
|
-
"@earendil-works/pi-coding-agent": "^0.84.
|
|
56
|
-
"@earendil-works/pi-tui": "^0.84.
|
|
53
|
+
"@earendil-works/pi-agent-core": "^0.84.4",
|
|
54
|
+
"@earendil-works/pi-ai": "^0.84.4",
|
|
55
|
+
"@earendil-works/pi-coding-agent": "^0.84.4",
|
|
56
|
+
"@earendil-works/pi-tui": "^0.84.4",
|
|
57
57
|
"@types/node": "^22.0.0",
|
|
58
58
|
"typebox": "^1.1.38",
|
|
59
59
|
"typescript": "^5.6.0",
|
|
@@ -21,7 +21,6 @@ import { createWorkerStallWatchdog } from "../../worker-watchdog.js";
|
|
|
21
21
|
|
|
22
22
|
interface PendingUpdate {
|
|
23
23
|
observations: string[];
|
|
24
|
-
summaries: string[];
|
|
25
24
|
reviews: string[];
|
|
26
25
|
mainAgentOutputTokens: number;
|
|
27
26
|
mainAgentToolCalls: number;
|
|
@@ -219,7 +218,6 @@ export class Contemplator {
|
|
|
219
218
|
/** Bounds retries of one poisoned memory update so future updates can run. */
|
|
220
219
|
private consecutiveFlushFailures = 0;
|
|
221
220
|
private seenObservationIds = new Set<string>();
|
|
222
|
-
private seenSummaryIds = new Set<string>();
|
|
223
221
|
private seenReviewIds = new Set<string>();
|
|
224
222
|
private inFlightReviewKeys = new Set<string>();
|
|
225
223
|
private inFlightReviewIds = new Set<string>();
|
|
@@ -304,7 +302,6 @@ export class Contemplator {
|
|
|
304
302
|
this.history = [];
|
|
305
303
|
this.pending = undefined;
|
|
306
304
|
this.seenObservationIds.clear();
|
|
307
|
-
this.seenSummaryIds.clear();
|
|
308
305
|
this.seenReviewIds.clear();
|
|
309
306
|
this.inFlightReviewKeys.clear();
|
|
310
307
|
this.inFlightReviewIds.clear();
|
|
@@ -321,7 +318,6 @@ export class Contemplator {
|
|
|
321
318
|
this.runtime.contemplatorState = {
|
|
322
319
|
running: false,
|
|
323
320
|
pendingObservations: 0,
|
|
324
|
-
pendingSummaries: 0,
|
|
325
321
|
pendingReviews: 0,
|
|
326
322
|
responsesSinceRun: 0,
|
|
327
323
|
waitingFor: "idle",
|
|
@@ -431,7 +427,6 @@ export class Contemplator {
|
|
|
431
427
|
...this.runtime.contemplatorState,
|
|
432
428
|
running: this.running,
|
|
433
429
|
pendingObservations: this.pending?.observations.length ?? 0,
|
|
434
|
-
pendingSummaries: this.pending?.summaries.length ?? 0,
|
|
435
430
|
pendingReviews: this.pending?.reviews.length ?? 0,
|
|
436
431
|
responsesSinceRun: this.turnsSinceRun,
|
|
437
432
|
waitingFor,
|
|
@@ -457,7 +452,6 @@ export class Contemplator {
|
|
|
457
452
|
this.reviewerSessions.clear();
|
|
458
453
|
resetProjection = fullProjection(entries);
|
|
459
454
|
this.seenObservationIds.clear();
|
|
460
|
-
this.seenSummaryIds.clear();
|
|
461
455
|
this.seenReviewIds.clear();
|
|
462
456
|
this.pending = undefined;
|
|
463
457
|
this.turnsSinceRun = 0;
|
|
@@ -465,7 +459,6 @@ export class Contemplator {
|
|
|
465
459
|
this.runtime.contemplatorState = {
|
|
466
460
|
running: false,
|
|
467
461
|
pendingObservations: 0,
|
|
468
|
-
pendingSummaries: 0,
|
|
469
462
|
pendingReviews: 0,
|
|
470
463
|
responsesSinceRun: 0,
|
|
471
464
|
waitingFor: "idle",
|
|
@@ -547,12 +540,10 @@ export class Contemplator {
|
|
|
547
540
|
for (const id of memoryReferenceIds(text)) coveredIds.add(id);
|
|
548
541
|
}
|
|
549
542
|
this.seenObservationIds = new Set(resetProjection.observations.filter((item) => coveredIds.has(item.id)).map((item) => item.id));
|
|
550
|
-
this.seenSummaryIds = new Set(resetProjection.summaries.filter((item) => coveredIds.has(item.id)).map((item) => item.id));
|
|
551
543
|
this.seenReviewIds = new Set((resetProjection.reviews ?? []).filter((item) => coveredIds.has(item.id)).map((item) => item.id));
|
|
552
544
|
const unprocessedObservations = resetProjection.observations.length - this.seenObservationIds.size;
|
|
553
|
-
const unprocessedSummaries = resetProjection.summaries.length - this.seenSummaryIds.size;
|
|
554
545
|
const unprocessedReviews = (resetProjection.reviews?.length ?? 0) - this.seenReviewIds.size;
|
|
555
|
-
if (unprocessedReviews > 0 || unprocessedObservations >= this.runtime.config.contemplatorMinNewObservations
|
|
546
|
+
if (unprocessedReviews > 0 || unprocessedObservations >= this.runtime.config.contemplatorMinNewObservations) {
|
|
556
547
|
this.turnsSinceRun = this.runtime.config.contemplatorMinTurns;
|
|
557
548
|
}
|
|
558
549
|
}
|
|
@@ -607,31 +598,24 @@ export class Contemplator {
|
|
|
607
598
|
}
|
|
608
599
|
const projection = fullProjection(branchEntries);
|
|
609
600
|
const observations = projection.observations.map((item) => `[${item.id}] ${item.content}`);
|
|
610
|
-
const summaries = projection.summaries.map((item) => `[${item.id}] ${item.content}`);
|
|
611
601
|
const reviews = projection.reviews ?? [];
|
|
612
602
|
const newObservationItems = projection.observations.filter((item) => !this.seenObservationIds.has(item.id));
|
|
613
|
-
const newSummaryItems = projection.summaries.filter((item) => !this.seenSummaryIds.has(item.id));
|
|
614
603
|
const newReviewItems = reviews.filter((item) => !this.seenReviewIds.has(item.id));
|
|
615
604
|
const newObservations = newObservationItems.map((item) => `[${item.id}] ${item.content}`);
|
|
616
|
-
const newSummaries = newSummaryItems.map((item) => `[${item.id}] ${item.content}`);
|
|
617
605
|
const newReviews = newReviewItems.map(reviewSummaryLine);
|
|
618
606
|
for (const item of newObservationItems) this.seenObservationIds.add(item.id);
|
|
619
|
-
for (const item of newSummaryItems) this.seenSummaryIds.add(item.id);
|
|
620
607
|
for (const item of newReviewItems) this.seenReviewIds.add(item.id);
|
|
621
608
|
debugLog("contemplator.update", {
|
|
622
609
|
observationCount: observations.length,
|
|
623
|
-
summaryCount: summaries.length,
|
|
624
610
|
newObservationCount: newObservations.length,
|
|
625
|
-
newSummaryCount: newSummaries.length,
|
|
626
611
|
newReviewCount: newReviews.length,
|
|
627
612
|
turnsSinceRun: this.turnsSinceRun,
|
|
628
613
|
pending: this.pending !== undefined,
|
|
629
614
|
running: this.running,
|
|
630
615
|
});
|
|
631
|
-
if (newObservations.length > 0 ||
|
|
616
|
+
if (newObservations.length > 0 || newReviews.length > 0) {
|
|
632
617
|
this.pending = {
|
|
633
618
|
observations: mergeMemoryLines(this.pending?.observations ?? [], newObservations),
|
|
634
|
-
summaries: mergeMemoryLines(this.pending?.summaries ?? [], newSummaries),
|
|
635
619
|
reviews: mergeMemoryLines(this.pending?.reviews ?? [], newReviews),
|
|
636
620
|
mainAgentOutputTokens: assistantOutputTokens(branchEntries),
|
|
637
621
|
mainAgentToolCalls: assistantToolCallCount(branchEntries),
|
|
@@ -648,7 +632,7 @@ export class Contemplator {
|
|
|
648
632
|
this.pending.mainAgentOutputTokens = assistantOutputTokens(branchEntries);
|
|
649
633
|
this.pending.mainAgentToolCalls = assistantToolCallCount(branchEntries);
|
|
650
634
|
this.pending.mainAgentActiveTimeMs = agentActiveTimeMs(branchEntries);
|
|
651
|
-
const enoughMemories = this.pending.reviews.length > 0 || this.pending.observations.length >= this.runtime.config.contemplatorMinNewObservations
|
|
635
|
+
const enoughMemories = this.pending.reviews.length > 0 || this.pending.observations.length >= this.runtime.config.contemplatorMinNewObservations;
|
|
652
636
|
if (this.probeCooldownPendingIds.size > 0) {
|
|
653
637
|
this.publishState("probe");
|
|
654
638
|
debugLog("contemplator.waiting", { reason: "probe_delivery", pendingProbeCount: this.probeCooldownPendingIds.size });
|
|
@@ -661,14 +645,12 @@ export class Contemplator {
|
|
|
661
645
|
turnsSinceRun: this.turnsSinceRun,
|
|
662
646
|
minTurns: this.runtime.config.contemplatorMinTurns,
|
|
663
647
|
minNewObservations: this.runtime.config.contemplatorMinNewObservations,
|
|
664
|
-
minNewSummaries: this.runtime.config.contemplatorMinNewSummaries,
|
|
665
648
|
});
|
|
666
649
|
return;
|
|
667
650
|
}
|
|
668
651
|
this.publishState(this.running ? "running" : "ready");
|
|
669
652
|
debugLog("contemplator.triggered", {
|
|
670
653
|
pendingObservationCount: this.pending.observations.length,
|
|
671
|
-
pendingSummaryCount: this.pending.summaries.length,
|
|
672
654
|
pendingReviewCount: this.pending.reviews.length,
|
|
673
655
|
turnsSinceRun: this.turnsSinceRun,
|
|
674
656
|
});
|
|
@@ -705,7 +687,6 @@ export class Contemplator {
|
|
|
705
687
|
this.publishState("running", { lastStartedAt: startedAt, lastError: undefined });
|
|
706
688
|
debugLog("contemplator.start", {
|
|
707
689
|
newObservationCount: update.observations.length,
|
|
708
|
-
newSummaryCount: update.summaries.length,
|
|
709
690
|
newReviewCount: update.reviews.length,
|
|
710
691
|
historyMessageCount: this.history.length,
|
|
711
692
|
});
|
|
@@ -727,14 +708,13 @@ export class Contemplator {
|
|
|
727
708
|
const pending = this.pending as PendingUpdate | undefined;
|
|
728
709
|
this.pending = {
|
|
729
710
|
observations: mergeMemoryLines(pending?.observations ?? [], update.observations),
|
|
730
|
-
summaries: mergeMemoryLines(pending?.summaries ?? [], update.summaries),
|
|
731
711
|
reviews: mergeMemoryLines(pending?.reviews ?? [], update.reviews),
|
|
732
712
|
mainAgentOutputTokens: update.mainAgentOutputTokens,
|
|
733
713
|
mainAgentToolCalls: update.mainAgentToolCalls,
|
|
734
714
|
mainAgentActiveTimeMs: update.mainAgentActiveTimeMs,
|
|
735
715
|
};
|
|
736
716
|
} else {
|
|
737
|
-
debugLog("contemplator.poisoned_update_released", { reason: resolved.reason, observationCount: update.observations.length,
|
|
717
|
+
debugLog("contemplator.poisoned_update_released", { reason: resolved.reason, observationCount: update.observations.length, reviewCount: update.reviews.length });
|
|
738
718
|
this.consecutiveFlushFailures = 0;
|
|
739
719
|
}
|
|
740
720
|
this.turnsSinceRun = 0; // Back off until fresh primary responses arrive; never retry every checkpoint.
|
|
@@ -759,7 +739,6 @@ export class Contemplator {
|
|
|
759
739
|
const reviewerEnabled = this.runtime.config.reviewerEnabled;
|
|
760
740
|
const updateSections: string[] = [];
|
|
761
741
|
if (update.observations.length > 0) updateSections.push(`OBSERVATIONS:\n${update.observations.join("\n")}`);
|
|
762
|
-
if (update.summaries.length > 0) updateSections.push(`SUMMARIES:\n${update.summaries.join("\n")}`);
|
|
763
742
|
if (update.reviews.length > 0) updateSections.push(`REVIEWS:\n${update.reviews.join("\n")}`);
|
|
764
743
|
const updateBody = updateSections.length > 0 ? updateSections.join("\n\n") : "(no new memories)";
|
|
765
744
|
const finalActionNames = reviewerEnabled
|
|
@@ -925,14 +904,13 @@ export class Contemplator {
|
|
|
925
904
|
const pending = this.pending as PendingUpdate | undefined;
|
|
926
905
|
this.pending = {
|
|
927
906
|
observations: mergeMemoryLines(pending?.observations ?? [], update.observations),
|
|
928
|
-
summaries: mergeMemoryLines(pending?.summaries ?? [], update.summaries),
|
|
929
907
|
reviews: mergeMemoryLines(pending?.reviews ?? [], update.reviews),
|
|
930
908
|
mainAgentOutputTokens: update.mainAgentOutputTokens,
|
|
931
909
|
mainAgentToolCalls: update.mainAgentToolCalls,
|
|
932
910
|
mainAgentActiveTimeMs: update.mainAgentActiveTimeMs,
|
|
933
911
|
};
|
|
934
912
|
} else {
|
|
935
|
-
debugLog("contemplator.poisoned_update_released", { reason: failureMessage, observationCount: update.observations.length,
|
|
913
|
+
debugLog("contemplator.poisoned_update_released", { reason: failureMessage, observationCount: update.observations.length, reviewCount: update.reviews.length });
|
|
936
914
|
this.consecutiveFlushFailures = 0;
|
|
937
915
|
}
|
|
938
916
|
this.turnsSinceRun = 0; // Back off until fresh primary responses arrive; never retry every checkpoint.
|
|
@@ -950,8 +928,7 @@ export class Contemplator {
|
|
|
950
928
|
const waitingForProbe = this.probeCooldownPendingIds.size > 0;
|
|
951
929
|
const pendingHasEnoughMemories = this.pending !== undefined && (
|
|
952
930
|
this.pending.reviews.length > 0 ||
|
|
953
|
-
this.pending.observations.length >= this.runtime.config.contemplatorMinNewObservations
|
|
954
|
-
this.pending.summaries.length >= this.runtime.config.contemplatorMinNewSummaries
|
|
931
|
+
this.pending.observations.length >= this.runtime.config.contemplatorMinNewObservations
|
|
955
932
|
);
|
|
956
933
|
const waitingFor = waitingForProbe
|
|
957
934
|
? "probe"
|
|
@@ -6,7 +6,7 @@ export function buildContemplatorSystemPrompt(
|
|
|
6
6
|
|
|
7
7
|
Neither you nor the primary agent should be assumed to know the correct solution. You are jointly exploring a problem space from different perspectives. The primary agent interacts with the actual environment and carries out the work. You maintain a longer-term view of the reasoning, evidence, assumptions, alternatives, unresolved questions${reviewerEnabled ? ", and recurring structural patterns" : ""} that emerge over time.
|
|
8
8
|
|
|
9
|
-
You receive incremental observations
|
|
9
|
+
You receive incremental observations about primary-agent activity. Pay extra attention to memories about the user’s intent, priorities, constraints, corrections, and desired outcome. Older summarized memories remain available through search_memories and recall when you need historical context, but summary maintenance is not itself a new event.
|
|
10
10
|
|
|
11
11
|
You see only the memory ledger, not the primary agent’s live activity. Your understanding may be incomplete or slightly stale. Do not infer inactivity, failure, or lack of progress from missing recent results. A result may simply not have reached memory yet.
|
|
12
12
|
|
|
@@ -59,7 +59,7 @@ function renderMessage(message: StoredMessage, compacted: boolean): string {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
function liveStateLine(state: ContemplatorRunState): string {
|
|
62
|
-
const pending = `${state.pendingObservations} observations / ${state.
|
|
62
|
+
const pending = `${state.pendingObservations} observations / ${state.pendingReviews} reviews pending`;
|
|
63
63
|
const timing = `Last start: ${state.lastStartedAt === undefined ? "not run this launch" : new Date(state.lastStartedAt).toISOString()} · Last end: ${state.lastCompletedAt === undefined ? "not completed this launch" : new Date(state.lastCompletedAt).toISOString()}`;
|
|
64
64
|
const error = state.lastError ? `\nLast error: ${state.lastError}` : "";
|
|
65
65
|
if (state.running) return `LIVE · running for ${Math.max(0, Math.floor((Date.now() - (state.lastStartedAt ?? Date.now())) / 60_000))}m · ${pending}\n${timing}${error}`;
|
package/src/commands/settings.ts
CHANGED
|
@@ -10,7 +10,7 @@ type ModelRegistryLike = {
|
|
|
10
10
|
getAll(): Array<{ provider: string; id: string }>;
|
|
11
11
|
find?(provider: string, id: string): { contextWindow?: number } | undefined;
|
|
12
12
|
};
|
|
13
|
-
type NumberSetting = "observeAfterTokens" | "compactAfterTokens" | "observerChunkMaxTokens" | "newMemoryPoolMaxTokens" | "oldMemoryPoolTargetTokens" | "agentMaxTurns" | "contemplatorMinNewObservations" | "
|
|
13
|
+
type NumberSetting = "observeAfterTokens" | "compactAfterTokens" | "observerChunkMaxTokens" | "newMemoryPoolMaxTokens" | "oldMemoryPoolTargetTokens" | "agentMaxTurns" | "contemplatorMinNewObservations" | "contemplatorMinTurns" | "summarizerRetriggerTokens" | "summarizerSamplingThresholdTokens";
|
|
14
14
|
type BooleanSetting = "contemplatorEnabled" | "showContemplatorMessages" | "reviewerEnabled" | "summarizerEnabled" | "compactionObserverEnabled" | "showWorkerNotifications" | "passive" | "debugLog";
|
|
15
15
|
|
|
16
16
|
function modelLabel(model: ConfiguredModel | undefined): string {
|
|
@@ -216,7 +216,6 @@ export function registerSettingsCommand(pi: ExtensionAPI, runtime: Runtime): voi
|
|
|
216
216
|
`Contemplator model: ${hasOverride(settings, "contemplatorModel") ? modelLabel(runtime.config.contemplatorModel) : `${modelLabel(runtime.getDefaultConfig().contemplatorModel)} (default)`}`,
|
|
217
217
|
`Show contemplator messages: ${scalarLabel(runtime, "showContemplatorMessages")}`,
|
|
218
218
|
`Contemplator new-observation trigger (count): ${scalarLabel(runtime, "contemplatorMinNewObservations")}`,
|
|
219
|
-
`Contemplator new-summary trigger (count): ${scalarLabel(runtime, "contemplatorMinNewSummaries")}`,
|
|
220
219
|
`Contemplator response spacing (count): ${scalarLabel(runtime, "contemplatorMinTurns")}`,
|
|
221
220
|
`Summarizer enabled: ${scalarLabel(runtime, "summarizerEnabled")}`,
|
|
222
221
|
`New memory pool protection budget (tokens): ${scalarLabel(runtime, "newMemoryPoolMaxTokens")}`,
|
|
@@ -272,7 +271,6 @@ export function registerSettingsCommand(pi: ExtensionAPI, runtime: Runtime): voi
|
|
|
272
271
|
["New memory pool protection budget (tokens):", "newMemoryPoolMaxTokens", "New memory pool protection budget (tokens)"],
|
|
273
272
|
["Old memory pool target (tokens, advisory):", "oldMemoryPoolTargetTokens", "Old memory pool target (tokens, advisory)"],
|
|
274
273
|
["Contemplator new-observation trigger (count):", "contemplatorMinNewObservations", "Contemplator new-observation trigger (count)"],
|
|
275
|
-
["Contemplator new-summary trigger (count):", "contemplatorMinNewSummaries", "Contemplator new-summary trigger (count)"],
|
|
276
274
|
["Contemplator response spacing (count):", "contemplatorMinTurns", "Contemplator response spacing (count)"],
|
|
277
275
|
["Summarizer old-pool retrigger growth (tokens):", "summarizerRetriggerTokens", "Summarizer old-pool retrigger growth (tokens)"],
|
|
278
276
|
["Summarizer input cap before sampling (tokens):", "summarizerSamplingThresholdTokens", "Summarizer input cap before sampling (tokens)"],
|
package/src/commands/status.ts
CHANGED
|
@@ -130,7 +130,7 @@ export function registerStatusCommand(pi: ExtensionAPI, runtime: Runtime): void
|
|
|
130
130
|
`Cumulative agent time: ${formatDuration(agentActiveTimeMs(entries))}`,
|
|
131
131
|
`Observe source during compaction: ${runtime.config.compactionObserverEnabled === false ? "disabled" : "enabled"}`,
|
|
132
132
|
`Contemplator: ${runtime.config.contemplatorEnabled ? "enabled" : "disabled"}`,
|
|
133
|
-
`Contemplator trigger: ${runtime.contemplatorState.pendingObservations} observations / ${runtime.contemplatorState.
|
|
133
|
+
`Contemplator trigger: ${runtime.contemplatorState.pendingObservations} observations / ${runtime.contemplatorState.pendingReviews} reviews pending; ${runtime.contemplatorState.responsesSinceRun} / ${runtime.config.contemplatorMinTurns} primary responses; ${contemplatorWaitingLabel(runtime.contemplatorState.waitingFor)}`,
|
|
134
134
|
`Contemplator model: ${runtime.config.contemplatorModel ? `${runtime.config.contemplatorModel.provider}/${runtime.config.contemplatorModel.id}` : "current session model"}`,
|
|
135
135
|
`Contemplator messages: ${runtime.config.showContemplatorMessages ? "visible" : "hidden"}`,
|
|
136
136
|
`Structural reviewer: ${runtime.config.reviewerEnabled === false ? "disabled" : "enabled"}`,
|
package/src/config.ts
CHANGED
|
@@ -60,7 +60,6 @@ export interface Config {
|
|
|
60
60
|
/** Optional model override used only by short-lived structural reviewers. */
|
|
61
61
|
reviewerModel?: ConfiguredModel;
|
|
62
62
|
contemplatorMinNewObservations: number;
|
|
63
|
-
contemplatorMinNewSummaries: number;
|
|
64
63
|
/** Minimum primary-model responses after contemplator completion, or after delivery of its probe, before the next run. */
|
|
65
64
|
contemplatorMinTurns: number;
|
|
66
65
|
/** Stateless loss-aware summarizer for the old memory pool. */
|
|
@@ -87,7 +86,6 @@ export const DEFAULTS: Config = {
|
|
|
87
86
|
showContemplatorMessages: true,
|
|
88
87
|
reviewerEnabled: true,
|
|
89
88
|
contemplatorMinNewObservations: 8,
|
|
90
|
-
contemplatorMinNewSummaries: 1,
|
|
91
89
|
contemplatorMinTurns: 10,
|
|
92
90
|
summarizerEnabled: true,
|
|
93
91
|
summarizerRetriggerTokens: 2_000,
|
|
@@ -210,7 +208,6 @@ function normalizeSettingsConfig(value: Record<string, unknown>): Partial<Config
|
|
|
210
208
|
"oldMemoryPoolTargetTokens",
|
|
211
209
|
"agentMaxTurns",
|
|
212
210
|
"contemplatorMinNewObservations",
|
|
213
|
-
"contemplatorMinNewSummaries",
|
|
214
211
|
"contemplatorMinTurns",
|
|
215
212
|
"summarizerRetriggerTokens",
|
|
216
213
|
"summarizerSamplingThresholdTokens",
|
|
@@ -393,7 +393,8 @@ export function scheduleSummarizer(pi: ExtensionAPI, runtime: Runtime, ctx: Cons
|
|
|
393
393
|
runtime.lastSummarizerRun = { ...runtime.lastSummarizerRun!, status: "completed", summary };
|
|
394
394
|
debugLog("summarizer.appended", { summaries: result.commit.summaries.length, consumed: result.commit.metrics.consumedMemoryCount, sampled: result.sample?.sampled ?? false });
|
|
395
395
|
if (shouldNotifyWorker(runtime, ctx)) ctx.ui?.notify(`pi-contemplator: summarizer completed — ${summary}`, "info");
|
|
396
|
-
|
|
396
|
+
// Summaries compact older memories; they are not new events and must not
|
|
397
|
+
// wake or enter the contemplator's incremental update stream.
|
|
397
398
|
} else {
|
|
398
399
|
successfullyCompleted = true;
|
|
399
400
|
runtime.lastSummarizerRun = { ...runtime.lastSummarizerRun!, status: "completed", summary: "No safe summaries were created." };
|
package/src/runtime.ts
CHANGED
|
@@ -25,7 +25,7 @@ export type SessionSettings = Partial<Pick<Config,
|
|
|
25
25
|
| "compactAfterTokensMode" | "compactAfterTokensRatio"
|
|
26
26
|
| "newMemoryPoolMaxTokens" | "oldMemoryPoolTargetTokens" | "agentMaxTurns"
|
|
27
27
|
| "showWorkerNotifications" | "passive" | "compactionObserverEnabled" | "contemplatorEnabled" | "showContemplatorMessages" | "reviewerEnabled"
|
|
28
|
-
| "contemplatorMinNewObservations" | "
|
|
28
|
+
| "contemplatorMinNewObservations" | "contemplatorMinTurns"
|
|
29
29
|
| "summarizerEnabled" | "summarizerRetriggerTokens" | "summarizerSamplingThresholdTokens"
|
|
30
30
|
| "debugLog"
|
|
31
31
|
>> & {
|
|
@@ -80,7 +80,6 @@ export interface SummarizerRunView {
|
|
|
80
80
|
export interface ContemplatorRunState {
|
|
81
81
|
running: boolean;
|
|
82
82
|
pendingObservations: number;
|
|
83
|
-
pendingSummaries: number;
|
|
84
83
|
pendingReviews: number;
|
|
85
84
|
/** Completed primary-model responses since the current completion/probe-delivery spacing anchor. */
|
|
86
85
|
responsesSinceRun: number;
|
|
@@ -140,7 +139,7 @@ export function computeSessionSettings(entries: readonly unknown[]): SessionSett
|
|
|
140
139
|
const numberKeys = [
|
|
141
140
|
"observeAfterTokens", "observerChunkMaxTokens", "compactAfterTokens",
|
|
142
141
|
"newMemoryPoolMaxTokens", "oldMemoryPoolTargetTokens", "agentMaxTurns",
|
|
143
|
-
"contemplatorMinNewObservations", "
|
|
142
|
+
"contemplatorMinNewObservations", "contemplatorMinTurns",
|
|
144
143
|
"summarizerRetriggerTokens", "summarizerSamplingThresholdTokens",
|
|
145
144
|
] as const;
|
|
146
145
|
for (const key of booleanKeys) if (typeof data[key] === "boolean") restored[key] = data[key];
|
|
@@ -209,7 +208,6 @@ export class Runtime {
|
|
|
209
208
|
contemplatorState: ContemplatorRunState = {
|
|
210
209
|
running: false,
|
|
211
210
|
pendingObservations: 0,
|
|
212
|
-
pendingSummaries: 0,
|
|
213
211
|
pendingReviews: 0,
|
|
214
212
|
responsesSinceRun: 0,
|
|
215
213
|
waitingFor: "idle",
|
|
@@ -299,7 +297,6 @@ export class Runtime {
|
|
|
299
297
|
this.contemplatorState = {
|
|
300
298
|
running: false,
|
|
301
299
|
pendingObservations: 0,
|
|
302
|
-
pendingSummaries: 0,
|
|
303
300
|
pendingReviews: 0,
|
|
304
301
|
responsesSinceRun: 0,
|
|
305
302
|
waitingFor: "idle",
|