feat: implement workflow findings sharing for inter-agent communication in workflows
This commit is contained in:
+18
-7
@@ -109,21 +109,32 @@ impl Tool for NoteFinding {
|
||||
|
||||
/// Record `text` as a finding visible to sibling agents in the run.
|
||||
///
|
||||
/// Flow: extract `text` argument → forward to
|
||||
/// `app::workflow::engine::note_finding` → return a truncated
|
||||
/// confirmation echo.
|
||||
/// Flow: extract `text` argument → push into
|
||||
/// `ctx.workflow_findings` (the per-invocation Arc threaded through
|
||||
/// `execute_primitive`) → return a truncated confirmation echo.
|
||||
///
|
||||
/// Why: findings are ephemeral (not persisted to memory) and are
|
||||
/// meant to be prepended to sibling agents' next tool-round context.
|
||||
/// Why: findings are scoped per workflow invocation, not global,
|
||||
/// so concurrent workflow runs are isolated from each other.
|
||||
/// If no workflow findings Arc is set (called outside a workflow),
|
||||
/// the call is silently ignored.
|
||||
///
|
||||
/// Return: confirmation string containing up to the first 80 chars
|
||||
/// of the recorded text.
|
||||
fn run(&self, _ctx: &ToolCtx, args: &Value) -> Result<String> {
|
||||
fn run(&self, ctx: &ToolCtx, args: &Value) -> Result<String> {
|
||||
let text = args.get("text")
|
||||
.and_then(|v| v.as_str())
|
||||
.ok_or_else(|| anyhow!("missing required argument: text"))?;
|
||||
|
||||
crate::app::workflow::engine::note_finding(text);
|
||||
if let Some(ref findings) = ctx.workflow_findings {
|
||||
if let Ok(mut f) = findings.lock() {
|
||||
f.push(text.to_string());
|
||||
}
|
||||
} else {
|
||||
tracing::debug!(
|
||||
"[note_finding] called outside a workflow run — discarding: {}",
|
||||
text.chars().take(80).collect::<String>(),
|
||||
);
|
||||
}
|
||||
Ok(format!("finding recorded: {}", text.chars().take(80).collect::<String>()))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user