All notable changes to this project are documented here. The format follows Keep a Changelog, and the project adheres to Semantic Versioning.
Unreleased
0.1.0 - 2026-11-30
Added
AgentCall.run/3: one call runs the tool loop overllm_call.request.toolsis the only tool list, and each call it produces goes throughToolCall.run/4.- Four outcomes:
{:ok, Result.t()},{:exhausted, Result.t()},{:pending, Pending.t()}and{:error, Error.t()}.{:ok, _}means the model asked for no more tools; a:max_tokensfinish stays visible inResult.stop_reasoninstead of being flattened into success. AgentCall.resume/3: continues a paused turn. It takes exactly one ofapproval:(:granted | :denied) orinput:({:answer, term}or{:cancel, term}), matchingPending.kind.AgentCall.Pending: serializable pause data carrying the request, the pause payload, the transcript, positionalresultsslots, the remaining calls and the counters.kindis:approval | :input;approvalandinputare mutually exclusive.resultshas one%LlmCall.ToolResult{}ornilper assistant tool call, in call order, andremainingis the calls with anilslot. It survives:erlang.term_to_binary/1and resumes with its counters and last usage.AgentCall.Checkpointand the versioned envelope: the state after a completed tool turn (version,run_id,request,transcript,steps,tool_calls,usage,last_usage).Checkpoint.dump/1wraps aCheckpointor aPendingin a versioned binary;load/1uses a:safedecode and checks the envelope version, type and portable payload. Another version is{:error, :unsupported_version}and anything else malformed is{:error, :invalid}. Cross-version resume is not promised while the package is0.x.:checkpointevent after every completed tool turn, before the next request, andAgentCall.resume_checkpoint/3: it continues atcheckpoint.steps + 1with the checkpoint transcript and does not re-run a completed tool. A pause is still aPendingresumed withresume/3; a no-tool final answer is the terminalResult. There is no mid-stream or partial-turn checkpoint; a stream failure discards that turn's partial content and the last checkpoint retries it.- The caller-owned journal pattern: append
Checkpoint.dump/1checkpoint and pending records fromon_event:and append the terminalResultthe run returns. The library adds noAgentCall.Journalbehaviour, store, ETS table or process; a failed store write is caught by the caller and itscancel_when:stops the run at the next safe boundary. AgentCall.Thread: the caller-owned thread contract.load/1returns the thread snapshot (messagesand the latestcheckpoint/pending/result) andappend/2accepts aCheckpoint,Pending,ResultorEvent;thread_idis the caller's opaque key. The library calls neither callback and ships no store, process, table or schema. The guide resumes a pending before a checkpoint, appends the terminalResultafter the outcome, and catches a store failure for the existingcancel_when:.AgentCall.Inputanduse AgentCall.Input: the input-pause payload and the marker for model-initiated input tools. Every tool a marked module declares is an input tool: its schema reaches the model throughToolCall.describe/2, but insideAgentCallthe function is never invoked and a call pauses with the assembled call and its spec.prompt:: a one-arity caller policy at:turnand{:tool, call}boundaries. It returns:contor{:ask, payload}; an ask pauses as an input pause withsource: :policy. It runs again after a resume and must inspect the transcript or results. A raise, throw, exit or malformed return is a:configurationerror.:input_requiredin the event union;:run_startedreportsprompt?:andinput_tools:. Approval and input both finish as:pending, discriminated byPending.kind.- A marked input tool's call is checked before the
prompt:policy, and the tool-phase policy before approval; anarguments_errorstill becomes anis_errorresult instead of a pause. max_steps:: budget guards at turn entry and before dispatch. A turn at the budget still receives its answer; its tools do not run, and{:exhausted, _}reportshalt_reason: :budget.cancel_when:: a caller policy checked at:turn(after the budget/context check, before the request) and:tools(after the response, before any call). A cancel is terminal:{:exhausted, result}withhalt_reason: {:cancelled, reason}, no request at:turnand no tool at:tools. A:toolscancel wins over an equally due budget stop. The policy is re-supplied on resume and is not checked before the paused batch a resume re-dispatches.max_concurrency:: opt-in parallel tool execution in ordered waves of at most that many calls. Results keep their call-order slots; a pause stops later waves and preserves results completed after an earlier pause; the final user turn filters thenilslots and keeps call order.1is the default and keeps the serial contract. A parallel pause must re-supply the option on resume.run_id:: a non-empty correlation id, generated when omitted, onResult,Pendingand everyEvent.resume/3keeps the pending id; an empty supplied id is a:configurationerror, and a hand-builtPendingwith a nil id is normalized on resume.:telemetryspans for runs, turns, tool calls and streamed turns:[:agent_call, :run | :turn | :tool | :stream, :start | :stop | :exception], withrun_idmetadata and no messages, arguments, results, headers or credentials. A tool stop reportsoutcome: :ok | :error | :pending; anis_errortool result is:error. A raising handler cannot change a run.context:: a caller policy before every request that may pass the transcript through, replace it with a compacted one, or stop the run. A stop returns{:exhausted, _}withhalt_reason: {:context, reason}; the library owns no tokenizer, model window, trimming or summary.on_event:: observe-only events for run, context, step, tool, checkpoint, approval, input and delta boundaries.:run_startedis first and:finishedis last, and an observer that raises cannot change the outcome.stream: true: each turn is read throughLlmCall.stream/3and assembled internally — text, thinking with the signature that follows its block,Content.Rawparts and tool calls — with:text_deltaand:thinking_deltaevents. The outcome shape is unchanged, but streamed responses do not fully matchcomplete/3:response.id,response.modelandresponse.rawstaynil, and tool calls are appended after text and thinking instead of at their provider position.tool_opts:,max_result_bytes:andformat_result:for dispatch and result rendering, pluscodec:andheaders:forwarded tollm_call.format_result:accepts a two-arity renderer that also receives the byte budget, andAgentCall.default_format/2is the default: it bounds its own collection walk instead of rendering a value that would be truncated.Checkpoint.dump/2withcompress:, and a per-record compression default: a text transcript is written compressed, a transcript carrying an image, file or video source is written uncompressed, because deflating base64 media costs proportional time for a fraction of the bytes.AgentCall.AgentTool.run/4: runs a complete inner agent from an ordinaryToolCallmodule and returns its final text as the outer tool result.inputis a string or a message list; the helper copies the request and never mutates it. The inner request keeps its model, system prompt and tools, and the outer tool's timeout bounds the whole inner run.on_pending:resolves an inner approval/input pause — without it the pause is{:error, {:pending, kind}}and never becomes an outerPending; a callback failure or an{:error, reason}decision is terminal.on_result:observes the inner terminalResultand cannot change the result;on_event:is forwarded to every inner run and resume. An empty inner answer is"", which the outer renderer turns into"(no output)"; an inner:exhaustedis{:error, {:exhausted, halt_reason, text}}and an inner error is{:error, {:inner, kind, message}}. No process, store, schema or nested-Pendingpropagation.- Public data and types:
AgentCall.Result,AgentCall.Pending,AgentCall.Checkpoint,AgentCall.Error,AgentCall.Event,AgentCall.Context,AgentCall.Cancel,AgentCall.Input,AgentCall.AgentToolandAgentCall.Thread. context:may return{:cont, messages, tools}to replace the tool set for that turn and every later one, so a single run can grant tools progressively. The narrowed set is both what the model is offered and what the loop dispatches, and it travels onPendingandCheckpointso a resume keeps it.:step_startedreports each turn's set.
Changed
- A malformed tool entry is a
:configurationerror before the first event when the problem is the entry's shape or options. A%LlmCall.ToolSpec{}whose values one dialect refuses stays that codec's:llmerror, because the rule is protocol-specific:kind: :builtinis legal on Anthropic and Gemini and refused by OpenAI Chat, and a non-stringprovider_optionskey or a non-JSONparametersvalue is the same case.
Fixed
A
{module, opts}tool entry whose options the codec cannot take is now a:configurationerror before the first event. The entry is forwarded tollm_callverbatim, sostrict: :fine_tuned(atool_callrender mode, not a codec option) and any unknown key used to reach the codec and come back as an:llmerror attributed to the provider, after:run_started, with no:configurationerror to point at the entry. The accepted set isstrict:with a boolean ornil.Dispatch.map/1reports an impropertoolslist as a:configurationerror instead of raisingFunctionClauseErrorfrom insideEnumerable.is_list/1accepts an improper list, so the reduce walked into a clause it has no clause for; every other malformed list was already a:configurationerror.Checkpointrecord validation compares a struct's field set without sorting both key lists. EveryMessageand content part goes through it, so a 3,000-message record validated in 1.74 ms instead of 0.90 ms; the field set is still matched exactly, so a struct with one field too many or too few is still refused.A rendered tool result is now checked for valid UTF-8. A renderer returning invalid bytes used to reach the model and fail as an
:llmerror on the next request ("request body is not JSON-encodable"), which reads as a transport problem; it is a:toolerror naming the renderer instead. The check covers the text that is sent, so a capped result costs the cap rather than the renderer's output, and it applies to a turn answer as well as a tool result — the message names which one.A renderer result that is not valid UTF-8 is now refused at every size. Over the cap, truncation backed off one byte at a time until the prefix validated, which for bytes that were never UTF-8 meant backing off to nothing: a 100 KB malformed result reached the model as
"(no output)"instead of an error, and the back-off rescanned the prefix at every step.default_format/2now formats without truncating, so the dispatch step cuts once, and the UTF-8 check refuses the value consistently.Resume records are checked before a run: a malformed top-level
Pending, positional results/remaining mismatch, aUsagefield that is notnilor a non-negative integer, aToolResultwith non-text content or a non-booleanis_error, a transcript with a non-Messageentry or invalidMessagerole/content, an invalidContentfield (Text.text, media source,Thinking.text/signature,Rawdata), invalid requestmodel/provider_options/system/tool_choice/output/modalities/reasoning/params/ stream, invalidToolSpecfields, and aToolCallwith invalid nullable fields are:configurationerrors. A tool-targetInput.sourcemust be:modelor:policy;specmust be aToolSpecorniland its name must match the paused call,inserted_ataDateTime, andApproval.Request.id/module/tool/args/inserted_athave their declared types. A model-source tool input requires a spec and a nil prompt.ToolResult/ToolCallidentifiers remain nullable, as the dependency contract allows. A malformedrun/3request, including impropermessages/toolslists, non-Messageentries and fake nested structs, is rejected the same way instead of crashing in the loop; live requests are not required to be portable. A turn-input resume checks the budget before rendering the answer.The README's examples use DeepSeek: the Quick start, usage, approval, input, thread and agent-tool snippets use
MyApp.DeepSeek,deepseek-chatandDEEPSEEK_API_KEY, and the compiled example's default client matches.The guide's example context policy no longer keeps a tail that starts with a tool result; it drops to a clean user turn or keeps the whole transcript. The example thread, journal and Research flows accept an injected client, the example stores cap their history, and
Journal.latest_checkpoint/2filters byrun_id.
Compatibility
- Elixir 1.18+. Runtime dependencies are
llm_call ~> 0.4.0,tool_call ~> 0.4and:telemetry ~> 1.0. - A persisted
CheckpointorPendingis guaranteed to load in the release that wrote it; cross-version resume is not promised while the package is0.x.