gateway

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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