JuliusBrussee/caveman · error
tool message requires tool_call_id
Error message
tool message requires tool_call_id
What it means
Sentinel from validateCorpusMessage: a message with role "tool" lacks a non-empty tool_call_id. Tool results must be correlated to the assistant tool call that produced them, so a bare ID is mandatory for role=tool messages.
Solutions
- Set tool_call_id on every role="tool" message to the id of the corresponding assistant tool call
- Ensure the id is non-empty and within the 2048-char bound
- Drop orphaned tool results whose originating call is missing from the corpus
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at cacheengine/cachebench/corpus.go:383 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/ef20c906aa8f8834.
Report an issue: GitHub.
Appendix: source
Thrown at cacheengine/cachebench/corpus.go:383
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)
if rowBytes > limits.MaxRetainedBytes-*retainedBytes {
return fmt.Errorf("retained corpus byte limit %d exceeded", limits.MaxRetainedBytes)
}View on GitHub (pinned to 766dce6b13)