Agentix.Conversation.Config (Agentix v0.1.0)

Copy Markdown View Source

Per-conversation configuration: which model, the system prompt, the (fixed) tool list, and runtime knobs.

The runtime knobs mirror the install/config contract:

  • working_budget — token budget for the assembled context.
  • injection_reserve — token budget reserved for pre-hook injections; over-reserve injection is a loud Agentix.Hook.OverflowError.
  • tool_retention — global default tool-result retention (%{mode: :age | :count, value: pos_integer, never_evict: boolean}; a tool's own :retention overrides it). Reserved: the tool-result reducer is not wired into the assembly path, so this is not currently applied.
  • compaction_window — how many recent turns the sliding-window reducer keeps verbatim. Reserved: the sliding-window reducer is not wired into the assembly path, so this is not currently applied.
  • default_timeout — suspension expiry default, in milliseconds.
  • hook_timeout — per parallel pre-hook deadline, in milliseconds; a hook that exceeds it is shut down and recorded as a crashed (skipped) injector. Sequential hooks run inline and are the author's responsibility to keep bounded.
  • audit? — record model_calls for replay/evals (off by default).
  • hooksAgentix.Hook structs run around each model call.
  • stream_transformer — a (chunk -> chunk) seam applied to each stream chunk (nil is the identity default).
  • persistence / notifier / pubsub — wiring resolved at runtime; nil falls back to the application-level configuration.

Like tools, hooks/stream_transformer are functions, not JSON-serializable; they live here and are rebuilt from config on revival (verbatim for the ETS adapter).

Summary

Functions

Builds a config from attrs. Requires a non-empty :model string. Raises ArgumentError if :model is missing/blank, if working_budget, injection_reserve, default_timeout, or hook_timeout is not a positive integer, if stream_transformer is neither nil nor a 1-arity function, or on unknown keys. String keys naming a known field are accepted (so a config can be rebuilt from a persistence adapter that round-trips settings as JSON).

Types

t()

@type t() :: %Agentix.Conversation.Config{
  audit?: boolean(),
  compaction_window: pos_integer(),
  default_timeout: pos_integer(),
  hook_timeout: pos_integer(),
  hooks: [Agentix.Hook.t()],
  injection_reserve: pos_integer(),
  model: String.t(),
  notifier: module() | nil,
  persistence: module() | {module(), keyword()} | nil,
  pubsub: atom() | nil,
  stream_transformer: (term() -> term()) | nil,
  system_prompt: String.t() | nil,
  tool_retention: %{
    mode: :age | :count,
    value: pos_integer(),
    never_evict: boolean()
  },
  tools: list(),
  working_budget: pos_integer()
}

Functions

new(attrs)

@spec new(keyword() | map()) :: t()

Builds a config from attrs. Requires a non-empty :model string. Raises ArgumentError if :model is missing/blank, if working_budget, injection_reserve, default_timeout, or hook_timeout is not a positive integer, if stream_transformer is neither nil nor a 1-arity function, or on unknown keys. String keys naming a known field are accepted (so a config can be rebuilt from a persistence adapter that round-trips settings as JSON).