agent

package
v1.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package agent declares the building blocks for implement vet agent.

Index

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 NewMockAgent

func NewMockAgent() *mockAgent

NewMockAgent creates a new mock agent

func NewMockSession

func NewMockSession() *mockSession

NewMockSession creates a new mock session

func NewReactQueryAgent

func NewReactQueryAgent(model model.ToolCallingChatModel,
	config ReactQueryAgentConfig, opts ...reactQueryAgentOpt,
) (*reactQueryAgent, error)

func NewSession

func NewSession(memory Memory) (*session, error)

func NewSimpleMemory

func NewSimpleMemory() (*simpleMemory, error)

func StartUI

func StartUI(agent Agent, session Session) error

StartUI starts the TUI application with the default configuration

func StartUIWithConfig

func StartUIWithConfig(agent Agent, session Session, config AgentUIConfig) error

StartUIWithConfig starts the TUI application with the provided configuration

func WithTools

func WithTools(tools []tool.BaseTool) reactQueryAgentOpt

Types

type Agent

type Agent interface {
	// Execute executes the agent with the given input and returns the output.
	// Internally the agent may perform a multi-step operation based on config,
	// instructions and available tools.
	Execute(context.Context, Session, Input, ...AgentExecutionContextOpt) (Output, error)
}

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
}

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)

type AgentToolCallIntrospectionFn

type AgentToolCallIntrospectionFn func(context.Context, string, string) (string, error)

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 Input

type Input struct {
	Query string
}

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
}

type Memory

type Memory interface {
	AddInteraction(ctx context.Context, interaction *schema.Message) error
	GetInteractions(ctx context.Context) ([]*schema.Message, error)
	Clear(ctx context.Context) error
}

type Model

type Model struct {
	Vendor string
	Name   string
	Fast   bool
	Client model.ToolCallingChatModel
}

func BuildModelFromEnvironment

func BuildModelFromEnvironment(fastMode bool) (*Model, error)

BuildModelFromEnvironment builds a model from the environment variables. The order of preference is: 1. OpenAI 2. Claude 3. Gemini 4. Others..

type Output

type Output struct {
	Answer string
	Format AnswerFormat
}

type ReactQueryAgentConfig

type ReactQueryAgentConfig struct {
	MaxSteps     int
	SystemPrompt string
}

type Session

type Session interface {
	ID() string
	Memory() Memory
}

type ToolBuilder

type ToolBuilder interface {
	Build(context.Context) ([]tool.BaseTool, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL