@bastani/atomic 0.8.26-alpha.7 → 0.8.26-alpha.8

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +5 -8
  3. package/dist/builtin/intercom/CHANGELOG.md +6 -0
  4. package/dist/builtin/intercom/package.json +1 -1
  5. package/dist/builtin/mcp/CHANGELOG.md +6 -0
  6. package/dist/builtin/mcp/package.json +1 -1
  7. package/dist/builtin/subagents/CHANGELOG.md +6 -0
  8. package/dist/builtin/subagents/package.json +1 -1
  9. package/dist/builtin/web-access/CHANGELOG.md +6 -0
  10. package/dist/builtin/web-access/package.json +1 -1
  11. package/dist/builtin/workflows/CHANGELOG.md +6 -0
  12. package/dist/builtin/workflows/package.json +1 -1
  13. package/dist/builtin/workflows/src/extension/wiring.ts +13 -1
  14. package/dist/builtin/workflows/src/runs/foreground/executor.ts +12 -6
  15. package/dist/builtin/workflows/src/runs/foreground/stage-runner.ts +2 -2
  16. package/dist/builtin/workflows/src/shared/authoring-contract.d.ts +2 -2
  17. package/dist/builtin/workflows/src/shared/types.ts +3 -3
  18. package/dist/builtin/workflows/src/tui/stage-chat-view.ts +1 -9
  19. package/dist/core/agent-session.d.ts +5 -5
  20. package/dist/core/agent-session.d.ts.map +1 -1
  21. package/dist/core/agent-session.js +64 -173
  22. package/dist/core/agent-session.js.map +1 -1
  23. package/dist/core/atomic-guide-command.d.ts.map +1 -1
  24. package/dist/core/atomic-guide-command.js +1 -1
  25. package/dist/core/atomic-guide-command.js.map +1 -1
  26. package/dist/core/extensions/types.d.ts +3 -2
  27. package/dist/core/extensions/types.d.ts.map +1 -1
  28. package/dist/core/extensions/types.js.map +1 -1
  29. package/dist/core/session-manager.d.ts.map +1 -1
  30. package/dist/core/session-manager.js +1 -1
  31. package/dist/core/session-manager.js.map +1 -1
  32. package/dist/core/slash-commands.d.ts.map +1 -1
  33. package/dist/core/slash-commands.js +1 -2
  34. package/dist/core/slash-commands.js.map +1 -1
  35. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  36. package/dist/modes/interactive/components/chat-session-host.js +1 -1
  37. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  38. package/dist/modes/interactive/components/context-compaction-summary-message.d.ts +17 -0
  39. package/dist/modes/interactive/components/context-compaction-summary-message.d.ts.map +1 -0
  40. package/dist/modes/interactive/components/context-compaction-summary-message.js +83 -0
  41. package/dist/modes/interactive/components/context-compaction-summary-message.js.map +1 -0
  42. package/dist/modes/interactive/components/index.d.ts +1 -0
  43. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  44. package/dist/modes/interactive/components/index.js +1 -0
  45. package/dist/modes/interactive/components/index.js.map +1 -1
  46. package/dist/modes/interactive/interactive-mode.d.ts +1 -1
  47. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  48. package/dist/modes/interactive/interactive-mode.js +28 -38
  49. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  50. package/dist/modes/rpc/rpc-client.d.ts +3 -3
  51. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  52. package/dist/modes/rpc/rpc-client.js +1 -1
  53. package/dist/modes/rpc/rpc-client.js.map +1 -1
  54. package/dist/modes/rpc/rpc-types.d.ts +2 -2
  55. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  56. package/dist/modes/rpc/rpc-types.js.map +1 -1
  57. package/docs/compaction.md +71 -38
  58. package/docs/extensions.md +9 -5
  59. package/docs/index.md +1 -1
  60. package/docs/json.md +2 -2
  61. package/docs/rpc.md +19 -40
  62. package/docs/sdk.md +2 -2
  63. package/docs/session-format.md +3 -3
  64. package/docs/sessions.md +2 -3
  65. package/docs/settings.md +2 -2
  66. package/docs/usage.md +2 -4
  67. package/package.json +1 -1
@@ -1,30 +1,32 @@
1
1
  # Compaction & Branch Summarization
2
2
 
