{"record":{"id":"2b87413cb33aacaa","repo":"alibaba/open-code-review","slug":"grouping-llm-call-w","errorCode":null,"errorMessage":"grouping LLM call: %w","messagePattern":"grouping LLM call: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/grouping.go","lineNumber":220,"sourceCode":"\t\t})\n\t}\n\n\tif maxTokens <= 0 {\n\t\tmaxTokens = 4096\n\t}\n\n\tresp, err := client.CompletionsWithCtx(ctx, llm.ChatRequest{\n\t\tModel:     modelName,\n\t\tMessages:  messages,\n\t\tMaxTokens: maxTokens,\n\t})\n\tduration := time.Since(startTime)\n\n\tif err != nil {\n\t\tif rec != nil {\n\t\t\trec.SetError(err, duration)\n\t\t}\n\t\treturn nil, nil, fmt.Errorf(\"grouping LLM call: %w\", err)\n\t}\n\n\tusage = resp.Usage\n\n\tcontent := resp.Content()\n\tif content == \"\" {\n\t\tif rec != nil {\n\t\t\trec.SetError(fmt.Errorf(\"grouping LLM returned empty response\"), duration)\n\t\t}\n\t\treturn nil, usage, fmt.Errorf(\"grouping LLM returned empty response\")\n\t}\n\n\tgroups, err = parseGroupingResponse(content, diffs)\n\tif rec != nil {\n\t\tif err != nil {\n\t\t\trec.SetError(fmt.Errorf(\"grouping response parse failed: %w\", err), duration)\n\t\t} else {\n\t\t\trec.SetResponse(resp, duration)","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/internal/agent/grouping.go#L202-L238","documentation":"In callGroupingLLM, after CompletionsWithCtx returns an error, the task record is marked failed and the error is wrapped as \"grouping LLM call\". This is the grouping-stage analogue of a plan/request failure: the LLM call that groups changed files into review groups did not complete.","triggerScenarios":"groupDiffs → callGroupingLLM when the LLM client returns an error: auth failure, network error, rate limit, timeout, or context cancellation during the grouping request.","commonSituations":"Invalid API key, provider outage, request exceeding timeout, 429 rate limit on repos with many changed files, proxy blocking the API host.","solutions":["Unwrap the error to see the provider/HTTP cause (401/429/timeout).","Fix LLM configuration (API key, model, endpoint) and verify with a single small request.","For rate limits or timeouts, retry with backoff or reduce MaxTokens/group size.","Check network egress (proxy, firewall, DNS) if errors are connection-level."],"exampleFix":"// before: 'grouping LLM call: 429 too many requests'\nocr review  # immediate retry after burst\n// after: wait/backoff, or lower concurrency, then re-run\nsleep 30 && ocr review --resume","handlingStrategy":"retry","validationCode":"// pre-flight: cheap completion to validate key/endpoint before grouping\nif err := pingLLM(client, model); err != nil { return err }","typeGuard":null,"tryCatchPattern":"groups, usage, err := callGroupingLLM(ctx, diffs, client, model, task, maxTokens, opts)\nif err != nil {\n    if isTransient(err) { // 429/timeout/network\n        time.Sleep(backoff)\n        groups, usage, err = callGroupingLLM(ctx, diffs, client, model, task, maxTokens, opts)\n    }\n}","preventionTips":["Add client-side timeout and retry policies for the grouping request.","Validate API keys and endpoints before large reviews.","Reduce grouping prompt size for big change sets to avoid rate limits.","Resume the session after fixing the cause instead of re-reviewing from scratch."],"tags":["llm","network","api","grouping"],"backgroundTag":"llm-request-failed","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}