@bastani/atomic 0.9.73 → 0.9.74

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 (193) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/dist/builtin/intercom/package.json +1 -1
  3. package/dist/builtin/mcp/package.json +1 -1
  4. package/dist/builtin/subagents/package.json +1 -1
  5. package/dist/builtin/web-access/package.json +1 -1
  6. package/dist/builtin/workflows/CHANGELOG.md +32 -0
  7. package/dist/builtin/workflows/README.md +2 -2
  8. package/dist/builtin/workflows/builtin/adversarial-verification.js +2 -2
  9. package/dist/builtin/workflows/builtin/{chunk-2377r57g.js → chunk-8kdrnrpa.js} +1 -1
  10. package/dist/builtin/workflows/builtin/{chunk-t8y25z1j.js → chunk-8ycbc76t.js} +1 -1
  11. package/dist/builtin/workflows/builtin/{chunk-vbrmytm5.js → chunk-a4fdm2cw.js} +1 -1
  12. package/dist/builtin/workflows/builtin/{chunk-9pjdp2td.js → chunk-d5cxskkp.js} +3 -3
  13. package/dist/builtin/workflows/builtin/{chunk-tpsw128z.js → chunk-d9pz64yp.js} +3 -3
  14. package/dist/builtin/workflows/builtin/{chunk-z0d03ktm.js → chunk-gp0s6m45.js} +1 -1
  15. package/dist/builtin/workflows/builtin/{chunk-4kygv34g.js → chunk-m8eg152f.js} +1 -1
  16. package/dist/builtin/workflows/builtin/{chunk-mswg7kc7.js → chunk-r39ypw6b.js} +1 -1
  17. package/dist/builtin/workflows/builtin/{chunk-q7dry6km.js → chunk-va2h64a6.js} +3 -3
  18. package/dist/builtin/workflows/builtin/generate-and-filter.js +2 -2
  19. package/dist/builtin/workflows/builtin/goal.js +4 -4
  20. package/dist/builtin/workflows/builtin/index.js +9 -9
  21. package/dist/builtin/workflows/builtin/loop-until-done.js +2 -2
  22. package/dist/builtin/workflows/builtin/ralph.js +4 -4
  23. package/dist/builtin/workflows/builtin/tournament.js +2 -2
  24. package/dist/builtin/workflows/package.json +1 -1
  25. package/dist/builtin/workflows/src/authoring.d.ts +2 -0
  26. package/dist/builtin/workflows/src/extension/index.bundle.mjs +403 -76
  27. package/dist/builtin/workflows/src/extension/local-worker-entry.mjs +387 -60
  28. package/dist/builtin/workflows/src/index.js +393 -62
  29. package/dist/builtin/workflows/src/local-worker-entry.mjs +387 -60
  30. package/dist/builtin/workflows/src/shared/serializable-error-families.d.ts +1 -0
  31. package/dist/builtin/workflows/src/shared/structured-output-errors.d.ts +50 -0
  32. package/dist/config.d.ts +2 -0
  33. package/dist/config.d.ts.map +1 -1
  34. package/dist/config.js +4 -0
  35. package/dist/config.js.map +1 -1
  36. package/dist/core/agent-session-background-compaction.d.ts.map +1 -1
  37. package/dist/core/agent-session-background-compaction.js +2 -1
  38. package/dist/core/agent-session-background-compaction.js.map +1 -1
  39. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  40. package/dist/core/agent-session-compaction.js +98 -4
  41. package/dist/core/agent-session-compaction.js.map +1 -1
  42. package/dist/core/agent-session-detached-tools.d.ts +20 -5
  43. package/dist/core/agent-session-detached-tools.d.ts.map +1 -1
  44. package/dist/core/agent-session-detached-tools.js +97 -21
  45. package/dist/core/agent-session-detached-tools.js.map +1 -1
  46. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  47. package/dist/core/agent-session-message-queue.js +2 -1
  48. package/dist/core/agent-session-message-queue.js.map +1 -1
  49. package/dist/core/agent-session-methods.d.ts +3 -1
  50. package/dist/core/agent-session-methods.d.ts.map +1 -1
  51. package/dist/core/agent-session-methods.js.map +1 -1
  52. package/dist/core/agent-session-persistent-custom-messages.d.ts.map +1 -1
  53. package/dist/core/agent-session-persistent-custom-messages.js +12 -4
  54. package/dist/core/agent-session-persistent-custom-messages.js.map +1 -1
  55. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  56. package/dist/core/agent-session-prompt.js +33 -0
  57. package/dist/core/agent-session-prompt.js.map +1 -1
  58. package/dist/core/compaction/background-compaction.d.ts +11 -5
  59. package/dist/core/compaction/background-compaction.d.ts.map +1 -1
  60. package/dist/core/compaction/background-compaction.js +19 -10
  61. package/dist/core/compaction/background-compaction.js.map +1 -1
  62. package/dist/core/compaction/compaction-boundary.d.ts +10 -0
  63. package/dist/core/compaction/compaction-boundary.d.ts.map +1 -1
  64. package/dist/core/compaction/compaction-boundary.js +30 -2
  65. package/dist/core/compaction/compaction-boundary.js.map +1 -1
  66. package/dist/core/compaction/compaction-runner.d.ts +7 -0
  67. package/dist/core/compaction/compaction-runner.d.ts.map +1 -1
  68. package/dist/core/compaction/compaction-runner.js +13 -5
  69. package/dist/core/compaction/compaction-runner.js.map +1 -1
  70. package/dist/core/compaction/compaction-types.d.ts +1 -1
  71. package/dist/core/compaction/compaction-types.js +1 -1
  72. package/dist/core/compaction/compaction-types.js.map +1 -1
  73. package/dist/core/compaction/deleted-ranges.d.ts +17 -2
  74. package/dist/core/compaction/deleted-ranges.d.ts.map +1 -1
  75. package/dist/core/compaction/deleted-ranges.js +44 -5
  76. package/dist/core/compaction/deleted-ranges.js.map +1 -1
  77. package/dist/core/compaction/history-recall.d.ts +32 -0
  78. package/dist/core/compaction/history-recall.d.ts.map +1 -0
  79. package/dist/core/compaction/history-recall.js +275 -0
  80. package/dist/core/compaction/history-recall.js.map +1 -0
  81. package/dist/core/compaction/index.d.ts +2 -0
  82. package/dist/core/compaction/index.d.ts.map +1 -1
  83. package/dist/core/compaction/index.js +2 -0
  84. package/dist/core/compaction/index.js.map +1 -1
  85. package/dist/core/compaction/pi-summary-fallback.d.ts.map +1 -1
  86. package/dist/core/compaction/pi-summary-fallback.js +1 -0
  87. package/dist/core/compaction/pi-summary-fallback.js.map +1 -1
  88. package/dist/core/compaction/planner-outcome.d.ts +14 -0
  89. package/dist/core/compaction/planner-outcome.d.ts.map +1 -1
  90. package/dist/core/compaction/planner-outcome.js +8 -0
  91. package/dist/core/compaction/planner-outcome.js.map +1 -1
  92. package/dist/core/compaction/range-planner-diagnostics.d.ts +35 -10
  93. package/dist/core/compaction/range-planner-diagnostics.d.ts.map +1 -1
  94. package/dist/core/compaction/range-planner-diagnostics.js +67 -24
  95. package/dist/core/compaction/range-planner-diagnostics.js.map +1 -1
  96. package/dist/core/compaction/range-planner.d.ts +7 -4
  97. package/dist/core/compaction/range-planner.d.ts.map +1 -1
  98. package/dist/core/compaction/range-planner.js +43 -19
  99. package/dist/core/compaction/range-planner.js.map +1 -1
  100. package/dist/core/compaction/refusal-recovery.d.ts +27 -0
  101. package/dist/core/compaction/refusal-recovery.d.ts.map +1 -0
  102. package/dist/core/compaction/refusal-recovery.js +65 -0
  103. package/dist/core/compaction/refusal-recovery.js.map +1 -0
  104. package/dist/core/compaction/region-trimming.d.ts +23 -0
  105. package/dist/core/compaction/region-trimming.d.ts.map +1 -1
  106. package/dist/core/compaction/region-trimming.js +59 -15
  107. package/dist/core/compaction/region-trimming.js.map +1 -1
  108. package/dist/core/compaction/structured-compaction-input.d.ts +19 -1
  109. package/dist/core/compaction/structured-compaction-input.d.ts.map +1 -1
  110. package/dist/core/compaction/structured-compaction-input.js +30 -17
  111. package/dist/core/compaction/structured-compaction-input.js.map +1 -1
  112. package/dist/core/compaction/transcript-serialization.d.ts +9 -3
  113. package/dist/core/compaction/transcript-serialization.d.ts.map +1 -1
  114. package/dist/core/compaction/transcript-serialization.js +18 -10
  115. package/dist/core/compaction/transcript-serialization.js.map +1 -1
  116. package/dist/core/messages.d.ts +5 -1
  117. package/dist/core/messages.d.ts.map +1 -1
  118. package/dist/core/messages.js +21 -3
  119. package/dist/core/messages.js.map +1 -1
  120. package/dist/core/session-manager-core.js +1 -1
  121. package/dist/core/session-manager-core.js.map +1 -1
  122. package/dist/core/session-manager-history.d.ts +1 -1
  123. package/dist/core/session-manager-history.d.ts.map +1 -1
  124. package/dist/core/session-manager-history.js +2 -5
  125. package/dist/core/session-manager-history.js.map +1 -1
  126. package/dist/core/settings-defaults.d.ts +2 -0
  127. package/dist/core/settings-defaults.d.ts.map +1 -1
  128. package/dist/core/settings-defaults.js +2 -0
  129. package/dist/core/settings-defaults.js.map +1 -1
  130. package/dist/core/settings-manager-basic-accessors.d.ts +2 -0
  131. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  132. package/dist/core/settings-manager-basic-accessors.js +3 -0
  133. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  134. package/dist/core/settings-schema.d.ts +2 -0
  135. package/dist/core/settings-schema.d.ts.map +1 -1
  136. package/dist/core/settings-schema.js +4 -0
  137. package/dist/core/settings-schema.js.map +1 -1
  138. package/dist/core/storage/session/conformance.d.ts.map +1 -1
  139. package/dist/core/storage/session/conformance.js +12 -0
  140. package/dist/core/storage/session/conformance.js.map +1 -1
  141. package/dist/core/storage/session/jsonl-session-store.d.ts.map +1 -1
  142. package/dist/core/storage/session/jsonl-session-store.js +3 -0
  143. package/dist/core/storage/session/jsonl-session-store.js.map +1 -1
  144. package/dist/core/storage/session/legacy-session-store.d.ts.map +1 -1
  145. package/dist/core/storage/session/legacy-session-store.js +3 -0
  146. package/dist/core/storage/session/legacy-session-store.js.map +1 -1
  147. package/dist/core/storage/session/memory-session-store.d.ts.map +1 -1
  148. package/dist/core/storage/session/memory-session-store.js +3 -0
  149. package/dist/core/storage/session/memory-session-store.js.map +1 -1
  150. package/dist/core/storage/session/sql-session-store.d.ts.map +1 -1
  151. package/dist/core/storage/session/sql-session-store.js +12 -3
  152. package/dist/core/storage/session/sql-session-store.js.map +1 -1
  153. package/dist/core/storage/session/types.d.ts +3 -0
  154. package/dist/core/storage/session/types.d.ts.map +1 -1
  155. package/dist/core/storage/session/types.js +3 -0
  156. package/dist/core/storage/session/types.js.map +1 -1
  157. package/dist/core/tools/history-protocol.d.ts +3 -0
  158. package/dist/core/tools/history-protocol.d.ts.map +1 -1
  159. package/dist/core/tools/history-protocol.js +7 -87
  160. package/dist/core/tools/history-protocol.js.map +1 -1
  161. package/dist/core/tools/history-transcript.d.ts +24 -0
  162. package/dist/core/tools/history-transcript.d.ts.map +1 -0
  163. package/dist/core/tools/history-transcript.js +110 -0
  164. package/dist/core/tools/history-transcript.js.map +1 -0
  165. package/dist/index.d.ts +1 -1
  166. package/dist/index.d.ts.map +1 -1
  167. package/dist/index.js.map +1 -1
  168. package/dist/main-session.d.ts.map +1 -1
  169. package/dist/main-session.js +21 -5
  170. package/dist/main-session.js.map +1 -1
  171. package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
  172. package/dist/modes/interactive/components/compaction-boundary-message.js +7 -3
  173. package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
  174. package/dist/modes/interactive/interactive-render-chat.js +2 -2
  175. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  176. package/dist/session-id-target.d.ts +1 -0
  177. package/dist/session-id-target.d.ts.map +1 -1
  178. package/dist/session-id-target.js +3 -0
  179. package/dist/session-id-target.js.map +1 -1
  180. package/docs/compaction/reference.md +3 -2
  181. package/docs/compaction.md +35 -7
  182. package/docs/development.md +1 -1
  183. package/docs/sdk/reference.md +6 -5
  184. package/docs/sessions.md +3 -3
  185. package/docs/settings.md +3 -0
  186. package/docs/storage.md +2 -0
  187. package/docs/workflows/api-reference.md +15 -3
  188. package/docs/workflows/authoring.md +2 -2
  189. package/docs/workflows/operations.md +1 -0
  190. package/docs/workflows/reliable-design.md +1 -1
  191. package/npm-shrinkwrap.json +32 -32
  192. package/package.json +3 -3
  193. package/schemas/settings.schema.json +5 -0
