docs/design.md is the canonical spec. This page is the plan of record: the
order work lands in, what each slice has to prove, and what is deliberately not
scheduled. It changes more often than the design.
Current release line: 0.1.0 (prepared; not yet published).
1. Where this stands
0.1.0is prepared (not yet published):run/3,resume/3, the public types, live events, the caller-owned context policy, approval and input pauses, streaming, the four-codec replay matrix, and the P0 runtime controls (cancellation, parallel tools,run_id, telemetry); the agent-as-tool helper (§24) and the checkpoint/journal seam (§25) are implemented.- The full suite is green: local
mix cion Elixir 1.20.5/OTP 29,mix docs --warnings-as-errorsandmix hex.build; CI is configured for Elixir 1.18.6/OTP 27 and 1.20.5/OTP 29. - CI is wired;
priv/plts/is ignored. - P0 runtime controls are implemented per design §23 and prepared as part of 0.1.0; the release checks stop before publishing.
- The agent-as-tool helper is implemented per design §24; it is part of 0.1.0, including the outer-loop integration and the release docs.
- The checkpoint/journal seam is implemented per design §25; it is part of 0.1.0.
- The caller-owned thread/context adapter is implemented per design §26; it is part of 0.1.0.
- Not published to Hex yet.
2. Delivery order for 0.1
Each slice ends with a green gate and a commit, and depends only on the slices before it.
| # | Slice | Gate |
|---|---|---|
| 1 | Baseline. VibeKit mix ci (credo, dialyzer, spec_lint, ex_dna, reach), a fixture HTTP server skeleton, and the CI workflow. Dependencies and the formatter are already in the scaffold. | mix ci green on the empty suite. |
| 2 | Types and options. Result (including halt_reason), Pending (including last_usage), Error, Event with exactly the fields design §9 pins; AgentCall.Context policy types; option validation as :configuration, including on_event: and context:; usage summation that skips nil. | Unit tests for validation, the structs' shapes, and nil-preserving totals. |
| 3 | Single-turn loop. Dispatch map from ToolCall.describe/2; complete/3; assistant turn plus user turn of results; the no-call finish; :max_tokens left visible; :run_started, :step_started, :step_finished, :finished; observer errors cannot change the run. | Happy path against a fixture server, the exact event sequence, and a replay test per bundled codec. |
| 4 | Dispatch edges. Invalid arguments, tool error, raise/exit, hallucinated name, a spec with no runner, empty and oversized results, duplicate names; :tool_call_started / :tool_result around each dispatch. | One test per row of design §12, each asserting the exact ToolResult the model would see, plus start-before-side-effect ordering. |
| 5 | Budget. Entry and pre-dispatch guards; a turn at the budget answers but runs no tool; {:exhausted, _} carries the transcript and halt_reason: :budget; nothing reaches max_steps + 1. | Termination tests, including a model that calls tools forever. |
| 6 | Context policy. context: option and AgentCall.Context types; {:cont, messages} pass-through and compaction; {:stop, reason} before a request; :context_updated; halt_reason: {:context, reason}; malformed returns and raises as :configuration. | Fixture server asserts the compacted messages; a stop at step 1 has response: nil and steps: 0; a stop after a turn keeps the last response; resume re-supplies the policy. |
| 7 | Pending and resume. Resuming from a serialized Pending; a multi-call pause; one user turn in call order; denial; approval/head mismatch; a re-pause; counters reported once; :approval_required and :run_started(resumed?: true) with continued step numbers; context: re-supplied. | term_to_binary round trip, and the three-call pause test, including its event sequence. |
| 8 | Streaming. Accumulator for text, thinking with signatures, and raw parts; assembler built with the client's JSON decoder; finish/1; HTTP.Error mapped to :llm; id/model nil; stream failures not synthesized; :text_delta / :thinking_delta only here. | Stream/complete parity from the same fixture content, delta gating and ordering, plus the replay tests in stream mode. |
| 9 | Release. README example, Hex metadata, CHANGELOG, docs, including the event and context contracts. | mix ci green at zero clones; mix hex.build clean. |
All nine slices are delivered; the table stays as the delivery record.
Slices 3–8 are the library; slices 1 and 9 are the packaging around it. Nothing in a later slice changes a public type introduced earlier, so a slice can ship as a pre-release if that becomes useful.
3. Deferred by choice
- A public
step/2. Not scheduled. The input pause is a second pause type, but it is data + resume, so the condition is met without reopening a step machine. Reopen only if a pause needs to inspect a running computation between steps (deferred execution, an external tool), not just carry a value. - Retry, backoff and rate limiting. Never in core.
Error.causecarriesretryable?andretry_after_ms; the policy stays with the caller. - Persistence and resumable sessions. The library stores nothing. Design §25
adds a versioned
Pending/Checkpointenvelope andresume_checkpoint/3; design §26 adds the caller-ownedAgentCall.Threadbehaviour. The caller's journal/thread store owns storage, expiry and retention. No ETS table, database or process is planned. - Provider catalog, model routing and auth lookup.
llm_call's non-goals too. - Memory, RAG, planning, autonomous multi-agent orchestration, agent-to-agent
messaging. Framework territory. The synchronous, caller-owned agent-as-a-tool
helper (§24) and the caller-owned
AgentCall.Threadbehaviour (§26) are supported; the library orchestrates nothing and stores no thread. - Prompt templates and tool schema authoring.
llm_callandtool_callown them. - Non-text tool results. Blocked on
llm_call'sToolResulttype; revisit only if it widens. - Built-in token counting, window lookup, trimming or summarization. Never
in core. The
context:policy is the seam; a reusable policy belongs in an application or a separate package. - Automatic retry after a provider context error. Not in 0.1. The policy is the prevention; the provider error is the fallback. A retry action would change the policy decision union and needs its own bound.
4. What would change this plan
StreamAssemblergrows a full-response fold. Delete our accumulator. It is the largest bespoke piece and the one most likely to drift from the codecs.llm_callchanges the canonical transcript shape. The replay tests and slices 3–8 move before any new feature; a broken transcript is not a bug to work around.ToolCall.Approval.Requeststops being serializable.Pendingis no longer data, the A1 escape hatch is gone, and the design reopens.- A pause needs to inspect a running computation between steps. The input
pause is still data + resume; a pause that must run code between the
model and a tool (deferred execution, an external tool) would return the
step/2question. - A caller needs parallel tools before 0.1 ships. Delivered in 0.1.0 as
max_concurrency:; slots and pause semantics are pinned in design §23.2. - Fixture-server replay fails for any dialect. Stop feature work; the loop's transcript is wrong.
- Event volume or blocking observers hurt throughput. A per-run queue or process becomes the design; the observer contract does not promise isolation.
- A product needs a stop button. Delivered in 0.1.0 as
cancel_when:at safe boundaries; it is never folded into the observer's return value. - A context policy needs a retry after the provider rejects a request. The
decisionunion gains a retry action with an explicit bound; that is a new design, not a context-policy tweak. - Callers keep reimplementing the same compaction policy. A reference implementation belongs in a separate package, not in the core.
5. Criteria for a new capability
A capability enters the core only when all four hold:
- It is expressible as data plus the existing outcome union, not as a new execution mode or a new return shape.
- It adds no provider-specific branch, and
llm_call/tool_callkeep their jobs. - Its failure modes are testable against fixtures, and the tests assert what the
model sees — not just what
run/3returns. - Any promise it makes about refusing caller input stops where the codec
decides. The test is whether a rule would judge differently for two dialects:
if it would, it belongs to
llm_calland not here.kind: :builtinis legal on Anthropic and Gemini and refused by OpenAI Chat, sorun/3's pre-request check covers field types and the chosen dialect reports its verdict on values as its own:llmerror. Reproducing that verdict here would both over-reject a spec another dialect accepts and leave the documented promise out of step with the code.
Anything that fails the first is a different library, not a feature here. Anything that fails the fourth is a promise this library cannot keep; scope the promise to what it can decide, rather than widening the check into a branch.
6. Definition of done for 0.1
run/3andresume/3implemented per design §9–§12.- Every row of design §12 has a test asserting the exact tool result.
- Replay tests pass for the four bundled codecs.
- Termination, honesty and
Pending-serialization tests pass. - Event sequence tests pass for all four outcomes; an observer that raises cannot
change an outcome;
:tool_call_startedprecedes the tool's side effect. - Context-policy tests pass: pass-through, compaction, stop at step 1, stop after
a turn, malformed return/raise, resume, and
:context_updatedordering. mix cigreen withex_dnaat zero clones.- README example compiles, Hex docs build, CHANGELOG records 0.1.0.
- No anti-goal from design §18 is present.
7. 0.1.0 — input and prompt control surface
Design §22. The first release adds a second pause kind without changing the outcome
union: approval stays binary, and user input becomes data plus one resume/3.
| # | Slice | Gate |
|---|---|---|
| 1 | Types and options. AgentCall.Input (struct + use AgentCall.Input); Pending.kind/input; resume input:; halt_reason {:input, _}; prompt:; :input_required; :run_started prompt?/input_tools. | Unit tests for the struct, option validation, Pending round trip, and the event type. |
| 2 | Model input tools. Marker detection in the dispatch map; a marked module's call pauses; arguments_error does not pause; the answer/cancel becomes the call's result; the runner never runs. | A real request through the fixture server; the marker's schema reaches llm_call; no tool execution; answer and cancel asserted. |
| 3 | Turn prompts. prompt: at :turn; ask pauses before :step_started; answer is a user message and continues the same turn; cancel is {:exhausted, halt_reason: {:input, reason}}; policy errors are :configuration. | Exact event order; the next request body contains the user answer; cancel sends no request. |
| 4 | Tool prompts. prompt: at {:tool, call}; ask pauses before approval; answer is the call's result and the tool does not run; cancel is is_error; :cont still reaches approval; the input-tool check wins. | Ordering tests with a marked input tool, a tool prompt and an approval in one turn. |
| 5 | Integration and release. Multi-pause and re-pause; serialization; counters/last_usage; streaming turns that call an input tool; replay of an input result through the four codecs; README/CHANGELOG/docs; version 0.1.0. | mix ci, docs and mix hex.build; the four-codec replay includes an input result; no new runtime dependency. |
0.1.0 is prepared, not published. The P0 runtime controls are part of the first release; see §9.
8. Definition of done for the 0.1.0 input extension
AgentCall.Input,Pending.kind/input,resume input:andhalt_reason {:input, _}implemented per design §22.- A marked input tool and a
prompt:policy each have tests for ask, answer, cancel, malformed return/raise, and a multi-pause turn. - The input-tool check wins over the prompt policy; a tool prompt wins over approval; approval still works in the same turn.
- Turn answers are user messages; tool answers are tool results; a turn cancel
is
:exhaustedwith{:input, _}; a tool cancel isis_error. - No new process, store, schema dependency, application config or global state.
mix cigreen; docs and Hex build green; the four-codec replay includes an input result.
9. 0.1.0 P0 runtime controls (internal 0.3 plan)
Design §23. These are part of the first release; the package version stays
0.1.0; no later package version is implied.
| # | Slice | Gate |
|---|---|---|
| 1 | Cancellation and run_id. cancel_when: at :turn/:tools; halt_reason {:cancelled, _}; run_id on Result/Pending/Event; :run_started cancel?. | No request or tool ran at either boundary; before/after a turn; policy errors are :configuration; supplied/generated run_id round trips. |
| 2 | Parallel tools. max_concurrency:; positional Pending.results slots [ToolResult | nil]; ordered tasks; first pause; later completed results; re-pause; one user turn in call order; serial 1 preserved. | Serial and parallel pause/re-pause; counters/last_usage; input/approval/tool-prompt combinations; dispatcher error aborts. |
| 3 | Telemetry. :telemetry dependency; run/turn/tool/stream spans; run_id metadata; no messages/args; handler failures cannot change the outcome. | Attach/detach handlers; start/stop/outcome assertions; durations; the gate stays green. |
| 4 | Release. design §23/roadmap/CHANGELOG/README; mix ci, docs, mix hex.build; no publish. | All green at 0.1.0; mix hex.publish --dry-run stops at auth. |
All four slices are delivered; the table stays as the delivery record.
10. Definition of done for the 0.1.0 P0 extension
- Cancellation is safe-boundary only; a
:turncancel sends no request and a:toolscancel runs no tool. A cancel wins over an equally due budget stop, and a resumed paused batch is not re-checked. - Parallel results are positional; the final user turn filters nils and keeps
call order;
max_concurrency:is a wave size and a pause stops later waves; serial1is unchanged. A parallel pause must re-supply the option on resume. run_idis on the public data and telemetry; a supplied empty id is rejected and a nilPending.run_idis normalized on resume.- Tool spans report an
is_errorresult as:error; a failed stream emits:exceptionwithout stop; a tool-target input answer has only its original:pendingtool span. mix ci, docs andmix hex.buildpass at0.1.0; no publish.
11. 0.1.0 — agent as a tool
Design §24. The helper is part of the first release; the package stays 0.1.0.
| # | Slice | Gate |
|---|---|---|
| 1 | Helper and mapping. AgentCall.AgentTool.run/4; string/message input; inner run options; text/error/exhausted/pending mapping; on_result:. | Inner text and tool runs; exhausted/error; unresolved pending; input forms; the caller's request is not mutated. |
| 2 | Nested pauses and observation. on_pending: for approval/input, several pauses, kind mismatch, callback raise/malformed; on_event:; inner run_id/telemetry. | Grant/deny/answer/cancel; callback failure; outer is_error where expected; no outer Pending propagation. |
| 3 | Outer integration and release. A real ToolCall module in a test calls the helper; outer AgentCall.run/3; README/CHANGELOG/examples; design §24; gate. | Outer transcript/telemetry; mix ci, docs, mix hex.build; no publish. |
12. Definition of done for the 0.1.0 agent tool
AgentCall.AgentTool.run/4runs an inner agent synchronously and returns its final text or a mapped error.- The helper never mutates the caller's request and never adds a process/store/ schema.
- An inner pause is handled by
on_pending:or returned as an error; it is never propagated as an outerPending. on_event:/on_result:observe only; their failures cannot change the result.- The outer integration test runs a sub-agent through a normal
ToolCallmodule. mix ci, docs andmix hex.buildpass at0.1.0; no publish.
13. 0.1.0 — checkpoint and journal seam
Design §25. Part of the first release; the package stays 0.1.0.
| # | Slice | Gate |
|---|---|---|
| 1 | Checkpoint data and envelope. AgentCall.Checkpoint; dump/1/load/1; the versioned Pending envelope; version/type/safe decode. | Round-trip for Pending and Checkpoint; version/invalid payload; the Pending fields unchanged. |
| 2 | Checkpoint event and resume. :checkpoint after a completed tool turn; resume_checkpoint/3; no completed tool re-run; options/pending/stream/budget. | Event order; no pause/no-tool/partial; resume counters/transcript; pending after resume; stream failure; malformed checkpoint. |
| 3 | Journal guide and release. Fake-store test; journal guide/example; README/CHANGELOG/design/roadmap; gate. | Store failure via cancel_when; mix ci, docs, mix hex.build; no publish. |
All three slices are delivered; the table stays as the delivery record.
14. Definition of done for the 0.1.0 checkpoint seam
Checkpoint.dump/loadround-tripsPendingandCheckpoint; version/type and an invalid payload are rejected; the library stores nothing.- A completed tool turn emits one
:checkpoint; a pause, a no-tool final and a partial stream emit none. resume_checkpoint/3continues at the next turn; no completed tool re-runs; the run options are re-supplied; a pending after resume is a normalresume/3pause.- The journal is the caller's append-only log; a store failure sets the caller's
flag and
cancel_when:stops at the next boundary; noJournalbehaviour or process. mix ci, docs andmix hex.buildpass at0.1.0; no publish.
15. 0.1.0 — thread and context adapter
Design §26. Part of the first release; the package stays 0.1.0.
| # | Slice | Gate |
|---|---|---|
| 1 | Behaviour and types. AgentCall.Thread with load/1/append/2; snapshot/thread_record types; test adapter. | Compiler; empty/populated snapshot; append all record kinds. |
| 2 | Example adapter and integration. Pending→resume/3, checkpoint→resume_checkpoint/3, messages→run/3; on_event append; context; store failure/cancel; result. | Three paths; no completed-tool re-run; no library process/table; last checkpoint resumes. |
| 3 | Docs and release. README/CHANGELOG/example/design/roadmap; gate. | mix ci, docs, mix hex.build; no publish. |
All three slices are delivered; the table stays as the delivery record.
16. Definition of done for the 0.1.0 thread adapter
AgentCall.Threadis a public behaviour withload/1/append/2; the library ships no implementation, process, table or schema.- The caller-owned snapshot has
messages/checkpoint/pending/result; pending wins over checkpoint; a fresh run uses messages. - The example adapter and integration prove the three paths, the on_event
append, the thread-aware
context:, the store failure +cancel_when, and no completed-tool re-run. - The terminal
Resultis appended after the outcome; the event stream and the result are separate records. mix ci, docs andmix hex.buildpass at0.1.0; no publish.