Adaptive execution strategy that automatically selects the best reasoning approach.
This strategy analyzes task characteristics and selects the most appropriate strategy (CoD, CoT, ReAct, AoT, ToT, GoT) for the given task. The strategy is re-evaluated when the previous reasoning completes and a new prompt arrives.
Overview
The Adaptive strategy:
- Analyzes prompt complexity and task type
- Selects the appropriate strategy based on heuristics
- Delegates all operations to the selected strategy
- Re-evaluates strategy when previous task completes
- Supports manual override via configuration
Strategy Selection
Strategies are selected based on task type keywords and complexity:
Task Type Detection (highest priority)
- Iterative Reasoning → TRM (Tiny-Recursive-Model)
- Keywords: puzzle, solve, step-by-step, iterate, improve, refine, recursive
- Synthesis → Graph-of-Thoughts (GoT)
- Keywords: synthesize, combine, merge, integrate, relationships, perspectives
- Tool use → ReAct
- Keywords: search, find, calculate, execute, fetch
- Exploration → Tree-of-Thoughts (ToT)
- Keywords: analyze, explore, compare, evaluate, alternatives
Complexity-based Selection (fallback)
- Simple tasks (score < 0.3) → Chain-of-Draft (CoD)
- Direct questions, simple calculations, factual queries
- Moderate tasks (0.3-0.7) → ReAct
- Tasks requiring tool use, multi-step operations
- Complex tasks (> 0.7) → Tree-of-Thoughts (ToT)
- Puzzles, planning, creative writing, complex reasoning
Configuration
Configure via strategy options when defining your agent:
use Jido.Agent,
name: "my_adaptive_agent",
strategy: {
Jido.AI.Reasoning.Adaptive.Strategy,
model: "anthropic:claude-sonnet-4-20250514",
default_strategy: :react,
available_strategies: [:cod, :cot, :react, :tot, :got, :trm]
}Options
:model(optional) - Model identifier passed to selected strategy:default_strategy(optional) - Default strategy if analysis is inconclusive, defaults to:react:strategy(optional) - Manual override to force a specific strategy:available_strategies(optional) - List of available strategies, defaults to [:cod, :cot, :react, :tot, :got, :trm]:complexity_thresholds(optional) - Map of thresholds for strategy selection
Signal Routing
Signal routes are delegated to the selected strategy. Before a strategy is selected, the adaptive strategy handles the initial routing.
State
State includes the selected strategy module and its state.
Summary
Functions
Analyzes a prompt and returns the recommended strategy.
Returns the complexity score for the current task.
Returns the currently selected strategy for an agent.
Returns the action atom for handling streaming LLM partial tokens.
Returns the action atom for handling LLM results.
Returns the action atom for handling request rejection events.
Returns the action atom for starting an adaptive exploration.
Types
@type complexity() :: :simple | :moderate | :complex
@type config() :: %{ optional(:model) => String.t(), optional(:default_strategy) => strategy_type(), optional(:available_strategies) => [strategy_type()], optional(:complexity_thresholds) => map(), optional(:strategy_opts) => keyword() }
@type strategy_type() :: :cod | :cot | :react | :aot | :tot | :got | :trm
Functions
Analyzes a prompt and returns the recommended strategy.
@spec get_complexity_score(Jido.Agent.t()) :: float() | nil
Returns the complexity score for the current task.
@spec get_selected_strategy(Jido.Agent.t()) :: strategy_type() | nil
Returns the currently selected strategy for an agent.
@spec llm_partial_action() :: :adaptive_llm_partial
Returns the action atom for handling streaming LLM partial tokens.
@spec llm_result_action() :: :adaptive_llm_result
Returns the action atom for handling LLM results.
@spec request_error_action() :: :adaptive_request_error
Returns the action atom for handling request rejection events.
@spec start_action() :: :adaptive_start
Returns the action atom for starting an adaptive exploration.