Skip to content

Config model override not applied to ReAct strategy (compile-time vs runtime) #25

Description

@ortegacmanuel

Problem

The model setting in config.toml and the GOODWIZARD_MODEL env var are read at runtime and logged correctly, but the ReAct strategy ignores them. The agent always uses the model hardcoded in the use Jido.AI.Agent macro in agent.ex.

Expected behavior

# config.toml
[agent]
model = "openai:gpt-4o"

or

GOODWIZARD_MODEL=openai:gpt-4o

Should make the agent use openai:gpt-4o. Instead it uses whatever is in:

# agent.ex
use Jido.AI.Agent,
  model: "anthropic:claude-sonnet-4-5",  # ← this always wins

What happens

  1. Config loads correctly: Config loaded from config.toml, model=openai:gpt-4o
  2. Agent starts with compiled model: model: "anthropic:claude-sonnet-4-5" (visible in strategy config in logs)
  3. LLM call uses Anthropic → fails if only OPENAI_API_KEY is set

Root cause

The model: option in use Jido.AI.Agent is captured at compile time by the macro and baked into the strategy config. Goodwizard.Config.model() reads the runtime value but nothing wires it into the ReAct strategy's config.model.

The TurnSetup.prepare/2 hook (called on_before_cmd) hydrates the system prompt and memory each turn, but doesn't override the strategy's model.

Impact

  • Changing models requires editing agent.ex and sub_agent.ex source code and recompiling
  • The config system gives a false impression that the model is configurable at runtime
  • Users setting GOODWIZARD_MODEL or editing config.toml will get unexpected behavior

Suggested fix

In TurnSetup.prepare/2 or on_before_cmd, read Config.model() and update the strategy config:

# Pseudocode — wire runtime model into strategy
configured_model = Goodwizard.Config.model()
agent = update_in(agent.state.__strategy__.config.model, fn _ -> configured_model end)

This would make the runtime config actually take effect for LLM calls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions