pub struct DagAgent<P: LlmProvider + 'static> { /* private fields */ }Expand description
A directed acyclic graph of agents.
Implementations§
Source§impl<P: LlmProvider + 'static> DagAgent<P>
impl<P: LlmProvider + 'static> DagAgent<P>
Sourcepub fn builder() -> DagAgentBuilder<P>
pub fn builder() -> DagAgentBuilder<P>
Create a new DagAgentBuilder.
Add nodes with .node("name", agent) and edges with
.edge("from", "to"). The builder validates the graph is acyclic
and that all edge endpoints reference declared nodes.
§Example
A diamond DAG: planner fans out to two workers that converge into a synthesizer.
use std::sync::Arc;
use heartbit_core::{
AgentRunner, AnthropicProvider, BoxedProvider, DagAgent,
};
let provider = Arc::new(BoxedProvider::new(AnthropicProvider::new(
"sk-...",
"claude-sonnet-4-20250514",
)));
let make = |prompt: &str| {
AgentRunner::builder(provider.clone())
.system_prompt(prompt)
.build()
.expect("agent build")
};
let dag = DagAgent::builder()
.node("plan", make("Outline the question."))
.node("research", make("Answer the question."))
.node("critique", make("Critique the proposed answer."))
.node("synth", make("Combine research and critique."))
.edge("plan", "research")
.edge("plan", "critique")
.edge("research", "synth")
.edge("critique", "synth")
.build()?;
let output = dag.execute("Should we use Rust?").await?;
println!("{}", output.result);Trait Implementations§
Source§impl<P: LlmProvider + 'static> Debug for DagAgent<P>
impl<P: LlmProvider + 'static> Debug for DagAgent<P>
Source§impl<P: LlmProvider + 'static> From<DagAgent<P>> for WorkflowRouter<P>
impl<P: LlmProvider + 'static> From<DagAgent<P>> for WorkflowRouter<P>
Auto Trait Implementations§
impl<P> Freeze for DagAgent<P>
impl<P> !RefUnwindSafe for DagAgent<P>
impl<P> Send for DagAgent<P>
impl<P> Sync for DagAgent<P>
impl<P> Unpin for DagAgent<P>
impl<P> UnsafeUnpin for DagAgent<P>
impl<P> !UnwindSafe for DagAgent<P>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more