feat: support require_plan_approval in template config

Templates can now set "require_plan_approval": true in template.json
to require user approval after plan generation before execution begins.
On rejection, the LLM re-enters the planning loop with user feedback.
This commit is contained in:
Fam Zheng
2026-03-12 19:25:35 +00:00
parent 30e25f589b
commit dae99d307a
2 changed files with 105 additions and 11 deletions

View File

@@ -12,6 +12,10 @@ pub struct TemplateInfo {
pub name: String,
pub description: String,
pub match_hint: String,
/// If true, the agent will wait for user approval after update_plan
/// before entering the execution phase.
#[serde(default)]
pub require_plan_approval: bool,
}
#[allow(dead_code)]
@@ -21,6 +25,7 @@ pub struct LoadedTemplate {
pub instructions: String,
pub external_tools: ExternalToolManager,
pub kb_files: Vec<(String, String)>,
pub require_plan_approval: bool,
}
#[derive(Debug, Clone, serde::Serialize)]
@@ -590,12 +595,14 @@ impl LoadedTemplate {
name: template_id.to_string(),
description: String::new(),
match_hint: String::new(),
require_plan_approval: false,
})
} else {
TemplateInfo {
name: template_id.to_string(),
description: String::new(),
match_hint: String::new(),
require_plan_approval: false,
}
};
@@ -610,12 +617,15 @@ impl LoadedTemplate {
let kb_files = scan_kb_files(&kb_dir).await;
tracing::info!("Template '{}': {} KB files", template_id, kb_files.len());
let require_plan_approval = info.require_plan_approval;
Ok(Self {
id: template_id.to_string(),
info,
instructions,
external_tools,
kb_files,
require_plan_approval,
})
}