agents

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 38 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultChildStatusTimeout    = 20 * time.Minute
	DefaultWaitingForUserTimeout = 5 * time.Minute
)
View Source
const DefaultChildAgentTimeout = 23 * time.Minute

DefaultChildAgentTimeout is the maximum duration a child agent run is allowed before its context is cancelled. This prevents hung tool calls inside the child from blocking the parent agent forever.

View Source
const Name = "llm/agents"

Variables

This section is empty.

Functions

This section is empty.

Types

type CancelInput added in v0.1.7

type CancelInput struct {
	ConversationID string `json:"conversationId"`
}

type CancelOutput added in v0.1.7

type CancelOutput struct {
	Status string `json:"status,omitempty"`
}

type DelegationInfo added in v0.1.8

type DelegationInfo struct {
	Enabled           bool `json:"enabled,omitempty"`
	MaxSameAgentDepth int  `json:"maxSameAgentDepth,omitempty"`
}

type ListItem

type ListItem struct {
	ID               string                 `json:"id"`
	Name             string                 `json:"name,omitempty"`
	Description      string                 `json:"description,omitempty"`
	Summary          string                 `json:"summary,omitempty"`
	Internal         bool                   `json:"internal,omitempty"`
	Tags             []string               `json:"tags,omitempty"`
	Priority         int                    `json:"priority,omitempty"`
	Capabilities     map[string]interface{} `json:"capabilities,omitempty"`
	Source           string                 `json:"source,omitempty"` // internal | external
	Responsibilities []string               `json:"responsibilities,omitempty"`
	InScope          []string               `json:"inScope,omitempty"`
	OutOfScope       []string               `json:"outOfScope,omitempty"`
}

ListItem is a directory entry describing an agent option for selection.

type ListOutput

type ListOutput struct {
	Items      []ListItem `json:"items"`
	ReuseNote  string     `json:"reuseNote,omitempty"`
	RunUsage   string     `json:"runUsage,omitempty"`
	NextAction string     `json:"nextAction,omitempty"`
}

ListOutput defines the response payload for agents:list.

type MeOutput

type MeOutput struct {
	ConversationID string `json:"conversationId,omitempty"`
	AgentName      string `json:"agentName,omitempty"`
	Model          string `json:"model,omitempty"`
}

MeOutput provides minimal execution context details.

type Option

type Option func(*Service)

New creates a Service bound to the internal agent runtime.

func WithAllowedIDs

func WithAllowedIDs(ids map[string]string) Option

WithAllowedIDs configures the set of allowed agent ids (directory view).

func WithCancelRegistry added in v0.1.7

func WithCancelRegistry(reg cancels.Registry) Option

func WithConversationClient

func WithConversationClient(c apiconv.Client) Option

WithConversationClient injects the conversation client and initializes linking/status helpers.

func WithDataService added in v0.1.8

func WithDataService(d data.Service) Option

func WithDirectoryProvider

func WithDirectoryProvider(f func() []ListItem) Option

func WithExternalRunner

func WithExternalRunner(run func(ctx context.Context, agentID, objective string, payload map[string]interface{}) (answer, status, taskID, contextID string, streamSupported bool, warnings []string, err error)) Option

WithExternalRunner configures an external execution path resolver used when the agentId refers to an external A2A entry.

func WithMCPManager added in v0.1.7

func WithMCPManager(mgr promptdef.MCPManager) Option

WithMCPManager injects an MCP manager so that MCP-sourced prompt profiles are rendered via the MCP server at delegation time.

func WithModelFinder added in v0.1.7

func WithModelFinder(f llm.Finder) Option

WithModelFinder injects a model finder used by the expansion sidecar to call a lightweight LLM that refines generic profile messages into task-specific ones.

func WithPromptRepo added in v0.1.7

func WithPromptRepo(repo *promptrepo.Repository) Option

WithPromptRepo injects a prompt-profile repository so that RunInput.PromptProfileId is resolved before the child turn begins.

func WithStreamPublisher

func WithStreamPublisher(p streaming.Publisher) Option

WithStreamPublisher wires a streaming publisher to the linking service so linked_conversation_attached events reach the SSE bus.

func WithStrict

func WithStrict(v bool) Option

WithStrict enables strict directory routing: only ids present in the directory may be run.

func WithToolRegistry added in v0.1.8

func WithToolRegistry(reg toolreg.Registry) Option

type RunInput

type RunInput struct {
	AgentID       string                 `json:"agentId"`
	Agent         *agentmdl.Agent        `json:"agent,omitempty" internal:"true"`
	Objective     string                 `json:"objective"`
	Context       map[string]interface{} `json:"context,omitempty"`
	Runtime       *agruntime.Context     `json:"runtime,omitempty"`
	ExecutionMode string                 `json:"executionMode,omitempty"`
	Async         *bool                  `json:"async,omitempty" internal:"true"`
	// ConversationID optionally overrides the conversation identifier when
	// not already provided by context.
	ConversationID string `json:"conversationId,omitempty"`
	// Streaming is an optional hint. Runtime policy/capabilities decide final behavior.
	Streaming *bool `json:"streaming,omitempty"`
	// ModelPreferences optionally hints how to select a model for this
	// run when the agent supports model preferences. When omitted, the
	// agent's configured model selection is used.
	ModelPreferences *llm.ModelPreferences `json:"modelPreferences,omitempty"`
	// ReasoningEffort optionally overrides agent-level reasoning effort
	// (e.g., low|medium|high) for this run when supported by the backend.
	ReasoningEffort *string `json:"reasoningEffort,omitempty"`
	// PromptProfileId optionally selects a scenario profile whose instructions,
	// tool bundles, and output template are applied to the child conversation.
	// When absent, behaviour is identical to today.
	PromptProfileId string `json:"promptProfileId,omitempty"`
	// ToolBundles optionally appends tool bundle ids on top of whatever the
	// profile floor already provides.  Safe to leave empty.
	ToolBundles []string `json:"toolBundles,omitempty"`
	// TemplateId optionally overrides the output template selected by the
	// profile (highest-priority tier in the three-tier resolution chain).
	TemplateId string `json:"templateId,omitempty"`

	// WorkspaceIntake optionally pre-provides the workspace-intake result for
	// this run. When present and validated, the runtime SKIPS the workspace-
	// intake LLM call entirely and uses this value as the turn's intake Context
	// (annotated as Source="caller-provided"). Validation rules are identical
	// to workspace intake's own output — SelectedAgentID must be in the
	// authorized agent set, and AppendToolBundles must be on the workspace
	// allowlist. When any
	// validation fails, the override is dropped (with a diagnostic) and
	// workspace intake runs normally.
	//
	// Use cases: programmatic clients with their own classifier, UI that
	// pre-populates routing fields, cached prior turns, or cross-conversation
	// seeds. See intake-impt.md §9 skip-rule (c).
	WorkspaceIntake *intakesvc.Context `json:"workspaceIntake,omitempty"`
}

RunInput defines the request payload for agents:run. Note: Conversation/turn/user identifiers are derived from context; they are intentionally not part of the input contract.

type RunOutput

type RunOutput struct {
	Answer          string   `json:"answer"`
	Status          string   `json:"status,omitempty"`
	ResultMode      string   `json:"resultMode,omitempty"`
	Error           string   `json:"error,omitempty"`
	ConversationID  string   `json:"conversationId,omitempty"`
	MessageID       string   `json:"messageId,omitempty"`
	TaskID          string   `json:"taskId,omitempty"`
	ContextID       string   `json:"contextId,omitempty"`
	StreamSupported bool     `json:"streamSupported,omitempty"`
	Warnings        []string `json:"warnings,omitempty"`
}

RunOutput defines the response payload for agents:run. Depending on routing (internal vs external), different handles will be set.

type Service

type Service struct {

	// ChildTimeout overrides DefaultChildAgentTimeout for internal runs.
	// Zero means use DefaultChildAgentTimeout.
	ChildTimeout time.Duration
	// contains filtered or unexported fields
}

Service exposes agent directory and execution as tool methods.

func New

func New(agent *agentsvc.Service, opts ...Option) *Service

func (*Service) AsyncConfig added in v0.1.7

func (s *Service) AsyncConfig(toolName string) *asynccfg.Config

func (*Service) AsyncConfigs added in v0.1.7

func (s *Service) AsyncConfigs() []*asynccfg.Config

func (*Service) CacheableMethods added in v0.1.7

func (s *Service) CacheableMethods() map[string]bool

CacheableMethods declares which methods produce cacheable outputs.

func (*Service) Method

func (s *Service) Method(name string) (svc.Executable, error)

Method resolves a method by name.

func (*Service) Methods

func (s *Service) Methods() svc.Signatures

Methods returns available methods.

func (*Service) Name

func (s *Service) Name() string

Name returns the service name.

func (*Service) ToolTimeout

func (s *Service) ToolTimeout() time.Duration

ToolTimeout suggests a larger timeout for llm/agents service tools which run full agent turns.

type StartInput added in v0.1.7

type StartInput = RunInput