package/docs/sessions.md CHANGED
@@ -152,7 +152,7 @@ You can search, navigate, or cancel while the picker loads sessions. Closing it
152
152
 
153
153
  ### Internal (workflow) sessions
154
154
 
155
- Sessions created by workflow stage execution are marked as **internal** and are excluded from the standard `/resume`, `atomic -r`, and `--continue` history by default. Use `/workflow resume <runId>` or the workflow tool's resume/status actions to inspect and continue a workflow run and its stages. A workflow stage session can also be opened directly by passing its session ID to `--session`.
155
+ Sessions created by workflow stage execution are marked as **internal** and are excluded from the standard `/resume`, `atomic -r`, and `--continue` history by default. Use `/workflow resume <runId>` or the workflow tool's resume/status actions to inspect and continue a workflow run and its stages. A workflow stage session can also be opened directly by passing its session ID to `--session`. A stage's own transcript is recalled with `history://sessions/<id>` like any other session.
156
156
 
157
157
  ## Recalling earlier work
158
158
 
@@ -165,9 +165,9 @@ The agent can look back at this project's earlier sessions and workflow runs, ev
165
165
  | `history://workflows` | Recent workflow runs, newest first. |
166
166
  | `history://workflows/<runId>` | One run: inputs, stages with links to their session transcripts, result and error. |
