composition

package
v0.0.0-...-140e820 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package composition provides agent composition patterns.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentResult

type AgentResult struct {
	AgentName string
	Message   *agenkit.Message
	Error     error
}

AgentResult holds the result from a single agent execution.

type Condition

type Condition func(message *agenkit.Message) bool

Condition is a function that determines whether to use an agent.

func And

func And(conditions ...Condition) Condition

And combines multiple conditions with AND logic.

func ContentContains

func ContentContains(substr string) Condition

ContentContains returns a condition that checks if message content contains a substring.

func MetadataEquals

func MetadataEquals(key string, value interface{}) Condition

MetadataEquals returns a condition that checks if metadata key equals value.

func MetadataHasKey

func MetadataHasKey(key string) Condition

MetadataHasKey returns a condition that checks if metadata contains a key.

func Not

func Not(condition Condition) Condition

Not negates a condition.

func Or

func Or(conditions ...Condition) Condition

Or combines multiple conditions with OR logic.

func RoleEquals

func RoleEquals(role string) Condition

RoleEquals returns a condition that checks if message role equals the given role.

type ConditionalAgent

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

ConditionalAgent routes messages to different agents based on conditions.

func NewConditionalAgent

func NewConditionalAgent(name string, defaultAgent agenkit.Agent) *ConditionalAgent

NewConditionalAgent creates a new conditional agent.

func (*ConditionalAgent) AddRoute

func (c *ConditionalAgent) AddRoute(condition Condition, agent agenkit.Agent)

AddRoute adds a conditional route.

func (*ConditionalAgent) Capabilities

func (c *ConditionalAgent) Capabilities() []string

Capabilities returns combined capabilities of all agents.

func (*ConditionalAgent) GetDefaultAgent

func (c *ConditionalAgent) GetDefaultAgent() agenkit.Agent

GetDefaultAgent returns the default agent.

func (*ConditionalAgent) GetRoutes

func (c *ConditionalAgent) GetRoutes() []ConditionalRoute

GetRoutes returns the conditional routes.

func (*ConditionalAgent) Introspect

func (c *ConditionalAgent) Introspect() *agenkit.IntrospectionResult

Introspect returns introspection result for the conditional agent.

func (*ConditionalAgent) Name

func (c *ConditionalAgent) Name() string

Name returns the name of the conditional agent.

func (*ConditionalAgent) Process

func (c *ConditionalAgent) Process(ctx context.Context, message *agenkit.Message) (*agenkit.Message, error)

Process routes the message to the first agent whose condition is met.

type ConditionalRoute

type ConditionalRoute struct {
	Condition Condition
	Agent     agenkit.Agent
}

ConditionalRoute represents a condition-agent pair.

type FallbackAgent

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

FallbackAgent tries agents in order until one succeeds. This implements the Fallback/Retry pattern for reliability.

func NewFallbackAgent

func NewFallbackAgent(name string, agents ...agenkit.Agent) (*FallbackAgent, error)

NewFallbackAgent creates a new fallback agent.

func (*FallbackAgent) Capabilities

func (f *FallbackAgent) Capabilities() []string

Capabilities returns combined capabilities of all agents.

func (*FallbackAgent) GetAgents

func (f *FallbackAgent) GetAgents() []agenkit.Agent

GetAgents returns the list of fallback agents.

func (*FallbackAgent) Introspect

func (f *FallbackAgent) Introspect() *agenkit.IntrospectionResult

Introspect returns introspection result for the fallback agent.

func (*FallbackAgent) Name

func (f *FallbackAgent) Name() string

Name returns the name of the fallback agent.

func (*FallbackAgent) Process

func (f *FallbackAgent) Process(ctx context.Context, message *agenkit.Message) (*agenkit.Message, error)

Process tries each agent in order until one succeeds.

type ParallelAgent

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

ParallelAgent executes multiple agents concurrently and combines their results.

func NewParallelAgent

func NewParallelAgent(name string, agents ...agenkit.Agent) (*ParallelAgent, error)

NewParallelAgent creates a new parallel agent.

func (*ParallelAgent) Capabilities

func (p *ParallelAgent) Capabilities() []string

Capabilities returns combined capabilities of all agents.

func (*ParallelAgent) GetAgents

func (p *ParallelAgent) GetAgents() []agenkit.Agent

GetAgents returns the list of agents that run in parallel.

func (*ParallelAgent) Introspect

func (p *ParallelAgent) Introspect() *agenkit.IntrospectionResult

Introspect returns introspection result for the parallel agent.

func (*ParallelAgent) Name

func (p *ParallelAgent) Name() string

Name returns the name of the parallel agent.

func (*ParallelAgent) Process

func (p *ParallelAgent) Process(ctx context.Context, message *agenkit.Message) (*agenkit.Message, error)

Process executes all agents in parallel and combines their results.

type SequentialAgent

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

SequentialAgent executes multiple agents in sequence, passing output from one agent as input to the next.

func NewSequentialAgent

func NewSequentialAgent(name string, agents ...agenkit.Agent) (*SequentialAgent, error)

NewSequentialAgent creates a new sequential agent.

func (*SequentialAgent) Capabilities

func (s *SequentialAgent) Capabilities() []string

Capabilities returns combined capabilities of all agents.

func (*SequentialAgent) GetAgents

func (s *SequentialAgent) GetAgents() []agenkit.Agent

GetAgents returns the list of agents in the sequence.

func (*SequentialAgent) Introspect

func (s *SequentialAgent) Introspect() *agenkit.IntrospectionResult

Introspect returns introspection result for the sequential agent.

func (*SequentialAgent) Name

func (s *SequentialAgent) Name() string

Name returns the name of the sequential agent.

func (*SequentialAgent) Process

func (s *SequentialAgent) Process(ctx context.Context, message *agenkit.Message) (*agenkit.Message, error)

Process executes all agents in sequence.

Jump to

Keyboard shortcuts

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