pluginlimits

package
v2.3.0-unstable.10 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: AGPL-3.0 Imports: 9 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 pluginlimits sets the largest gRPC message plugins and plugin hosts exchange, and recognises a plugin that refused a message for its size.

A gRPC server accepts 4 MiB per message unless told otherwise, and go-plugin's DefaultGRPCServer does not tell it. A request body over that size (a long context, a few base64 screenshots, one PDF) then failed in every post_auth plugin. The plugin SDKs serve with GRPCServer instead, and the hosts' brokered servers add ServerOptions, so both sides accept MaxMsgBytes. go-plugin's client side already allows math.MaxInt32.

A plugin built on an older SDK keeps the 4 MiB limit. Hosts wrap its refusal with AsTooLarge so the caller can answer 413 naming the plugin.

Index

Constants

View Source
const DefaultMaxMsgBytes = 64 << 20

DefaultMaxMsgBytes is 64 MiB, above the LLM vendors' request limits (Anthropic's is 32 MB).

View Source
const EnvMaxMsgBytes = "PLUGIN_GRPC_MAX_MSG_BYTES"

EnvMaxMsgBytes ("PLUGIN_GRPC_MAX_MSG_BYTES") overrides DefaultMaxMsgBytes, in bytes. The hosts pass it to plugin processes (see pkg/pluginenv), so one setting covers both sides.

View Source
const HostServiceMaxMsgBytes = 8 << 20

HostServiceMaxMsgBytes is the largest message a plugin may send the host's brokered service API (KV, events, edge payloads, management calls). Those calls carry no LLM bodies; the largest is a 5 MB Studio KV value. It is not tied to MaxMsgBytes, so raising the body limit does not let a plugin push larger messages into the host.

View Source
const LegacyMaxMsgBytes = 4 << 20

LegacyMaxMsgBytes is gRPC's default receive limit, which plugins built before AI Studio 2.3 still have.

Variables

View Source
var ErrRequestTooLarge = errors.New("request is larger than plugins accept")

ErrRequestTooLarge: a request is over MaxMsgBytes, so the host refuses it without calling the plugin (no plugin can be sent it).

Functions

func AsTooLarge

func AsTooLarge(err error, plugin, hook string, bytes int) error

AsTooLarge wraps err in a *TooLargeError when IsTooLarge(err), and returns it unchanged otherwise.

func CheckSize

func CheckSize(plugin, hook string, bytes int) error

CheckSize returns a *TooLargeError wrapping ErrRequestTooLarge when a message of bytes is over MaxMsgBytes, so the host can refuse it before marshalling it for a plugin that would refuse it anyway.

func ClientMessage

func ClientMessage(err error) string

ClientMessage is what a client is told about a request refused as too large for a plugin. It names no plugin: which plugins an LLM runs is the operator's configuration. The host logs the full error.

func GRPCServer

func GRPCServer(opts []grpc.ServerOption) *grpc.Server

GRPCServer is a drop-in for go-plugin's DefaultGRPCServer (the ServeConfig GRPCServer field) that adds ServerOptions.

func HostServiceServerOptions

func HostServiceServerOptions() []grpc.ServerOption

HostServiceServerOptions returns the receive limit for a host's brokered service-API server.

func IsRequestTooLarge

func IsRequestTooLarge(err error) bool

IsRequestTooLarge reports whether err is a request refused for its size, by a plugin or by the host's limit.

func IsTooLarge

func IsTooLarge(err error) bool

IsTooLarge reports whether err is gRPC refusing a message for its size, on either end: "received message larger than max" or "trying to send message larger than max". A plugin's own ResourceExhausted (a quota, say) is not.

func MaxMsgBytes

func MaxMsgBytes() int

MaxMsgBytes returns EnvMaxMsgBytes when it holds a positive whole number, capped at math.MaxInt32 (gRPC's own ceiling), and DefaultMaxMsgBytes otherwise.

func ServerOptions

func ServerOptions() []grpc.ServerOption

ServerOptions returns the receive and send limits for a plugin's gRPC server, which the host sends request and response bodies.

Types

type TooLargeError

type TooLargeError struct {
	Plugin string // plugin name
	Hook   string // hook or RPC, e.g. "post_auth"
	Bytes  int    // size of the message the host sent
	Err    error
}

TooLargeError is a plugin call that failed, or was not made, because the message was over the plugin's gRPC limit (Err is ErrRequestTooLarge when the host's own limit refused it).

func AsTooLargeError

func AsTooLargeError(err error) (*TooLargeError, bool)

AsTooLargeError returns the *TooLargeError in err's chain, if any.

func (*TooLargeError) Error

func (e *TooLargeError) Error() string

func (*TooLargeError) Unwrap

func (e *TooLargeError) Unwrap() error

Jump to

Keyboard shortcuts

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