167
167
 
168
- `search` with `history://sessions`, `history://workflows` or `history://` finds text in the most recent records and labels each match with a URL and line number that `read` can open. Searching workflow runs also searches their stages' session transcripts, which session listings leave out because stage sessions are internal. A multi-record search covers one page, the newest 25 records unless you add `?limit=N` and `?offset=N`, and skips the current session. Its first result, kept even when the search is narrowed with `:N-M`, says which records it covered and gives the URL that continues the search. When `history://` searches both and one of them cannot be read, for example because no workflow history is registered, the result names it and the reason beside the other's matches. A phrase that straddles a split point of a very long line can be missed.
168
+ `search` with `history://sessions`, `history://workflows` or `history://` finds text in the most recent records and labels each match with a URL and line number that `read` can open. Searching workflow runs also searches their stages' session transcripts, which session listings leave out because stage sessions are internal. A multi-record search covers one page, the newest 25 records unless you add `?limit=N` and `?offset=N`, and skips the current session, which you reach through its own `history://sessions/<id>` URL instead. Its first result, kept even when the search is narrowed with `:N-M`, says which records it covered and gives the URL that continues the search. When `history://` searches both and one of them cannot be read, for example because no workflow history is registered, the result names it and the reason beside the other's matches. A phrase that straddles a split point of a very long line can be missed.
169
169
 
