JuliusBrussee/caveman · error
cacheengine: request exceeds configured byte limit
Error message
cacheengine: request exceeds configured byte limit
What it means
Thrown by the native engine entry point when len(request.Body) exceeds the configured e.maxRequestBytes. The check is a hard trust-boundary guard before any parsing or caching logic runs (and after nil-context/configErr checks), so oversized bodies are rejected without being read or copied.
Source
Thrown at cacheengine/native.go:32
)
// Optimize applies provider-native cache metadata or returns copied original
// bytes on every unsupported or unsafe path. It makes no network call.
func (e *Engine) Optimize(ctx context.Context, request NativeRequest) (NativeResult, error) {
if e == nil || e.guard == nil || e.prefixSafety == nil || e.resolveProfile == nil {
return NativeResult{}, errors.New("cacheengine: nil engine")
}
if e.configErr != nil {
return NativeResult{}, e.configErr
}
if ctx == nil {
return NativeResult{}, errors.New("cacheengine: nil context")
}
if err := ctx.Err(); err != nil {
return NativeResult{}, err
}
if len(request.Body) > e.maxRequestBytes {
return NativeResult{}, errors.New("cacheengine: request exceeds configured byte limit")
}
original := append([]byte(nil), request.Body...)
unsupported := Profile{ID: "unsupported", Mode: ModeUnsupported, Attribution: AttributionNone}
result := NativeResult{
Body: original,
Decision: DecisionPassThrough,
Reason: ReasonUnsupported,
Profile: unsupported,
Plan: Plan{
Decision: DecisionPassThrough, Reason: ReasonUnsupported,
ProfileID: unsupported.ID, Mode: unsupported.Mode, Attribution: unsupported.Attribution,
EconomicsBasis: "unavailable", KeyShardCount: 1,
},
ClaimBasis: "none",
VerifiedSavingsUSD: 0,
}
if !validNativeIdentity(request) {
result.Reason = ReasonMalformedRequestView on GitHub (pinned to 27d5a3981a)
Solutions
- Raise the engine's maxRequestBytes configuration to match your real request sizes (and your provider's own body limit)
- Trim or offload large content (documents to retrieval, older turns dropped) before sending
- Align limits: make any upstream proxy/body limit <= the engine's configured cap so rejection happens at the edge with a clear error
Example fix
// before
engine, _ := cacheengine.NewNative(cacheengine.Config{}) // default cap too small for big chats
// after
engine, _ := cacheengine.NewNative(cacheengine.Config{MaxRequestBytes: 16 * 1024 * 1024}) Defensive patterns
Strategy: validation
Validate before calling
if len(body) > cfg.MaxRequestBytes { return fmt.Errorf("body %d bytes exceeds cap %d", len(body), cfg.MaxRequestBytes) } Type guard
// n/a
Try / catch
if err := eng.Execute(ctx, req); err != nil {
if strings.Contains(err.Error(), "request exceeds configured byte limit") { return http.StatusRequestEntityTooLarge, trim(req) }
return 0, err
} Prevention
- Set the engine cap at or above your ingress body cap
- Drop old turns / offload documents instead of growing bodies unbounded
When it happens
Trigger: Calling the native Execute/Evaluate entry point with a request body larger than the engine's configured maximum request size, while ctx is non-nil and the engine has no config error.
Common situations: Whole conversation histories or large attached documents inlined into the body; raising prompt sizes in production without raising the engine's byte cap; a middleware in front that enforces a different (higher) limit than the engine's, so requests pass one guard and fail the other.
Related errors
- cacheengine: stable prefix exceeds configured byte limit
- cachebench: provider population exceeds 1024
- cachebench: invalid observation read limits
- cacheengine: segment exceeds framing limit
- row limit %d exceeded
AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15).
Data as JSON: /api/errors/04cad23073f98145.
Report an issue: GitHub.