Documentation
¶
Overview ¶
Package agent declares the building blocks for implement vet agent.
Index ¶
- func NewAgentUI(agent Agent, session Session, config AgentUIConfig) *agentUI
- func NewMcpClientToolBuilder(config McpClientToolBuilderConfig) (*mcpClientToolBuilder, error)
- func NewMockAgent() *mockAgent
- func NewMockSession() *mockSession
- func NewReactQueryAgent(model model.ToolCallingChatModel, config ReactQueryAgentConfig, ...) (*reactQueryAgent, error)
- func NewSession(memory Memory) (*session, error)
- func NewSimpleMemory() (*simpleMemory, error)
- func NewToolContentCompactor(config ToolContentCompactorConfig) func(context.Context, []*schema.Message) []*schema.Message
- func StartUI(agent Agent, session Session) error
- func StartUIWithConfig(agent Agent, session Session, config AgentUIConfig) error
- func WithTools(tools []tool.BaseTool) reactQueryAgentOpt
- type Agent
- type AgentExecutionContext
- type AgentExecutionContextOpt
- type AgentToolCallIntrospectionFn
- type AgentUIConfig
- type AnswerFormat
- type Input
- type McpClientToolBuilderConfig
- type Memory
- type Model
- type Output
- type ReactQueryAgentConfig
- type Session
- type ToolBuilder
- type ToolContentCompactorConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAgentUI ¶
func NewAgentUI(agent Agent, session Session, config AgentUIConfig) *agentUI
NewAgentUI creates a new agent UI instance
func NewMcpClientToolBuilder ¶
func NewMcpClientToolBuilder(config McpClientToolBuilderConfig) (*mcpClientToolBuilder, error)
NewMcpClientToolBuilder creates a new MCP client tool builder for `vet` MCP server. This basically connects to vet MCP server over SSE or executes the `vet server mcp` command to start a MCP server in stdio mode. We maintain loose coupling between the MCP client and the MCP server by allowing the client to be configured with a set of flags to enable/disable specific tools. We do this to ensure vet MCP contract is not violated and evolves independently. vet Agents will in turn depend on vet MCP server for data access.
func NewReactQueryAgent ¶
func NewReactQueryAgent(model model.ToolCallingChatModel, config ReactQueryAgentConfig, opts ...reactQueryAgentOpt, ) (*reactQueryAgent, error)
func NewSession ¶
func NewSimpleMemory ¶
func NewSimpleMemory() (*simpleMemory, error)
func NewToolContentCompactor ¶ added in v1.13.0
func NewToolContentCompactor(config ToolContentCompactorConfig) func(context.Context, []*schema.Message) []*schema.Message
NewToolContentCompactor returns a MessageRewriter that compacts tool result content for the specified tool names. It preserves the most recent tool result for each tool name and replaces earlier results with a compact placeholder, reducing context window usage when tools are called repeatedly.
func StartUIWithConfig ¶
func StartUIWithConfig(agent Agent, session Session, config AgentUIConfig) error
StartUIWithConfig starts the TUI application with the provided configuration
Types ¶
type AgentExecutionContext ¶
type AgentExecutionContext struct {
// OnToolCall is called when the agent is about to call a tool.
// This is used for introspection only and not to mutate the agent's behavior.
OnToolCall func(context.Context, Session, Input, string, string) error
// OnThinking is called when the model produces reasoning/thinking content.
// This is used for introspection only and not to mutate the agent's behavior.
OnThinking func(ctx context.Context, content string) error
}
AgentExecutionContext is to pass additional context to the agent on a per execution basis. This is required so that an agent can be configured and shared with different components while allowing the component to pass additional context to the agent.
type AgentExecutionContextOpt ¶
type AgentExecutionContextOpt func(*AgentExecutionContext)
func WithThinkingHook ¶ added in v1.13.0
func WithThinkingHook(fn func(ctx context.Context, content string) error) AgentExecutionContextOpt
func WithToolCallHook ¶
type AgentToolCallIntrospectionFn ¶
AgentToolCallIntrospectionFn is a function that introspects a tool call. This is aligned with eino contract.
type AgentUIConfig ¶
type AgentUIConfig struct {
Width int
Height int
InitialSystemMessage string
TextInputPlaceholder string
TitleText string
MaxHistory int
// Only for informational purposes.
ModelName string
ModelVendor string
ModelFast bool
}
AgentUIConfig defines the configuration for the UI
func DefaultAgentUIConfig ¶
func DefaultAgentUIConfig() AgentUIConfig
DefaultAgentUIConfig returns the opinionated default configuration for the UI
type AnswerFormat ¶
type AnswerFormat string
const ( AnswerFormatMarkdown AnswerFormat = "markdown" AnswerFormatJSON AnswerFormat = "json" )
type McpClientToolBuilderConfig ¶
type McpClientToolBuilderConfig struct {
// Common config
ClientName string
ClientVersion string
// SSE client config
SseURL string
Headers map[string]string
// Stdout client config
SkipDefaultTools bool
SQLQueryToolEnabled bool
SQLQueryToolDBPath string
PackageRegistryToolEnabled bool
// Enable debug mode for the MCP client.
Debug bool
}
type Model ¶
type Model struct {
Vendor string
Name string
Fast bool
Client model.ToolCallingChatModel
}
func BuildModelFromEnvironment ¶
BuildModelFromEnvironment builds a model from the environment variables. The order of preference is: 1. OpenAI 2. Claude 3. Gemini 4. Others..
When enableThinking is true, models that support reasoning/thinking content will be configured to include it in responses (e.g. Gemini's IncludeThoughts).
type Output ¶
type Output struct {
Answer string
Format AnswerFormat
}
type ReactQueryAgentConfig ¶
type ToolContentCompactorConfig ¶ added in v1.13.0
type ToolContentCompactorConfig struct {
// ToolNames is the list of tool names whose results should be compacted.
ToolNames []string
// MinContentSize is the minimum content length (in bytes) for a tool result
// to be eligible for compaction. Results shorter than this are left as-is.
// Default: 0 (compact all matching results regardless of size).
MinContentSize int
// CompactMessage is the replacement content for compacted tool results.
// If empty, a default message is used.
CompactMessage string
}
ToolContentCompactorConfig configures the behavior of NewToolContentCompactor.
func DefaultToolContentCompactorConfig ¶ added in v1.13.0
func DefaultToolContentCompactorConfig() ToolContentCompactorConfig
DefaultToolContentCompactorConfig returns a baseline config with sensible defaults. Callers should set ToolNames for their specific agent.