orchestration

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildAgentTree

func BuildAgentTree(cfg Config) (adk_agent.Agent, error)

BuildAgentTree creates a hierarchical agent tree with an orchestrator root and specialized sub-agents. Sub-agents are created data-driven from specs. When cfg.Specs is nil, the built-in agentSpecs are used (backward compatible). Agents with no tools are skipped unless AlwaysInclude is set (e.g. Planner).

Types

type AgentSpec

type AgentSpec struct {
	// Name is the ADK agent name used for transfer_to_agent delegation.
	Name string
	// Description is a one-line summary for the orchestrator's routing table.
	Description string
	// Instruction is the full system prompt with I/O spec and constraints.
	Instruction string
	// Prefixes are tool name prefixes this agent handles.
	Prefixes []string
	// Keywords are routing hints for the orchestrator's decision protocol.
	Keywords []string
	// Capabilities are semantic ability descriptions for description-based routing.
	// These supplement tool-derived capabilities with explicit domain labels.
	Capabilities []string
	// Accepts describes the expected input format.
	Accepts string
	// Returns describes the expected output format.
	Returns string
	// CannotDo lists things this agent must not attempt (negative constraints).
	CannotDo []string
	// ExampleRequests are concrete routing examples for the orchestrator.
	ExampleRequests []string
	// Disambiguation explains when NOT to pick this agent (overlap resolution).
	Disambiguation string
	// AlwaysInclude creates this agent even with zero tools (e.g. Planner).
	AlwaysInclude bool
	// SessionIsolation indicates this agent should use a child session
	// instead of the parent session.
	SessionIsolation bool
}

AgentSpec defines a sub-agent's identity, routing metadata, and prompt structure.

func BuiltinSpecs added in v0.4.0

func BuiltinSpecs() []AgentSpec

BuiltinSpecs returns a copy of the default built-in agent specifications.

func DefaultAgentSpecs added in v0.7.0

func DefaultAgentSpecs() []AgentSpec

DefaultAgentSpecs returns a shallow copy of the built-in agent specs.

type Config

type Config struct {
	// Tools is the full set of available tools.
	Tools []*agent.Tool
	// Model is the primary LLM model adapter.
	Model model.LLM
	// SystemPrompt is the base system instruction.
	SystemPrompt string
	// AdaptTool converts an internal tool to an ADK tool.
	// Callers should pass adk.AdaptTool.
	AdaptTool ToolAdapter
	// RemoteAgents are external A2A agents to include as sub-agents.
	RemoteAgents []adk_agent.Agent
	// MaxDelegationRounds limits the number of orchestrator→sub-agent
	// delegation rounds per user turn. Zero means use default (10).
	MaxDelegationRounds int
	// SubAgentPrompt builds the final system prompt for each sub-agent.
	// When nil, the original spec.Instruction is used unchanged.
	SubAgentPrompt SubAgentPromptFunc
	// UniversalTools are tools given directly to the orchestrator
	// (e.g. builtin_list/builtin_invoke dispatchers).
	UniversalTools []*agent.Tool
	// Specs overrides the default built-in agent specifications.
	// When nil, the built-in agentSpecs are used (backward compatible).
	Specs []AgentSpec
	// DynamicAgents provides P2P agents discovered at runtime.
	// When set, discovered agents are added to the routing table.
	DynamicAgents agentpool.DynamicAgentProvider
}

Config holds orchestration configuration.

type DynamicToolSet added in v0.4.0

type DynamicToolSet map[string][]*agent.Tool

DynamicToolSet is a map-based tool set keyed by agent name. Unlike RoleToolSet, it supports arbitrary agent names from dynamic specs.

func PartitionToolsDynamic added in v0.4.0

func PartitionToolsDynamic(tools []*agent.Tool, specs []AgentSpec) DynamicToolSet

PartitionToolsDynamic splits tools into agent-specific sets based on the given specs. Each tool is assigned to the first spec whose prefixes match. Tools with a "builtin_" prefix are skipped (orchestrator-only). Tools with a "tool_output_" prefix are distributed to all non-empty, tool-bearing agent sets (excluding AlwaysInclude-only agents with no other tools). Unmatched tools are stored under the empty-string key.

func (DynamicToolSet) Unmatched added in v0.4.0

func (ds DynamicToolSet) Unmatched() []*agent.Tool

Unmatched returns tools that matched no agent spec.

type RoleToolSet

type RoleToolSet struct {
	Operator   []*agent.Tool
	Navigator  []*agent.Tool
	Vault      []*agent.Tool
	Librarian  []*agent.Tool
	Automator  []*agent.Tool
	Planner    []*agent.Tool // Always empty — LLM-only reasoning.
	Chronicler []*agent.Tool
	Ontologist []*agent.Tool
	Unmatched  []*agent.Tool // Tools matching no prefix — tracked separately.
}

RoleToolSet defines which tools belong to each sub-agent role.

func PartitionTools

func PartitionTools(tools []*agent.Tool) RoleToolSet

PartitionTools splits tools into role-specific sets based on tool name prefixes. Matching order: Librarian → Chronicler → Automator → Navigator → Vault → Operator → Unmatched. Unlike the previous implementation, unmatched tools are NOT assigned to any agent. Tools with a "tool_output_" prefix are distributed to all non-empty, tool-bearing agent sets (universal tools). Planner is excluded since it has no tools.

type SubAgentPromptFunc

type SubAgentPromptFunc func(agentName, defaultInstruction string) string

SubAgentPromptFunc builds the final instruction for a sub-agent. agentName is the spec name (e.g. "operator"), defaultInstruction is the hard-coded spec.Instruction. The function returns the assembled system prompt that should replace spec.Instruction. When nil, the original spec.Instruction is used (backward compatible).

type ToolAdapter

type ToolAdapter func(t *agent.Tool, agentName string) (adk_tool.Tool, error)

ToolAdapter converts an internal agent.Tool to an ADK tool.Tool. The agentName parameter identifies the sub-agent that will own the tool, allowing downstream hooks and middleware to track which agent invoked it. This is injected to avoid a direct dependency on the adk package, which carries transitive imports that may cause import cycles.

Jump to

Keyboard shortcuts

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