handoff

package
v1.11.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2026 License: MIT Imports: 8 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"`
	ToolName        string         `json:"tool_name,omitempty"`
	ToolDescription string         `json:"tool_description,omitempty"`
	TransferMessage string         `json:"transfer_message,omitempty"`
	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       []types.Message `json:"messages,omitempty"`
	Variables      map[string]any  `json:"variables,omitempty"`
	ParentHandoff  string          `json:"parent_handoff,omitempty"`
}

HandoffContext为交接提供了上下文.

type HandoffEnabledFunc added in v1.10.0

type HandoffEnabledFunc func(ctx context.Context, opts HandoffOptions) (bool, error)

type HandoffHistoryMapper added in v1.10.0

type HandoffHistoryMapper func(history []types.Message) []types.Message

type HandoffHook added in v1.10.0

type HandoffHook func(ctx context.Context, handoff *Handoff) error

type HandoffInputData added in v1.10.0

type HandoffInputData struct {
	InputHistory  []types.Message `json:"input_history,omitempty"`
	PreHandoff    []types.Message `json:"pre_handoff,omitempty"`
	NewMessages   []types.Message `json:"new_messages,omitempty"`
	InputMessages []types.Message `json:"input_messages,omitempty"`
	Context       HandoffContext  `json:"context"`
}

HandoffInputData 对齐官方 Agents SDK 的 handoff input filter 语义, 用于在交接发生时重写下一位 agent 看到的历史和新增消息。

func (HandoffInputData) Clone added in v1.10.0

Clone returns a shallow-cloned HandoffInputData with deep-copied slices/maps.

type HandoffInputFilter added in v1.10.0

type HandoffInputFilter func(ctx context.Context, data HandoffInputData) (HandoffInputData, error)

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
	OnHandoff               HandoffHook
	InputFilter             HandoffInputFilter
	Enabled                 *bool
	EnableFunc              HandoffEnabledFunc
	ToolNameOverride        string
	ToolDescriptionOverride string
	NestHistory             *bool
	HistoryMapper           HandoffHistoryMapper
}

交接选项配置交接。

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 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