Agentic.Loop.Stages.ModeRouter
(agentic v0.2.2)
Copy Markdown
Mode-aware routing stage. Replaces StopReasonRouter.
Routes based on the triple (mode, phase, stop_reason) to decide what to do
with the LLM response. All phase transitions go through Phase.transition/2.
Routing Table
| Mode | Phase | Stop Reason | Action |
|---|---|---|---|
| :agentic | :execute | end_turn | Accumulate text → next (CommitmentGate) |
| :agentic | :execute | tool_use | Store pending_tool_calls → next (ToolExecutor) |
| :agentic_planned | :plan | end_turn | Parse plan → transition to :execute → reentry |
| :agentic_planned | :execute | end_turn | Accumulate text → next (CommitmentGate) |
| :agentic_planned | :execute | tool_use | Store pending_tool_calls → next (ToolExecutor) |
| :agentic_planned | :verify | end_turn | Accumulate verification result → done |
| :turn_by_turn | :review | end_turn | Build proposal → next (HumanCheckpoint) |
| :turn_by_turn | :review | tool_use | Store pending_tool_calls → next (ToolExecutor) |
| :turn_by_turn | :execute | end_turn | Transition to :review → reentry |
| :turn_by_turn | :execute | tool_use | Store pending_tool_calls → next (ToolExecutor) |
| :conversational | :execute | end_turn | Accumulate text → done |
| any | any | max_tokens | Return what we have → done |
Callbacks
Optional callbacks on ctx.callbacks:
:on_response_facts-(ctx, text) -> :ok:on_persist_turn-(ctx, text) -> :ok