Skip to main content

bamboo_engine/runtime/managers/
mini_loop.rs

1use async_trait::async_trait;
2use bamboo_agent_core::tools::ToolCall;
3use bamboo_agent_core::{AgentError, Session};
4
5/// Result of a mini-loop fast decision.
6#[derive(Debug, Clone)]
7pub struct MiniLoopDecision {
8    pub answer: String,
9    pub prompt_tokens: u64,
10    pub completion_tokens: u64,
11}
12
13/// Executor for cheap model fast decisions.
14///
15/// Used for task evaluation, compression decisions, routing,
16/// retry classification, and other lightweight LLM-powered judgments
17/// that should not consume the main model's budget or streaming path.
18#[async_trait]
19pub trait MiniLoopExecutor: Send + Sync {
20    /// Execute a fast decision using a cheap model.
21    async fn decide(
22        &self,
23        session: &Session,
24        prompt: &str,
25        context: &str,
26    ) -> Result<MiniLoopDecision, AgentError>;
27
28    /// Evaluate task progress using a fast model.
29    async fn evaluate_task(
30        &self,
31        session: &Session,
32        tool_calls: &[ToolCall],
33        round: usize,
34    ) -> Result<MiniLoopDecision, AgentError>;
35}