feat: implement abort mechanism for workflows and subagents

This commit is contained in:
asepharyana
2026-07-13 09:09:23 +07:00
parent 65647ce517
commit 104b0daf4c
5 changed files with 104 additions and 32 deletions
+5 -2
View File
@@ -22,7 +22,7 @@
use std::collections::HashMap;
use std::fmt::Write;
use std::sync::{Arc, Mutex};
use std::sync::{Arc, Mutex, atomic::AtomicBool};
use crate::app::workflow::engine::{execute_primitive, LiveStateFn, AgentStatus};
use crate::app::workflow::script::{ScriptPrimitive, ScriptOptions, WorkflowScript};
use crate::app::subagent::division;
@@ -45,6 +45,7 @@ pub fn run_company_pipeline(
session_dir: &std::path::Path,
workspaces: &[std::path::PathBuf],
turn_events: Option<&Arc<Mutex<std::collections::VecDeque<crate::app::state::runtime::TurnEvent>>>>,
abort_flag: &Option<Arc<AtomicBool>>,
) -> anyhow::Result<String> {
let divisions = division::all_divisions();
let mut pipeline_scripts: Vec<ScriptPrimitive> = Vec::with_capacity(divisions.len());
@@ -102,6 +103,7 @@ pub fn run_company_pipeline(
&args,
1,
true,
abort_flag,
live_ref,
session_dir,
workspaces,
@@ -126,6 +128,7 @@ pub fn run_company_pipeline_quick(
session_dir: &std::path::Path,
workspaces: &[std::path::PathBuf],
turn_events: Option<&Arc<Mutex<std::collections::VecDeque<crate::app::state::runtime::TurnEvent>>>>,
abort_flag: &Option<Arc<AtomicBool>>,
) -> anyhow::Result<String> {
let divisions = division::all_divisions();
// Only use first 3 divisions for quick pipeline: Strategy, Engineering, Quality
@@ -174,7 +177,7 @@ pub fn run_company_pipeline_quick(
let results = execute_primitive(
&wf.script, &args, 1, true,
live.as_ref(), session_dir, workspaces, &findings, None,
abort_flag, live.as_ref(), session_dir, workspaces, &findings, None,
)?;
let all_findings = findings.lock()