feat: implement workflow findings sharing for inter-agent communication in workflows
This commit is contained in:
+11
-2
@@ -88,7 +88,7 @@ impl Tool for SpawnAgents {
|
||||
},
|
||||
};
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
let live: Option<crate::app::workflow::engine::LiveStateFn> = _ctx.turn_events.as_ref().map(|turn_events| {
|
||||
let turn_events = turn_events.clone();
|
||||
let f: crate::app::workflow::engine::LiveStateFn = Arc::new(move |agent_id: String, status| {
|
||||
@@ -104,6 +104,10 @@ impl Tool for SpawnAgents {
|
||||
f
|
||||
});
|
||||
|
||||
// Create a per-invocation findings scope so subagents spawned
|
||||
// by this tool call are isolated from any other concurrent
|
||||
// spawn_agents or workflow_run invocations.
|
||||
let findings: Arc<Mutex<Vec<String>>> = Arc::new(Mutex::new(Vec::new()));
|
||||
let results = crate::app::workflow::engine::execute_primitive(
|
||||
&wf.script,
|
||||
&HashMap::new(),
|
||||
@@ -112,6 +116,7 @@ impl Tool for SpawnAgents {
|
||||
live.as_ref(),
|
||||
&_ctx.session_dir,
|
||||
&_ctx.workspaces,
|
||||
&findings,
|
||||
)?;
|
||||
format_results(results, "parallel")
|
||||
}
|
||||
@@ -173,7 +178,7 @@ impl Tool for SpawnPipeline {
|
||||
},
|
||||
};
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::sync::{Arc, Mutex};
|
||||
let live: Option<crate::app::workflow::engine::LiveStateFn> = _ctx.turn_events.as_ref().map(|turn_events| {
|
||||
let turn_events = turn_events.clone();
|
||||
let f: crate::app::workflow::engine::LiveStateFn = Arc::new(move |agent_id: String, status| {
|
||||
@@ -189,6 +194,9 @@ impl Tool for SpawnPipeline {
|
||||
f
|
||||
});
|
||||
|
||||
// Per-invocation findings scope isolates this pipeline from any
|
||||
// other concurrent spawn_agents / spawn_pipeline / workflow_run.
|
||||
let findings: Arc<Mutex<Vec<String>>> = Arc::new(Mutex::new(Vec::new()));
|
||||
let results = crate::app::workflow::engine::execute_primitive(
|
||||
&wf.script,
|
||||
&HashMap::new(),
|
||||
@@ -197,6 +205,7 @@ impl Tool for SpawnPipeline {
|
||||
live.as_ref(),
|
||||
&_ctx.session_dir,
|
||||
&_ctx.workspaces,
|
||||
&findings,
|
||||
)?;
|
||||
format_results(results, "pipeline")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user