Skip to main content

codetether_agent/rlm/
executor_bridge.rs

1//! Compatibility executor backed by the crate router.
2
3use anyhow::Result;
4use std::sync::Arc;
5
6use crate::provider::Provider;
7use crate::rlm::context_trace::{ContextTrace, ContextTraceSummary};
8use crate::rlm::oracle::TraceStep;
9use crate::rlm::{RlmAnalysisResult, RlmConfig};
10
11mod analysis;
12mod context;
13mod trace;
14
15/// Legacy-compatible `RlmExecutor` facade over [`RlmRouter`].
16pub struct RlmExecutor {
17    pub(super) context: String,
18    pub(super) provider: Arc<dyn Provider>,
19    pub(super) model: String,
20    pub(super) max_iterations: usize,
21    pub(super) trace_steps: Vec<TraceStep>,
22    pub(super) context_trace: ContextTrace,
23}
24
25impl RlmExecutor {
26    /// Create an executor for `context`, `provider`, and `model`.
27    pub fn new(context: String, provider: Arc<dyn Provider>, model: String) -> Self {
28        Self {
29            context,
30            provider,
31            model,
32            max_iterations: RlmConfig::default().max_iterations,
33            trace_steps: Vec::new(),
34            context_trace: ContextTrace::new(32_768),
35        }
36    }
37
38    /// Set maximum router iterations.
39    pub fn with_max_iterations(mut self, max: usize) -> Self {
40        self.max_iterations = max;
41        self
42    }
43
44    /// Compatibility no-op; the engine owns temperature policy.
45    pub fn with_temperature(self, _temperature: f32) -> Self {
46        self
47    }
48
49    /// Compatibility no-op; progress is emitted through router events.
50    pub fn with_verbose(self, _verbose: bool) -> Self {
51        self
52    }
53
54    /// Trace steps captured from the latest run.
55    pub fn trace_steps(&self) -> &[TraceStep] {
56        &self.trace_steps
57    }
58
59    /// Context trace summary for the latest run.
60    pub fn context_trace_summary(&self) -> ContextTraceSummary {
61        self.context_trace.summary()
62    }
63
64    /// Execute analysis through the crate RLM router.
65    pub async fn analyze(&mut self, query: &str) -> Result<RlmAnalysisResult> {
66        analysis::analyze(self, query).await
67    }
68}