eino-adk
SKILL.md
Eino ADK Development Guide
When to Use This Skill
Use this skill when:
- User needs to build AI Agent applications
- User asks how to use Eino ADK
- User needs to implement multi-agent systems, workflows, human-in-the-loop
- User wants to understand core concepts like Agent, Runner, Tool
Quick Start
Step 1: Import Required Packages
import (
"context"
"errors"
"fmt"
"io"
"github.com/cloudwego/eino/adk"
"github.com/cloudwego/eino/adk/prebuilt/planexecute"
"github.com/cloudwego/eino/adk/prebuilt/supervisor"
"github.com/cloudwego/eino/components/model"
"github.com/cloudwego/eino/components/tool"
"github.com/cloudwego/eino/schema"
)
Step 2: Create ChatModelAgent
agent, err := adk.NewChatModelAgent(ctx, &adk.ChatModelAgentConfig{
Name: "my_agent",
Description: "An agent that helps with tasks",
Instruction: "You are a helpful assistant.",
Model: chatModel, // model.ToolCallingChatModel
ToolsConfig: adk.ToolsConfig{
Tools: []tool.BaseTool{myTool},
},
})
Step 3: Create Runner and Execute
runner := adk.NewRunner(ctx, adk.RunnerConfig{
Agent: agent,
EnableStreaming: true,
})
events := runner.Run(ctx, []schema.Message{
schema.UserMessage("Hello!"),
})
for event, ok := events.Next(); ok; event, ok = events.Next() {
if event.Output != nil && event.Output.MessageOutput != nil {
if stream := event.Output.MessageOutput.MessageStream; stream != nil {
for {
chunk, err := stream.Recv()
if errors.Is(err, io.EOF) {
break
}
if err != nil {
// handle error
break
}
fmt.Print(chunk.Content)
}
}
}
}
Note: MessageStream is automatically closed by ADK, no manual cleanup required.
Core Workflow
Basic Execution Flow
- Create Agent - Use
NewChatModelAgentor prebuilt agents - Create Runner - Use
NewRunnerto wrap the Agent - Execute - Call
runner.Run()orrunner.Query() - Process Events - Iterate
AsyncIterator[*AgentEvent]to handle output
Key Interfaces
| Interface | Location | Description |
|---|---|---|
| Agent | references/core-concepts.md | Core Agent interface |
| Runner | references/core-concepts.md | Execution entry point |
| AgentEvent | references/core-concepts.md | Event stream |
| Session | references/core-concepts.md | Session state |
Common Patterns
1. Basic Agent
See examples.md
agent, _ := adk.NewChatModelAgent(ctx, &adk.ChatModelAgentConfig{...})
runner := adk.NewRunner(ctx, adk.RunnerConfig{
Agent: agent,
EnableStreaming: true,
})
events := runner.Query(ctx, "Hello!")
for event, ok := events.Next(); ok; event, ok = events.Next() {
if event.Output != nil && event.Output.MessageOutput != nil {
if stream := event.Output.MessageOutput.MessageStream; stream != nil {
for {
chunk, err := stream.Recv()
if errors.Is(err, io.EOF) {
break
}
if err != nil {
// handle error
break
}
fmt.Print(chunk.Content)
}
}
}
}
2. Workflow Agent
See examples.md
// Sequential - executes sub-agents in order
agent := adk.NewSequentialAgent(ctx, &adk.SequentialAgentConfig{
SubAgents: []adk.Agent{agent1, agent2},
})
// Parallel - executes sub-agents concurrently
agent := adk.NewParallelAgent(ctx, &adk.ParallelAgentConfig{
SubAgents: []adk.Agent{agent1, agent2},
})
// Loop - iterates until condition met
agent := adk.NewLoopAgent(ctx, &adk.LoopAgentConfig{
SubAgents: []adk.Agent{agent1},
MaxIterations: 5,
})
3. Multi-Agent Systems
See examples.md
// Supervisor pattern
supervisor := supervisor.New(ctx, &supervisor.Config{
Supervisor: supervisorAgent,
SubAgents: []adk.Agent{agent1, agent2},
})
// Plan-Execute-Replan pattern
entryAgent := planexecute.New(ctx, &planexecute.Config{
Planner: planAgent,
Executor: execAgent,
Replanner: replanAgent,
})
4. Agent as Tool
See examples.md
agentTool := adk.NewAgentTool(ctx, subAgent,
adk.WithFullChatHistoryAsInput(),
)
5. Interruption and Resume
See examples.md
// Trigger interruption (in tool's InvokableRun method)
err := adk.StatefulInterrupt(ctx, &ReviewInfo{...}, args)
return "", err
// Resume execution
iter, _ := runner.Resume(ctx, checkpointID)
6. Session Values
// Store
adk.AddSessionValue(ctx, "key", value)
// Retrieve
value, _ := adk.GetSessionValue(ctx, "key")
Configuration
Key configuration options in configuration.md:
- ChatModelAgentConfig
- RunnerConfig
- ToolsConfig
- AgentMiddleware
API Reference
Key APIs in api-reference.md:
- NewChatModelAgent
- NewRunner
- Run/Query/Resume
- NewAgentTool
Error Handling
Common error handling:
- Tool call failure: Check tool definition and parameters
- Model call failure: Check Model configuration and API Key
- Resume failure: Verify CheckpointStore and ResumeInfo
- Concurrency issues: Ensure Agent instances are not shared
References
- Core Concepts - Detailed core concepts
- API Reference - API documentation
- Examples - Example scenarios
- Configuration - Configuration options
Weekly Installs
6
Repository
cylixlee/skillsFirst Seen
7 days ago
Security Audits
Installed on
opencode6
gemini-cli6
github-copilot6
codex6
amp6
cline6