Baton.Config (Baton v0.27.4)

Copy Markdown View Source

Runtime configuration and repo resolution.

Repo

The repo is read from Oban's own configuration, so Baton always uses the same repo as the jobs it orchestrates:

Baton.Config.repo()         # default Oban instance
Baton.Config.repo(MyOban)   # named instance

Host configuration

config :baton,
  oban_name: Oban,                 # default
  pubsub: MyApp.PubSub,            # required if using the dashboard/events
  pricing: Baton.Pricing.Default,
  llm_timeout: :timer.minutes(10),
  snooze_seconds: 15,
  stale_executing_threshold_seconds: 600,
  result_store: Baton.ResultStore.Postgres,  # large-result backend
  inline_threshold_bytes: 32_768,             # spill above this size
  max_result_bytes: 16_777_216,               # reject results above this
  result_cache_enabled: false,                # node-local read cache (off)
  max_cache_bytes: 67_108_864                 # read-cache byte budget

Summary

Functions

Configured host context provider for portable flows.

Configured host guard runner (a Baton.Flow.GuardRunner) for portable flow LLM nodes.

Configured host prompt resolver for portable flow LLM nodes.

Configured host registry for portable flow action nodes.

Encoded result size (bytes) at or below which a result is stored inline on the node row. Larger results spill to result_store/0. Default 32 KB.

The configured LLM client module used by Baton.Debug.call_llm/3.

Maximum runtime for an LLM step in milliseconds (default: ten minutes).

Byte budget for the read cache. When an insert would exceed it the cache is flushed wholesale. Default 64 MB.

Hard ceiling (bytes) on an encoded result. A step returning a result larger than this fails with {:error, :result_too_large} rather than persisting a blob that would pressure the shared store. Default 16 MB.

Configured Oban instance name (default: Oban).

The configured pricing module (a Baton.Pricing implementation).

The Phoenix.PubSub server used for live step events.

The configured Baton.RateLimiter used as a pre-call token-throughput gate by Baton.LLMStep. Defaults to Baton.RateLimiter.Noop (reserves nothing), so the engine runs unchanged until a host opts in.

Resolve the Ecto repo from Oban's config.

Whether the node-local read cache (Baton.ResultCache) is enabled. Off by default — a pure performance opt-in for repeated reads of large results.

The backend module (a Baton.ResultStore implementation) used to store step results too large to keep inline. Defaults to the built-in Postgres backend.

Snooze interval (seconds, default 15) used both to park a dependent step at insert and to recheck when a dependency is still pending.

Age (seconds) past which an executing dep is treated as failed (default 600).

Functions

flow_context_provider()

@spec flow_context_provider() :: module() | nil

Configured host context provider for portable flows.

flow_guard_runner()

@spec flow_guard_runner() :: module() | nil

Configured host guard runner (a Baton.Flow.GuardRunner) for portable flow LLM nodes.

flow_prompt_resolver()

@spec flow_prompt_resolver() :: module() | nil

Configured host prompt resolver for portable flow LLM nodes.

flow_registry()

@spec flow_registry() :: module() | nil

Configured host registry for portable flow action nodes.

inline_threshold_bytes()

@spec inline_threshold_bytes() :: pos_integer()

Encoded result size (bytes) at or below which a result is stored inline on the node row. Larger results spill to result_store/0. Default 32 KB.

llm_client()

@spec llm_client() :: module() | nil

The configured LLM client module used by Baton.Debug.call_llm/3.

Must export complete/2 taking (messages, opts) and returning {:ok, response} or {:error, reason}. Returns nil if unconfigured, in which case call_llm/3 raises a helpful error.

config :baton, llm_client: MyApp.LLM

llm_timeout()

@spec llm_timeout() :: pos_integer()

Maximum runtime for an LLM step in milliseconds (default: ten minutes).

This is the safe default used by Baton.LLMWorker when an individual worker does not declare its own timeout. Hosts should set their Oban orphan-job recovery window above this value.

max_cache_bytes()

@spec max_cache_bytes() :: pos_integer()

Byte budget for the read cache. When an insert would exceed it the cache is flushed wholesale. Default 64 MB.

max_result_bytes()

@spec max_result_bytes() :: pos_integer()

Hard ceiling (bytes) on an encoded result. A step returning a result larger than this fails with {:error, :result_too_large} rather than persisting a blob that would pressure the shared store. Default 16 MB.

oban_name()

@spec oban_name() :: atom()

Configured Oban instance name (default: Oban).

pricing()

@spec pricing() :: module()

The configured pricing module (a Baton.Pricing implementation).

pubsub()

@spec pubsub() :: atom() | nil

The Phoenix.PubSub server used for live step events.

Returns nil if not configured; Baton.Events no-ops when nil, so the engine runs fine without Phoenix.

rate_limiter()

@spec rate_limiter() :: module()

The configured Baton.RateLimiter used as a pre-call token-throughput gate by Baton.LLMStep. Defaults to Baton.RateLimiter.Noop (reserves nothing), so the engine runs unchanged until a host opts in.

config :baton, rate_limiter: MyApp.LLM.RateLimiter

repo(name \\ nil)

@spec repo(atom() | nil) :: module()

Resolve the Ecto repo from Oban's config.

result_cache_enabled?()

@spec result_cache_enabled?() :: boolean()

Whether the node-local read cache (Baton.ResultCache) is enabled. Off by default — a pure performance opt-in for repeated reads of large results.

result_store()

@spec result_store() :: module()

The backend module (a Baton.ResultStore implementation) used to store step results too large to keep inline. Defaults to the built-in Postgres backend.

snooze_seconds()

@spec snooze_seconds() :: pos_integer()

Snooze interval (seconds, default 15) used both to park a dependent step at insert and to recheck when a dependency is still pending.

With completion-triggered dispatch (Baton.Reschedule + Baton.RescheduleReporter) the happy path no longer waits this out, so this is essentially a fallback: it only governs latency when a dispatch nudge is lost. A smaller value shortens that worst-case tail at the cost of slightly more frequent rechecks in that rare case.

stale_executing_threshold_seconds()

@spec stale_executing_threshold_seconds() :: pos_integer()

Age (seconds) past which an executing dep is treated as failed (default 600).

Must exceed your longest step's runtime

A dependency that has been executing for longer than this is assumed stuck and is cancelled, cascading to its dependents (see Baton.Check). If a healthy step can legitimately run longer than this threshold — e.g. a long LLM completion whose Baton.LLMWorker :timeout is raised above 600s — set this higher than that step's timeout, or the engine will cancel a running step and fail the workflow. Keep threshold > longest step timeout.