{"record":{"id":"4261c0da502eeeb1","repo":"JuliusBrussee/caveman","slug":"cachebench-invalid-scenario-token-or-turn-count","errorCode":null,"errorMessage":"cachebench: invalid scenario token or turn count","messagePattern":"cachebench: invalid scenario token or turn count","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cacheengine/cachebench/trace.go","lineNumber":91,"sourceCode":"\t\t\t\tID: fmt.Sprintf(\"turn-%03d-tool-result\", turn+1), Kind: \"tool_result\", Turn: turn + 1,\n\t\t\t\tText:   fixtureText(fmt.Sprintf(\"workspace result turn %d\", turn+1), scenario.ToolResultTokens),\n\t\t\t\tTokens: scenario.ToolResultTokens,\n\t\t\t},\n\t\t)\n\t}\n\treturn Trace{\n\t\tProvider: provider, Scenario: scenario, Requests: requests,\n\t\tTokenBasis:  \"deterministic declared fixture tokens; provider counts required for observed evidence\",\n\t\tTimingBasis: TimingSynthetic,\n\t}, nil\n}\n\nfunc validateScenario(provider ProviderConfig, scenario Scenario) error {\n\tif strings.TrimSpace(provider.Provider) == \"\" || strings.TrimSpace(provider.Model) == \"\" || strings.TrimSpace(provider.Endpoint) == \"\" {\n\t\treturn errors.New(\"cachebench: provider, model, and endpoint required\")\n\t}\n\tif scenario.Turns < 2 || scenario.StaticTokens <= 0 || scenario.UserTokens <= 0 || scenario.AssistantTokens < 0 || scenario.ToolResultTokens < 0 || scenario.SummaryTokens < 0 {\n\t\treturn errors.New(\"cachebench: invalid scenario token or turn count\")\n\t}\n\tif scenario.CompactionEvery < 0 || scenario.Step <= 0 || scenario.AssumedTTL <= 0 {\n\t\treturn errors.New(\"cachebench: invalid scenario timing\")\n\t}\n\treturn nil\n}\n\nfunc nativeRequest(provider ProviderConfig, scenario Scenario, epoch string, body []byte) cacheengine.NativeRequest {\n\texpectedCalls := scenario.Turns\n\tif scenario.CompactionEvery > 0 && expectedCalls > scenario.CompactionEvery {\n\t\texpectedCalls = scenario.CompactionEvery\n\t}\n\treturn cacheengine.NativeRequest{\n\t\tScope: \"cachebench/real-agent\", Epoch: epoch, PartitionKey: \"agent-session-1\",\n\t\tExpectedRequestsPerMinute: 20, ExpectedCalls: expectedCalls,\n\t\tProvider: provider.Provider, Model: provider.Model, Region: provider.Region, Endpoint: provider.Endpoint,\n\t\tBody: body, RuntimeMode: \"optimize\", AuthMode: \"payg\", PrefixTokens: scenario.StaticTokens,\n\t}","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/cacheengine/cachebench/trace.go#L73-L109","documentation":"Error \"cachebench: invalid scenario token or turn count\" thrown in JuliusBrussee/caveman.","triggerScenarios":"Thrown at cacheengine/cachebench/trace.go:91 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Fix the scenario token and turn counts to valid values."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}