JuliusBrussee/caveman · error
message exceeds byte limit
Error message
message exceeds byte limit
What it means
Sentinel from validateCorpusMessage: the computed messageBytes total (content + role + tool_call_id + name + tool-call id/type/name) exceeds limits.MaxMessageBytes. This is the aggregate per-message budget check after individual field validation passed.
Solutions
- Shrink the message (drop tool calls or shorten content) so its aggregate byte size fits MaxMessageBytes
- Increase MaxMessageBytes in CorpusLimits when the corpus legitimately carries larger messages
- Split one huge message into multiple smaller turns where semantically acceptable
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at cacheengine/cachebench/corpus.go:380 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of JuliusBrussee/caveman@766dce6b13 (2026-08-18).
Data as JSON: /api/errors/51000b28a2462662.
Report an issue: GitHub.
Appendix: source
Thrown at cacheengine/cachebench/corpus.go:380
if len(message.Content) > 0 {
var content any
if err := json.Unmarshal(message.Content, &content); err != nil {
return errors.New("content must decode")
}
if content != nil {
if _, ok := content.(string); !ok {
return errors.New("content must be string or null")
}
}
}
for _, call := range message.ToolCalls {
if call.Type != "function" || !validBoundedText(call.ID, 2048, false) || !validBoundedText(call.Function.Name, 512, false) || !validUniqueJSONObject([]byte(call.Function.Arguments)) {
return errors.New("tool call requires function type, id, function name, and JSON arguments")
}
messageBytes += len(call.ID) + len(call.Type) + len(call.Function.Name) + len(call.Function.Arguments)
}
if messageBytes > limits.MaxMessageBytes {
return errors.New("message exceeds byte limit")
}
if message.Role == "tool" && message.ToolCallID == "" {
return errors.New("tool message requires tool_call_id")
}
return nil
}
func appendCorpusRow(rows *[]CorpusRow, sessions map[string]bool, retainedBytes *int64, row CorpusRow, limits CorpusLimits) error {
if len(*rows) >= limits.MaxRows {
return fmt.Errorf("row limit %d exceeded", limits.MaxRows)
}
if !sessions[row.SessionID] {
if len(sessions) >= limits.MaxSessions {
return fmt.Errorf("session limit %d exceeded", limits.MaxSessions)
}
sessions[row.SessionID] = true
}
rowBytes := corpusRowRetainedBytes(row)View on GitHub (pinned to 766dce6b13)