Alloy.Agent.Config (alloy v0.12.4)

Copy Markdown View Source

Configuration for an agent run.

Built from the options passed to Alloy.run/2. Immutable for the duration of the run.

Summary

Types

Memory store binding — {store_module, opaque_store_term}. The store module implements Alloy.Memory. The store term is whatever the module needs (keyword list, map, pid, struct) — Alloy passes it through verbatim.

t()

Functions

Builds a config from Alloy.run/2 options.

Returns an updated config with a new provider while preserving unrelated options.

Types

compaction()

@type compaction() :: %{
  reserve_tokens: pos_integer(),
  keep_recent_tokens: pos_integer(),
  fallback: :truncate,
  clear_tool_results: boolean(),
  keep_recent_tool_results: non_neg_integer(),
  summary_system_prompt: String.t(),
  summary_prompt: String.t()
}

memory()

@type memory() :: {module(), term()} | nil

Memory store binding — {store_module, opaque_store_term}. The store module implements Alloy.Memory. The store term is whatever the module needs (keyword list, map, pid, struct) — Alloy passes it through verbatim.

As of 0.12.0, memory is Anthropic-only. Alloy.run/2 raises if :memory is set with any other provider.

t()

@type t() :: %Alloy.Agent.Config{
  code_execution: boolean(),
  compaction: compaction(),
  compaction_explicit: %{
    reserve_tokens: boolean(),
    keep_recent_tokens: boolean()
  },
  context: map(),
  fallback_providers: [{module(), map()}],
  max_budget_cents: number() | nil,
  max_pending: non_neg_integer(),
  max_retries: non_neg_integer(),
  max_tokens: pos_integer(),
  max_tokens_explicit?: boolean(),
  max_turns: pos_integer(),
  memory: memory(),
  middleware: [module()],
  model_catalog: module(),
  model_metadata_overrides: map(),
  on_compaction: (list(), Alloy.Agent.State.t() -> any()) | nil,
  on_shutdown: (struct() -> any()) | nil,
  provider: module(),
  provider_config: map(),
  pubsub: module() | nil,
  retry_backoff_ms: pos_integer(),
  subscribe: [String.t()],
  system_prompt: String.t() | nil,
  timeout_ms: pos_integer(),
  tool_timeout: pos_integer(),
  tools: [module() | Alloy.Tool.Inline.t()],
  until_tool: String.t() | nil,
  working_directory: String.t()
}

Functions

from_opts(opts)

@spec from_opts(keyword()) :: t()

Builds a config from Alloy.run/2 options.

with_provider(config, provider)

@spec with_provider(t(), module() | {module(), keyword() | map()}) :: t()

Returns an updated config with a new provider while preserving unrelated options.

If max_tokens was not set explicitly, the budget is re-derived from the new provider model, current model_metadata_overrides, and model_catalog.