Expand description
§Scheduler
Scheduler: loop guard and 6-state turn FSM.
§Overview
The scheduler is the core orchestration component that manages agent turn execution. It implements a finite state machine (FSM) with the following states:
- Start: Initialize turn, load session
- LLM Call: Send request to LLM
- Parse Action: Parse LLM response into structured action
- Execute Tool: Run tool if action is a tool call
- Update State: Update session state with results
- Loop/Finish: Either continue or complete the turn
§Loop Guard
The LoopGuard ensures turn termination by tracking:
- Number of steps (LLM calls)
- Number of tool calls
- Consecutive errors
- Elapsed time
If any limit is exceeded, the turn is terminated with an appropriate GuardReason.
§Example
ⓘ
use bob_runtime::scheduler::LoopGuard;
use bob_core::types::TurnPolicy;
let policy = TurnPolicy::default();
let mut guard = LoopGuard::new(policy);
while guard.can_continue() {
guard.record_step();
// Execute step...
}Structs§
- Loop
Guard - Safety net that guarantees turn termination by tracking steps,
tool calls, consecutive errors, and elapsed time against
TurnPolicylimits.
Functions§
- run_
turn - Execute a single agent turn as a 6-state FSM.
- run_
turn_ stream - Execute a single turn in streaming mode and return an event stream.