handoff

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentCapability

type AgentCapability struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	TaskTypes   []string `json:"task_types"`
	Priority    int      `json:"priority"`
}

Agent Captainable 描述一个代理能够做什么.

type Handoff

type Handoff struct {
	ID          string         `json:"id"`
	FromAgentID string         `json:"from_agent_id"`
	ToAgentID   string         `json:"to_agent_id"`
	Task        Task           `json:"task"`
	Status      HandoffStatus  `json:"status"`
	Context     HandoffContext `json:"context"`
	Result      *HandoffResult `json:"result,omitempty"`
	CreatedAt   time.Time      `json:"created_at"`
	AcceptedAt  *time.Time     `json:"accepted_at,omitempty"`
	CompletedAt *time.Time     `json:"completed_at,omitempty"`
	Timeout     time.Duration  `json:"timeout"`
	RetryCount  int            `json:"retry_count"`
	MaxRetries  int            `json:"max_retries"`
	// contains filtered or unexported fields
}

Handoff代表着从一个代理人到另一个代理人的任务代表团.

type HandoffAgent

type HandoffAgent interface {
	ID() string
	Capabilities() []AgentCapability
	CanHandle(task Task) bool
	AcceptHandoff(ctx context.Context, handoff *Handoff) error
	ExecuteHandoff(ctx context.Context, handoff *Handoff) (*HandoffResult, error)
}

支持交接的代理商的交接代理接口.

type HandoffContext

type HandoffContext struct {
	ConversationID string         `json:"conversation_id,omitempty"`
	Messages       []Message      `json:"messages,omitempty"`
	Variables      map[string]any `json:"variables,omitempty"`
	ParentHandoff  string         `json:"parent_handoff,omitempty"`
}

HandoffContext为交接提供了上下文.

type HandoffManager

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

HandoffManager管理代理人的交割.

func NewHandoffManager

func NewHandoffManager(logger *zap.Logger) *HandoffManager

NewHandoffManager创建了新的交接管理器.

func (*HandoffManager) FindAgent

func (m *HandoffManager) FindAgent(task Task) (HandoffAgent, error)

FindAgent 找到任务的最佳代理 。

func (*HandoffManager) GetHandoff

func (m *HandoffManager) GetHandoff(handoffID string) (*Handoff, error)

找汉多夫拿回身份证

func (*HandoffManager) Handoff

func (m *HandoffManager) Handoff(ctx context.Context, opts HandoffOptions) (*Handoff, error)

Handoff会向另一个特工交接

func (*HandoffManager) RegisterAgent

func (m *HandoffManager) RegisterAgent(agent HandoffAgent)

代理人登记代理人进行交割.

func (*HandoffManager) UnregisterAgent

func (m *HandoffManager) UnregisterAgent(agentID string)

未注册代理删除代理 。

type HandoffOptions

type HandoffOptions struct {
	FromAgentID string
	ToAgentID   string
	Task        Task
	Context     HandoffContext
	Timeout     time.Duration
	MaxRetries  int
	Wait        bool
}

交接选项配置交接。

type HandoffResult

type HandoffResult struct {
	Output   any    `json:"output"`
	Error    string `json:"error,omitempty"`
	Duration int64  `json:"duration_ms"`
}

HandoffResult包含完成交接的结果.

type HandoffStatus

type HandoffStatus string

交接状态代表交接状态.

const (
	StatusPending    HandoffStatus = "pending"
	StatusAccepted   HandoffStatus = "accepted"
	StatusRejected   HandoffStatus = "rejected"
	StatusInProgress HandoffStatus = "in_progress"
	StatusCompleted  HandoffStatus = "completed"
	StatusFailed     HandoffStatus = "failed"
)

type Message

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

信件代表对话信息 。

type Task

type Task struct {
	Type        string         `json:"type"`
	Description string         `json:"description"`
	Input       any            `json:"input"`
	Priority    int            `json:"priority"`
	Metadata    map[string]any `json:"metadata,omitempty"`
}

任务代表着正在移交的任务。

Jump to

Keyboard shortcuts

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