Add fresh-agent Ralph loops
This commit is contained in:
1044
src/agent.rs
1044
src/agent.rs
File diff suppressed because it is too large
Load Diff
@@ -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 approval_mode = match self.permission_mode {
|
||||
PermissionMode::Heuristic => crate::agent::ShellApprovalMode::Heuristic,
|
||||
PermissionMode::Ai => {
|
||||
let model = self.config.model;
|
||||
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 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())?;
|
||||
crate::agent::ShellApprovalMode::Ai(Box::new(crate::agent::AiRiskClassifier::new(
|
||||
.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 => {
|
||||
crate::agent::ShellApprovalMode::Ai(Box::new(crate::agent::AiRiskClassifier::new(
|
||||
service,
|
||||
effective.engine,
|
||||
effective.turn,
|
||||
transient_cache_path(),
|
||||
Duration::from_secs(self.config.idle_timeout_minutes.max(1) as u64 * 60),
|
||||
idle_timeout,
|
||||
)))
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user