Skip to content

Alloy v0.16.0 — Major-lab wire parity & cooperative harness controls

Latest

Choose a tag to compare

@chrisohalloran chrisohalloran released this 27 Nov 13:05
· 1 commit to main since this release
1cd3673

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 :cancelled status, error kind, and atom result.error: Alloy.Agent.State.status(), Alloy.Result.status, and Alloy.Provider.Error.kind() add :cancelled. Cooperatively cancelled runs return {:error, %Alloy.Result{status: :cancelled, error: :cancelled}} (with any %Alloy.Provider.Error{kind: :cancelled} in result.metadata.run.provider_error), so result.error is no longer guaranteed to be a String.t() on {:error, result}. Callers with exhaustive case matches on run/turn status or provider error kind must handle :cancelled, and persistent Alloy.Provider.Codex (persist_session: true) callers should rotate :session_generation after :cancelled.
  • Fail-closed Alloy.Middleware.run_before_tool_call/2: Direct callers of Middleware.run_before_tool_call/2 must handle the new :cancelled return value when state.config.cancel_token is cancelled (explicit {:block, reason} verdicts remain preserved).
  • Global provider config validation for :api_key, :origin_key, and :reasoning: Alloy.Agent.Config now validates auth and :reasoning options on every primary and :fallback_providers config (including custom providers). Any provider configured with a 0-arity :api_key function or auth_scheme: :bearer requires a non-empty string :origin_key, any :reasoning key 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_key values as printable ASCII without CR/LF characters.
  • Injected :alloy_cancel_token and :reasoning provider config keys: When :cancel_token is set, Alloy injects :alloy_cancel_token into provider_config alongside :alloy_request_deadline, and when top-level :reasoning is 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: nil continues to omit "thinking").
  • Stricter OpenAIStream and OpenAI streaming 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 in context[: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: or data:) and document (data:, uri:, or origin-scoped file_id:) content blocks across Anthropic, OpenAI, XAI, and Gemini (plus image URLs on OpenAICompat), with origin-scoped file_id and Gemini File API URI omission in Alloy.Message.normalize_for/3 on cross-origin switches.
    • Dynamic 0-arity :api_key callbacks (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) plus auth_scheme: :bearer support.
    • First-class provider caching and native tools: Anthropic :cache TTL ("5m" / "1h") and :web_search shorthand; OpenAI/xAI :prompt_cache_key and :prompt_cache_retention; Gemini :cached_content, :google_search, :url_context, and :code_execution (all stripped automatically on compaction summary requests).
  • Portable :reasoning option: Unified :reasoning config (nil | :off | :low | :medium | :high | :xhigh | %{effort: ..., display: ...}) across all 6 built-in providers (updatable via Alloy.Agent.State.prepare/2, forwarded to fallback providers, stripped on compaction summaries, and overridable by explicit extra_body / generation_config).
  • Uniform v1 streaming events (docs/events.md):
    • :thinking_delta across 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 both Alloy.run/2 and Alloy.stream/3.
    • :tool_update (%{id:, name:, chunk:, start_event_seq:}) marshalled back to the caller process via per-call Process.alias/0 with bounded in-flight backpressure, wired into Alloy.Tool.Core.Bash alongside 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 when nil) propagated through Turn, Retry, OwnedWorker, HTTP, SSE, CodexRunner/Codex, Compactor, Middleware, and Executor — including timeout_ms: :infinity runs, OS process-group teardown, verbatim compaction history preservation, retry/fallback suppression, and valid repaired transcripts (Alloy.Transcript.validate/1 == :ok).
  • Mid-run :steering & completion :follow_up callbacks:
    • :steering polled between completed tool batches to redirect active runs, skip remaining unstarted batches with synthetic error tool_result blocks, and bypass :stop_after_tool.
    • :follow_up polled before normal non-refusal :end_turn completion once :until_tool is satisfied, bounded by :max_turns, :timeout_ms, and :cancel_token, firing :after_completion once on final completion.
    • Strict [%Alloy.Message{}] and JSON-compatibility validation plus :redact exception/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_update marshalling, and native :parent_call_id tagging across :tool_start, :tool_update, :tool_end, tool telemetry, and metadata.
    • Updated examples/minimal_host/code_mode.exs and docs/recipes/code-mode.md to route single nested calls through Executor.run_tool/3, clamp outer deadlines, and finalize child calls gracefully on cancellation/timeout.
  • Optional Alloy.ModelCatalog metadata & LLMDB recipe:
    • Added optional c:Alloy.ModelCatalog.max_output_tokens/1, c:Alloy.ModelCatalog.capabilities/1, and c:Alloy.ModelCatalog.pricing/1 callbacks plus Alloy.ModelCatalog.info/1,2 (fully backwards-compatible with minimal v0.14 catalogs exporting only context_window/1).
    • Implemented all three optional callbacks in Alloy.ModelMetadata (including gpt-5.2-pro/gpt-5.4-pro structured_output?: false, grok-4.20-multi-agent tools?: false, non-reasoning Grok distinction, and nil optional metadata for retired models).
    • Added provider-scoped LLMDB adapter recipe (docs/recipes/llm-db-catalog.md) and docs/upgrading-to-0.16.md.