ExAgent.ModelSettings (ExAgent v2.0.1)

View Source

Per-request knobs sent to the model. Provider-specific options that are not first-class fields can be carried in the immutable :extra map.

OpenAI Chat Completions (including OpenRouter) merges extra into the request body. Top-level atom/string keys are normalized to strings; string keys win duplicates. Non-nil first-class fields take precedence. model, messages, tools and stream are reserved and cannot be replaced via extra.

For example, extra: %{"reasoning" => %{"effort" => "low"}, "tool_choice" => "auto"} allows OpenRouter reasoning controls and overrides the default tool choice ("required" for structured output, "auto" for function tools). Provider support and validation of extra values remain the caller's responsibility. Other providers may interpret extra differently.

ExAgent.Models.ReqLLM currently rejects nonempty extra rather than merging arbitrary wire fields. Its timeout is receive inactivity: non-nil request settings override the instance HTTP default, then 60 seconds. This struct does not expose a total-call deadline or pool-checkout timeout; those are distinct transport budgets, not aliases for timeout. Stock ReqLLM nevertheless derives its pool default from the receive value. The adapter's separate per-instance total_timeout bounds a single buffered operation, not the whole agent run.

Summary

Functions

Merge two settings, overrides winning on non-nil values.

Build settings from a keyword/enum of options, ignoring nils.

Types

t()

@type t() :: %ExAgent.ModelSettings{
  extra: map(),
  frequency_penalty: float() | nil,
  max_tokens: pos_integer() | nil,
  presence_penalty: float() | nil,
  temperature: float() | nil,
  timeout: pos_integer() | nil,
  top_p: float() | nil
}

Functions

merge(base, overrides)

@spec merge(t(), t() | nil) :: t()

Merge two settings, overrides winning on non-nil values.

new(opts)

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

Build settings from a keyword/enum of options, ignoring nils.