@foliox/transparent-compact-pi 0.11.3 → 0.11.4
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/docs/DESIGN.md +22 -38
- package/extensions/index.ts +12 -63
- package/package.json +1 -1
- package/skills/context-retrieval/SKILL.md +5 -46
package/docs/DESIGN.md
CHANGED
|
@@ -111,11 +111,8 @@ unchanged; their presentation in a later checkpoint may tighten under budget pre
|
|
|
111
111
|
|
|
112
112
|
When omitted observations, payloads, or provenance are needed, prefer
|
|
113
113
|
`context_lookup` with a specific historical question. Recovery results supply
|
|
114
|
-
ENTRY ids for targeted follow-up. For
|
|
115
|
-
|
|
116
|
-
remains a `context_lookup` task.
|
|
117
|
-
The list/grep tools remain fallbacks when lookup findings are incomplete. For
|
|
118
|
-
current state, inspect files. There is no required-document reread checklist.
|
|
114
|
+
ENTRY ids for targeted follow-up questions. For current state, inspect files.
|
|
115
|
+
There is no required-document reread checklist.
|
|
119
116
|
|
|
120
117
|
All newly compacted custom messages follow the same stub policy, regardless of
|
|
121
118
|
extension, display setting, or content format. Long type names are abbreviated
|
|
@@ -431,9 +428,9 @@ attribution.
|
|
|
431
428
|
|
|
432
429
|
The subagent uses three internal tools: `list_entries`, `grep`, and `show_entry`.
|
|
433
430
|
These search the rendered lines directly, so no temporary file, second session
|
|
434
|
-
copy, or cleanup is needed.
|
|
435
|
-
|
|
436
|
-
|
|
431
|
+
copy, or cleanup is needed. Individual results and the final answer have size
|
|
432
|
+
limits. Follow pages only when omitted content is needed, not to exhaust every
|
|
433
|
+
match or entry.
|
|
437
434
|
|
|
438
435
|
The default substantive search budget is 25 turns. Valid continuation-only turns
|
|
439
436
|
do not spend it; new queries, changed parameters, or replayed cursors do. A separate
|
|
@@ -442,7 +439,7 @@ ceiling caps all search-phase model calls at three times the configured turn bud
|
|
|
442
439
|
search counts. When either budget ends searching, one final tool-free model call
|
|
443
440
|
writes up partial findings; a failed write-up falls back to the latest text,
|
|
444
441
|
explicitly labeled incomplete. A plain-text answer after the paging-only budget
|
|
445
|
-
warning also carries an incomplete-findings marker
|
|
442
|
+
warning also carries an incomplete-findings marker, without
|
|
446
443
|
an extra write-up call. Both normal-answer and forced-write-up instructions distinguish
|
|
447
444
|
unreached evidence from absence: an incomplete search does not establish that the
|
|
448
445
|
answer was never recorded. Lookup requests use normal provider caching
|
|
@@ -480,14 +477,11 @@ files through filesystem tools. This restriction does not apply to user-requeste
|
|
|
480
477
|
session audits, debugging, or cross-session analysis, which can use ordinary file
|
|
481
478
|
tools. Lookup itself still cannot search other sessions or abandoned branches.
|
|
482
479
|
|
|
483
|
-
The extension registers
|
|
480
|
+
The extension registers one main-agent recovery tool:
|
|
484
481
|
|
|
485
482
|
| Tool | Purpose |
|
|
486
483
|
|---|---|
|
|
487
484
|
| `context_lookup` | Recover outputs, findings, decisions, reasoning, and provenance hidden by compaction, including conflicts with new evidence. A subagent searches the raw branch and returns relevant findings. Accepts only `question`. |
|
|
488
|
-
| `context_list_entries` | Post-compaction fallback: list raw session ENTRY headers and previews. |
|
|
489
|
-
| `context_grep` | Post-compaction fallback: regex-search raw history, including thinking and tool outputs, with entry attribution. |
|
|
490
|
-
| `context_show_entry` | Recover a specific detail hidden by compaction at a known ENTRY id, or after lookup. Optional `includeRelated` recovers matched call/result entries only when that counterpart is needed. |
|
|
491
485
|
|
|
492
486
|
For example, ask the agent to recover the build error observed before compaction.
|
|
493
487
|
It can call `context_lookup` with:
|
|
@@ -498,26 +492,18 @@ It can call `context_lookup` with:
|
|
|
498
492
|
}
|
|
499
493
|
```
|
|
500
494
|
|
|
501
|
-
ENTRY ids returned by
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
Lookup, listing, and grep use concise capability-oriented advertisements. The
|
|
505
|
-
`context_show_entry` advertisement retains small-first retrieval and continuation
|
|
506
|
-
only while the requested detail is missing, incomplete, or needs more context to
|
|
507
|
-
resolve ambiguity; stop once the question is answered. The skill retains bounded
|
|
508
|
-
recovery guidance, including that a partial search does not establish absence.
|
|
509
|
-
Advertisement changes do not change payload limits, defaults, or retrieval behavior,
|
|
510
|
-
and do not guarantee small total responses. No automatic decision sweep or new
|
|
511
|
-
re-orientation instruction is added.
|
|
495
|
+
ENTRY ids returned by lookup can narrow subsequent `context_lookup` questions.
|
|
496
|
+
The skill explains recovery scope and limitations, including that a partial
|
|
497
|
+
search does not establish absence.
|
|
512
498
|
|
|
513
499
|
Ordinary entry retrieval defaults to `includeRelated=false`. Related expansion
|
|
514
|
-
|
|
515
|
-
|
|
500
|
+
is available to the subagent; it is one-hop and chronological: a result includes
|
|
501
|
+
its originating assistant entry (including any
|
|
516
502
|
sibling calls), not sibling outputs; an assistant includes its matched results.
|
|
517
503
|
Relations come from raw call IDs and matching tool names, never transcript text.
|
|
518
504
|
Ambiguous duplicate IDs, orphan results, and mismatched tool names do not establish
|
|
519
505
|
relations. Sequential ID reuse is matched separately. Branch scoping and source
|
|
520
|
-
overrides apply
|
|
506
|
+
overrides apply to both single-entry and related-entry retrieval.
|
|
521
507
|
|
|
522
508
|
Related expansions share the usual character/line guards. Keep `includeRelated`
|
|
523
509
|
unchanged when following an offset; changing it starts a different retrieval and
|
|
@@ -525,17 +511,15 @@ spends a substantive subagent search turn. An expansion of an unfinished call ma
|
|
|
525
511
|
change if results arrive later; restart paging if its source changes.
|
|
526
512
|
|
|
527
513
|
The subagent searches in its own context and returns findings with entry
|
|
528
|
-
references. Its raw search results stay out of the main conversation.
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
calls from bypassing the limit. Blocked attempts return a short fallback note
|
|
538
|
-
without launching a subagent; later lookups after other work remain available.
|
|
514
|
+
references. Its raw search results stay out of the main conversation.
|
|
515
|
+
Budget-limited findings retain an incomplete marker even if the write-up fails.
|
|
516
|
+
|
|
517
|
+
By default, three consecutive `context_lookup` attempts are allowed until a user
|
|
518
|
+
message, a bash execution, or another tool's result resets the limit. Assistant
|
|
519
|
+
text and thinking neither increase nor reset the count. Pending lookup calls in
|
|
520
|
+
the same batch also count, preventing parallel calls from bypassing the limit.
|
|
521
|
+
Blocked attempts return a short limit notice without launching a subagent;
|
|
522
|
+
later lookups after other work remain available.
|
|
539
523
|
|
|
540
524
|
### Instruction envelope and persistent re-orientation
|
|
541
525
|
|
package/extensions/index.ts
CHANGED
|
@@ -855,12 +855,12 @@ const REORIENT_BLOCK = `**Post-compaction re-orientation.** ${RECOVERY_HISTORY_N
|
|
|
855
855
|
const REVISION_NOTE_PREFIX = "- Checkpoint context revised: ";
|
|
856
856
|
const CHECKPOINT_EXPLANATION = `**Compacted conversation follows.** The earlier part of this conversation has been compacted into the checkpoint below. This is not the full transcript. ${RECOVERY_HISTORY_NOTE}`;
|
|
857
857
|
|
|
858
|
-
const RECOVERY_INSTRUCTIONS = `**Recovering hidden details.** Use \`context_lookup\` with a specific historical question: a subagent searches this conversation's full session history and returns relevant findings. Use the recovery tools for history established by this conversation or its checkpoint, not for project discovery or exploration of other sessions
|
|
858
|
+
const RECOVERY_INSTRUCTIONS = `**Recovering hidden details.** Use \`context_lookup\` with a specific historical question: a subagent searches this conversation's full session history and returns relevant findings. Use the recovery tools for history established by this conversation or its checkpoint, not for project discovery or exploration of other sessions.`;
|
|
859
859
|
|
|
860
860
|
const EVIDENCE_BOUNDARY_RULE = "**Evidence boundary:** Tool stubs omit supporting details. Most output and detailed payloads are omitted. Inline observations are historical, not verification of unshown details or current state. Use `context_lookup` for omitted observations or provenance; inspect sources for current state.";
|
|
861
861
|
|
|
862
862
|
const REORIENT_MESSAGE = "transparent-compact:reorient";
|
|
863
|
-
const RECOVERY_RECAP = `**Recovery recap.** ${RECOVERY_SCOPE_RULE} For unfamiliar project details or missing requirements, inspect project files or ask the user instead.
|
|
863
|
+
const RECOVERY_RECAP = `**Recovery recap.** ${RECOVERY_SCOPE_RULE} For unfamiliar project details or missing requirements, inspect project files or ask the user instead. ${RECOVERY_FILESYSTEM_RULE} Keep these evidence/recovery rules in force as work continues.`;
|
|
864
864
|
|
|
865
865
|
function latestVerbatimCompaction(entries: SessionEntry[]) {
|
|
866
866
|
for (let i = entries.length - 1; i >= 0; i--) {
|
|
@@ -1246,8 +1246,7 @@ function showEntry(transcripts: Transcript[], opts: { id: string; includeRelated
|
|
|
1246
1246
|
}) : `No entry with id "${opts.id}" found.`;
|
|
1247
1247
|
}
|
|
1248
1248
|
|
|
1249
|
-
//
|
|
1250
|
-
// subagent accepts a logical transcript name (not a filesystem path).
|
|
1249
|
+
// Subagent paging parameters use logical transcript names, not filesystem paths.
|
|
1251
1250
|
const OFFSET_FIELD = Type.Optional(Type.Integer({ minimum: 0, description: "Character offset (UTF-16 units, default 0). Use the next offset reported by the previous page." }));
|
|
1252
1251
|
const FILE_FIELD = Type.Optional(Type.String({ description: "Logical transcript name. Omit for all." }));
|
|
1253
1252
|
const THROUGH_ENTRY_FIELD = Type.Optional(Type.String({ description: "Last ENTRY id included in this paginated listing/search. Keep the reported throughEntry on subsequent pages to exclude newly appended calls/results; omit to start a fresh search." }));
|
|
@@ -1268,15 +1267,12 @@ const SHOW_FIELDS = {
|
|
|
1268
1267
|
offset: OFFSET_FIELD,
|
|
1269
1268
|
};
|
|
1270
1269
|
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
// Append outside the truncated findings so the next-step guidance survives
|
|
1275
|
-
// even a long write-up. Normal successful answers remain unchanged.
|
|
1270
|
+
// Keep the incomplete-findings marker outside the truncated write-up.
|
|
1271
|
+
// Normal successful answers remain unchanged.
|
|
1276
1272
|
function lookupPartialFindings(text: string, marker: string): string {
|
|
1277
1273
|
const status = truncateHead(marker, 1_000); // Provider error messages can be large too.
|
|
1278
|
-
const budget = cfg.lookupAnswerMaxChars - status.length -
|
|
1279
|
-
return `${truncateHead(text, budget)}\n${status}
|
|
1274
|
+
const budget = cfg.lookupAnswerMaxChars - status.length - 1;
|
|
1275
|
+
return `${truncateHead(text, budget)}\n${status}`;
|
|
1280
1276
|
}
|
|
1281
1277
|
|
|
1282
1278
|
const LOOKUP_WRITEUP_PROMPT =
|
|
@@ -1509,13 +1505,11 @@ function sessionTranscript(ctx: { sessionManager: { getBranch: () => SessionEntr
|
|
|
1509
1505
|
}
|
|
1510
1506
|
|
|
1511
1507
|
// ============================================================================
|
|
1512
|
-
// Main-agent
|
|
1508
|
+
// Main-agent lookup admission
|
|
1513
1509
|
// ============================================================================
|
|
1514
1510
|
|
|
1515
|
-
const FALLBACK_TOOL_NAMES = new Set(["context_list_entries", "context_grep", "context_show_entry"]);
|
|
1516
|
-
|
|
1517
1511
|
/** Count prior lookup attempts since the last user/ordinary-work/bash boundary.
|
|
1518
|
-
*
|
|
1512
|
+
* Text and thinking neither increase nor reset the count. Deduplicate call/result ids, and include
|
|
1519
1513
|
* earlier siblings in the current assistant message even before results exist:
|
|
1520
1514
|
* two parallel lookups cannot both claim the first slot. Later siblings are
|
|
1521
1515
|
* excluded. Raw branch state follows reload, resume, compaction, and forks. */
|
|
@@ -1528,11 +1522,10 @@ function consecutiveLookups(ctx: { sessionManager: { getBranch: () => SessionEnt
|
|
|
1528
1522
|
const m = e.message;
|
|
1529
1523
|
if (m.role === "user" || m.role === "bashExecution") break;
|
|
1530
1524
|
if (m.role === "toolResult") {
|
|
1531
|
-
if (FALLBACK_TOOL_NAMES.has(m.toolName)) continue;
|
|
1532
1525
|
if (m.toolName !== "context_lookup") break;
|
|
1533
1526
|
calls.add(m.toolCallId);
|
|
1534
1527
|
} else if (m.role === "assistant") {
|
|
1535
|
-
for (const b of m.content) {
|
|
1528
|
+
for (const b of m.content ?? []) {
|
|
1536
1529
|
if (b.type !== "toolCall") continue;
|
|
1537
1530
|
if (b.id === toolCallId) break;
|
|
1538
1531
|
if (b.name === "context_lookup") calls.add(b.id);
|
|
@@ -1542,49 +1535,6 @@ function consecutiveLookups(ctx: { sessionManager: { getBranch: () => SessionEnt
|
|
|
1542
1535
|
return calls.size;
|
|
1543
1536
|
}
|
|
1544
1537
|
|
|
1545
|
-
function registerDirectTools(pi: ExtensionAPI): void {
|
|
1546
|
-
const pre = "Fallback after context_lookup, when its findings are incomplete; same scope as context_lookup. ";
|
|
1547
|
-
const run = (ctx: { sessionManager: { getBranch: () => SessionEntry[] } }, f: (t: Transcript[]) => string) => {
|
|
1548
|
-
try {
|
|
1549
|
-
const transcript = sessionTranscript(ctx);
|
|
1550
|
-
if (transcript.index.length === 0) return { content: [{ type: "text" as const, text: "No entries found on the session branch." }], details: undefined };
|
|
1551
|
-
return { content: [{ type: "text" as const, text: f([transcript]) }], details: undefined };
|
|
1552
|
-
} catch (err) {
|
|
1553
|
-
return { content: [{ type: "text" as const, text: `Tool error: ${errMsg(err)}` }], details: undefined };
|
|
1554
|
-
}
|
|
1555
|
-
};
|
|
1556
|
-
pi.registerTool({
|
|
1557
|
-
name: "context_list_entries",
|
|
1558
|
-
label: "Context: list entries",
|
|
1559
|
-
description: pre + "List raw session ENTRY headers and previews, including compacted entries, in pages of up to 12000 payload characters, plus cursor notes. Follow all reported continuation parameters (offset and throughEntry).",
|
|
1560
|
-
promptSnippet: "Fallback: list this conversation's entries for post-compaction recovery",
|
|
1561
|
-
parameters: Type.Object(LIST_FIELDS),
|
|
1562
|
-
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
1563
|
-
return run(ctx, (t) => listEntries(t, params));
|
|
1564
|
-
},
|
|
1565
|
-
});
|
|
1566
|
-
pi.registerTool({
|
|
1567
|
-
name: "context_grep",
|
|
1568
|
-
label: "Context: grep",
|
|
1569
|
-
description: pre + "Regex-search the full raw session branch, including compacted thinking and tool outputs, with surrounding lines and entry attribution. pattern is a JS regex (case-insensitive). Up to 12000 payload characters per page, plus cursor notes. Follow all reported continuation parameters (offset, charOffset, throughEntry) for remaining matches or oversized lines. Historical thinking is not verified fact.",
|
|
1570
|
-
promptSnippet: "Fallback: search this conversation's evidence hidden by compaction",
|
|
1571
|
-
parameters: Type.Object(GREP_FIELDS),
|
|
1572
|
-
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
1573
|
-
return run(ctx, (t) => grepTranscript(t, params));
|
|
1574
|
-
},
|
|
1575
|
-
});
|
|
1576
|
-
pi.registerTool({
|
|
1577
|
-
name: "context_show_entry",
|
|
1578
|
-
label: "Context: show entry",
|
|
1579
|
-
description: "Read a known raw session entry to recover a specific detail hidden by compaction. Use an ENTRY id returned by context_lookup, context_grep, or context_list_entries. Prefer context_lookup when search or interpretation is needed; same scope as context_lookup. Start with a small maxLines. Optional includeRelated=true includes matched tool call/result entries; use it only if the counterpart is needed. Returns up to 24000 payload characters and maxLines lines per page, plus attribution/cursor notes; a page may not contain the entire entry. Continue with the reported offset only if the requested detail is missing, incomplete, or needs more context to resolve ambiguity, keeping includeRelated unchanged. Stop once the question is answered; do not expand surrounding history by default.",
|
|
1580
|
-
promptSnippet: "Recover a specific detail hidden by compaction at a known ENTRY id in this conversation.",
|
|
1581
|
-
parameters: Type.Object(SHOW_FIELDS),
|
|
1582
|
-
async execute(_toolCallId, params, _signal, _onUpdate, ctx) {
|
|
1583
|
-
return run(ctx, (t) => showEntry(t, params));
|
|
1584
|
-
},
|
|
1585
|
-
});
|
|
1586
|
-
}
|
|
1587
|
-
|
|
1588
1538
|
// ============================================================================
|
|
1589
1539
|
// Extension
|
|
1590
1540
|
// ============================================================================
|
|
@@ -2144,13 +2094,12 @@ export default function (pi: ExtensionAPI) {
|
|
|
2144
2094
|
// --------------------------------------------------------------------------
|
|
2145
2095
|
// context_lookup tool: subagent research over the raw session branch
|
|
2146
2096
|
// --------------------------------------------------------------------------
|
|
2147
|
-
registerDirectTools(pi);
|
|
2148
2097
|
pi.registerTool({
|
|
2149
2098
|
name: "context_lookup",
|
|
2150
2099
|
label: "Context lookup",
|
|
2151
2100
|
executionMode: "sequential",
|
|
2152
2101
|
description:
|
|
2153
|
-
`Retrieve earlier outputs, findings, decisions, and reasoning hidden by compaction. Ask \`context_lookup\` where an earlier finding came from, what a command actually printed, or why you reached a conclusion, especially when earlier notes conflict with new evidence. A subagent searches this conversation's full raw active branch in its own context and returns relevant findings. ${RECOVERY_SOURCE_GUIDANCE} ${RECOVERY_SCOPE_RULE}
|
|
2102
|
+
`Retrieve earlier outputs, findings, decisions, and reasoning hidden by compaction. Ask \`context_lookup\` where an earlier finding came from, what a command actually printed, or why you reached a conclusion, especially when earlier notes conflict with new evidence. A subagent searches this conversation's full raw active branch in its own context and returns relevant findings. ${RECOVERY_SOURCE_GUIDANCE} ${RECOVERY_SCOPE_RULE} ${RECOVERY_FILESYSTEM_RULE}`,
|
|
2154
2103
|
promptSnippet: "Retrieve earlier outputs, findings, decisions, and reasoning hidden by compaction, including the provenance of earlier conclusions",
|
|
2155
2104
|
parameters: Type.Object({
|
|
2156
2105
|
question: Type.String({ description: "A specific question about earlier in this conversation: an output, source of a finding, reason for a decision, or evidence behind notes that conflict with new observations." }),
|
|
@@ -2158,7 +2107,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
2158
2107
|
async execute(toolCallId, params, signal, _onUpdate, ctx) {
|
|
2159
2108
|
if (cfg.lookupMaxCalls > 0 && consecutiveLookups(ctx, toolCallId) >= cfg.lookupMaxCalls) {
|
|
2160
2109
|
return {
|
|
2161
|
-
content: [{ type: "text", text: `context_lookup consecutive-call limit reached (${cfg.lookupMaxCalls})
|
|
2110
|
+
content: [{ type: "text", text: `context_lookup consecutive-call limit reached (${cfg.lookupMaxCalls}).` }],
|
|
2162
2111
|
details: undefined,
|
|
2163
2112
|
};
|
|
2164
2113
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foliox/transparent-compact-pi",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.4",
|
|
4
4
|
"description": "Model-free, deterministic, and self-aware compaction; with session-backed subagent context recovery, and optional context pruning and fidelity controls.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -24,12 +24,11 @@ those tasks; use ordinary file tools as needed for the requested analysis.
|
|
|
24
24
|
This skill pairs with the `@foliox/transparent-compact-pi` extension, which provides:
|
|
25
25
|
|
|
26
26
|
- **Verbatim compaction** — a deterministic checkpoint retains user messages, assistant prose, and compact tool-call signatures. Thinking and most tool outputs are removed from the active model context, not from the raw session history. Explicitly selected read outputs remain verbatim in the checkpoint or uncompacted tail. Earlier spans are re-rendered flat, with recovery guidance before them and an evidence-boundary warning after them. Persistent task-relevant recovery reminders and a recap follow the retained tail; later compactions replace the old generated reminders rather than duplicating them. An inherited opaque base is kept when needed.
|
|
27
|
-
- **`context_lookup`** —
|
|
28
|
-
- **Bounded direct tools** — use `context_show_entry` for a specific detail hidden by compaction at a known ENTRY id returned by a recovery tool. If lookup findings are incomplete, use `context_list_entries` to locate an entry, `context_grep` to find a narrow passage, or `context_show_entry` to inspect a known entry. Their raw results enter this conversation; retrieve only what the question needs. For recovery of details hidden by compaction, these are the permitted direct tools, not filesystem access to session files.
|
|
27
|
+
- **`context_lookup`** — a subagent searches the full raw session branch in its **own** context and returns relevant findings. At lookup time, the extension mechanically renders the branch into entry-anchored text with an authoritative entry/section index, in memory.
|
|
29
28
|
|
|
30
29
|
Pi normally saves sessions under `~/.pi/agent/sessions/`; custom session locations also work. In-memory sessions retain history only while the process lives and cannot be resumed after exit.
|
|
31
30
|
|
|
32
|
-
If `context_lookup` is not in your tool list,
|
|
31
|
+
If `context_lookup` is not in your tool list, report that recovery is unavailable. Do not search session files manually for compaction recovery.
|
|
33
32
|
|
|
34
33
|
## When to use
|
|
35
34
|
|
|
@@ -60,60 +59,20 @@ context_lookup({ question: "What exact error did the earlier test run return for
|
|
|
60
59
|
```
|
|
61
60
|
|
|
62
61
|
You may include an ENTRY id from an earlier recovery result in the question to
|
|
63
|
-
narrow the search.
|
|
64
|
-
passage, `context_show_entry` can read that entry directly. Prefer
|
|
65
|
-
`context_lookup` when search or interpretation is needed. For post-compaction
|
|
66
|
-
recovery, continue paging only if the requested detail is missing, incomplete, or
|
|
67
|
-
needs more context to resolve ambiguity; stop once the question is answered.
|
|
62
|
+
narrow the search.
|
|
68
63
|
|
|
69
64
|
For `context_lookup`, only supply `question`. Lookup covers all earlier compactions on the current branch automatically. It does **not** search abandoned branches or unrelated sessions. If the detail is absent, report that limitation instead of claiming it was recovered or widening this recovery search through filesystem tools.
|
|
70
65
|
|
|
71
66
|
A study harness may configure `MECH_COMPACT_LOOKUP_SESSION_FILE` to make the extension search a full session rather than a pruned fork. This is extension configuration, not a tool argument or a file the main agent should read. Do not discover or change the override to broaden a lookup.
|
|
72
67
|
|
|
73
|
-
## Bounded fallback and pagination
|
|
74
|
-
|
|
75
|
-
If the subagent comes up short, use `context_list_entries` for an overview,
|
|
76
|
-
`context_grep` for specific historical evidence, and `context_show_entry` for
|
|
77
|
-
an identified entry. Do not immediately repeat the subagent query. The three
|
|
78
|
-
fallback tools neither increase nor reset the lookup count: they are part of
|
|
79
|
-
the same recovery episode. Narration and thinking do not reset it either. Only
|
|
80
|
-
a tool result outside the four recovery tools, a user message, or a bash
|
|
81
|
-
execution resets the limit.
|
|
82
|
-
|
|
83
|
-
Search responses are pages, not necessarily complete evidence. Continue only
|
|
84
|
-
when the needed detail is missing, incomplete, or needs more context to resolve
|
|
85
|
-
ambiguity; do not exhaust every match or entry merely because a continuation is
|
|
86
|
-
available. A partial search does not establish that something never happened.
|
|
87
|
-
Keep other parameters unchanged and use all continuation parameters printed at
|
|
88
|
-
the end of a limited page:
|
|
89
|
-
|
|
90
|
-
- Listings and entry retrieval: `offset` counts characters (UTF-16 code units)
|
|
91
|
-
in the rendered listing or entry, starting at 0.
|
|
92
|
-
- Grep: `offset` counts matches, starting at 0; `charOffset` continues within
|
|
93
|
-
the context of an oversized match. Grep reports how many matches remain.
|
|
94
|
-
- `maxLines` and `maxMatches` limit a page, not the backing history. Increasing
|
|
95
|
-
them does not remove the character guard. Use the reported cursor instead.
|
|
96
|
-
- `context_show_entry` defaults to a single entry. `includeRelated=true` adds
|
|
97
|
-
unambiguously matched tool call/result entries in chronological order. Keep
|
|
98
|
-
this flag unchanged when paging. A result expands to its originating assistant,
|
|
99
|
-
not sibling outputs; an assistant expands to its matched results.
|
|
100
|
-
|
|
101
|
-
Listing/grep cursors also report `throughEntry`: retain this original last-entry
|
|
102
|
-
id on subsequent pages, so newly appended calls/results cannot keep expanding
|
|
103
|
-
the search. The source is rendered afresh. If you change
|
|
104
|
-
search/context parameters or navigate to another branch, restart at `offset=0`
|
|
105
|
-
(and `charOffset=0` for grep) without `throughEntry`. If grep reports an invalid
|
|
106
|
-
`charOffset`, retry that match at the same `offset` with `charOffset=0` and your
|
|
107
|
-
intended context parameters.
|
|
108
|
-
|
|
109
68
|
## Rules
|
|
110
69
|
|
|
111
|
-
1. **For recovery of details hidden by compaction, do not read or grep raw session JSONL files through filesystem tools.**
|
|
70
|
+
1. **For recovery of details hidden by compaction, do not read or grep raw session JSONL files through filesystem tools.** Use `context_lookup`. Raw filesystem recovery would refill the compacted context. This restriction does not apply to user-requested session audits, debugging, or cross-session analysis.
|
|
112
71
|
2. Ask narrowly scoped questions using exact error strings, file paths, function names, or the command whose output you need. Recover tightly related details together; use separate queries for independent facts. Ask the subagent for evidence, not for a solution to the broader task.
|
|
113
72
|
3. Findings cite ENTRY ids and the logical transcript name. Retain these citations when relying on recovered facts. The renderer preserves full thinking, text, tool-call arguments, and tool results, although individual search results have output limits.
|
|
114
73
|
4. Distinguish **user instructions**, **observed tool output**, and **reasoning at the time**. A recovered `[thinking]` block is a historical hypothesis, not verified fact. Earlier assistant prose is not independently observed evidence either.
|
|
115
74
|
5. Historical tool output proves what was observed then, not what is true now. Review uncommitted work and re-verify current build/test state when needed. **Before using `write` to replace an existing file, re-read it unless its current contents are already visible in context. Do not reconstruct unchanged sections from memory.** This is not a blanket reread requirement for small exact-match `edit`s.
|
|
116
|
-
6. Lookups can return incomplete findings or fail. State what remains missing; do not invent details or treat a partial answer as exhaustive.
|
|
75
|
+
6. Lookups can return incomplete findings or fail. State what remains missing; do not invent details or treat a partial answer as exhaustive. A partial search does not establish that something never happened.
|
|
117
76
|
|
|
118
77
|
## Independent exports
|
|
119
78
|
|