170
- When a view or search covers other projects, its links carry `?project=` so they read back in the same scope. A workflow stage's session opens through its run even when the stage ran in its own directory or worktree.
170
+ When a view or search covers other projects, its links carry `?project=` so they read back in the same scope. A workflow stage's session opens through its run even when the stage ran in its own directory or worktree. The current session always opens through its own URL. After a compaction removes lines from the agent's context, the compacted context names that URL so the agent can `search` it for the removed text, including text removed by earlier compactions of the same session, and `read` it with `:N-M`. It also points the agent at `history://sessions`, `history://workflows` and `history://` for the project's other sessions and workflow runs, before it redoes an investigation or when a removed decision, error message, file path or result matters, and reminds it that a multi-record search covers the newest records and pages on with `?offset=`. Compaction itself adds a short `Recalled context` section of matching lines from this history; see [Recalled context](/compaction#recalled-context).
171
171
 
172
172
  By default only the current project's history is visible. Other projects' sessions appear only when a sessions URL carries `?project=all` or `?project=<dir>`, which the agent uses only when you ask it to. Workflow history is always limited to the current project and includes runs you started with `/workflow` as well as runs the agent started, including finished runs that recorded no checkpoints and cancelled runs. `history://` is read-only.
173
173
 
package/docs/settings.md CHANGED
@@ -329,6 +329,7 @@ On a genuine first run, Atomic previews available themes and asks whether to opt
329
329
  | `compaction.modelOverrides` | object | `{}` | Exact `"provider/modelId"` keys with optional `reserveTokens` and `preserve_recent` overrides |
