@@ -28,16 +28,17 @@ GraphAgent implements the `agent.Agent` interface and can:
2828
2929- ** Act as Independent Agent** : Execute directly through Runner
3030- ** Act as SubAgent** : Be used as a sub-agent by other Agents (such as LLMAgent)
31- - ** No SubAgent Support ** : GraphAgent itself does not support sub-agents, focusing on workflow execution
31+ - ** Host SubAgents ** : Register child agents via ` graphagent.WithSubAgents ` and invoke them through ` AddAgentNode `
3232
33- This design allows GraphAgent to flexibly integrate into complex multi-Agent systems .
33+ This design lets GraphAgent plug into other agents while orchestrating its own specialized sub-agents .
3434
3535### Key Features
3636
3737- ** Type-safe state management** : Use Schema to define state structure, support custom Reducers
3838- ** Conditional routing** : Dynamically select execution paths based on state
3939- ** LLM node integration** : Built-in support for large language models
4040- ** Tool nodes** : Support function calls and external tool integration
41+ - ** Agent nodes** : Delegate parts of the workflow to registered sub-agents
4142- ** Streaming execution** : Support real-time event streams and progress tracking
4243- ** Concurrency safety** : Thread-safe graph execution
4344- ** Checkpoint-based Time Travel** : Navigate through execution history and restore previous states
@@ -452,21 +453,40 @@ GraphAgent supports various configuration options:
452453
453454``` go
454455// Multiple options can be used when creating GraphAgent.
455- graphAgent , err := graphagent.New (" workflow-name" , compiledGraph,
456+ graphAgent , err := graphagent.New (
457+ " workflow-name" ,
458+ compiledGraph,
456459 graphagent.WithDescription (" Workflow description" ),
457460 graphagent.WithInitialState (graph.State {
458461 " initial_data" : " Initial data" ,
459462 }),
460- graphagent.WithChannelBufferSize (1024 ),
461- graphagent.WithModelCallbacks (&model.Callbacks {
462- // Model callback configuration.
463- }),
464- graphagent.WithToolCallbacks (&tool.Callbacks {
465- // Tool callback configuration.
463+ graphagent.WithChannelBufferSize (1024 ), // Tune event buffer size
464+ graphagent.WithCheckpointSaver (memorySaver), // Persist checkpoints if needed
465+ graphagent.WithSubAgents ([]agent.Agent {subAgent}), // Register sub-agents by name
466+ graphagent.WithAgentCallbacks (&agent.Callbacks {
467+ // Agent-level callbacks.
466468 }),
467469)
468470```
469471
472+ > Model/tool callbacks are configured per node, e.g. ` AddLLMNode(..., graph.WithModelCallbacks(...)) `
473+ > or ` AddToolsNode(..., graph.WithToolCallbacks(...)) ` .
474+
475+ Once sub-agents are registered you can delegate within the graph via agent nodes:
476+
477+ ``` go
478+ // Assume subAgent.Info().Name == "assistant"
479+ stateGraph.AddAgentNode (" assistant" ,
480+ graph.WithName (" Delegate to assistant agent" ),
481+ graph.WithDescription (" Invoke the pre-registered assistant agent" ),
482+ )
483+
484+ // During execution the GraphAgent looks up a sub-agent with the same name and runs it
485+ ```
486+
487+ > The agent node uses its ID for the lookup, so keep ` AddAgentNode("assistant") `
488+ > aligned with ` subAgent.Info().Name == "assistant" ` .
489+
470490### 4. Conditional Routing
471491
472492``` go
@@ -1688,9 +1708,9 @@ func main() {
16881708** Key Features** :
16891709
16901710- GraphAgent implements the ` agent.Agent ` interface and can be used as a sub-agent by other Agents
1691- - Coordinator Agents can delegate tasks to GraphAgent through the ` transfer_to_agent ` tool
1692- - GraphAgent focuses on workflow execution and does not support its own sub-agents
1693- - This design enables seamless integration of complex workflows with multi-Agent systems
1711+ - Coordinator Agents can delegate tasks to GraphAgent through the ` transfer_to_agent ` tool or custom logic
1712+ - GraphAgent can in turn delegate to registered sub-agents through ` graphagent.WithSubAgents ` + ` AddAgentNode `
1713+ - This design enables seamless, bi-directional integration between complex workflows and multi-Agent systems
16941714
16951715## Troubleshooting
16961716
@@ -1730,8 +1750,8 @@ The Graph package provides a powerful and flexible workflow orchestration system
17301750
17311751- GraphAgent implements the ` agent.Agent ` interface
17321752- Can be used as a sub-agent of other Agents
1753+ - Can also orchestrate other agents via ` graphagent.WithSubAgents ` and ` AddAgentNode `
17331754- Supports complex multi-Agent collaboration scenarios
1734- - Focuses on workflow execution, does not support its own sub-agents
17351755
17361756** Best Practices** :
17371757
0 commit comments