feat: implement workflow findings sharing for inter-agent communication in workflows

This commit is contained in:
asepharyana
2026-07-13 03:12:37 +07:00
parent dc0f1c7647
commit a080957c26
11 changed files with 154 additions and 65 deletions
+8 -1
View File
@@ -2,19 +2,25 @@
//! including the default read-only tool set for reviewer agents.
use std::path::PathBuf;
use std::sync::{Arc, Mutex};
use super::spawn::AgentDefinition;
/// Default read-only tool names granted to `role == "reviewer"` agents.
pub const REVIEWER_ALLOWED: &[&str] = &["read", "grep", "glob", "recall", "remember"];
/// Per-invocation configuration for a subagent: prompt, allowed tools,
/// step budget, and the session directory it should operate against.
/// step budget, session directory, and optional workflow-findings Arc
/// for cross-agent communication within a workflow run.
pub struct SubagentContext {
pub system_prompt: String,
pub allowed_tools: Vec<String>,
pub max_steps: usize,
pub session_dir: PathBuf,
pub workspaces: Vec<PathBuf>,
/// Ephemeral findings shared between sibling subagents in the same
/// workflow run. Set by the workflow engine; `note_finding` writes
/// into this from tool code via `ToolCtx.workflow_findings`.
pub workflow_findings: Option<Arc<Mutex<Vec<String>>>>,
}
/// Build a `SubagentContext` from an `AgentDefinition`.
@@ -41,5 +47,6 @@ pub fn build_subagent_context(def: AgentDefinition) -> SubagentContext {
max_steps,
session_dir: PathBuf::new(),
workspaces: Vec::new(),
workflow_findings: None,
}
}
+1
View File
@@ -96,6 +96,7 @@ pub fn run_subagent(ctx: SubagentContext, tx: mpsc::Sender<SubagentEvent>) -> an
.session_dir(ctx.session_dir.clone())
.workspaces(ctx.workspaces.clone())
.origin(crate::app::state::types::Origin::SubAgent)
.workflow_findings(ctx.workflow_findings.clone())
.build();
// Build tool list once before the loop