Documentation
¶
Overview ¶
Package anthropicmessages provides shared Anthropic Messages protocol execution.
Index ¶
- Variables
- func ModelCapabilities(model string) lipapi.BackendCaps
- func NewBackend(cfg Config) execbackend.Backend
- func ParamsForCall(call *lipapi.Call, cand routing.AttemptCandidate) (anthropic.MessageNewParams, error)
- func ReplaySupport() lipapi.ReasoningReplaySupport
- type CacheController
- func (c *CacheController) IssueTarget(target CacheTarget, observedAt time.Time) (promptcache.Observation, error)
- func (c *CacheController) Release(_ context.Context, req promptcache.ReleaseRequest) error
- func (c *CacheController) Renew(ctx context.Context, req promptcache.RenewRequest) (promptcache.RenewResponse, error)
- func (c *CacheController) TargetCount() int
- type CacheControllerConfig
- type CacheObservation
- type CacheObservationHook
- type CacheTarget
- type Config
- type RenewalCacheControl
- type RenewalMessage
- type RenewalSnapshot
- type RenewalSystemBlock
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoCacheEvidence = errors.New("anthropic: cache residency is not proven") ErrTargetNotFound = errors.New("anthropic: cache target not found") )
Functions ¶
func ModelCapabilities ¶
func ModelCapabilities(model string) lipapi.BackendCaps
ModelCapabilities returns negotiated backend caps for a resolved Anthropic model id. Rules are intentionally small; expand as catalog data grows.
func NewBackend ¶
func NewBackend(cfg Config) execbackend.Backend
func ParamsForCall ¶
func ParamsForCall(call *lipapi.Call, cand routing.AttemptCandidate) (anthropic.MessageNewParams, error)
ParamsForCall builds an Anthropic message create payload from a canonical call using the default Anthropic behavior (no role normalization, no model normalization). It is retained for callers and tests that exercise the shared protocol directly; the runtime path uses paramsForCall.
func ReplaySupport ¶
func ReplaySupport() lipapi.ReasoningReplaySupport
ReplaySupport is the static historical-reasoning dialect profile for Anthropic Messages.
Types ¶
type CacheController ¶
type CacheController struct {
// contains filtered or unexported fields
}
func NewCacheController ¶
func NewCacheController(cfg CacheControllerConfig) (*CacheController, error)
func (*CacheController) IssueTarget ¶
func (c *CacheController) IssueTarget(target CacheTarget, observedAt time.Time) (promptcache.Observation, error)
func (*CacheController) Release ¶
func (c *CacheController) Release(_ context.Context, req promptcache.ReleaseRequest) error
func (*CacheController) Renew ¶
func (c *CacheController) Renew(ctx context.Context, req promptcache.RenewRequest) (promptcache.RenewResponse, error)
func (*CacheController) TargetCount ¶
func (c *CacheController) TargetCount() int
type CacheControllerConfig ¶
type CacheObservation ¶
type CacheObservation struct {
Lineage promptcache.ObservationLineage
Model string
TTL string
Renewal RenewalSnapshot
Evidence promptcache.CacheEvidence
ObservedAt time.Time
CredentialID string
}
CacheObservation is the provider-neutral stream-side data handed to the owning plugin's observation hook on a committed successful turn. Renewal is the exact cacheable prefix (including the cache breakpoint) that created/read the provider cache entry, so the renewal request can reproduce it byte-for-byte.
type CacheObservationHook ¶
type CacheObservationHook func(context.Context, CacheObservation) (promptcache.Observation, error)
CacheObservationHook, when non-nil, issues a renewable target from committed foreground cache evidence. It is supplied by the owning plugin only when automatic enrollment is enabled; nil keeps observation emission off.
type CacheTarget ¶
type CacheTarget struct {
ALegID string
BLegID string
BackendInstanceID string
TargetID promptcache.TargetID
GenerationID promptcache.GenerationID
Model string
Renewal RenewalSnapshot
AccountID string
WorkspaceID string
TTL string
Evidence promptcache.CacheEvidence
}
type Config ¶
type Config struct {
BackendID string
BaseURL string
APIKey string
APIKeys []string
Credentials []credpool.Credential
HTTPClient *http.Client
SDKMaxRetries *int
RateLimitFallback time.Duration
ModelInventory modelinventory.Provider
ProviderCounter accountingapp.ProviderCounter
NormalizeRoles bool
NormalizeModel func(string) string
ThinkingFromEffort bool
OmitToolChoice bool
// CompatibleModeAuth enables optional credentials for built-in compatible
// modes: empty resolved keys omit x-api-key. Native Anthropic must leave false.
CompatibleModeAuth bool
CacheEnrollment string
CacheTTL string
// CacheObservation, when non-nil, issues a renewable target from committed
// foreground cache evidence on successful terminals. It is supplied by the
// owning plugin only for automatic enrollment; nil keeps emission off.
CacheObservation CacheObservationHook
}
type RenewalCacheControl ¶
type RenewalMessage ¶
type RenewalSnapshot ¶
type RenewalSnapshot struct {
Model string
System []RenewalSystemBlock
Messages []RenewalMessage
RawRequest json.RawMessage `json:"-"`
}
RenewalSnapshot is the minimal request shape used by zero-output residency maintenance. RawRequest, when non-empty, is the exact wire body for the renewal, sanitized only for controls that cannot be used with max_tokens=0. Compatible tools and tool-choice settings remain intact so the provider sees the same cache-affecting request shape. RawRequest takes precedence over the typed System/Messages fields and guarantees byte-for-byte prefix reproduction.
type RenewalSystemBlock ¶
type RenewalSystemBlock struct {
Type string `json:"type,omitempty"`
Text string `json:"text,omitempty"`
CacheControl *RenewalCacheControl `json:"cache_control,omitempty"`
}