tools

package
v0.2.75 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// MaxRecursionDepth is the maximum allowed recursion depth
	MaxRecursionDepth = 5
)

Variables

This section is empty.

Functions

func GetInvocationID added in v0.2.71

func GetInvocationID(ctx context.Context) string

GetInvocationID returns the invocation ID for this sub-agent call, or "".

func GetParentAgent added in v0.2.71

func GetParentAgent(ctx context.Context) string

GetParentAgent returns the name of the invoking parent agent, or "".

func GetRecursionDepth added in v0.2.71

func GetRecursionDepth(ctx context.Context) int

GetRecursionDepth returns the current sub-agent recursion depth.

func GetSubAgentName added in v0.2.71

func GetSubAgentName(ctx context.Context) string

GetSubAgentName returns the name of the sub-agent being invoked, or "".

func IsSubAgentCall added in v0.2.71

func IsSubAgentCall(ctx context.Context) bool

IsSubAgentCall reports whether ctx is inside a sub-agent invocation.

func ValidateRecursionDepth added in v0.2.71

func ValidateRecursionDepth(ctx context.Context) error

ValidateRecursionDepth reports an error when the sub-agent recursion depth has exceeded MaxRecursionDepth.

func WithStreamForwarder added in v0.2.3

func WithStreamForwarder(ctx context.Context, forwarder interfaces.StreamForwarder) context.Context

WithStreamForwarder adds a stream forwarder to the context

func WithSubAgentContext added in v0.2.71

func WithSubAgentContext(ctx context.Context, parentAgent, subAgentName string) context.Context

WithSubAgentContext records a sub-agent invocation on ctx, incrementing the recursion depth.

Types

type AgentTool added in v0.0.26

type AgentTool struct {
	// contains filtered or unexported fields
}

AgentTool wraps an agent to make it callable as a tool

func NewAgentTool added in v0.0.26

func NewAgentTool(agent SubAgent) *AgentTool

NewAgentTool creates a new agent tool wrapper

func (*AgentTool) Description added in v0.0.26

func (at *AgentTool) Description() string

Description returns the description of what the tool does

func (*AgentTool) DisplayName added in v0.0.53

func (at *AgentTool) DisplayName() string

DisplayName implements interfaces.ToolWithDisplayName.DisplayName

func (*AgentTool) Execute added in v0.0.26

func (at *AgentTool) Execute(ctx context.Context, args string) (string, error)

Execute implements interfaces.Tool.Execute

func (*AgentTool) Internal added in v0.0.53

func (at *AgentTool) Internal() bool

Internal implements interfaces.InternalTool.Internal

func (*AgentTool) Name added in v0.0.26

func (at *AgentTool) Name() string

Name returns the name of the tool

func (*AgentTool) Parameters added in v0.0.26

func (at *AgentTool) Parameters() map[string]interfaces.ParameterSpec

Parameters returns the parameters that the tool accepts

func (*AgentTool) Run added in v0.0.26

func (at *AgentTool) Run(ctx context.Context, input string) (string, error)

Run executes the tool with the given input

func (*AgentTool) SetDescription added in v0.0.26

func (at *AgentTool) SetDescription(description string)

SetDescription allows updating the tool description

func (*AgentTool) WithLogger added in v0.0.26

func (at *AgentTool) WithLogger(logger logging.Logger) *AgentTool

WithLogger sets a custom logger for the agent tool

func (*AgentTool) WithTimeout added in v0.0.26

func (at *AgentTool) WithTimeout(timeout time.Duration) *AgentTool

WithTimeout sets a custom timeout for the agent tool

func (*AgentTool) WithTracer added in v0.0.26

func (at *AgentTool) WithTracer(tracer interfaces.Tracer) *AgentTool

WithTracer sets a custom tracer for the agent tool

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry implements the ToolRegistry interface

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new tool registry

func (*Registry) Get

func (r *Registry) Get(name string) (interfaces.Tool, bool)

Get returns a tool by name

func (*Registry) List

func (r *Registry) List() []interfaces.Tool

List returns all registered tools

func (*Registry) Register

func (r *Registry) Register(tool interfaces.Tool)

Register registers a tool with the registry

type SubAgent added in v0.0.26

type SubAgent interface {
	Run(ctx context.Context, input string) (string, error)
	RunStream(ctx context.Context, input string) (<-chan interfaces.AgentStreamEvent, error)
	RunDetailed(ctx context.Context, input string) (*interfaces.AgentResponse, error)
	GetName() string
	GetDescription() string
}

SubAgent interface defines the minimal interface needed for a sub-agent

Directories

Path Synopsis
Package graphrag provides tools for interacting with GraphRAG knowledge graphs.
Package graphrag provides tools for interacting with GraphRAG knowledge graphs.

Jump to

Keyboard shortcuts

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