Repository navigation
Alloy 0.16 brings major-lab wire parity (multimodal PDFs/documents, image URLs,
dynamic :api_key callbacks, provider caching, Gemini native tools, portable
:reasoning), uniform v1 streaming events, cooperative cancellation
(Alloy.Cancel), mid-run :steering and completion :follow_up controls,
Alloy.Tool.Executor.run_tool/3, and optional Alloy.ModelCatalog capability
and pricing metadata — with zero new mandatory runtime dependencies. See
Upgrading to 0.16.
Breaking Changes
- New
:cancelledstatus, error kind, and atomresult.error:Alloy.Agent.State.status(),Alloy.Result.status, andAlloy.Provider.Error.kind()add:cancelled. Cooperatively cancelled runs return{:error, %Alloy.Result{status: :cancelled, error: :cancelled}}(with any%Alloy.Provider.Error{kind: :cancelled}inresult.metadata.run.provider_error), soresult.erroris no longer guaranteed to be aString.t()on{:error, result}. Callers with exhaustivecasematches on run/turn status or provider error kind must handle:cancelled, and persistentAlloy.Provider.Codex(persist_session: true) callers should rotate:session_generationafter:cancelled. - Fail-closed
Alloy.Middleware.run_before_tool_call/2: Direct callers ofMiddleware.run_before_tool_call/2must handle the new:cancelledreturn value whenstate.config.cancel_tokenis cancelled (explicit{:block, reason}verdicts remain preserved). - Global provider config validation for
:api_key,:origin_key, and:reasoning:Alloy.Agent.Confignow validates auth and:reasoningoptions on every primary and:fallback_providersconfig (including custom providers). Any provider configured with a 0-arity:api_keyfunction orauth_scheme: :bearerrequires a non-empty string:origin_key, any:reasoningkey in provider config must conform to Alloy's portable format (nil | :off | :low | :medium | :high | :xhigh | %{effort: ..., display: ...}), and built-in HTTP providers validate both static string and callback:api_keyvalues as printable ASCII without CR/LF characters. - Injected
:alloy_cancel_tokenand:reasoningprovider config keys: When:cancel_tokenis set, Alloy injects:alloy_cancel_tokenintoprovider_configalongside:alloy_request_deadline, and when top-level:reasoningis set, Alloy injects normalized:reasoning; custom providers using strict option validators should tolerate unknown:alloy_*keys and:reasoning. - Anthropic
reasoning: :off: Explicitly sends%{"thinking" => %{"type" => "disabled"}}(reasoning: nilcontinues to omit"thinking"). - Stricter
OpenAIStreamandOpenAIstreaming tool-call validation:Alloy.Provider.OpenAIStream(Chat Completions streaming) rejects negative/malformed tool-call indices and conflicting tool identities (id/name) with non-retryable:protocol_error, and invalid/non-object tool argument JSON with retryable:malformed_reply;Alloy.Provider.OpenAI(OpenAI/xAI Responses streaming) rejects conflicting tool-call headers and contradictory completed arguments with:malformed_reply(retryable before output is emitted; retries/fallbacks remain suppressed once output has been emitted to caller callbacks). Alloy.Events.build_correlation_id/1: Empty strings ("") and invalid UTF-8 values incontext[:request_id]/context[:correlation_id]now fall back to a generated correlation ID so downstream tool events and telemetry always carry valid non-empty UTF-8 correlation IDs.
Added
- Multimodal & major-lab wire parity:
- Portable
image(url:ordata:) anddocument(data:,uri:, or origin-scopedfile_id:) content blocks acrossAnthropic,OpenAI,XAI, andGemini(plusimageURLs onOpenAICompat), with origin-scopedfile_idand Gemini File API URI omission inAlloy.Message.normalize_for/3on cross-origin switches. - Dynamic 0-arity
:api_keycallbacks (resolved per HTTP attempt within the request deadline and cancellation token, rejecting non-ASCII/CR/LF keys, never invoked during origin hashing, and redacting auth error diagnostics) plusauth_scheme: :bearersupport. - First-class provider caching and native tools: Anthropic
:cacheTTL ("5m"/"1h") and:web_searchshorthand; OpenAI/xAI:prompt_cache_keyand:prompt_cache_retention; Gemini:cached_content,:google_search,:url_context, and:code_execution(all stripped automatically on compaction summary requests).
- Portable
- Portable
:reasoningoption: Unified:reasoningconfig (nil | :off | :low | :medium | :high | :xhigh | %{effort: ..., display: ...}) across all 6 built-in providers (updatable viaAlloy.Agent.State.prepare/2, forwarded to fallback providers, stripped on compaction summaries, and overridable by explicitextra_body/generation_config). - Uniform v1 streaming events (
docs/events.md)::thinking_deltaacross Anthropic, OpenAI/xAI Responses, Gemini, and OpenAICompat/OpenAIStream.:tool_call_delta(%{id:, index:, name:, arguments_delta:}) across streaming providers.:turn_start(%{turn:}) and:turn_end(%{turn:, status:, stop_reason:, usage:}) across bothAlloy.run/2andAlloy.stream/3.:tool_update(%{id:, name:, chunk:, start_event_seq:}) marshalled back to the caller process via per-callProcess.alias/0with bounded in-flight backpressure, wired intoAlloy.Tool.Core.Bashalongside optional:bash_on_output.
- Cooperative cancellation (
Alloy.Cancel):- Lock-free
:atomics-backed cancellation tokens (new/0,cancel/1,cancelled?/1,combine/2,valid?/1, zero processes, zero ETS tables, zero polling overhead whennil) propagated throughTurn,Retry,OwnedWorker,HTTP,SSE,CodexRunner/Codex,Compactor,Middleware, andExecutor— includingtimeout_ms: :infinityruns, OS process-group teardown, verbatim compaction history preservation, retry/fallback suppression, and valid repaired transcripts (Alloy.Transcript.validate/1 == :ok).
- Lock-free
- Mid-run
:steering& completion:follow_upcallbacks::steeringpolled between completed tool batches to redirect active runs, skip remaining unstarted batches with synthetic errortool_resultblocks, and bypass:stop_after_tool.:follow_uppolled before normal non-refusal:end_turncompletion once:until_toolis satisfied, bounded by:max_turns,:timeout_ms, and:cancel_token, firing:after_completiononce on final completion.- Strict
[%Alloy.Message{}]and JSON-compatibility validation plus:redactexception/throw/exit sanitization for both callbacks.
- Reusable single-tool execution (
Alloy.Tool.Executor.run_tool/3) & native:parent_call_id:- Shared single-tool execution entrypoint with full middleware, validation, supervised timeout/deadline clamping (
state.run_deadline), composed cancellation (Alloy.Cancel), truncation, caller-process:tool_updatemarshalling, and native:parent_call_idtagging across:tool_start,:tool_update,:tool_end, tool telemetry, and metadata. - Updated
examples/minimal_host/code_mode.exsanddocs/recipes/code-mode.mdto route single nested calls throughExecutor.run_tool/3, clamp outer deadlines, and finalize child calls gracefully on cancellation/timeout.
- Shared single-tool execution entrypoint with full middleware, validation, supervised timeout/deadline clamping (
- Optional
Alloy.ModelCatalogmetadata &LLMDBrecipe:- Added optional
c:Alloy.ModelCatalog.max_output_tokens/1,c:Alloy.ModelCatalog.capabilities/1, andc:Alloy.ModelCatalog.pricing/1callbacks plusAlloy.ModelCatalog.info/1,2(fully backwards-compatible with minimal v0.14 catalogs exporting onlycontext_window/1). - Implemented all three optional callbacks in
Alloy.ModelMetadata(includinggpt-5.2-pro/gpt-5.4-prostructured_output?: false,grok-4.20-multi-agenttools?: false, non-reasoning Grok distinction, andniloptional metadata for retired models). - Added provider-scoped
LLMDBadapter recipe (docs/recipes/llm-db-catalog.md) anddocs/upgrading-to-0.16.md.
- Added optional