StartInput launches an agent asynchronously and returns a conversation handle. It shares the same public fields as RunInput, but the service forces async=true.

type StartOutput added in v0.1.7

type StartOutput struct {
	ConversationID    string   `json:"conversationId,omitempty"`
	Status            string   `json:"status,omitempty"`
	ResultMode        string   `json:"resultMode,omitempty"`
	Message           string   `json:"message,omitempty"`
	AssistantResponse string   `json:"assistantResponse,omitempty"`
	TaskID            string   `json:"taskId,omitempty"`
	ContextID         string   `json:"contextId,omitempty"`
	StreamSupported   bool     `json:"streamSupported,omitempty"`
	Warnings          []string `json:"warnings,omitempty"`
}

type StatusInput

type StatusInput struct {
	ConversationID       string `json:"conversationId,omitempty"`
	ParentConversationID string `json:"parentConversationId,omitempty"`
	ParentTurnID         string `json:"parentTurnId,omitempty"`
}

StatusInput queries the status of one child conversation or all children for a parent conversation / turn pair.

type StatusItem

type StatusItem struct {
	ConversationID            string `json:"conversationId,omitempty"`
	ParentConversationID      string `json:"parentConversationId,omitempty"`
	ParentTurnID              string `json:"parentTurnId,omitempty"`
	AgentID                   string `json:"agentId,omitempty"`
	Status                    string `json:"status,omitempty"`
	RawStatus                 string `json:"rawStatus,omitempty"`
	Terminal                  bool   `json:"terminal,omitempty"`
	Error                     string `json:"error,omitempty"`
	CreatedAt                 string `json:"createdAt,omitempty"`
	UpdatedAt                 string `json:"updatedAt,omitempty"`
	AssistantNarrationPreview string `json:"assistantNarrationPreview,omitempty"`
	AssistantOutputPreview    string `json:"assistantOutputPreview,omitempty"`
	HasFinalResponse          bool   `json:"hasFinalResponse,omitempty"`
	LastMessageAt             string `json:"lastMessageAt,omitempty"`
}

type StatusOutput

type StatusOutput struct {
	ConversationID string `json:"conversationId,omitempty"`
	Status         string `json:"status,omitempty"`
	RawStatus      string `json:"rawStatus,omitempty"`
	Terminal       bool   `json:"terminal,omitempty"`
	Error          string `json:"error,omitempty"`
	Message        string `json:"message,omitempty"`
	MessageKind    string `json:"messageKind,omitempty"`
}

type ToolDetailsInput added in v0.1.8

type ToolDetailsInput struct {
	Names []string `json:"names,omitempty"`
}

type ToolDetailsItem added in v0.1.8

type ToolDetailsItem struct {
	Name         string                 `json:"name"`
	Description  string                 `json:"description,omitempty"`
	Parameters   map[string]interface{} `json:"parameters,omitempty"`
	Required     []string               `json:"required,omitempty"`
	OutputSchema map[string]interface{} `json:"outputSchema,omitempty"`
	Cacheable    bool                   `json:"cacheable,omitempty"`
}

type ToolDetailsOutput added in v0.1.8

type ToolDetailsOutput struct {
	Items []ToolDetailsItem `json:"items,omitempty"`
}

type TopologyInput added in v0.1.8

type TopologyInput struct {
	AgentIDs []string `json:"agentIds,omitempty"`
}

type TopologyItem added in v0.1.8

type TopologyItem struct {
	ID               string         `json:"id"`
	Name             string         `json:"name,omitempty"`
	Description      string         `json:"description,omitempty"`
	Internal         bool           `json:"internal,omitempty"`
	Skills           []string       `json:"skills,omitempty"`
	ToolBundles      []string       `json:"toolBundles,omitempty"`
	ToolNames        []string       `json:"toolNames,omitempty"`
	TemplateBundles  []string       `json:"templateBundles,omitempty"`
	PromptProfiles   []string       `json:"promptProfiles,omitempty"`
	PlannerEnabled   bool           `json:"plannerEnabled,omitempty"`
	PlannerAgentID   string         `json:"plannerAgentId,omitempty"`
	Responsibilities []string       `json:"responsibilities,omitempty"`
	InScope          []string       `json:"inScope,omitempty"`
	OutOfScope       []string       `json:"outOfScope,omitempty"`
	Delegation       DelegationInfo `json:"delegation,omitempty"`
}

type TopologyOutput added in v0.1.8

type TopologyOutput struct {
	Items []TopologyItem `json:"items,omitempty"`
}

Jump to

Keyboard shortcuts

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