Loops
A Loop defines the execution strategy an agent follows — how it reasons, when it invokes tools, and when it stops. Chimera ships four loop variants, each suited to different problem types.
Available Loops
Section titled “Available Loops”| Loop | Module | Strategy |
|---|---|---|
ReAct | chimera.core.loop | Reason, Act, Observe — the default |
PlanAndExecute | chimera.core.loops.plan_execute | Generate a plan first, then execute it |
Reflexion | chimera.core.loops.reflexion | Act, then periodically reflect and improve |
TreeOfThought | chimera.core.loops.tree_of_thought | Generate N candidates, evaluate, pick the best |
All loops share the same interface:
def run( self, provider: Provider, tools: list[BaseTool], context: Context, env: Environment | None,) -> AgentResult:ReAct (Default)
Section titled “ReAct (Default)”ReAct (Reason + Act) is the standard agentic loop. At each step:
- Reason — the model produces text and/or tool calls
- Act — tool calls are executed against the environment
- Observe — tool results are added to the context
- Repeat — until the model responds with no tool calls, or
max_stepsis reached
from chimera.core.loop import ReAct
loop = ReAct(max_steps=50)The loop terminates with success=True when the model produces a final text-only response (no tool calls). It terminates with success=False when max_steps is exhausted or a loop is detected.
PlanAndExecute
Section titled “PlanAndExecute”PlanAndExecute splits reasoning into two explicit phases:
- Phase 1 (Plan) — the model generates a plan (text-only response, no tools)
- Phase 2 (Execute) — a follow-up prompt (“Now execute the plan you just created, step by step.”) triggers ReAct-style tool execution
from chimera.core.loops.plan_execute import PlanAndExecute
loop = PlanAndExecute(max_steps=50)