3
- LLMs have limited context windows. When conversations grow too long, Atomic uses compaction to summarize older content while preserving recent work. This page covers both auto-compaction and branch summarization.
3
+ LLMs have limited context windows. When conversations grow too long, Atomic uses a deletion-only form of Context Compaction called **Verbatim Compaction**: it deletes safe older transcript objects while preserving every retained object byte-for-byte. This page covers auto-compaction, manual compaction, and branch summarization.
4
+
5
+ Atomic's default compaction design and terminology are informed by Morph's Context Compaction work: <https://www.morphllm.com/context-compaction>. In particular, Atomic follows the same core idea that coding agents benefit from deleting low-signal context instead of rewriting high-signal details like file paths, line numbers, and error strings into a lossy summary.
4
6
 
5
7
  **Source files** ([atomic](https://github.com/bastani-inc/atomic)):
6
8
  - [`packages/coding-agent/src/core/compaction/compaction.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/compaction/compaction.ts) - Summary compaction logic
7
- - [`packages/coding-agent/src/core/compaction/context-compaction.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/compaction/context-compaction.ts) - Deletion-only context compaction
9
+ - [`packages/coding-agent/src/core/compaction/context-compaction.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/compaction/context-compaction.ts) - Verbatim context compaction
8
10
  - [`packages/coding-agent/src/core/compaction/branch-summarization.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/compaction/branch-summarization.ts) - Branch summarization
9
11
  - [`packages/coding-agent/src/core/compaction/utils.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/compaction/utils.ts) - Shared utilities (file tracking, serialization)
10
- - [`packages/coding-agent/src/core/session-manager.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/session-manager.ts) - Entry types (`CompactionEntry`, `BranchSummaryEntry`)
12
+ - [`packages/coding-agent/src/core/session-manager.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/session-manager.ts) - Entry types (`ContextCompactionEntry`, `CompactionEntry`, `BranchSummaryEntry`)
11
13
  - [`packages/coding-agent/src/core/extensions/types.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/extensions/types.ts) - Extension event types
12
14
 
13
15
  For TypeScript definitions in your project, inspect `node_modules/@bastani/atomic/dist/`.
14
16
 
15
17
  ## Overview
16
18
 
17
- Atomic has two compaction/summarization mechanisms:
19
+ Atomic has three compaction/summarization mechanisms:
18
20
 
19
21
  | Mechanism | Trigger | Purpose |
20
22
  |-----------|---------|---------|
21
- | Summary compaction | Context exceeds threshold, or `/compact [instructions]` | Summarize old messages to free up context |
22
- | Context compaction | `/context-compact` | Delete safe old transcript objects while retaining surviving content verbatim |
23
+ | Default context compaction (Verbatim Compaction) | Context exceeds threshold, context overflow, or `/compact` | Delete safe old transcript objects while retaining surviving content verbatim |
24
+ | Summary compaction internals | Core APIs and legacy extension hooks | Summarize old messages into replacement context |
23
25
  | Branch summarization | `/tree` navigation | Preserve context when switching branches |
24
26
 
25
- Summary compaction and branch summarization use the same structured summary format and track file operations cumulatively. `/context-compact` is separate: it has no user-facing arguments, uses a fixed internal prompt, validates model-proposed deletion targets locally, and stores logical deletions in a `context_compaction` entry.
27
+ `/compact` has no user-facing arguments. It uses a fixed internal prompt, validates model-proposed deletion targets locally, and stores logical deletions in a `context_compaction` entry. Auto-compaction uses the same deletion-only path.
26
28
 
27
- ## Compaction
29
+ ## Default Context Compaction (Verbatim Compaction)
28
30
 
29
31
  ### When It Triggers
30
32
 
@@ -36,18 +38,66 @@ contextTokens > contextWindow - reserveTokens
36
38
 
37
39
  By default, `reserveTokens` is 16384 tokens. Configure it in `~/.atomic/agent/settings.json` or `<project-dir>/.atomic/settings.json`; legacy `.pi` paths are also supported. This leaves room for the LLM's response.
38
40
 
39
- You can also trigger manually with `/compact [instructions]`, where optional instructions focus the summary.
41
+ You can also trigger manually with `/compact`. Custom summary instructions are no longer accepted because retained transcript content stays verbatim.
40
42
 
41
43
  ### How It Works
42
44
 
43
- 1. **Find cut point**: Walk backwards from newest message, accumulating token estimates until `keepRecentTokens` is reached. The default is 20k tokens; configure it in `~/.atomic/agent/settings.json` or `<project-dir>/.atomic/settings.json`. Legacy `.pi` paths are also supported.
44
- 2. **Extract messages**: Collect messages from the previous kept boundary (or session start) up to the cut point
45
- 3. **Generate summary**: Call LLM to summarize with structured format, passing the previous summary as iterative context when present
46
- 4. **Append entry**: Save `CompactionEntry` with summary and `firstKeptEntryId`
47
- 5. **Reload**: Session reloads, using summary + messages from `firstKeptEntryId` onwards
45
+ 1. Build a compactable transcript for the active branch with stable entry IDs and content-block indexes.
46
+ 2. Ask the selected model, with a fixed internal prompt, for JSON deletion targets only.
47
+ 3. Validate the plan locally: unknown IDs, protected user messages, recent operations, unresolved errors, and tool-call/tool-result orphaning fail closed.
48
+ 4. Write a backup snapshot for persisted sessions.
49
+ 5. Append a `context_compaction` entry containing validated logical deletion targets and stats.
50
+ 6. Rebuild active LLM context by filtering those targets. Retained entries/content blocks are reused unchanged.
51
+
52
+ Tradeoff: compaction performs logical deletion during session rebuild instead of physically rewriting JSONL. The full raw history remains in the session file and backup, while the active LLM context is reduced.
53
+
54
+ ### Verbatim Compaction Diagram
55
+
56
+ Unlike legacy summary compaction, Verbatim Compaction does not add a generated summary or rewrite retained messages. It appends a `context_compaction` entry that records exactly which older transcript objects should be hidden from future active context rebuilds.
48
57
 
49
58
  ```
50
- Before compaction:
59
+ Before verbatim compaction:
60
+
61
+ entry: 0 1 2 3 4 5 6 7
62
+ ┌─────┬─────┬─────┬──────┬─────┬──────┬──────┬─────┐
63
+ │ hdr │ usr │ ass │ tool │ usr │ ass │ tool │ ass │
64
+ └─────┴─────┴─────┴──────┴─────┴──────┴──────┴─────┘
65
+ │ │ │ │
66
+ └──────┴────────────┴──────┘
67
+ planner may mark low-signal old objects
68
+
69
+ Validated deletion plan:
70
+
71
+ delete entry 2 (older assistant text)
72
+ delete entry 3 (superseded tool output)
73
+ keep entries 0,1,4,5,6,7 unchanged
74
+
75
+ After compaction (new entry appended; JSONL remains append-only):
76
+
77
+ entry: 0 1 2 3 4 5 6 7 8
78
+ ┌─────┬─────┬─────┬──────┬─────┬──────┬──────┬─────┬─────┐
79
+ │ hdr │ usr │ ass │ tool │ usr │ ass │ tool │ ass │ ctx │
80
+ └─────┴─────┴─────┴──────┴─────┴──────┴──────┴─────┴─────┘
81
+ ╳ ╳ ↑
82
+ logical deletions context_compaction entry
83
+
84
+ What the LLM sees after rebuild:
85
+
86
+ ┌────────┬─────┬─────┬──────┬──────┬─────┐
87
+ │ system │ usr │ usr │ ass │ tool │ ass │
88
+ └────────┴─────┴─────┴──────┴──────┴─────┘
89
+ entry 1 entry 4 entry 5 entry 6 entry 7
90
+
91
+ No generated summary is inserted. Every surviving entry/content block is reused
92
+ verbatim; deleted objects are simply omitted from the active LLM context.
93
+ ```
94
+
95
+ ## Summary Compaction Internals
96
+
97
+ The older summarization pipeline still exists in the core compaction module and for legacy extension hook types, but `/compact` and auto-compaction no longer use it by default.
98
+
99
+ ```
100
+ Before summary compaction:
51
101
 
52
102
  entry: 0 1 2 3 4 5 6 7 8 9
53
103
  ┌─────┬─────┬─────┬─────┬──────┬─────┬─────┬──────┬──────┬─────┐
@@ -80,23 +130,6 @@ What the LLM sees:
80
130
 
81
131
  On repeated compactions, the summarized span starts at the previous compaction's kept boundary (`firstKeptEntryId`), not at the compaction entry itself, falling back to the entry after the previous compaction if that kept entry cannot be found in the path. This preserves messages that survived the earlier compaction by including them in the next summarization pass as well. Atomic also recalculates `tokensBefore` from the rebuilt session context before writing the new `CompactionEntry`, so the token count reflects the actual pre-compaction context being replaced.
82
132
 
83
- ## Context Compaction (`/context-compact`)
84
-
85
- `/context-compact` is a fixed no-argument command for deletion-only compaction. Unlike `/compact [prompt]`, it never accepts custom instructions and never asks the model to write replacement context.
86
-
87
- How it works in this first iteration:
88
-
89
- 1. Build a compactable transcript for the active branch with stable entry IDs and content-block indexes.
90
- 2. Ask the selected model, with a fixed internal prompt, for JSON deletion targets only.
91
- 3. Validate the plan locally: unknown IDs, protected user messages, recent operations, unresolved errors, and tool-call/tool-result orphaning fail closed.
92
- 4. Write a backup snapshot for persisted sessions.
93
- 5. Append a `context_compaction` entry containing validated logical deletion targets and stats.
94
- 6. Rebuild active LLM context by filtering those targets. Retained entries/content blocks are reused unchanged.
95
-
96
- `/context-compact anything` is invalid in the main interactive UI and trailing text is not treated as a prompt. Workflow-stage chat consumes extra text without invoking compaction so it is not sent to the model.
97
-
98
- Tradeoff: this iteration performs logical deletion during session rebuild instead of physically rewriting JSONL. The full raw history remains in the session file and backup, while the active LLM context is reduced.
99
-
100
133
  ### Split Turns
101
134
 
102
135
  A "turn" starts with a user message and includes all assistant responses and tool calls until the next user message. Normally, compaction cuts at turn boundaries.
@@ -152,14 +185,14 @@ interface CompactionEntry<T = unknown> {
152
185
  details?: T; // implementation-specific data
153
186
  }
154
187
 
155
- // Default compaction uses this for details (from compaction.ts):
188
+ // Legacy summary compaction uses this for details (from compaction.ts):
156
189
  interface CompactionDetails {
157
190
  readFiles: string[];
158
191
  modifiedFiles: string[];
159
192
  }
160
193
  ```
161
194
 
162
- Extensions can store any JSON-serializable data in `details`. The default compaction tracks file operations, but custom extension implementations can use their own structure.
195
+ Extensions can store any JSON-serializable data in `details`. The legacy summary compaction pipeline tracks file operations, but custom extension implementations can use their own structure.
163
196
 
164
197
  See [`prepareCompaction()`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/compaction/compaction.ts) and [`compact()`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/compaction/compaction.ts) for the implementation.
165
198
 
@@ -287,11 +320,11 @@ Tool results are truncated to 2000 characters during serialization. Content beyo
287
320
 
288
321
  ## Custom Summarization via Extensions
289
322
 
290
- Extensions can intercept and customize both compaction and branch summarization. See [`extensions/types.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/extensions/types.ts) for event type definitions.
323
+ Extensions can still customize the legacy summary compaction pipeline and branch summarization. Default `/compact` and auto-compaction use deletion-only context compaction and do not call summary customization hooks. See [`extensions/types.ts`](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/src/core/extensions/types.ts) for event type definitions.
291
324
 
292
325
  ### session_before_compact
293
326
 
294
- Fired before auto-compaction or `/compact`. Can cancel or provide custom summary. See `SessionBeforeCompactEvent` and `CompactionPreparation` in the types file.
327
+ Fired before legacy summary compaction. Can cancel or provide custom summary. See `SessionBeforeCompactEvent` and `CompactionPreparation` in the types file.
295
328
 
296
329
  ```typescript
297
330
  pi.on("session_before_compact", async (event, ctx) => {
@@ -406,8 +439,8 @@ Configure compaction in `~/.atomic/agent/settings.json` or `<project-dir>/.atomi
406
439
 
407
440
  | Setting | Default | Description |
408
441
  |---------|---------|-------------|
409
- | `enabled` | `true` | Enable auto-compaction |
442
+ | `enabled` | `true` | Enable automatic Verbatim Compaction |
410
443
  | `reserveTokens` | `16384` | Tokens to reserve for LLM response |
411
- | `keepRecentTokens` | `20000` | Recent tokens to keep (not summarized) |
444
+ | `keepRecentTokens` | `20000` | Recent tokens to protect from deletion |
412
445
 
413
446
  Disable auto-compaction with `"enabled": false`. You can still compact manually with `/compact`.
@@ -322,6 +322,9 @@ user sends another prompt ◄─────────────────
322
322
  └─► resources_discover { reason: "startup" }
323
323
 
324
324
  /compact or auto-compaction
325
+ └─► compaction_start / compaction_end (deletion-only context compaction)
326
+
327
+ legacy summary compaction APIs
325
328
  ├─► session_before_compact (can cancel or customize)
326
329
  └─► session_compact
327
330
 
@@ -413,7 +416,7 @@ Do cleanup work in `session_shutdown`, then reestablish any in-memory state in `
413
416
 
414
417
  #### session_before_compact / session_compact
415
418
 
416
- Fired on compaction. See [Compaction](/compaction) for details.
419
+ Fired by the legacy summary compaction pipeline. `/compact` and auto-compaction now use deletion-only context compaction by default, so extensions should not rely on these events for default compaction. See [Compaction](/compaction) for details.
417
420
 
418
421
  ```typescript
419
422
  pi.on("session_before_compact", async (event, ctx) => {
@@ -947,13 +950,12 @@ if (usage && usage.tokens > 100_000) {
947
950
 
948
951
  ### ctx.compact()
949
952
 
950
- Trigger compaction without awaiting completion. Use `onComplete` and `onError` for follow-up actions.
953
+ Trigger Atomic's default Verbatim Compaction without awaiting completion. This is deletion-only Context Compaction: retained transcript content stays unchanged, and older low-signal objects are omitted by validated logical deletion. The approach is informed by Morph's Context Compaction write-up: <https://www.morphllm.com/context-compaction>. Use `onComplete` and `onError` for follow-up actions.
951
954
 
952
955
  ```typescript
953
956
  ctx.compact({
954
- customInstructions: "Focus on recent changes",
955
957
  onComplete: (result) => {
956
- ctx.ui.notify("Compaction completed", "info");
958
+ ctx.ui.notify(`Compaction deleted ${result.stats.objectsDeleted} objects`, "info");
957
959
  },
958
960
  onError: (error) => {
959
961
  ctx.ui.notify(`Compaction failed: ${error.message}`, "error");
@@ -961,6 +963,8 @@ ctx.compact({
961
963
  });
962
964
  ```
963
965
 
966
+ `customInstructions` is deprecated and ignored for default compaction because Verbatim Compaction never asks the model to write a custom summary.
967
+
964
968
  ### ctx.getSystemPrompt()
965
969
 
966
970
  Returns Atomic's current system prompt string.
@@ -2568,7 +2572,7 @@ All examples in [examples/extensions/](https://github.com/bastani-inc/atomic/tre
2568
2572
  | `prompt-customizer.ts` | Add context-aware tool guidance using `systemPromptOptions` | `on("before_agent_start")`, `BuildSystemPromptOptions` |
2569
2573
  | `file-trigger.ts` | File watcher triggers messages | `sendMessage` |
2570
2574
  | **Compaction & Sessions** |||
2571
- | `custom-compaction.ts` | Custom compaction summary | `on("session_before_compact")` |
2575
+ | `custom-compaction.ts` | Legacy custom compaction summary | `on("session_before_compact")` |
2572
2576
  | `trigger-compact.ts` | Trigger compaction manually | `compact()` |
2573
2577
  | `git-checkpoint.ts` | Git stash on turns | `on("turn_start")`, `on("session_before_fork")`, `exec` |
2574
2578
  | `auto-commit-on-exit.ts` | Commit on shutdown | `on("session_shutdown")`, `exec` |
package/docs/index.md CHANGED
@@ -37,7 +37,7 @@ For the full first-run flow, see [Quickstart](/quickstart).
37
37
  - [Settings](/settings) - global and project settings.
38
38
  - [Keybindings](/keybindings) - default shortcuts and custom keybindings.
39
39
  - [Sessions](/sessions) - session management, branching, and tree navigation.
40
- - [Compaction](/compaction) - context compaction and branch summarization.
40
+ - [Compaction](/compaction) - Verbatim Compaction, context management, and branch summarization.
41
41
 
42
42
  ## Customization
43
43
 
package/docs/json.md CHANGED
@@ -18,12 +18,12 @@ type AgentSessionEvent =
18
18
  | { type: "session_info_changed"; name: string | undefined }
19
19
  | { type: "model_changed"; model: Model<Api>; previousModel: Model<Api> | undefined; source: "set" | "cycle" | "restore" }
20
20
  | { type: "thinking_level_changed"; level: ThinkingLevel }
21
- | { type: "compaction_end"; reason: "manual" | "threshold" | "overflow"; result: CompactionResult | undefined; aborted: boolean; willRetry: boolean; errorMessage?: string }
21
+ | { type: "compaction_end"; reason: "manual" | "threshold" | "overflow"; result: ContextCompactionResult | undefined; aborted: boolean; willRetry: boolean; errorMessage?: string }
22
22
  | { type: "auto_retry_start"; attempt: number; maxAttempts: number; delayMs: number; errorMessage: string }
23
23
  | { type: "auto_retry_end"; success: boolean; attempt: number; finalError?: string };
24
24
  ```
25
25
 
26
- `queue_update` emits the full pending steering and follow-up queues whenever they change. `session_info_changed`, `model_changed`, and `thinking_level_changed` report interactive session metadata changes. `compaction_start` and `compaction_end` cover both manual and automatic compaction.
26
+ `queue_update` emits the full pending steering and follow-up queues whenever they change. `session_info_changed`, `model_changed`, and `thinking_level_changed` report interactive session metadata changes. `compaction_start` and `compaction_end` cover both manual and automatic Verbatim Compaction, Atomic's deletion-only Context Compaction approach inspired by <https://www.morphllm.com/context-compaction>.
27
27
 
28
28
  Base events come from `AgentEvent` in `@earendil-works/pi-agent-core` (installed as an Atomic dependency):
29
29
 
package/docs/rpc.md CHANGED
@@ -352,46 +352,18 @@ Response:
352
352
 
353
353
  #### compact
354
354
 
355
- Manually compact conversation context to reduce token usage.
355
+ Run Atomic's default Verbatim Compaction to reduce token usage. This command has no prompt/config fields; send no custom instructions. Atomic asks the selected model for deletion targets using a fixed internal prompt, validates them, appends a `context_compaction` entry, and rebuilds active context with surviving entries/content blocks reused verbatim. This deletion-only Context Compaction approach is informed by Morph's article: <https://www.morphllm.com/context-compaction>.
356
356
 
357
357
  ```json
358
358
  {"type": "compact"}
359
359
  ```
360
360
 
361
- With custom instructions:
362
- ```json
363
- {"type": "compact", "customInstructions": "Focus on code changes"}
364
- ```
365
-
366
361
  Response:
367
362
  ```json
368
363
  {
369
364
  "type": "response",
370
365
  "command": "compact",
371
366
  "success": true,
372
- "data": {
373
- "summary": "Summary of conversation...",
374
- "firstKeptEntryId": "abc123",
375
- "tokensBefore": 150000,
376
- "details": {}
377
- }
378
- }
379
- ```
380
-
381
- #### context_compact
382
-
383
- Run deletion-only context compaction. This command has no prompt/config fields; send no custom instructions. Atomic asks the selected model for deletion targets using a fixed internal prompt, validates them, appends a `context_compaction` entry, and rebuilds active context.
384
-
385
- ```json
386
- {"type": "context_compact"}
387
- ```
388
-
389
- Response:
390
- ```json
391
- {
392
- "type": "response",
393
- "command": "context_compact",
394
- "success": true,
395
367
  "data": {
396
368
  "promptVersion": 1,
397
369
  "deletedTargets": [{ "kind": "entry", "entryId": "abc123" }],
@@ -404,7 +376,7 @@ Response:
404
376
  "tokensAfter": 120000,
405
377
  "percentReduction": 20
406
378
  },
407
- "backupPath": "/path/to/session.jsonl.2026-06-06T00-00-00-000Z.context-compact.bak"
379
+ "backupPath": "/path/to/session.jsonl.2026-06-06T00-00-00-000Z.compact.bak"
408
380
  }
409
381
  }
410
382
  ```
@@ -787,10 +759,10 @@ Events are streamed to stdout as JSON lines during agent operation. Events do NO
787
759
  | `tool_execution_update` | Tool execution progress (streaming output) |
788
760
  | `tool_execution_end` | Tool completes |
789
761
  | `queue_update` | Pending steering/follow-up queue changed |
790
- | `compaction_start` | Summary compaction begins |
791
- | `compaction_end` | Summary compaction completes |
792
- | `context_compaction_start` | Deletion-only context compaction begins |
793
- | `context_compaction_end` | Deletion-only context compaction completes |
762
+ | `compaction_start` | Default Verbatim Compaction begins |
763
+ | `compaction_end` | Default Verbatim Compaction completes |
764
+ | `context_compaction_start` | Legacy context-compaction RPC begins |
765
+ | `context_compaction_end` | Legacy context-compaction RPC completes |
794
766
  | `auto_retry_start` | Auto-retry begins (after transient error) |
795
767
  | `auto_retry_end` | Auto-retry completes (success or final failure) |
796
768
  | `extension_error` | Extension threw an error |
@@ -940,7 +912,7 @@ Emitted whenever the pending steering or follow-up queue changes.
940
912
 
941
913
  ### compaction_start / compaction_end
942
914
 
943
- Emitted when compaction runs, whether manual or automatic.
915
+ Emitted when default Verbatim Compaction runs, whether manual or automatic. The result records deletion targets and stats rather than a generated summary.
944
916
 
945
917
  ```json
946
918
  {"type": "compaction_start", "reason": "threshold"}
@@ -953,10 +925,17 @@ The `reason` field is `"manual"`, `"threshold"`, or `"overflow"`.
953
925
  "type": "compaction_end",
954
926
  "reason": "threshold",
955
927
  "result": {
956
- "summary": "Summary of conversation...",
957
- "firstKeptEntryId": "abc123",
958
- "tokensBefore": 150000,
959
- "details": {}
928
+ "promptVersion": 1,
929
+ "deletedTargets": [{ "kind": "entry", "entryId": "abc123" }],
930
+ "protectedEntryIds": ["user-task-entry"],
931
+ "stats": {
932
+ "objectsBefore": 20,
933
+ "objectsAfter": 19,
934
+ "objectsDeleted": 1,
935
+ "tokensBefore": 150000,
936
+ "tokensAfter": 120000,
937
+ "percentReduction": 20
938
+ }
960
939
  },
961
940
  "aborted": false,
962
941
  "willRetry": false
@@ -971,7 +950,7 @@ If compaction failed (e.g., API quota exceeded), `result` is `null`, `aborted` i
971
950
 
972
951
  ### context_compaction_start / context_compaction_end
973
952
 
974
- Emitted for `/context-compact` and RPC `context_compact`. The shape mirrors manual compaction events, but `reason` is always `"manual"` and the `result` contains `deletedTargets`, `protectedEntryIds`, `stats`, `promptVersion`, and optional `backupPath` instead of a summary.
953
+ Legacy RPC `context_compact` emits these events. The result contains `deletedTargets`, `protectedEntryIds`, `stats`, `promptVersion`, and optional `backupPath`.
975
954
 
976
955
  ### auto_retry_start / auto_retry_end
977
956
 
package/docs/sdk.md CHANGED
@@ -109,8 +109,8 @@ interface AgentSession {
109
109
  // In-place tree navigation within the current session file
110
110
  navigateTree(targetId: string, options?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string }): Promise<{ editorText?: string; cancelled: boolean }>;
111
111
 
112
- // Compaction
113
- compact(customInstructions?: string): Promise<CompactionResult>;
112
+ // Verbatim Compaction (deletion-only Context Compaction)
113
+ compact(): Promise<ContextCompactionResult>;
114
114
  abortCompaction(): void;
115
115
 
116
116
  // Abort current operation
@@ -223,7 +223,7 @@ Emitted when the user changes the thinking/reasoning level.
223
223
 
224
224
  ### CompactionEntry
225
225
 
226
- Created when context is compacted. Stores a summary of earlier messages.
226
+ Legacy summary-compaction entry. Stores a generated summary of earlier messages for older APIs and extension hooks. Default `/compact` and auto-compaction now create `ContextCompactionEntry` records instead.
227
227
 
228
228
  ```json
229
229
  {"type":"compaction","id":"f6g7h8i9","parentId":"e5f6g7h8","timestamp":"2024-12-03T14:10:00.000Z","summary":"User discussed X, Y, Z...","firstKeptEntryId":"c3d4e5f6","tokensBefore":50000}
@@ -235,10 +235,10 @@ Optional fields:
235
235
 
236
236
  ### ContextCompactionEntry
237
237
 
238
- Created by `/context-compact`. Stores validated logical deletion targets, not replacement text. During `buildSessionContext()`, matching entries/content blocks are filtered from active LLM context while retained content remains verbatim.
238
+ Created by `/compact` and auto-compaction. Stores Atomic's default **Verbatim Compaction** data: validated logical deletion targets, not replacement text. During `buildSessionContext()`, matching entries/content blocks are filtered from active LLM context while retained content remains verbatim. This deletion-only Context Compaction approach is informed by Morph's write-up at <https://www.morphllm.com/context-compaction>.
239
239
 
240
240
  ```json
241
- {"type":"context_compaction","id":"ctx12345","parentId":"f6g7h8i9","timestamp":"2024-12-03T14:12:00.000Z","promptVersion":1,"deletedTargets":[{"kind":"entry","entryId":"b2c3d4e5"}],"protectedEntryIds":["a1b2c3d4"],"stats":{"objectsBefore":20,"objectsAfter":19,"objectsDeleted":1,"tokensBefore":50000,"tokensAfter":43000,"percentReduction":14},"backupPath":"/path/session.jsonl.2024-12-03T14-12-00-000Z.context-compact.bak"}
241
+ {"type":"context_compaction","id":"ctx12345","parentId":"f6g7h8i9","timestamp":"2024-12-03T14:12:00.000Z","promptVersion":1,"deletedTargets":[{"kind":"entry","entryId":"b2c3d4e5"}],"protectedEntryIds":["a1b2c3d4"],"stats":{"objectsBefore":20,"objectsAfter":19,"objectsDeleted":1,"tokensBefore":50000,"tokensAfter":43000,"percentReduction":14},"backupPath":"/path/session.jsonl.2024-12-03T14-12-00-000Z.compact.bak"}
242
242
  ```
243
243
 
244
244
  `deletedTargets` entries are either whole entries (`{ kind: "entry", entryId }`) or content blocks (`{ kind: "content_block", entryId, blockIndex }`). The JSONL file remains append-only; this is logical deletion for active context rebuild.
package/docs/sessions.md CHANGED
@@ -29,8 +29,7 @@ For the JSONL file format and SessionManager API, see [Session Format](/session-
29
29
  | `/tree` | Navigate the current session tree |
30
30
  | `/fork` | Create a new session from a previous user message |
31
31
  | `/clone` | Duplicate the current active branch into a new session |
32
- | `/compact [prompt]` | Summarize older context; see [Compaction](/compaction) |
33
- | `/context-compact` | Apply validated deletion-only logical compaction; no arguments |
32
+ | `/compact` | Apply Verbatim Compaction with validated logical deletions; see [Compaction](/compaction) |
34
33
  | `/export [file]` | Export session to HTML |
35
34
  | `/share` | Upload as private GitHub gist with shareable HTML link |
36
35
 
@@ -129,7 +128,7 @@ When prompted, choose one of:
129
128
  2. summarize with the default prompt
130
129
  3. summarize with custom focus instructions
131
130
 
132
- See [Compaction](/compaction) for branch summarization internals and extension hooks.
131
+ See [Compaction](/compaction) for Verbatim Compaction, branch summarization internals, and extension hooks.
133
132
 
134
133
  ## Session Format
135
134
 
package/docs/settings.md CHANGED
@@ -90,9 +90,9 @@ Set `ATOMIC_SKIP_VERSION_CHECK=1` to disable the Atomic version update check. Us
90
90
 
91
91
  | Setting | Type | Default | Description |
92
92
  |---------|------|---------|-------------|
93
- | `compaction.enabled` | boolean | `true` | Enable auto-compaction |
93
+ | `compaction.enabled` | boolean | `true` | Enable automatic Verbatim Compaction |
94
94
  | `compaction.reserveTokens` | number | `16384` | Tokens reserved for LLM response |
95
- | `compaction.keepRecentTokens` | number | `20000` | Recent tokens to keep (not summarized) |
95
+ | `compaction.keepRecentTokens` | number | `20000` | Recent tokens to protect from deletion |
96
96
 
97
97
  ```json
98
98
  {
package/docs/usage.md CHANGED
@@ -48,8 +48,7 @@ Type `/` in the editor to open command completion. Extensions can register custo
48
48
  | `/tree` | Jump to any point in the session and continue from there |
49
49
  | `/fork` | Create a new session from a previous user message |
50
50
  | `/clone` | Duplicate the current active branch into a new session |
51
- | `/compact [prompt]` | Manually compact context, optionally with custom instructions |
52
- | `/context-compact` | Delete safe older transcript objects verbatim; no arguments |
51
+ | `/compact` | Run Verbatim Compaction by deleting safe older transcript objects |
53
52
  | `/copy` | Copy last assistant message to clipboard |
54
53
  | `/export [file]` | Export session to HTML |
55
54
  | `/share` | Upload as private GitHub gist with shareable HTML link |
@@ -90,8 +89,7 @@ Useful session commands:
90
89
  - `/tree` navigates the in-file session tree and can summarize abandoned branches.
91
90
  - `/fork` creates a new session from an earlier user message.
92
91
  - `/clone` duplicates the current active branch into a new session file.
93
- - `/compact` summarizes older messages to free context.
94
- - `/context-compact` uses a fixed no-argument deletion-only planner and applies only validated logical deletions; trailing text is not used as a prompt.
92
+ - `/compact` uses Verbatim Compaction: a fixed no-argument deletion-only planner applies only validated logical deletions; retained transcript content stays verbatim. Atomic's approach is informed by Morph's Context Compaction article: <https://www.morphllm.com/context-compaction>.
95
93
 
96
94
  See [Sessions](/sessions) and [Compaction](/compaction) for details.
97
95
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/atomic",
3
- "version": "0.8.26-alpha.7",
3
+ "version": "0.8.26-alpha.8",
4
4
  "description": "Atomic coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "atomicConfig": {