gateway

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package gateway is an optional runtime.Runtime decorator (backlog AO-042) that puts spend caps, tracing, and failover in front of any underlying runtime — the role agentgateway/plano play in front of providers. Wire one gateway per flow to enforce a per-flow budget; the Tracer hook is where OpenTelemetry plugs in so every model call is traced.

Index

Constants

This section is empty.

Variables

View Source
var ErrBudgetExceeded = errors.New("gateway: per-flow spend cap exceeded")

ErrBudgetExceeded is returned when a dispatch would exceed the spend cap.

Functions

This section is empty.

Types

type Gateway

type Gateway struct {
	// contains filtered or unexported fields
}

Gateway wraps an underlying runtime.

func New

func New(under runtime.Runtime, opts Options) *Gateway

New builds a gateway over under.

func (*Gateway) Dispatch

func (g *Gateway) Dispatch(ctx context.Context, spec runtime.RunSpec) (runtime.Run, error)

Dispatch enforces the budget, traces the call, delegates, and fails over.

func (*Gateway) Name

func (g *Gateway) Name() string

Name implements runtime.Runtime.

func (*Gateway) Spent

func (g *Gateway) Spent() float64

Spent returns the total charged so far.

type Options

type Options struct {
	Limit       float64            // spend cap; 0 = unlimited
	DefaultCost float64            // cost charged per dispatch when no per-agent cost
	Costs       map[string]float64 // per-agent cost overrides
	Tracer      Tracer             // call tracer (OTel adapter, etc.)
	Failover    map[string]string  // agent -> fallback agent on dispatch error
}

Options configures a gateway.

type Tracer

type Tracer interface {
	Dispatch(agent, runID string, cost float64)
}

Tracer observes every admitted model call (implement with OTel in production).

Jump to

Keyboard shortcuts

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