Normandy.Agents.BaseAgentConfig (normandy v2.2.0)

View Source

Configuration structure for BaseAgent instances.

Stores all stateful information for an agent including schemas, memory, model configuration, and prompt specifications.

Option groups: retry (Normandy.Resilience.Retry options or nil), circuit_breaker (Normandy.Resilience.CircuitBreaker options or nil; the agent uses the breaker shared by every agent with the same client module, endpoint, model and options, see circuit_breaker_key/1) and guardrails ([input:, output:, streaming_mode:, chunk_size:, on_violation:]). A guardrails list built by hand may leave keys out: guardrail/2 reads a missing key as its default.

Summary

Types

The guardrails group; see Normandy.Guardrails.

Any %BaseAgentConfig{}, including a partially filled one (field types unchecked).

t()

Functions

The key of the shared circuit breaker this config's LLM calls go through (Normandy.Resilience.CircuitBreaker.key/3 of its client, model and circuit_breaker options), or nil when circuit_breaker is nil. Read at each call, so a changed model uses that model's breaker. CircuitBreaker.fetch/1 finds the running breaker.

The guardrails a config has when it sets none.

The max_tokens used when a config sets none: 16000.

The max_tool_result_chars a config has when it sets none: 100000 characters (graphemes).

One guardrails setting of config; a key left out of a hand-built guardrails list reads as its default (default_guardrails/0).

Types

guardrails()

@type guardrails() :: [
  input: [Normandy.Guardrails.spec()],
  output: [Normandy.Guardrails.spec()],
  streaming_mode: :accumulate | :incremental,
  chunk_size: pos_integer(),
  on_violation: :block | :warn
]

The guardrails group; see Normandy.Guardrails.

partial()

@type partial() :: %Normandy.Agents.BaseAgentConfig{
  behaviours: term(),
  circuit_breaker: term(),
  client: term(),
  current_user_input: term(),
  enable_json_retry: term(),
  guardrails: term(),
  initial_memory: term(),
  input_schema: term(),
  json_retry_max_attempts: term(),
  max_tokens: term(),
  max_tool_concurrency: term(),
  max_tool_iterations: term(),
  max_tool_result_chars: term(),
  mcp_servers: term(),
  memory: term(),
  model: term(),
  name: term(),
  output_schema: term(),
  prompt_specification: term(),
  resolved_context_window: term(),
  retry: term(),
  session_id: term(),
  temperature: term(),
  tool_context: term(),
  toolset: term()
}

Any %BaseAgentConfig{}, including a partially filled one (field types unchecked).

t()

@type t() :: %Normandy.Agents.BaseAgentConfig{
  behaviours: Normandy.Behaviours.Config.t() | nil,
  circuit_breaker: keyword() | nil,
  client: struct(),
  current_user_input: String.t() | nil,
  enable_json_retry: boolean(),
  guardrails: guardrails(),
  initial_memory: map(),
  input_schema: struct(),
  json_retry_max_attempts: pos_integer(),
  max_tokens: pos_integer(),
  max_tool_concurrency: pos_integer(),
  max_tool_iterations: pos_integer(),
  max_tool_result_chars: pos_integer() | nil,
  mcp_servers: list() | nil,
  memory: map(),
  model: String.t(),
  name: String.t() | nil,
  output_schema: struct(),
  prompt_specification: Normandy.Components.PromptSpecification.t(),
  resolved_context_window: {String.t(), pos_integer()} | nil,
  retry: keyword() | nil,
  session_id: String.t() | nil,
  temperature: float() | nil,
  tool_context: map(),
  toolset: Normandy.Tools.Toolset.t() | nil
}

Functions

circuit_breaker_key(base_agent_config)

@spec circuit_breaker_key(t()) :: Normandy.Resilience.CircuitBreaker.key() | nil

The key of the shared circuit breaker this config's LLM calls go through (Normandy.Resilience.CircuitBreaker.key/3 of its client, model and circuit_breaker options), or nil when circuit_breaker is nil. Read at each call, so a changed model uses that model's breaker. CircuitBreaker.fetch/1 finds the running breaker.

default_guardrails()

@spec default_guardrails() :: guardrails()

The guardrails a config has when it sets none.

default_max_tokens()

@spec default_max_tokens() :: pos_integer()

The max_tokens used when a config sets none: 16000.

default_max_tool_result_chars()

@spec default_max_tool_result_chars() :: pos_integer()

The max_tool_result_chars a config has when it sets none: 100000 characters (graphemes).

guardrail(base_agent_config, key)

@spec guardrail(t(), :input | :output | :streaming_mode | :chunk_size | :on_violation) ::
  term()

One guardrails setting of config; a key left out of a hand-built guardrails list reads as its default (default_guardrails/0).