Skip to main content

codetether_rlm/router/
auto_process.rs

1//! Top-level `auto_process` entry point.
2
3use super::host::RouterHost;
4use super::legacy_process;
5use super::types::CrateAutoProcessContext;
6use crate::config::RlmConfig;
7use crate::result::RlmResult;
8use std::time::Instant;
9use tracing::{info, warn};
10
11/// Process large output through the RLM iterative analysis loop.
12pub async fn auto_process(
13    output: &str,
14    ctx: CrateAutoProcessContext<'_>,
15    config: &RlmConfig,
16    host: &mut dyn RouterHost,
17) -> anyhow::Result<RlmResult> {
18    let start = Instant::now();
19    info!(tool = ctx.tool_id, "RLM: Starting auto-processing");
20
21    match crate::engine::process(output, &ctx, config).await {
22        Ok(Some(result)) => return Ok(result),
23        Ok(None) => {}
24        Err(e) => warn!(error = %e, "RLM engine failed, using legacy loop"),
25    }
26
27    legacy_process::run(output, ctx, config, host, start).await
28}