Add fresh-agent Ralph loops

This commit is contained in:
Georg Bauer
2026-08-29 21:05:07 +02:00
parent f12aafcb2e
commit f2772f20c5
2 changed files with 1067 additions and 28 deletions

View File

@@ -1266,27 +1266,50 @@ impl App {
self.agent_tools = Some((session_id, Arc::new(Mutex::new(tools))));
}
let tools = Arc::clone(&self.agent_tools.as_ref().unwrap().1);
let model = self.config.model;
let generation = self.config.active_generation();
let runtime = self.config.runtime_for(model);
let effective =
crate::settings::effective_settings(model, &generation, &runtime, &models_path())?;
let service = self
.generation_service
.as_ref()
.ok_or_else(|| "The model runtime is unavailable.".to_owned())?
.clone();
let idle_timeout = Duration::from_secs(self.config.idle_timeout_minutes.max(1) as u64 * 60);
let mut child_turn = effective.turn.clone();
child_turn.system_prompt = crate::agent::ralph_system_prompt(
model,
&child_turn.system_prompt,
self.config.dev_brain.enabled,
);
if let Some(agents) = self.session_agents_prompt() {
child_turn.system_prompt.push_str("\n\n");
child_turn.system_prompt.push_str(agents);
}
if let Some(skills) = self.dev_brain_skills_prompt() {
child_turn.system_prompt.push_str("\n\n");
child_turn.system_prompt.push_str(&skills);
}
tools
.lock()
.unwrap_or_else(|poisoned| poisoned.into_inner())
.enable_ralph(
service.clone(),
model,
effective.engine.clone(),
child_turn,
idle_timeout,
);
let approval_mode = match self.permission_mode {
PermissionMode::Heuristic => crate::agent::ShellApprovalMode::Heuristic,
PermissionMode::Ai => {
let generation = self.config.active_generation();
let runtime = self.config.runtime_for(self.config.model);
let effective = crate::settings::effective_settings(
self.config.model,
&generation,
&runtime,
&models_path(),
)?;
let service = self
.generation_service
.as_ref()
.ok_or_else(|| "The model runtime is unavailable.".to_owned())?;
crate::agent::ShellApprovalMode::Ai(Box::new(crate::agent::AiRiskClassifier::new(
service.clone(),
service,
effective.engine,
effective.turn,
transient_cache_path(),
Duration::from_secs(self.config.idle_timeout_minutes.max(1) as u64 * 60),
idle_timeout,
)))
}
};