router

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package router assembles the top-level agent for a workload: a Chat-mode coordinator with the workload's specialists as SubAgents.

This uses ADK v2's canonical dispatch pattern (see google.golang.org/adk/v2/examples/multiagent/task_sub_agent):

  • Chat-mode LlmAgent = the coordinator (top-level driver).
  • Task-mode LlmAgents in SubAgents = per-failure-mode specialists. ADK auto-installs one `task` tool per Task sub-agent; the coordinator's LLM invokes a specialist by calling that tool.
  • SingleTurn-mode LlmAgents in SubAgents = cheap classifiers. ADK auto-installs one `single_turn` tool per SingleTurn sub-agent; the coordinator's LLM invokes the classifier by calling that tool.

This is "LLM-as-router" delivered via the SubAgents dispatch pattern rather than an explicit workflow.Workflow graph. runner.Runner requires the root agent to be a Chat-mode LlmAgent (see runner.go isLlmAgent + Mode check), so a bare Workflow cannot be a root agent — a graph shape must be composed underneath a coordinator or driven out-of-runner.

Explicit workflow.Workflow shapes (fan-out-fan-in, adversarial verifier, autonomous loop, etc.) remain available for use cases the SubAgents pattern doesn't cover; those land as a follow-on when the first shape needs them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(cfg Config) (adkagent.Agent, error)

Build assembles the coordinator + SubAgents shape and returns the root agent that a runner can drive. It does not construct a runner — that's the caller's responsibility (letting the caller choose the session service, artifact store, etc.).

Types

type Config

type Config struct {
	// Bundle is the workload definition. Used for the coordinator's
	// name, description, and roster ordering.
	Bundle workload.Bundle

	// Specialists is the roster of specialist agents, indexed by
	// spec name. Every name in Bundle.Specialists must be present.
	Specialists map[string]adkagent.Agent

	// Model is the model the coordinator itself uses. Specialists may
	// use different models (their construction already bound them).
	Model model.LLM

	// Instruction, when non-empty, replaces the default coordinator
	// system prompt.
	Instruction string
}

Config describes how to build a coordinator for a given workload.

Jump to

Keyboard shortcuts

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