Documentation
¶
Overview ¶
Package openresponsescompat implements the generic remote OpenResponses backend mode for remote OpenResponses-capable providers and routers.
It provides strict secret-free configuration, factory construction, and a create mapping for both canonical authority forms pinned to the OpenResponses 2026-04-24 profile. Item-authority calls map directly; legacy message-authority calls (OpenAI Chat, OpenAI Responses, Anthropic, Gemini) are projected to ordered items through the explicit canonical legacy→ordered-items projector before request building. A schema-valid non-streaming JSON or streaming SSE request is built without forwarding proxy IDs, sessions, native refs, or arbitrary call extensions. Complete JSON response resources and incremental SSE streams are parsed through the production codec/state semantics into canonical lifecycle events; SSE reads are strictly pull-driven and bounded, and the first canonical event is peeked before commitment so pre-output transport/protocol failures stay retryable by core. Conflicting authority, provider replay dialects, source-specific opaque extensions, and unsupported content are rejected before any HTTP round trip.
The package reuses shared infrastructure (endpoint descriptors, env-based credential resolution, static model inventory, canonical capabilities and dialects, shared outbound HTTP client) and imports no provider SDK or external executable connector.
Index ¶
- Constants
- Variables
- func Build(instanceID string, n yaml.Node, upstream *http.Client) (execbackend.Backend, error)
- func LifecycleOpenResponsesCompatible(instanceID string, n yaml.Node, upstream *http.Client, ...) (pluginreg.BackendBuildResult, error)
- func NewBackend(spec BackendSpec) execbackend.Backend
- func OpenResponsesTransportCaps() lipapi.BackendTransportCaps
- type BackendSpec
- type CodecOptions
- type Config
- type DialectConfig
- type DialectRequirementConfig
- type ExtensionRequirementConfig
- type LimitError
- type NativeEvidence
- type RequestLimits
- type ResponseLimits
Constants ¶
const ( // ID is the stable built-in-compatible factory kind for the generic // remote OpenResponses backend (Requirement 9.1). ID = "custom-openresponses-compatible" // DefaultProfile is the pinned OpenResponses profile for this backend mode. DefaultProfile = "2026-04-24" // DefaultItemDialect and DefaultCompactionDialect name the pinned portable // profile dialects the generic mode satisfies unless explicitly overridden. DefaultItemDialect = "openresponses.2026-04-24" DefaultCompactionDialect = "openresponses.2026-04-24" )
const ( DefaultMaxRequestItems = 256 DefaultMaxRequestItemBytes = 1 << 20 DefaultMaxRequestContentParts = 256 DefaultMaxRequestTools = 128 DefaultMaxRequestExtensionBytes = 64 << 10 DefaultMaxResponseItems = 4096 DefaultMaxResponseEventBytes = 1 << 20 DefaultMaxResponseResourceBytes = 16 << 20 DefaultMaxResponseReasoningBytes = 1 << 20 DefaultMaxResponseTextBytes = 1 << 20 MaxAllowedRequestItems = 4096 MaxAllowedRequestItemBytes = 16 << 20 MaxAllowedRequestContentParts = 4096 MaxAllowedRequestTools = 2048 MaxAllowedRequestExtensionBytes = 1 << 20 MaxAllowedResponseItems = 65536 MaxAllowedResponseEventBytes = 16 << 20 MaxAllowedResponseResourceBytes = 64 << 20 MaxAllowedResponseReasoningBytes = 16 << 20 MaxAllowedResponseTextBytes = 16 << 20 )
Request/response limit defaults and maximum bounds. Values are independent per instance; limits reject zero, negative, and out-of-range configuration.
Variables ¶
var ( // ErrOperationUnsupported rejects operations the backend does not serve. ErrOperationUnsupported = errors.New("openresponsescompat: operation is not supported") // ErrUnrepresentable is the root for canonical semantics that cannot be // encoded to the pinned profile without silent semantic loss. ErrUnrepresentable = errors.New("openresponsescompat: request semantics not representable") // ErrLimitExceeded is the root for request/response limit exceedances. ErrLimitExceeded = errors.New("openresponsescompat: limit exceeded") // ErrMalformedResponse is the root for upstream responses that violate the // pinned profile status/content-type/body/resource contract. ErrMalformedResponse = errors.New("openresponsescompat: malformed upstream response") )
Stable error roots for the generic OpenResponses backend mapping. Errors returned through the Open seam carry the instance prefix and never echo request bodies, response bodies, or resolved credential values.
Functions ¶
func Build ¶
Build constructs one generic OpenResponses backend instance from strict compatible-mode YAML. Credentials are resolved from the environment lazily at request time; static inventory is loaded from config/file only. upstream is the shared outbound HTTP client; when nil, httpclient.Standard is used.
func LifecycleOpenResponsesCompatible ¶
func LifecycleOpenResponsesCompatible(instanceID string, n yaml.Node, upstream *http.Client, _ pluginreg.BackendFactoryDeps) (pluginreg.BackendBuildResult, error)
LifecycleOpenResponsesCompatible is the standardplugins lifecycle entrypoint for the generic OpenResponses built-in-compatible backend kind.
func NewBackend ¶
func NewBackend(spec BackendSpec) execbackend.Backend
NewBackend constructs the generic OpenResponses backend for one instance. The Open seam maps item-authoritative create calls to a context-aware non-streaming JSON request and parses the complete response resource into a canonical lifecycle stream.
func OpenResponsesTransportCaps ¶
func OpenResponsesTransportCaps() lipapi.BackendTransportCaps
OpenResponsesTransportCaps declares the generic mode's operation+transport surface: create over JSON and SSE, and compaction over non-streaming transport (the pinned profile's initial compaction transport).
Types ¶
type BackendSpec ¶
type BackendSpec struct {
ID string
APIKeyEnvVarRoot string
APIKey string
APIKeys []string
BaseURL string
HTTPClient *http.Client
RequestLimits RequestLimits
ResponseLimits ResponseLimits
Caps lipapi.BackendCaps
DialectSupport lipapi.DialectSupport
Inventory modelinventory.Provider
// Codec is the explicit codec customization/provenance seam for future
// provider connectors. The zero value resolves to the generic default via
// [NewBackend]; provider wrappers may pass explicit options to preserve
// instance/factory/profile provenance without provider-policy leakage.
Codec CodecOptions
}
BackendSpec carries the validated construction inputs for one instance.
type CodecOptions ¶
type CodecOptions struct {
// contains filtered or unexported fields
}
CodecOptions is the narrow, explicit, immutable codec customization seam for future provider connectors that reuse the shared OpenResponses wire codec (Requirement 9.12). It carries only bounded provenance identity and the pinned profile; provider-specific attribution, routing, billing, catalog, and proprietary controls are never representable here and stay in the connector (Requirement 4.11).
CodecOptions is immutable and safe for concurrent use: every field is validated at construction and read-only afterwards. It exposes no callbacks, no arbitrary option maps, and no provider-policy fields.
func DefaultCodecOptions ¶
func DefaultCodecOptions() CodecOptions
DefaultCodecOptions returns the generic-mode codec options: the pinned OpenResponses profile and the generic factory kind, with no provider label.
func NewCodecOptions ¶
func NewCodecOptions(profile, factoryKind, providerID string) (CodecOptions, error)
NewCodecOptions validates and returns the explicit codec options a future provider connector supplies. profile must be the pinned DefaultProfile (or empty to select it); factoryKind defaults to the generic ID; providerID is an optional bounded provenance label and must not carry provider policy, whitespace, control characters, or slashes.
func (CodecOptions) FactoryKind ¶
func (o CodecOptions) FactoryKind() string
FactoryKind returns the constructing factory kind (generic ID unless a future provider connector overrides it for provenance/diagnostics only).
func (CodecOptions) Profile ¶
func (o CodecOptions) Profile() string
Profile returns the pinned OpenResponses profile (always DefaultProfile for the generic codec; empty only for a zero-value CodecOptions).
func (CodecOptions) ProviderID ¶
func (o CodecOptions) ProviderID() string
ProviderID returns the bounded provider provenance label; empty means the generic remote mode. It is never forwarded on the wire.
type Config ¶
type Config struct {
BackendPrefix string
Profile string
BaseURL string
APIKeyEnvVarRoot string
Models config.CompatibleModeModelsConfig
Capabilities []lipapi.Capability
Dialects DialectConfig
RequestLimits RequestLimits
ResponseLimits ResponseLimits
}
Config is the strict, secret-free configuration surface for the generic OpenResponses backend. Successful decoding never retains literal credential values; credentials are resolved from the environment only.
type DialectConfig ¶
type DialectConfig struct {
Item []DialectRequirementConfig
Reasoning []DialectRequirementConfig
Compaction []DialectRequirementConfig
Extensions []ExtensionRequirementConfig
}
DialectConfig declares exact dialects and extension types satisfied by the configured remote endpoint.
type DialectRequirementConfig ¶
DialectRequirementConfig is one item/reasoning/compaction dialect declaration.
type ExtensionRequirementConfig ¶
ExtensionRequirementConfig is one bounded extension type declaration.
type LimitError ¶
LimitError carries the bounded identity of one exceeded configured limit.
func (*LimitError) Error ¶
func (e *LimitError) Error() string
func (*LimitError) Unwrap ¶
func (e *LimitError) Unwrap() error
type NativeEvidence ¶
type NativeEvidence struct {
ResponseID string
ItemIDs []string
ToolCallIDs []string
// ExtensionTypes preserves the bounded discriminators of valid
// vendor-prefixed output items/events accepted but not representable on
// the canonical stream.
ExtensionTypes []string
}
NativeEvidence captures bounded provider-native identity from a parsed response resource or stream. It is private attempt evidence: it is never forwarded to clients and never emitted on the canonical stream.