{"record":{"id":"8296094dd3e91b32","repo":"JuliusBrussee/caveman","slug":"session-limit-d-exceeded","errorCode":null,"errorMessage":"session limit %d exceeded","messagePattern":"session limit (.+?) exceeded","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/corpus.go","lineNumber":394,"sourceCode":"\t\t}\n\t\tmessageBytes += len(call.ID) + len(call.Type) + len(call.Function.Name) + len(call.Function.Arguments)\n\t}\n\tif messageBytes > limits.MaxMessageBytes {\n\t\treturn errors.New(\"message exceeds byte limit\")\n\t}\n\tif message.Role == \"tool\" && message.ToolCallID == \"\" {\n\t\treturn errors.New(\"tool message requires tool_call_id\")\n\t}\n\treturn nil\n}\n\nfunc appendCorpusRow(rows *[]CorpusRow, sessions map[string]bool, retainedBytes *int64, row CorpusRow, limits CorpusLimits) error {\n\tif len(*rows) >= limits.MaxRows {\n\t\treturn fmt.Errorf(\"row limit %d exceeded\", limits.MaxRows)\n\t}\n\tif !sessions[row.SessionID] {\n\t\tif len(sessions) >= limits.MaxSessions {\n\t\t\treturn fmt.Errorf(\"session limit %d exceeded\", limits.MaxSessions)\n\t\t}\n\t\tsessions[row.SessionID] = true\n\t}\n\trowBytes := corpusRowRetainedBytes(row)\n\tif rowBytes > limits.MaxRetainedBytes-*retainedBytes {\n\t\treturn fmt.Errorf(\"retained corpus byte limit %d exceeded\", limits.MaxRetainedBytes)\n\t}\n\t*retainedBytes += rowBytes\n\t*rows = append(*rows, row)\n\treturn nil\n}\n\nfunc corpusRetainedBytes(rows []CorpusRow) int64 {\n\tvar total int64\n\tfor _, row := range rows {\n\t\ttotal += corpusRowRetainedBytes(row)\n\t}\n\treturn total","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/cacheengine/cachebench/corpus.go#L376-L412","documentation":"A new session ID appeared after the session cap was already reached: appendCorpusRow only registers unseen session IDs, and it refuses when len(sessions) >= limits.MaxSessions. Existing sessions can keep adding rows; only distinct new sessions are blocked.","triggerScenarios":"A corpus row arrives whose SessionID has not been seen before while limits.MaxSessions distinct sessions are already registered.","commonSituations":"Replaying a wide fleet capture with many short sessions against limits tuned for a few long sessions; session IDs that change format (e.g. new suffix) after a provider migration, inflating distinct-session counts.","solutions":["Increase CorpusLimits.MaxSessions to the number of distinct session IDs in the file.","Normalize/merge session IDs before loading if IDs were split artificially.","Filter the corpus to the sessions you actually want to benchmark."],"exampleFix":"// before\nlimits.MaxSessions = 50\n// after\nlimits.MaxSessions = 5_000","handlingStrategy":"validation","validationCode":"func countSessions(path string) (int, error) {\n\tf, err := os.Open(path)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tdefer f.Close()\n\tseen := map[string]bool{}\n\tscanner := bufio.NewScanner(f)\n\tfor scanner.Scan() {\n\t\tvar row struct{ SessionID string `json:\"session_id\"` }\n\t\tif json.Unmarshal(scanner.Bytes(), &row) == nil && row.SessionID != \"\" {\n\t\t\tseen[row.SessionID] = true\n\t\t}\n\t}\n\treturn len(seen), scanner.Err()\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pre-count distinct session IDs and set MaxSessions above it.","Keep session ID format stable across pipeline versions.","Alert when distinct-session counts jump between corpus revisions."],"tags":["go","limits","sessions","configuration"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}