pi-context 2.0.0-beta.0 → 2.1.0
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/README.md +10 -10
- package/package.json +7 -6
- package/skills/context-management/SKILL.md +169 -238
- package/skills/context-management/references/development-and-troubleshooting.md +8 -8
- package/skills/context-management/references/interleaved-async-work.md +143 -0
- package/skills/context-management/references/planning-and-execution.md +11 -9
- package/skills/context-management/references/repeated-items-and-batch-work.md +11 -10
- package/skills/context-management/references/retry-branch-and-pivot.md +20 -11
- package/skills/context-management/references/search-research-and-reading.md +32 -11
- package/skills/context-management/references/task-switching-and-cleanup.md +22 -12
- package/src/index.ts +102 -54
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Interleaved Async Work
|
|
2
|
+
|
|
3
|
+
Use this reference when the hard part is **not** the external worker itself, but the current agent carrying several overlapping lines of work in one conversation.
|
|
4
|
+
|
|
5
|
+
Common examples:
|
|
6
|
+
|
|
7
|
+
- a main task continues while background jobs, subagents, reviewers, or tools may return later
|
|
8
|
+
- the user asks side questions while another front is still active
|
|
9
|
+
- progress updates, returned results, decisions, and new work are interleaved in the same thread
|
|
10
|
+
- several pending fronts have different next actions, and raw history starts making the current state hard to see
|
|
11
|
+
|
|
12
|
+
This is context management for the current agent. It is not a subagent-management policy. The goal is to keep the current working set clear enough to answer: **what am I doing now, what is parked, what just returned, and what raw context is still needed?**
|
|
13
|
+
|
|
14
|
+
## Mental model: fronts
|
|
15
|
+
|
|
16
|
+
Treat each overlapping line of work as a **front**.
|
|
17
|
+
|
|
18
|
+
A front may be:
|
|
19
|
+
|
|
20
|
+
- the current user-facing task
|
|
21
|
+
- a paused mainline task
|
|
22
|
+
- a background command or long-running job
|
|
23
|
+
- a subagent/reviewer/collaborator result that may return later
|
|
24
|
+
- a pending user decision
|
|
25
|
+
- a side request that should be answered before resuming the mainline
|
|
26
|
+
|
|
27
|
+
For each front, keep only one of these in the active working set:
|
|
28
|
+
|
|
29
|
+
- **Active raw front:** the thing you are reasoning about right now; keep necessary raw details.
|
|
30
|
+
- **Parked state capsule:** a paused or waiting front summarized by goal, current state, source pointers, next action, and blockers.
|
|
31
|
+
- **Stale process:** old logs, retries, status chatter, and abandoned paths whose lesson has already been captured.
|
|
32
|
+
|
|
33
|
+
The mistake to avoid is carrying every front raw at once.
|
|
34
|
+
|
|
35
|
+
## Working pattern
|
|
36
|
+
|
|
37
|
+
1. Identify the active front before each substantial reply or tool call.
|
|
38
|
+
2. If another front is still pending, keep it as a small state capsule rather than raw history.
|
|
39
|
+
3. When a result returns, capture it into the relevant front before responding.
|
|
40
|
+
4. If the returned result does not become the active front immediately, park it as state and preserve the user's current focus.
|
|
41
|
+
5. Before switching fronts, compact if the old front's raw process is now stale and the next front can continue from a summary.
|
|
42
|
+
6. If several fronts are tangled, run `context_timeline` to find the clean anchor and separate active, parked, completed, and stale paths.
|
|
43
|
+
|
|
44
|
+
## What to record per parked front
|
|
45
|
+
|
|
46
|
+
Use a short capsule:
|
|
47
|
+
|
|
48
|
+
- Front: short name for this line of work
|
|
49
|
+
- Goal: what this front is trying to accomplish
|
|
50
|
+
- State: waiting / running / returned / blocked / ready for next phase
|
|
51
|
+
- Latest stable result: what is known now
|
|
52
|
+
- Source pointers: files, links, task ids, log paths, branches, records, queries, or commands that identify where to re-check details
|
|
53
|
+
- Decisions and constraints: choices already made that still matter
|
|
54
|
+
- Rejected paths: approaches that should not be repeated
|
|
55
|
+
- Pending input or trigger: what would make this front active again
|
|
56
|
+
- Next action: what to do when resuming this front
|
|
57
|
+
|
|
58
|
+
This capsule is for future-you, not for the external worker. It should be enough to resume without rereading the interleaved raw thread.
|
|
59
|
+
|
|
60
|
+
If a front's detailed state is available from a reliable external source, keep the pointer, not the dump. For example, store the task id plus the command/log path to inspect it, not pages of status output; store the database query or record id, not every row; store the file path and relevant section, not the whole file. Copy raw details only when they are small, volatile, hard to retrieve, or needed for immediate reasoning.
|
|
61
|
+
|
|
62
|
+
## When to compact
|
|
63
|
+
|
|
64
|
+
Compact when interleaving has made raw context a worse working set:
|
|
65
|
+
|
|
66
|
+
- you are switching from one front to another after a noisy phase
|
|
67
|
+
- a side request arrives while the mainline is noisy but resumable from a capsule
|
|
68
|
+
- a background/subagent/reviewer/tool result returned and its raw logs are no longer needed
|
|
69
|
+
- the user has asked for status more than once and you cannot state all active fronts briefly
|
|
70
|
+
- a front was rejected, superseded, completed, or parked indefinitely
|
|
71
|
+
- the next action belongs to a different front than the recent raw history
|
|
72
|
+
- the active front started much earlier, and the middle of the thread is mostly completed or unrelated fronts
|
|
73
|
+
|
|
74
|
+
Do **not** compact just because async work exists. Compact when a front can safely be represented as state while another front becomes active.
|
|
75
|
+
|
|
76
|
+
## Choosing how far back to compact
|
|
77
|
+
|
|
78
|
+
Interleaved work often makes recent anchors poor targets: they may preserve the completed fronts that happened after the active front was launched. Be willing to compact aggressively when the summary can restore state.
|
|
79
|
+
|
|
80
|
+
A compact to an old anchor or even `root` is appropriate when:
|
|
81
|
+
|
|
82
|
+
- the active front can be described by a concise capsule
|
|
83
|
+
- completed fronts between the anchor and now no longer need raw context
|
|
84
|
+
- important details are recoverable from reliable source pointers
|
|
85
|
+
- the next action does not require inspecting the interleaved raw discussion
|
|
86
|
+
- you can name what remains active, what is parked, and what is done
|
|
87
|
+
|
|
88
|
+
Use a backup checkpoint for safety when the interleaved raw path may still matter, but do not keep it active just because it is long.
|
|
89
|
+
|
|
90
|
+
Before a deep compact, ask:
|
|
91
|
+
|
|
92
|
+
```text
|
|
93
|
+
Active now: which front am I resuming?
|
|
94
|
+
Parked: which fronts still wait for input/result?
|
|
95
|
+
Done: which fronts can be summarized or omitted?
|
|
96
|
+
Pointers: where can I re-check authoritative details?
|
|
97
|
+
Next: what is the immediate action after compacting?
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Handling returned results
|
|
101
|
+
|
|
102
|
+
When a delayed result appears in the middle of another thread:
|
|
103
|
+
|
|
104
|
+
1. **Capture:** identify which front it belongs to and summarize its result.
|
|
105
|
+
2. **Classify:** progress, stable completion, failure, decision needed, or noise.
|
|
106
|
+
3. **Choose focus:** decide whether this result should interrupt the current active front. If not, park it.
|
|
107
|
+
4. **Compact if needed:** if switching to it or away from it would drag stale logs/retries forward, compact first.
|
|
108
|
+
5. **Continue:** resume the chosen active front from a clean working set.
|
|
109
|
+
|
|
110
|
+
## Example capsules
|
|
111
|
+
|
|
112
|
+
```text
|
|
113
|
+
Front: import-test-flake
|
|
114
|
+
Goal: fix flaky import tests.
|
|
115
|
+
State: reviewer returned findings.
|
|
116
|
+
Latest stable result: fixed sleeps were rejected; signed retry strategy is still viable.
|
|
117
|
+
Source pointers: branch retry-import-tests, log tmp/import-flake.log.
|
|
118
|
+
Pending input or trigger: decide whether to implement bounded retries.
|
|
119
|
+
Next action: if accepted, implement bounded retry and rerun targeted tests.
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
```text
|
|
123
|
+
Front: docs-build
|
|
124
|
+
Goal: validate generated documentation before publishing.
|
|
125
|
+
State: background build running.
|
|
126
|
+
Latest stable result: source edits complete; validation not yet known.
|
|
127
|
+
Source pointers: task docs-build, output dist/docs/.
|
|
128
|
+
Pending input or trigger: build exit status.
|
|
129
|
+
Next action: on success, summarize validation; on failure, inspect first build/link error.
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## Common mistakes
|
|
133
|
+
|
|
134
|
+
Avoid:
|
|
135
|
+
|
|
136
|
+
- treating async/subagent management as the goal instead of keeping the current agent's working set clear
|
|
137
|
+
- carrying several fronts raw at once
|
|
138
|
+
- copying externally recoverable status dumps instead of preserving reliable source pointers
|
|
139
|
+
- letting a returned result overwrite the user's current active request without deciding focus
|
|
140
|
+
- reporting status repeatedly while the real problem is that fronts are not summarized
|
|
141
|
+
- compacting away a front without preserving how to resume it
|
|
142
|
+
- avoiding a deep compact even though source pointers and capsules can restore the active state
|
|
143
|
+
- resuming from memory when a small front capsule would be safer
|
|
@@ -30,9 +30,10 @@ Both variants use the same context-management rhythm.
|
|
|
30
30
|
2. Create a checkpoint for the clean plan-ready state.
|
|
31
31
|
3. Execute one subtask or phase.
|
|
32
32
|
4. If that subtask becomes noisy, let it get noisy locally.
|
|
33
|
-
5. Once the subtask produces a stable takeaway,
|
|
34
|
-
6. Continue with the next subtask from
|
|
33
|
+
5. Once the subtask produces a stable takeaway and another subtask or phase remains, compact to the anchor that gives the next subtask the cleanest sufficient working set, often the plan-ready or phase-start anchor.
|
|
34
|
+
6. Continue with the next subtask from that focused working set.
|
|
35
35
|
7. If the plan changes materially, checkpoint the updated plan state again.
|
|
36
|
+
8. If the last subtask completes the user's whole request, give the final answer without an automatic compact; decide on cleanup at the next user message if the conversation continues.
|
|
36
37
|
|
|
37
38
|
## Useful anchors
|
|
38
39
|
|
|
@@ -49,16 +50,17 @@ Run `context_timeline` when:
|
|
|
49
50
|
- several subtasks have already been executed
|
|
50
51
|
- the plan has changed more than once
|
|
51
52
|
- multiple branches now exist under the same plan
|
|
52
|
-
- you are unsure whether
|
|
53
|
+
- you are unsure whether the next subtask needs the overall plan, the current phase context, or only a summary
|
|
53
54
|
|
|
54
|
-
## When to
|
|
55
|
+
## When to compact
|
|
55
56
|
|
|
56
|
-
|
|
57
|
-
- a subtask is complete and its raw execution path is no longer worth keeping active
|
|
57
|
+
Compact when:
|
|
58
|
+
- a subtask is complete, another subtask remains, and its raw execution path is no longer worth keeping active
|
|
58
59
|
- a phase finished and the next phase should start from a cleaner state
|
|
59
60
|
- the plan remains valid but the current execution segment has become noisy
|
|
61
|
+
- a later user message starts a new task after the plan-driven task completed noisily
|
|
60
62
|
|
|
61
|
-
Do not
|
|
63
|
+
Do not compact just because a todo list exists. Compact when a specific execution segment has already served its purpose and can be compacted for an actual continuation. If the segment changed files, launched/stopped processes, or updated external systems, record those side effects in the summary; context navigation does not revert them.
|
|
62
64
|
|
|
63
65
|
## Replan
|
|
64
66
|
|
|
@@ -73,7 +75,7 @@ If the plan change is driven by failed branches or strategy shifts, also read `r
|
|
|
73
75
|
## Common mistakes
|
|
74
76
|
|
|
75
77
|
Avoid:
|
|
76
|
-
- keeping every finished subtask's raw reasoning active
|
|
77
|
-
-
|
|
78
|
+
- keeping every finished subtask's raw reasoning active instead of preserving only the reusable state
|
|
79
|
+
- choosing an anchor that drops the current plan state without preserving it in the summary
|
|
78
80
|
- failing to checkpoint the updated plan after a major replan
|
|
79
81
|
- confusing repeated-item work with plan-driven work when the subtasks are actually different in nature
|
|
@@ -14,10 +14,10 @@ Use this reference when the items are similar enough that the same method should
|
|
|
14
14
|
1. Create a checkpoint at the start of the overall repeated-item task.
|
|
15
15
|
2. If item 1 teaches you a reusable approach, checkpoint again after that approach becomes clear.
|
|
16
16
|
3. Work item by item.
|
|
17
|
-
4.
|
|
17
|
+
4. Compact after each completed item or completed mini-phase when another item remains and the raw path is no longer worth carrying forward.
|
|
18
18
|
5. Use timeline occasionally to verify that the history still has a clean structure.
|
|
19
19
|
|
|
20
|
-
For repeated-item work, the default
|
|
20
|
+
For repeated-item work, the default between-item move is not "keep carrying the last item's raw reasoning". Once an item is done, its takeaway is stable, and another item remains, compact to the repeated-work anchor or other baseline that preserves the reusable method without item-specific noise. If the last item completes the whole user request, deliver the final answer and wait for the next user message before deciding whether to compact.
|
|
21
21
|
|
|
22
22
|
## Useful anchors
|
|
23
23
|
|
|
@@ -31,16 +31,17 @@ Example checkpoint names:
|
|
|
31
31
|
|
|
32
32
|
Run `context_timeline` when:
|
|
33
33
|
- several items have already been processed
|
|
34
|
-
- item-level work has created multiple branches or
|
|
34
|
+
- item-level work has created multiple branches or compactions
|
|
35
35
|
- you want to confirm that the overall pattern still looks clean
|
|
36
36
|
- you are about to choose which anchor repeated work should keep returning to
|
|
37
37
|
|
|
38
|
-
## When to
|
|
38
|
+
## When to compact
|
|
39
39
|
|
|
40
|
-
|
|
41
|
-
- a representative item produced a reusable method
|
|
42
|
-
- a single item is complete and the raw path should be compacted
|
|
40
|
+
Compact after:
|
|
41
|
+
- a representative item produced a reusable method and the batch will continue
|
|
42
|
+
- a single item is complete, another item remains, and the raw path should be compacted
|
|
43
43
|
- an item-specific dead end is understood and should not remain active in full
|
|
44
|
+
- a new user message arrives after the batch completed, and the batch's raw path is stale baggage for the new task
|
|
44
45
|
|
|
45
46
|
## Example rhythm
|
|
46
47
|
|
|
@@ -53,16 +54,16 @@ context_checkpoint({ name: "vendor-review-method-clear" });
|
|
|
53
54
|
|
|
54
55
|
// ... process another item ...
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
context_compact({
|
|
57
58
|
target: "vendor-review-method-clear",
|
|
58
|
-
|
|
59
|
+
summary: "Current task: continue the vendor review batch. State: one more vendor review is complete; item-specific reasoning no longer needs to stay raw. Reusable method remains the active baseline. Next step: process the next vendor using the same method.",
|
|
59
60
|
backupCheckpoint: "vendor-review-item-7-history"
|
|
60
61
|
});
|
|
61
62
|
```
|
|
62
63
|
|
|
63
64
|
## Warning signs
|
|
64
65
|
|
|
65
|
-
Use stronger checkpoint/timeline/
|
|
66
|
+
Use stronger checkpoint/timeline/compact discipline when:
|
|
66
67
|
- each item creates lots of local reasoning
|
|
67
68
|
- you are starting to confuse one item's path with another's
|
|
68
69
|
- the repeated work is stretching across many turns
|
|
@@ -5,7 +5,7 @@ Use this reference when multiple approaches are being tried and abandoned cleanl
|
|
|
5
5
|
- failed branches that should not pollute the main line
|
|
6
6
|
- compare-and-choose work
|
|
7
7
|
- strategy pivots or goal shifts
|
|
8
|
-
- restarting from a
|
|
8
|
+
- restarting from a focused working set after a dead end
|
|
9
9
|
|
|
10
10
|
This is a **cross-cutting pattern reference**. Read it alongside a primary reference such as search/research, development/troubleshooting, or planning/execution when branch behavior becomes central.
|
|
11
11
|
|
|
@@ -14,24 +14,32 @@ This is a **cross-cutting pattern reference**. Read it alongside a primary refer
|
|
|
14
14
|
1. Checkpoint before opening a risky branch or alternative path.
|
|
15
15
|
2. Explore or implement that branch.
|
|
16
16
|
3. If anchor choice becomes unclear, inspect timeline.
|
|
17
|
-
4. Once the branch produces a stable lesson, decision, or dead-end,
|
|
18
|
-
5. Continue with the next branch or the chosen direction from that
|
|
17
|
+
4. Once the branch produces a stable lesson, decision, or dead-end, compact to the anchor that removes branch noise while preserving the state needed for the next attempt.
|
|
18
|
+
5. Continue with the next branch or the chosen direction from that focused state.
|
|
19
19
|
|
|
20
20
|
## When to review timeline
|
|
21
21
|
|
|
22
22
|
Run `context_timeline` when:
|
|
23
23
|
- multiple branches now exist
|
|
24
24
|
- you are unsure which branch actually stayed useful
|
|
25
|
-
- you need to choose
|
|
25
|
+
- you need to choose which pre-branch or older anchor gives the next attempt the best working set
|
|
26
26
|
- the next direction is clear but the old branch still clutters active context
|
|
27
27
|
|
|
28
|
-
## When to
|
|
28
|
+
## When to compact
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
Compact when:
|
|
31
31
|
- a branch clearly failed
|
|
32
32
|
- a comparison is complete and one option won
|
|
33
33
|
- the direction changed enough that the old path is now baggage
|
|
34
|
-
- the next attempt should start from a
|
|
34
|
+
- the next attempt should start from a focused state rather than the raw failed branch
|
|
35
|
+
|
|
36
|
+
When compacting after an abandoned branch, preserve:
|
|
37
|
+
|
|
38
|
+
- what was tried
|
|
39
|
+
- why it failed or was rejected
|
|
40
|
+
- what should not be repeated
|
|
41
|
+
- what remains valid
|
|
42
|
+
- the chosen next approach
|
|
35
43
|
|
|
36
44
|
## Strategy pivot
|
|
37
45
|
|
|
@@ -44,7 +52,7 @@ Examples:
|
|
|
44
52
|
|
|
45
53
|
In these cases:
|
|
46
54
|
- summarize what still matters
|
|
47
|
-
-
|
|
55
|
+
- compact to the anchor that removes the stale branch while preserving current task state
|
|
48
56
|
- continue under the new direction
|
|
49
57
|
|
|
50
58
|
## Example rhythm
|
|
@@ -54,9 +62,9 @@ context_checkpoint({ name: "oauth-fix-start" });
|
|
|
54
62
|
|
|
55
63
|
// ... try cookie-based approach ...
|
|
56
64
|
|
|
57
|
-
|
|
65
|
+
context_compact({
|
|
58
66
|
target: "oauth-fix-start",
|
|
59
|
-
|
|
67
|
+
summary: "Current task: continue the OAuth fix with a new approach. State: cookie-based approach is not viable because the callback flow loses session continuity. Rejected path: do not repeat cookie-based continuity for this flow. Still valid: callback validation and provider config findings. Decision: switch to signed state tokens. Next step: implement the signed-state approach.",
|
|
60
68
|
backupCheckpoint: "oauth-cookie-approach-history"
|
|
61
69
|
});
|
|
62
70
|
context_checkpoint({ name: "oauth-signed-state-start" });
|
|
@@ -67,5 +75,6 @@ context_checkpoint({ name: "oauth-signed-state-start" });
|
|
|
67
75
|
Avoid:
|
|
68
76
|
- opening alternative branches without a clean checkpoint first
|
|
69
77
|
- dragging failed branches forward after their lesson is already clear
|
|
70
|
-
-
|
|
78
|
+
- omitting the rejected path, failure reason, or chosen replacement from the compact summary
|
|
79
|
+
- compacting to a point that still includes the branch you meant to abandon
|
|
71
80
|
- treating every branch as equally worth preserving
|
|
@@ -17,10 +17,12 @@ This reference is for **input-heavy work where the process is much larger than t
|
|
|
17
17
|
1. Create a checkpoint before a large search or reading loop.
|
|
18
18
|
2. Search, browse, read, inspect, and follow leads normally.
|
|
19
19
|
3. If you lose orientation, review the timeline.
|
|
20
|
-
4. Once the investigation yields a stable finding,
|
|
21
|
-
5. Continue with the conclusion, recommendation, or next action instead of carrying the entire raw exploration forward.
|
|
20
|
+
4. Once the investigation yields a stable finding and there is another step to take, compact to the anchor that gives the next step a focused working set.
|
|
21
|
+
5. Continue with the conclusion, recommendation, or next action instead of carrying the entire raw exploration forward. If the finding is the final answer to the user's current request, answer first and wait; compact on the next user message if it starts new work.
|
|
22
22
|
|
|
23
|
-
Do not stop at "I already made a checkpoint" if the investigation phase is
|
|
23
|
+
Do not stop at "I already made a checkpoint" if the investigation phase is complete and the conversation is continuing. The cleanup move for completed research is usually a compact to the anchor that preserves only the raw context the next step still needs.
|
|
24
|
+
|
|
25
|
+
**Important:** “another step” includes the next phase of the same request. If you searched to find the right data source, previous task record, API shape, rule id, or query pattern, then the next execution step (running the real query/export, implementing, validating, etc.) is an immediate continuation. Compact before that execution step, not only before a future user message.
|
|
24
26
|
|
|
25
27
|
## When to checkpoint
|
|
26
28
|
|
|
@@ -44,17 +46,34 @@ Run `context_timeline` when:
|
|
|
44
46
|
- the investigation has already produced multiple checkpoints
|
|
45
47
|
- you are deciding which path should be compacted
|
|
46
48
|
|
|
47
|
-
## When to
|
|
49
|
+
## When to compact
|
|
48
50
|
|
|
49
|
-
|
|
51
|
+
Compact after the investigation produces one of these and there is a continuation that benefits from cleanup:
|
|
50
52
|
- a stable root cause
|
|
51
53
|
- a stable comparison result
|
|
52
54
|
- a dead-end conclusion
|
|
53
55
|
- a shortlist of viable next actions
|
|
56
|
+
- a located data source, old conversation, schema, rule id, query/API pattern, or other fact that unlocks execution
|
|
57
|
+
|
|
58
|
+
If you already have one of these, the investigation phase is usually complete enough to compact. If the next step is to use the finding in another tool call, compact first. If there is no continuation yet because you are about to give the final answer, wait until the next user message before deciding.
|
|
59
|
+
|
|
60
|
+
Do not compact in the middle of a still-open search loop just because the thread feels busy.
|
|
61
|
+
|
|
62
|
+
## Message quality for research compactions
|
|
63
|
+
|
|
64
|
+
Research compactions are especially sensitive to summary quality. The raw exploration may contain details that become important later, but returning to the backup branch is a context switch. Preserve the state needed to use the finding, not the whole journey.
|
|
54
65
|
|
|
55
|
-
|
|
66
|
+
Include:
|
|
67
|
+
- **Current task/state:** what the research unlocked and how it will be used next
|
|
68
|
+
- **Finding:** what is now known
|
|
69
|
+
- **Source anchors:** key files, URLs, docs, sessions, commands, queries, or records used to reach the finding
|
|
70
|
+
- **Evidence:** important numbers, errors, examples, IDs, or constraints that support the finding
|
|
71
|
+
- **Rejected leads:** only expensive dead ends that future-you should not repeat
|
|
72
|
+
- **Open questions:** what is still uncertain
|
|
73
|
+
- **Next step:** what to do immediately after compact
|
|
74
|
+
- **Backup pointer:** if `backupCheckpoint` is set, when to return to it
|
|
56
75
|
|
|
57
|
-
Do not
|
|
76
|
+
Do not compress research to only “found the answer”. That forces future-you to either trust an unsupported conclusion or switch back to the backup for basic details.
|
|
58
77
|
|
|
59
78
|
## Typical rhythm
|
|
60
79
|
|
|
@@ -63,17 +82,19 @@ context_checkpoint({ name: "timeout-investigation-start" });
|
|
|
63
82
|
|
|
64
83
|
// ... search logs, read code, compare docs, inspect outputs ...
|
|
65
84
|
|
|
85
|
+
// Stable finding found and the next action is execution/validation, so compact before continuing.
|
|
66
86
|
context_timeline();
|
|
67
87
|
|
|
68
|
-
|
|
88
|
+
context_compact({
|
|
69
89
|
target: "timeout-investigation-start",
|
|
70
|
-
|
|
90
|
+
backupCheckpoint: "timeout-investigation-raw-history",
|
|
91
|
+
summary: "Current task: plan mitigation for API timeouts. State: DB connection pool exhaustion is the likely root cause. Evidence: logs show pool wait timeouts during peak traffic; config has pool size 10; no network errors found in the checked logs. Rejected lead: API gateway timeout was downstream of DB waits, not the origin. Backup: timeout-investigation-raw-history if exact log lines are needed. Next step: propose mitigation and validation steps."
|
|
71
92
|
});
|
|
72
93
|
```
|
|
73
94
|
|
|
74
|
-
## Good
|
|
95
|
+
## Good compact outcomes
|
|
75
96
|
|
|
76
|
-
After
|
|
97
|
+
After compacting, you should be able to continue with:
|
|
77
98
|
- the finding
|
|
78
99
|
- the recommendation
|
|
79
100
|
- the next verification step
|
|
@@ -2,29 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
Use this reference when the main problem is not the task domain itself, but a change in thread state, such as:
|
|
4
4
|
- the user inserts a temporary side task
|
|
5
|
+
- the user starts a new task after a completed noisy task
|
|
5
6
|
- you need to pause one line of work and resume it later
|
|
6
7
|
- several active fronts now exist
|
|
7
8
|
- the thread is already messy and needs cleanup before continuing
|
|
8
|
-
- a finished noisy phase should be summarized and left behind
|
|
9
|
+
- a finished noisy phase should be summarized and left behind before new work starts
|
|
9
10
|
|
|
10
11
|
This reference is for **pause/resume, cleanup, and clean continuation**. It is not for repeated similar items or plan-driven execution.
|
|
11
12
|
|
|
12
|
-
##
|
|
13
|
+
## Three common variants
|
|
13
14
|
|
|
14
15
|
### Interruption / task switch
|
|
15
16
|
Use when you are actively switching away from one line of work and intend to come back.
|
|
16
17
|
|
|
18
|
+
### Completed-task handoff
|
|
19
|
+
Use when a previous task is complete, the user has now said something new, and the previous task's raw path is noisy enough that it should not be carried into the new work.
|
|
20
|
+
|
|
17
21
|
### Cleanup and continue
|
|
18
22
|
Use when the thread is already stale or messy and you want to compress it now, even though context management is being adopted late.
|
|
19
23
|
|
|
20
24
|
## Working pattern
|
|
21
25
|
|
|
22
26
|
1. Inspect timeline if anchor choice is unclear.
|
|
23
|
-
2. Before switching away or compacting a noisy path, preserve the
|
|
27
|
+
2. Before switching away or compacting a noisy path, preserve or choose the anchor that will give the resumed/new task a clean working set.
|
|
24
28
|
3. If needed, create a backup checkpoint for the current noisy branch.
|
|
25
|
-
4.
|
|
26
|
-
5.
|
|
27
|
-
6.
|
|
29
|
+
4. If the user has just started a new task after a completed noisy task, compact before doing the new task so the completed task becomes a compact summary rather than active baggage.
|
|
30
|
+
5. If the user asks a concrete side question while noisy mainline work is active, pause or summarize the active work, compact if the raw mainline history is no longer needed for the side question, answer the side question, and preserve how to resume the paused work.
|
|
31
|
+
6. Handle the side task or cleanup move.
|
|
32
|
+
7. Compact away the stale path when the handoff summary is clear.
|
|
33
|
+
8. Resume from the paused anchor or continue from the compacted state.
|
|
28
34
|
|
|
29
35
|
## Useful anchors
|
|
30
36
|
|
|
@@ -40,24 +46,28 @@ Run `context_timeline` when:
|
|
|
40
46
|
- multiple interruptions happened
|
|
41
47
|
- the pause lasted many turns
|
|
42
48
|
- several side-task branches now exist
|
|
43
|
-
- you are unsure which
|
|
49
|
+
- you are unsure which anchor gives the resumed/new task the right working set
|
|
44
50
|
- the thread is already messy and you need to find the right pre-noise checkpoint
|
|
45
51
|
|
|
46
|
-
## When to
|
|
52
|
+
## When to compact
|
|
47
53
|
|
|
48
|
-
|
|
54
|
+
Compact when:
|
|
49
55
|
- the interruption created lots of noise
|
|
50
56
|
- the side task is done and should not stay active in full
|
|
57
|
+
- the user begins a new task after a completed noisy task and the previous raw path is no longer useful in full
|
|
51
58
|
- a stale path is making current reasoning worse
|
|
52
59
|
- the useful state is now much smaller than the accumulated process
|
|
53
|
-
- you can express the
|
|
60
|
+
- you can express the handoff clearly in a summary
|
|
54
61
|
|
|
55
|
-
If the interruption was tiny and clean, a
|
|
62
|
+
Do not compact at the instant you finish a user-visible task if there is no known continuation. In that moment, deliver the answer and wait. If the next user message starts a new task, that is the right time to compact the completed task before proceeding. If the completed task changed files, browser state, tickets, or remote services, include those side effects in the handoff summary because the context move does not undo them. If the interruption was tiny and clean, a compact may be unnecessary. A checkpoint before switching away is still the key move.
|
|
56
63
|
|
|
57
64
|
## Common mistakes
|
|
58
65
|
|
|
59
66
|
Avoid:
|
|
60
67
|
- switching away without a pause checkpoint
|
|
68
|
+
- compacting immediately after a final answer just because the task completed
|
|
69
|
+
- starting a new, unrelated user task while still carrying the previous task's full raw path
|
|
61
70
|
- returning to the main line while still carrying the side task's full raw path
|
|
62
71
|
- trying to clean up without first checking timeline when anchor choice is unclear
|
|
63
|
-
-
|
|
72
|
+
- resetting past still-valid near-term context without carrying it in the summary
|
|
73
|
+
- forgetting that files and external systems remain in their latest state after context navigation
|