routing

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package routing provides LLM-driven capability dispatch for ArkTeam routed mode. The router makes a single, lightweight LLM call that treats indexed agent capabilities as a "tool list" and selects the best match for the incoming task — analogous to how an LLM picks a function when function-calling is enabled.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LLMFn

type LLMFn func(ctx context.Context, model, prompt string) (string, error)

LLMFn is the function signature for a single-turn LLM call. It matches the SemanticValidateFn / RouterFn signature in ArkRunReconciler so the same builder (pkg/validation.BuildSemanticValidateFn) can be reused.

type Result

type Result struct {
	// AgentName is the resolved ArkAgent name. Empty when no capability matched and no fallback.
	AgentName string
	// Capability is the selected capability ID. May be empty when fallback was used.
	Capability string
	// Reason is the router LLM's one-sentence explanation.
	Reason string
}

Result holds the outcome of a single routing decision.

func Route

func Route(
	ctx context.Context,
	reg *registry.Registry,
	routingCfg *arkonisv1alpha1.ArkTeamRoutingSpec,
	input map[string]string,
	llmFn LLMFn,
) (Result, error)

Route selects the best agent for the given task input by making a single LLM call using the capability index from the provided registry.

Error conditions:

  • routingCfg is nil or Model is empty → immediate error
  • registry has no indexed capabilities and no fallback is configured → error
  • LLM call fails → error
  • LLM response cannot be parsed → error
  • Capability matched but no agent found and no fallback → error

When a fallback agent is configured (routingCfg.Fallback), it is used instead of returning an error whenever the router cannot resolve a concrete agent.

Jump to

Keyboard shortcuts

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