330
330
  | `compaction.background` | boolean | `true` | Compact older context in the background while the agent keeps working; blocking compaction only on overflow or at the `reserveTokens` threshold when no background result is ready. `/settings`: **Background compaction**. See [Background compaction](/compaction#background-compaction) |
331
331
  | `compaction.backgroundThresholdPercent` | number | `75` | Percentage of the context window at which background compaction starts; above 0 and below 100. `/settings`: **Background compaction threshold** (50, 60, 70, 75, 80 or 90). While either background setting holds an invalid value, Atomic reports a settings warning on load or `/reload` and runs with background compaction off and the 75% default, and `/settings` shows those values until you pick valid ones |
332
+ | `compaction.historyRecall` | boolean | `true` | Add a short `Recalled context` section to each compacted context: lines from this session's earlier history, the project's other sessions and workflow runs that match the current task, each with a `history://` source to `read`. It never adds more than 10% of the kept context or 1,500 tokens, gives up after 3 seconds, and leaves the compacted context unchanged on any failure. `false` turns it off. See [Recalled context](/compaction#recalled-context) |
332
333
 
333
334
  ```json
334
335
  {
@@ -652,6 +653,8 @@ Workflow runs use a SQLite journal, by default the [journal store](/storage#the-
652
653
  }
653
654
  ```
654
655
 
656
+ `workflows.journal` selects where workflow runs are stored. Sessions, including the sessions of workflow stages, still use `sessions.storage` (default `~/.atomic/workflows/journal.sqlite`), so the `--session-store` path in a resume hint can differ from your journal path. To keep both in one file, set `sessions.storage` to the same path, or set the shared `storage` instead of either. Sessions already saved in the old store stay there; resume them with `--session-store <old path>`.
657
+
655
658
  #### Local worker pools
656
659
 
657
660
  Local worker pools are disabled unless `workflows.localWorkers` is set. With the option omitted, Atomic creates no worker tables, processes, or polling loops. A worker definition must be importable from its module path and export name. Only first-level `ctx.workflow(...)` child subtrees run in the pool; a root closure stays in the main process, and nested children stay on their assigned worker.
package/docs/storage.md CHANGED
@@ -162,6 +162,8 @@ A `skipped` result means consolidation did not finish, not that the run stayed i
162
162
 
163
163
  Select a journal file only to isolate runs, for example in tests or a sandbox: `workflows.journal.path`, `ATOMIC_WORKFLOW_JOURNAL_PATH`, `RunOpts.journal` and `createAgentSession({ journal })` keep working as one file. You do not need separate journals for performance: the store already keeps concurrent roots apart. A shared libSQL or Turso database stays one selection; the adapter scales it.
164
164
 
165
+ A journal selection does not move sessions. Sessions, including workflow stage sessions, follow `sessions.storage` or the shared `storage`. Set one of those to the same file if you want sessions and runs stored together.
166
+
165
167
  `admission.userLimits` counts across the runs of one database, so it needs an explicit journal file: set `workflows.journal.path` and use that path as `userDatabase`.
166
168
 
167
169
  ## Bring your own driver
@@ -787,7 +787,7 @@ If extension initialization fails and its session cannot be cleaned up, the stag
787
787
 
788
788
  A context overflow that the stage session's compaction has already failed to resolve is terminal for its candidate: it skips the same-candidate retry, because re-sending an identical request cannot fit a context compaction could not shrink, and advances straight to the next candidate.
789
789
 
790
- A schema-backed candidate gets the original prompt plus up to three corrective follow-ups to produce valid `structured_output`. Exhaustion records a failed attempt and advances to the next candidate with a fresh correction budget. Successful capture is never retried. If the chain runs out, the stage fails with its structured-output contract error.
790
+ A schema-backed candidate gets the original prompt, which the runtime closes with an instruction to finish by calling `structured_output` exactly once. If the turn ends without a successful call, the runtime runs that inference itself from the stage's final answer, and only when that fails does the candidate get up to three corrective follow-ups to produce valid `structured_output`. Exhaustion records a failed attempt and advances to the next candidate with a fresh correction budget. Successful capture is never retried. If the chain runs out, the stage fails with its structured-output contract error.
791
791
 
792
792
  Corrective follow-ups are reserved for turns that actually answered without a valid `structured_output` call. A schema-backed prompt that resolves without any assistant message is treated as a transient provider failure instead: it spends the same-candidate retry budget from `settings.retry`, then advances to the next candidate, and its attempt records carry `Model turn ended without an assistant message after the prompt (empty completion)` rather than the structured-output contract error. If every candidate ends that way, the run blocks as a recoverable `provider_unavailable` failure that can be resumed once the provider recovers. Cancellation during such a turn stops both the retries and the chain.
793
793
 
@@ -938,9 +938,20 @@ readonly schema?: TSchema;
938
938
 
939
939
  Enables one schema-backed `structured_output` call for that item. `ctx.stage`, `ctx.task`, `ctx.chain`, and `ctx.parallel` items accept a TypeBox schema or a plain JSON Schema descriptor object. The calling model supplies `instructions` and a nonempty named `state`, plus optional exact `model` and `fallbackModels` IDs. The tool infers a value matching the schema; that inferred value becomes the schema-backed `stage.prompt(...)` result or `WorkflowTaskResult.structured`. The calling model's arguments are not the result. The inferred result has no fixed size limit beyond the selected model's own output-token limit. Omit `model` to use the current stage chat model. After the primary and explicit fallbacks, the current chat model is tried if it was not already used. Atomic resolves each ID through the stage model registry. A registered classifier is used only when the schema is a finite Choice; otherwise that candidate is skipped and the skip is recorded. A classifier runtime failure advances to the next model unless the request was cancelled or refused for safety.
940
940
 
941
- A schema-backed `StageContext` supports one `prompt()` call, so create another stage for another structured prompt. A missing call, or an inference failure that exhausts the tool's own model chain, receives up to three corrective follow-ups quoting the contract error. That budget is per stage model candidate. A candidate that spends the initial prompt and all three follow-ups without a valid inferred result fails, and the stage advances to the next entry in [`fallbackModels`](#fallbackmodels), which receives the original stage prompt and its own fresh budget. With no stage fallback left, the stage fails with the contract error rather than completing. An explicit tool allowlist automatically receives `structured_output`, while items without `schema` do not.
941
+ Atomic closes every schema-backed prompt with an instruction to finish by calling `structured_output` exactly once, so the prompt does not have to say so; write only the task. If the model still ends its turn without a successful call, Atomic runs the same inference for it: the decision model, then its fallbacks, then the current chat model infer the result from the stage's task, its final assistant text and the recent exchange, and the stage completes with that result as if the model had called the tool. A call the model made and that succeeded is never inferred a second time. A stage whose turn left no assistant text is not inferred from, because the task alone would be guesswork.
942
942
 
943
- With both `schema` and `output`, ordinary text from the successful `structured_output` message goes to the artifact. The inferred tool result is the typed value. Corrective attempts and later turns cannot replace that pair. If the successful message has no ordinary text, the artifact uses the most recent earlier assistant text without a `structured_output` call, or stays empty with a warning. The pattern builtins save their inter-stage decisions as JSON separately.
943
+ A schema-backed `StageContext` supports one `prompt()` call, so create another stage for another structured prompt. A missing call that Atomic's own inference could not make up for, or an inference failure that exhausts the tool's own model chain, receives up to three corrective follow-ups quoting the contract error. Atomic's own inference failure is kept as the `cause` of the error the stage finally fails with, as a [`WorkflowStructuredOutputInferenceError`](#structured-output-inference-errors), and an inference that ran and failed is listed once in the stage's warnings. A decision model's invalid answer counts as a missing call, so the corrective follow-ups and the contract error apply to it as before. That budget is per stage model candidate. A candidate that spends the initial prompt and all three follow-ups without a valid inferred result fails, and the stage advances to the next entry in [`fallbackModels`](#fallbackmodels), which receives the original stage prompt and its own fresh budget. With no stage fallback left, the stage fails with the contract error rather than completing. An explicit tool allowlist automatically receives `structured_output`, while items without `schema` do not.
944
+
945
+ With both `schema` and `output`, ordinary text from the successful `structured_output` message goes to the artifact. The inferred tool result is the typed value. Corrective attempts and later turns cannot replace that pair. If the successful message has no ordinary text, or Atomic ran the inference because the model never called the tool, the artifact uses the most recent assistant text without a `structured_output` call, or stays empty with a warning. The pattern builtins save their inter-stage decisions as JSON separately.
946
+
947
+ #### Structured-output inference errors
948
+
949
+ `WorkflowStructuredOutputInferenceError` reports that Atomic's own `structured_output` inference for a schema-backed stage produced no result. It is never thrown on its own: the stage goes on to its corrective follow-ups, and the error is the `cause` of whatever the stage finally fails with. When the inference failed for a reason a corrective follow-up cannot repair, such as a deadline overrun or a provider outage, the stage's failure keeps the text of that failure, as for a failed call by the model. It has a stable `code`, a `hint`, `retryable: false`, JSON-safe `fields` (`runId`, `stageId`, `stageName`, `toolCallId`), `toJSON()` and `deserializeWorkflowStructuredOutputInferenceError()`. `isWorkflowStructuredOutputInferenceError(error)` also matches a copy from another process, and `findWorkflowStructuredOutputInferenceError(error)` returns the first one in a `cause` chain, at most eight levels deep. A cancelled stage is not a failure of the inference and never carries this error.
950
+
951
+ | Class | `code` | When | Fields | What to do |
952
+ |---|---|---|---|---|
953
+ | `WorkflowStructuredOutputInferenceError` | `auto-inference-failed` | The inference ran and failed; `cause` is the decision error. | `runId`, `stageId`, `stageName`, `toolCallId` | Check the [`decisionModel`](/settings#decisionmodel) and its credentials, raise [`schemaTimeoutMs`](#schematimeoutms) for a slow model, or end the stage with the final answer its schema needs |
954
+ | `WorkflowStructuredOutputInferenceError` | `tool-context-unavailable` | The stage's session offers no tool context to run the inference in, so it never ran. This is a custom `AgentSessionAdapter` whose sessions are not Atomic SDK sessions. | `runId`, `stageId`, `stageName`, `toolCallId` | Create the stage's session with the Atomic SDK; until then the corrective follow-ups are the only repair |
944
955
 
945
956
  ### `schemaTimeoutMs`
946
957
 
@@ -2263,6 +2274,7 @@ When a child workflow fails on a typed error, in this process or on a pooled wor
2263
2274
  | `family` | Errors | Guard |
2264
2275
  | --- | --- | --- |
2265
2276
  | `stage-wait` | [`StageWaitError`](#stage-wait-errors) and its subclasses | `isStageWaitError` |
2277
+ | `structured-output` | [`WorkflowStructuredOutputInferenceError`](#structured-output-inference-errors) | `isWorkflowStructuredOutputInferenceError` |
2266
2278
  | `tool-detachment` | `ToolDetachmentError` | `isToolDetachmentError` |
2267
2279
  | `run-eviction` | [`RunEvictionError`](#evicting-waiting-runs) and its subclasses | `isRunEvictionError` |
2268
2280
  | `git-provision` | `GitProvisionError`, `GitUnavailableError`, `GitProvisionTimeoutError`, `GitProvisionConfigError` | `isGitProvisionError` |
@@ -431,7 +431,7 @@ Use `Static<typeof schema>` (both `Static` and `TSchema` are re-exported from `@
431
431
  const gate = ctx.stage("review-gate", {
432
432
  schema: Type.Object({ approved: Type.Boolean() }, { additionalProperties: false }),
433
433
  });
434
- const decision = await gate.prompt("Review the implementation and call structured_output.");
434
+ const decision = await gate.prompt("Review the implementation.");
435
435
  if (!decision.approved) {
436
436
  await gate.sendUserMessage("Explain the highest-priority changes needed before approval.");
437
437
  }
@@ -681,7 +681,7 @@ A `verified` result is cached durably, so a resumed run does not click again. A
681
681
 
682
682
  ### Classifier and image models in `ctx.tool`
683
683
 
684
- Workflow stages run chat language models. For a schema-backed decision, use the stage's `schema` and `structured_output` tool. It resolves an exact chat or registered classifier ID through the stage model registry and falls back on a classifier runtime failure. The direct `@bastani/pi-ai` examples below are for cases that need the classifier's probabilities or image generation from workflow TypeScript inside `ctx.tool(name, args, fn, { timeoutMs })`. Those calls are durable, replayable nodes. `model: "auto"` selects only chat language models for stage execution; `decisionModel` may select a classifier for routing, but a classifier never executes a chat stage.
684
+ Workflow stages run chat language models. For a schema-backed decision, use the stage's `schema` and `structured_output` tool; write only the task in the prompt, because Atomic ends every schema-backed prompt with the instruction to finish by calling the tool exactly once and, if the model skips the call, runs the same inference itself from the stage's final answer. It resolves an exact chat or registered classifier ID through the stage model registry and falls back on a classifier runtime failure. The direct `@bastani/pi-ai` examples below are for cases that need the classifier's probabilities or image generation from workflow TypeScript inside `ctx.tool(name, args, fn, { timeoutMs })`. Those calls are durable, replayable nodes. `model: "auto"` selects only chat language models for stage execution; `decisionModel` may select a classifier for routing, but a classifier never executes a chat stage.
685
685
 
686
686
  Atomic provides `@bastani/atomic/workflows`, `typebox`, and the exact imports `@bastani/atomic`, `@bastani/pi-ai`, and `@bastani/pi-ai/providers/all` to workflow files. The latter three use the running CLI's module instances and version, including `AuthStorage`. These examples need no project-local package installation, in npm or standalone-binary installs. A project copy does not override these host-provided imports.
687
687
 
@@ -340,6 +340,7 @@ Controls work on a waiting stage:
340
340
 
341
341
  - Messages and steering to a stage waiting on a tool call are held, and reach the stage in order when it reopens. They are held in memory, so they are lost if Atomic stops before the stage wakes; Intercom sends wait in the run's queue and survive a restart. A message to a stage waiting between turns reopens it.
342
342
  - `pause` holds the stage: results that arrive meanwhile wait until you resume it.
343
+ - While a stage's conversation waits on a tool call's result, nothing starts a new turn on its session: a notification such as a finished subagent's, steering and follow-ups wait, and join the turn the result continues, and a compaction leaves the waiting call's turn in the conversation. If the conversation has moved past a waiting call anyway, for example because the model kept working, Atomic cancels that call and drops its late result instead of failing the stage: the stage keeps its own result, including a captured `structured_output`, and the run goes on. A result that arrives while the stage's session is still running waits for that run to settle first. A dropped call, and a stage prompt or retry that was not sent because the session waits on a result, are recorded in the [debug log](/development#debugging) as `stale-detached-call` and `stage-input-held-for-detached-results`.
343
344
  - `quit`, or a crash of the Atomic process, stops the wait. `/workflow resume` reopens the stage and starts the pending tool call again with the same call id and arguments, then continues the turn; a call whose result was saved before the stop is not started again, and the turn continues from that result. It does not send the stage's prompt again, also for a stage that waited between turns. A tool call can therefore run more than once across a restart.
344
345
  - If the session store the run resumes with does not hold a waiting stage's session, `/workflow resume` fails with `StageRehydrationError` (`session-not-found`) before changing anything, for a run that stopped with Atomic and for one that failed or is blocked alike. Resume with the session storage the run was started with; `atomic storage status` shows which one this process selects. On a machine that uses local-only storage and is not joined to shared storage, run `atomic team join <url> --token-file <path>` first (see [Team and CI setup](/guides/team-setup)); joining sets the team database but keeps sessions in a local store, so also select the session storage that holds the waiting stage's session. A child workflow, including one a worker pool runs, checks its own waiting stages when it starts again: a missing session fails the child with the same error before it does any work, and the pool does not retry it until the root is resumed, when the child checks again. The error's `rootRunId` names the run to resume; a worker pool keeps its children's sessions in a store that run's journal selects, so resume it with the journal storage it was started with, on the machine that ran a local pool.
345
346
  - If the session store is unreachable when the results arrive, Atomic saves the results with the stage's wait and tries to reopen the session, and to save the results into it, three times over a few seconds. When the store is still unreachable, the run is blocked, not failed, with `StageRehydrationError` (`session-unavailable`). Make the store reachable, then run `/workflow resume`: the stage continues its turn from the saved results and the tool does not run again.
@@ -237,7 +237,7 @@ export default workflow({
237
237
  prompt: [
238
238
  `Review the current ${branch} diff against ${baseRef} for ${issue}.`,
239
239
  "Inspect the code and tests. Approve only when the issue is fully met and the patch is safe.",
240
- "Return structured_output with approved and evidence-backed findings.",
240
+ "Report whether it is approved, with evidence-backed findings.",
241
241
  ].join("\n"),
242
242
  });
243
243
  const decision = review.structured as Static<typeof reviewDecision>;
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@bastani/atomic",
3
- "version": "0.9.73",
3
+ "version": "0.9.74",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@bastani/atomic",
9
- "version": "0.9.73",
9
+ "version": "0.9.74",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "@bastani/atomic-natives": "0.9.73",
13
- "@bastani/pi-ai": "0.9.73",
12
+ "@bastani/atomic-natives": "0.9.74",
13
+ "@bastani/pi-ai": "0.9.74",
14
14
  "@earendil-works/pi-agent-core": "1.5.0",
15
15
  "@earendil-works/pi-codemode": "1.5.0",
16
16
  "@earendil-works/pi-tui": "1.5.0",
@@ -427,18 +427,18 @@
427
427
  }
428
428
  },
429
429
  "node_modules/@bastani/atomic-natives": {
430
- "version": "0.9.73",
431
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives/-/atomic-natives-0.9.73.tgz",
430
+ "version": "0.9.74",
431
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives/-/atomic-natives-0.9.74.tgz",
432
432
  "license": "MIT",
433
433
  "optionalDependencies": {
434
- "@bastani/atomic-natives-darwin-arm64": "0.9.73",
435
- "@bastani/atomic-natives-darwin-x64": "0.9.73",
436
- "@bastani/atomic-natives-linux-arm64-gnu": "0.9.73",
437
- "@bastani/atomic-natives-linux-arm64-musl": "0.9.73",
438
- "@bastani/atomic-natives-linux-x64-gnu": "0.9.73",
439
- "@bastani/atomic-natives-linux-x64-musl": "0.9.73",
440
- "@bastani/atomic-natives-win32-arm64-msvc": "0.9.73",
441
- "@bastani/atomic-natives-win32-x64-msvc": "0.9.73"
434
+ "@bastani/atomic-natives-darwin-arm64": "0.9.74",
435
+ "@bastani/atomic-natives-darwin-x64": "0.9.74",
436
+ "@bastani/atomic-natives-linux-arm64-gnu": "0.9.74",
437
+ "@bastani/atomic-natives-linux-arm64-musl": "0.9.74",
438
+ "@bastani/atomic-natives-linux-x64-gnu": "0.9.74",
439
+ "@bastani/atomic-natives-linux-x64-musl": "0.9.74",
440
+ "@bastani/atomic-natives-win32-arm64-msvc": "0.9.74",
441
+ "@bastani/atomic-natives-win32-x64-msvc": "0.9.74"
442
442
  },
443
443
  "engines": {
444
444
  "bun": ">=1.4.2",
@@ -446,8 +446,8 @@
446
446
  }
447
447
  },
448
448
  "node_modules/@bastani/atomic-natives-darwin-arm64": {
449
- "version": "0.9.73",
450
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-arm64/-/atomic-natives-darwin-arm64-0.9.73.tgz",
449
+ "version": "0.9.74",
450
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-arm64/-/atomic-natives-darwin-arm64-0.9.74.tgz",
451
451
  "license": "MIT",
452
452
  "os": [
453
453
  "darwin"
@@ -458,8 +458,8 @@
458
458
  "optional": true
459
459
  },
460
460
  "node_modules/@bastani/atomic-natives-darwin-x64": {
461
- "version": "0.9.73",
462
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-x64/-/atomic-natives-darwin-x64-0.9.73.tgz",
461
+ "version": "0.9.74",
462
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-darwin-x64/-/atomic-natives-darwin-x64-0.9.74.tgz",
463
463
  "license": "MIT",
464
464
  "os": [
465
465
  "darwin"
@@ -470,8 +470,8 @@
470
470
  "optional": true
471
471
  },
472
472
  "node_modules/@bastani/atomic-natives-linux-arm64-gnu": {
473
- "version": "0.9.73",
474
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-gnu/-/atomic-natives-linux-arm64-gnu-0.9.73.tgz",
473
+ "version": "0.9.74",
474
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-gnu/-/atomic-natives-linux-arm64-gnu-0.9.74.tgz",
475
475
  "license": "MIT",
476
476
  "os": [
477
477
  "linux"
@@ -485,8 +485,8 @@
485
485
  "optional": true
486
486
  },
487
487
  "node_modules/@bastani/atomic-natives-linux-arm64-musl": {
488
- "version": "0.9.73",
489
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-musl/-/atomic-natives-linux-arm64-musl-0.9.73.tgz",
488
+ "version": "0.9.74",
489
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-arm64-musl/-/atomic-natives-linux-arm64-musl-0.9.74.tgz",
490
490
  "license": "MIT",
491
491
  "os": [
492
492
  "linux"
@@ -500,8 +500,8 @@
500
500
  "optional": true
501
501
  },
502
502
  "node_modules/@bastani/atomic-natives-linux-x64-gnu": {
503
- "version": "0.9.73",
504
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-gnu/-/atomic-natives-linux-x64-gnu-0.9.73.tgz",
503
+ "version": "0.9.74",
504
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-gnu/-/atomic-natives-linux-x64-gnu-0.9.74.tgz",
505
505
  "license": "MIT",
506
506
  "os": [
507
507
  "linux"
@@ -515,8 +515,8 @@
515
515
  "optional": true
516
516
  },
517
517
  "node_modules/@bastani/atomic-natives-linux-x64-musl": {
518
- "version": "0.9.73",
519
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-musl/-/atomic-natives-linux-x64-musl-0.9.73.tgz",
518
+ "version": "0.9.74",
519
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-linux-x64-musl/-/atomic-natives-linux-x64-musl-0.9.74.tgz",
520
520
  "license": "MIT",
521
521
  "os": [
522
522
  "linux"
@@ -530,8 +530,8 @@
530
530
  "optional": true
531
531
  },
532
532
  "node_modules/@bastani/atomic-natives-win32-arm64-msvc": {
533
- "version": "0.9.73",
534
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-arm64-msvc/-/atomic-natives-win32-arm64-msvc-0.9.73.tgz",
533
+ "version": "0.9.74",
534
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-arm64-msvc/-/atomic-natives-win32-arm64-msvc-0.9.74.tgz",
535
535
  "license": "MIT",
536
536
  "os": [
537
537
  "win32"
@@ -542,8 +542,8 @@
542
542
  "optional": true
543
543
  },
544
544
  "node_modules/@bastani/atomic-natives-win32-x64-msvc": {
545
- "version": "0.9.73",
546
- "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-x64-msvc/-/atomic-natives-win32-x64-msvc-0.9.73.tgz",
545
+ "version": "0.9.74",
546
+ "resolved": "https://registry.npmjs.org/@bastani/atomic-natives-win32-x64-msvc/-/atomic-natives-win32-x64-msvc-0.9.74.tgz",
547
547
  "license": "MIT",
548
548
  "os": [
549
549
  "win32"
@@ -554,8 +554,8 @@
554
554
  "optional": true
555
555
  },
556
556
  "node_modules/@bastani/pi-ai": {
557
- "version": "0.9.73",
558
- "resolved": "https://registry.npmjs.org/@bastani/pi-ai/-/pi-ai-0.9.73.tgz",
557
+ "version": "0.9.74",
558
+ "resolved": "https://registry.npmjs.org/@bastani/pi-ai/-/pi-ai-0.9.74.tgz",
559
559
  "license": "MIT",
560
560
  "dependencies": {
561
561
  "@anthropic-ai/sdk": "0.129.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/atomic",
3
- "version": "0.9.73",
3
+ "version": "0.9.74",
4
4
  "description": "Atomic coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "atomicConfig": {
@@ -89,8 +89,8 @@
89
89
  "prepublishOnly": "bun run clean && bun run build && bun run shrinkwrap"
90
90
  },
91
91
  "dependencies": {
92
- "@bastani/atomic-natives": "0.9.73",
93
- "@bastani/pi-ai": "0.9.73",
92
+ "@bastani/atomic-natives": "0.9.74",
93
+ "@bastani/pi-ai": "0.9.74",
94
94
  "@earendil-works/pi-agent-core": "1.5.0",
95
95
  "@earendil-works/pi-codemode": "1.5.0",
96
96
  "@earendil-works/pi-tui": "1.5.0",
@@ -273,6 +273,11 @@
273
273
  "exclusiveMaximum": 100,
274
274
  "description": "Percentage of the context window at which background compaction starts. The reserveTokens threshold still compacts in the foreground when no background result is ready.",
275
275
  "default": 75
276
+ },
277
+ "historyRecall": {
278
+ "type": "boolean",
279
+ "description": "Add a short Recalled context section to each compacted context: lines from this session's earlier compaction cycles, the project's other sessions and workflow runs that match the current task. False leaves the compacted context as the planner kept it.",
280
+ "default": true
276
281
  }
277
282
  }
278
283
  },