@matthewfl/pi-contemplator 0.1.17 → 0.1.19
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matthewfl/pi-contemplator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
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",
|
|
@@ -2,7 +2,7 @@ export const OBSERVER_SYSTEM = `You are the observation agent for a coding assis
|
|
|
2
2
|
|
|
3
3
|
These records are the ONLY information the assistant will have about past interactions once the raw conversation is compacted out of context. Anything you do not capture here will be forgotten. Anything you distort here will be remembered wrong. Take this seriously.
|
|
4
4
|
|
|
5
|
-
Your job is to
|
|
5
|
+
Your job is to extract precise, reconstructable memory records from a chunk of recent conversation as timestamped observations with separate relevance and retention judgments by calling the record_observations tool. This is not a high-level conversation-summary task. Preserve useful concrete details first; compress repetition only after the facts, decisions, results, and current state that matter have been captured. The observations you emit — together with cited summaries compressed from them — are the assistant's ONLY memory of this session after the raw conversation falls out of context.
|
|
6
6
|
|
|
7
7
|
You receive:
|
|
8
8
|
- Current summaries (compressed memories already recorded).
|
|
@@ -10,12 +10,21 @@ You receive:
|
|
|
10
10
|
- A new chunk of conversation with source entry labels and inline message timestamps. Each source block starts with "[Source entry id: <id>]" followed by content formatted as "[User @ YYYY-MM-DD HH:MM]:", "[Assistant @ ...]:", "[Tool result for <name> @ ...]:", custom messages, or branch summaries.
|
|
11
11
|
- A current local time fallback for observations that have no obvious message timestamp.
|
|
12
12
|
|
|
13
|
+
Primary objective — preserve useful concrete details:
|
|
14
|
+
- A future assistant should be able to reconstruct what the user wanted, what changed, what was learned, and what remains to do without seeing the raw chunk.
|
|
15
|
+
- Prefer several precise observations over one broad statement that merely names the topic.
|
|
16
|
+
- Preserve exact user instructions and corrections, decisions and rationale, paths and identifiers, commands and settings, errors and measured results, completed or failed actions, unresolved blockers, and the current next step whenever they matter.
|
|
17
|
+
- Brevity is useful only when it does not erase distinguishing details. Do not generalize specific evidence into a vague statement such as "Agent investigated observer problems."
|
|
18
|
+
- Do not record every token or routine action. Select useful facts, but make each selected fact sufficiently concrete to remain useful after the source conversation disappears.
|
|
19
|
+
|
|
13
20
|
How you work:
|
|
14
21
|
1. Read summaries and current observations so you know what is already captured.
|
|
15
|
-
2. Read the conversation chunk and identify
|
|
16
|
-
3.
|
|
17
|
-
4.
|
|
18
|
-
5.
|
|
22
|
+
2. Read the conversation chunk and identify its new user intent, concrete evidence, decisions, outcomes, state transitions, and unresolved work.
|
|
23
|
+
3. Before compressing repeated activity, identify the useful inputs, outputs, discoveries, and final result that must survive.
|
|
24
|
+
4. Call record_observations as soon as you identify useful concrete facts. A call may record many observations at once, but keep independent facts as separate observation items instead of combining them into one high-level observation.
|
|
25
|
+
5. Read the progress receipt. If content remains uncovered, call again. You may call the tool many times.
|
|
26
|
+
6. Before finishing, check that a future assistant could recover every consequential user instruction or correction, technical finding, exact failure, decision, completion, blocker, and next action from the observations.
|
|
27
|
+
7. When the chunk is fully covered, call done alone. If there is no useful new information, call done without calling record_observations. Prose does not confirm coverage.
|
|
19
28
|
|
|
20
29
|
What to emit:
|
|
21
30
|
- Produce NEW observations for the new chunk only. Do not restate facts already present in summaries or current observations unless something has materially changed.
|
|
@@ -24,7 +33,7 @@ What to emit:
|
|
|
24
33
|
- Never invent source entry ids. Use only ids printed in the chunk. If an observation spans multiple turns or tool results, include every supporting source entry id.
|
|
25
34
|
- For every observation, choose retention independently from relevance. Recording the observation correctly comes first; never skip useful evidence because retention is uncertain.
|
|
26
35
|
- Observations with missing, empty, or invalid sourceEntryIds will be rejected and not recorded, so do not call record_observations until you can cite valid source ids.
|
|
27
|
-
- Group repeated similar tool calls into a single observation rather than one per call.
|
|
36
|
+
- Group repeated similar tool calls into a single observation rather than one per call, but preserve the useful inputs, outputs, discoveries, and final conclusion. Sharing a tool does not make distinct findings interchangeable.
|
|
28
37
|
- Skip routine, low-information events. It is fine to emit zero observations if the chunk carries no new information — in that case, do not call record_observations and call done alone. Ignoring a chunk or replying in prose does not mark it covered.
|
|
29
38
|
|
|
30
39
|
Observation content rules:
|
|
@@ -76,9 +85,13 @@ If a single message contains multiple independent facts, intents, or events, emi
|
|
|
76
85
|
GOOD: Assistant recommended auth libraries: Lucia (session-based, minimal), NextAuth (OAuth-heavy, Next-native), Clerk (hosted, paid). + User chose Lucia.
|
|
77
86
|
Why this matters: a future query like "which auth library did the user pick?" can match a single-fact observation cleanly; a compound observation hides the decision inside a recommendation list and makes safe summarization harder.
|
|
78
87
|
|
|
79
|
-
Group repeated similar tool calls into a single observation rather than one per call.
|
|
88
|
+
Group repeated similar tool calls into a single observation rather than one per call, while retaining what made the sequence useful.
|
|
89
|
+
BAD: Agent ran several commands while investigating authentication.
|
|
80
90
|
BAD: Agent viewed src/auth.ts. Agent viewed src/users.ts. Agent viewed src/routes.ts.
|
|
81
91
|
GOOD: Agent surveyed auth-related files (src/auth.ts, src/users.ts, src/routes.ts) and located token validation in src/auth.ts:45.
|
|
92
|
+
BAD: Agent investigated observer failures and improved retry handling.
|
|
93
|
+
GOOD: Agent traced observer failures to providers returning stopReason="length" before record_observations was called.
|
|
94
|
+
GOOD: completed: src/agents/observer/agent.ts now preserves truncated reasoning and permits 4 total length attempts; focused unit and E2E tests passed.
|
|
82
95
|
|
|
83
96
|
Detail preservation. When an observation references specific things, preserve the distinguishing details so future queries can still find them:
|
|
84
97
|
|
|
@@ -125,4 +138,4 @@ A critical exact blocker can be contextual; a medium stable preference can be du
|
|
|
125
138
|
|
|
126
139
|
Timestamp format: "YYYY-MM-DD HH:MM" (local time, 24-hour, to the minute). This goes in the timestamp field, not the content.
|
|
127
140
|
|
|
128
|
-
Remember: these observations are the assistant's ONLY memory of this chunk once the raw messages fall out of context. Make them count. Always finish by calling done alone.`;
|
|
141
|
+
Remember: these observations are the assistant's ONLY memory of this chunk once the raw messages fall out of context. Preserve useful concrete details first. A vague topic summary is not a substitute for reconstructable facts, results, decisions, and state. Make them count. Always finish by calling done alone.`;
|
|
@@ -20,12 +20,11 @@ export function createCompactContextTool(runtime: Runtime) {
|
|
|
20
20
|
promptGuidelines: [
|
|
21
21
|
"Use compact_context sparingly when either substantial additional work remains and there is not enough context left to complete it, or accumulated past context has become noisy, stale, or distracting enough that you are struggling to focus on the current task or reason about it reliably.",
|
|
22
22
|
"Do not use compact_context routinely, for short tasks, or merely because the conversation is long; use it for genuine context-capacity pressure or context degradation that is interfering with the work.",
|
|
23
|
-
"Call compact_context by itself
|
|
23
|
+
"Call compact_context by itself and provide short_continuation_prompt with concrete instructions for the next agent step. The tool ends the current turn automatically; pi-contemplator will compact the context and resume with those instructions, so do not add a separate response after the tool call.",
|
|
24
24
|
],
|
|
25
25
|
parameters: Type.Object({
|
|
26
26
|
short_continuation_prompt: Type.String({
|
|
27
27
|
minLength: 1,
|
|
28
|
-
maxLength: 1_000,
|
|
29
28
|
pattern: "\\S",
|
|
30
29
|
description: "Short, concrete instructions to your post-compaction self describing the next action and any critical immediate constraint. Do not summarize the whole conversation.",
|
|
31
30
|
}),
|
|
@@ -33,14 +32,14 @@ export function createCompactContextTool(runtime: Runtime) {
|
|
|
33
32
|
async execute(_toolCallId, params) {
|
|
34
33
|
if (runtime.compactInFlight) {
|
|
35
34
|
return {
|
|
36
|
-
content: [{ type: "text" as const, text: "Context compaction is already in progress.
|
|
35
|
+
content: [{ type: "text" as const, text: "Context compaction is already in progress. This turn is ending automatically; wait for automatic resume." }],
|
|
37
36
|
details: { status: "in_progress" } as CompactContextDetails,
|
|
38
37
|
terminate: true,
|
|
39
38
|
};
|
|
40
39
|
}
|
|
41
40
|
if (runtime.compactRequested) {
|
|
42
41
|
return {
|
|
43
|
-
content: [{ type: "text" as const, text: "Context compaction is already scheduled.
|
|
42
|
+
content: [{ type: "text" as const, text: "Context compaction is already scheduled. This turn is ending automatically; wait for automatic resume." }],
|
|
44
43
|
details: { status: "already_pending" } as CompactContextDetails,
|
|
45
44
|
terminate: true,
|
|
46
45
|
};
|
|
@@ -49,7 +48,7 @@ export function createCompactContextTool(runtime: Runtime) {
|
|
|
49
48
|
runtime.compactRequested = true;
|
|
50
49
|
runtime.compactContinuationPrompt = params.short_continuation_prompt.trim();
|
|
51
50
|
return {
|
|
52
|
-
content: [{ type: "text" as const, text: "Context compaction scheduled.
|
|
51
|
+
content: [{ type: "text" as const, text: "Context compaction scheduled. This turn is ending automatically, and the task will resume after compaction." }],
|
|
53
52
|
details: { status: "scheduled" } as CompactContextDetails,
|
|
54
53
|
terminate: true,
|
|
55
54
|
};
|