Documentation
¶
Index ¶
- Variables
- type Agent
- func (a *Agent) AddSkills(ctx context.Context, exclude ...string)
- func (a *Agent) AddTool(ctx context.Context, tool common.Tool)
- func (a *Agent) AddTools(ctx context.Context, tool ...common.Tool)
- func (a *Agent) Do(ctx context.Context, args *common.AgentDoArgs, opts ...model.Option) (common.ContextUID, streaming.Stream[*common.Step], error)
- func (a *Agent) LoadRPCPluginTools(ctx context.Context, address ...string) error
- func (a *Agent) LoadSharedLibPluginTools(ctx context.Context, pluginDir ...string) error
- func (a *Agent) RegisterMCPTools(ctx context.Context, cli client.MCPClient) error
- func (a *Agent) Steer(ctx context.Context, args *common.AgentSteerArgs) error
- func (a *Agent) Think(ctx *common.AgentContext, args *ThinkArgs, opts ...model.Option) (*ThinkResult, error)
- type ThinkArgs
- type ThinkResult
Constants ¶
This section is empty.
Variables ¶
var ReactSystemPromptTemplate = buildReactPrompt(false, "%s", "%s", "")
ReactSystemPromptTemplate is the non-planning prompt template. Its two formatting arguments are the available skills and skill-usage instructions.
var ReactWithPlanSystemPromptTemplate = buildReactPrompt(true, "%s", "%s", "%s")
ReactWithPlanSystemPromptTemplate is the planning prompt template. Its three formatting arguments are the available skills, skill-usage instructions, and plan-usage instructions.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
func NewAgent ¶
func NewAgent( llm model.AgenticModel, modelMaxTokensK int, manager contextmgr.ContextManager, ) *Agent
NewAgent creates a tool-calling agent backed by Eino's model.AgenticModel.
The agent intentionally trusts the AgenticModel contract and does not branch on OpenAI/Claude/Gemini-specific message quirks. Provider differences should be handled by the Eino agentic model implementations and provider-specific model.Option values passed by callers.
Typical provider construction:
OpenAI Responses API:
import (
"github.com/cloudwego/eino-ext/components/model/agenticopenai"
)
llm, err := agenticopenai.NewResponsesModel(ctx, &agenticopenai.ResponsesConfig{
APIKey: "sk-...",
Model: "gpt-5.2",
// BaseURL is optional for OpenAI-compatible gateways.
// ByAzure can be set when using Azure OpenAI.
})
agent := react.NewAgent(llm, 128, nil)
Claude:
import (
"github.com/cloudwego/eino-ext/components/model/agenticclaude"
)
llm, err := agenticclaude.New(ctx, &agenticclaude.Config{
APIKey: "sk-ant-...",
Model: "claude-sonnet-4-5",
MaxTokens: 4096,
// ByBedrock or ByGoogleVertexAI can be set for hosted Claude.
})
agent := react.NewAgent(llm, 128, nil)
Gemini on Vertex AI:
import (
"cloud.google.com/go/auth/credentials"
"github.com/cloudwego/eino-ext/components/model/agenticgemini"
"google.golang.org/genai"
"os"
)
client, err := genai.NewClient(ctx, &genai.ClientConfig{
Backend: genai.BackendVertexAI,
Project: "your-gcp-project",
Location: "global", // or a region such as "us-central1"
// Credentials may be omitted when Application Default Credentials are available.
})
// Or initialize Vertex AI with service account credentials JSON.
credentialsJSON, err := os.ReadFile("/path/to/service-account.json")
if err != nil {
return err
}
creds, err := credentials.DetectDefault(&credentials.DetectOptions{
Scopes: []string{"https://www.googleapis.com/auth/cloud-platform"},
CredentialsJSON: credentialsJSON,
})
if err != nil {
return err
}
client, err = genai.NewClient(ctx, &genai.ClientConfig{
Backend: genai.BackendVertexAI,
Project: "your-gcp-project",
Location: "global",
Credentials: creds,
})
llm, err := agenticgemini.New(ctx, &agenticgemini.Config{
Client: client,
Model: "gemini-2.5-flash",
})
agent := react.NewAgent(llm, 128, nil)
Gemini Developer API uses the same agenticgemini model with a genai client configured by API key instead of BackendVertexAI.
func (*Agent) LoadRPCPluginTools ¶
func (*Agent) LoadSharedLibPluginTools ¶
func (*Agent) RegisterMCPTools ¶
func (*Agent) Steer ¶
Steer queues user messages in the conversation's context-manager-backed pending inbox. They are applied after the next complete non-final turn. A final answer discards pending messages and closes the inbox until the next Do appends a new user input.
func (*Agent) Think ¶
func (a *Agent) Think(ctx *common.AgentContext, args *ThinkArgs, opts ...model.Option) (*ThinkResult, error)
Think generates the next step and determines if compression is needed
type ThinkArgs ¶
type ThinkArgs struct {
UserInput common.AgentUserInput
SpecialRequirements []string
Compress bool
CompressionOptions common.CompressionOptions
Messages []*schema.AgenticMessage
SystemPrompt string
FinalAnswerStreamingFunc func(context.Context, []byte) error
}
type ThinkResult ¶
type ThinkResult struct {
RawResponse *schema.AgenticMessage
IsCompressed bool
CompressedMessages []*schema.AgenticMessage
Messages []*schema.AgenticMessage
PromptTokens int
CachedTokens int
CompletionTokens int
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package compression provides context-compression strategies for the React agent.
|
Package compression provides context-compression strategies for the React agent. |