eino-adk
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
More from cylixlee/cortex
pnpm
Node.js package manager with strict dependency resolution. Use when running pnpm specific commands, configuring workspaces, or managing dependencies with catalogs, patches, or overrides.
2vue-debug-guides
Vue 3 debugging and error handling for runtime errors, warnings, async failures, and SSR/hydration issues. Use when diagnosing or fixing Vue issues.
2frontend-design
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.
2golang-gin-api
Build REST APIs with Go Gin framework. Covers routing, handler patterns, request binding/validation, middleware chains, error handling, security headers (OWASP), CORS, timeout middleware, and layered project structure. Use when creating Go web servers, REST endpoints, HTTP handlers, or working with the Gin framework. Also activate when the user mentions Gin routes, middleware, JSON responses, request parsing, or API structure in Go.
2design-pattern
Applies object-oriented design principles and design patterns to generate maintainable, extensible code. Use when generating code that requires proper architectural layering, SOLID principles, and appropriate design patterns to solve recurring software design problems.
2golang-gin-auth
Implement authentication and authorization in Go Gin APIs. Covers JWT middleware (jti blacklisting, refresh rotation), login/register handlers, bcrypt password hashing, RBAC, CSRF protection, rate limiting on auth endpoints, secure cookies, and admin impersonation guards. Use when adding auth, login, signup, JWT tokens, user sessions, permissions, or role checks to a Gin application.
2