Jido.Composer.Orchestrator.Configure (Jido Composer v0.4.0)

Copy Markdown View Source

Runtime configuration API for orchestrator agents.

Orchestrators are defined declaratively via the DSL, but at runtime you often need to override fields before calling query_sync/3 — dynamic system prompts, RBAC-filtered tools, per-mode model selection, pre-loaded conversation history, or test cassette injection.

configure/2 applies overrides after new/0 but before query_sync/3. It handles internal rebuilds (nodes → tools → name_atoms → schema_keys) so callers never touch strategy internals.

Usage

agent = MyOrchestrator.new()

agent = MyOrchestrator.configure(agent,
  system_prompt: dynamic_prompt,
  nodes: filtered_action_modules,
  model: "anthropic:claude-sonnet-4-20250514",
  temperature: 0.7,
  max_tokens: 8192,
  req_options: [plug: {ReqCassette, cassette: "test"}],
  conversation: preloaded_context
)

{:ok, _agent, result} = MyOrchestrator.query_sync(agent, user_message, ambient)

Read-Filter-Write Pattern

Use get_action_modules/1 and get_termination_module/1 to inspect the current configuration, filter it, then write it back:

# Read what the DSL declared
modules = MyOrchestrator.get_action_modules(agent)
term_mod = MyOrchestrator.get_termination_module(agent)

# Filter by user role
filtered = Enum.filter(modules, &my_rbac_check/1)

# Write back — handles node/tool/atom rebuild + termination tool dedup
agent = MyOrchestrator.configure(agent, nodes: filtered)

Overridable Keys

KeyTypeBehaviour
:system_promptString.t()Replaces the DSL system prompt
:nodes[module()]Rebuilds nodes, tools, name_atoms, schema_keys
:modelString.t()Replaces the model identifier
:temperaturefloat()Replaces the temperature
:max_tokensinteger()Replaces max tokens
:max_iterationsinteger()Replaces max ReAct loop iterations
:req_optionskeyword()Replaces HTTP options
:conversationReqLLM.Context.t()Sets or replaces conversation context

Summary

Functions

Applies runtime overrides to an orchestrator agent's strategy state.

Returns the list of action/agent modules currently configured as nodes.

Returns the termination tool module, or nil if none is configured.

Functions

configure(agent, overrides)

@spec configure(
  Jido.Agent.t(),
  keyword()
) :: Jido.Agent.t()

Applies runtime overrides to an orchestrator agent's strategy state.

Accepts a keyword list with any combination of:

  • :system_prompt — replaces the system prompt
  • :nodes — list of action/agent modules; rebuilds ActionNode/AgentNode structs, tools, name_atoms, and schema_keys internally. Handles termination tool deduplication automatically.
  • :model — replaces the model identifier
  • :temperature — replaces the temperature
  • :max_tokens — replaces max tokens
  • :max_iterations — replaces max ReAct loop iterations
  • :req_options — replaces HTTP options (e.g. for cassette injection)
  • :conversation — sets or replaces conversation context

Returns the updated agent.

get_action_modules(agent)

@spec get_action_modules(Jido.Agent.t()) :: [module()]

Returns the list of action/agent modules currently configured as nodes.

get_termination_module(agent)

@spec get_termination_module(Jido.Agent.t()) :: module() | nil

Returns the termination tool module, or nil if none is configured.