alibaba/open-code-review · error

grouping LLM call: %w

Error message

grouping LLM call: %w

What it means

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.

Source

Thrown at internal/agent/grouping.go:220

		})
	}

	if maxTokens <= 0 {
		maxTokens = 4096
	}

	resp, err := client.CompletionsWithCtx(ctx, llm.ChatRequest{
		Model:     modelName,
		Messages:  messages,
		MaxTokens: maxTokens,
	})
	duration := time.Since(startTime)

	if err != nil {
		if rec != nil {
			rec.SetError(err, duration)
		}
		return nil, nil, fmt.Errorf("grouping LLM call: %w", err)
	}

	usage = resp.Usage

	content := resp.Content()
	if content == "" {
		if rec != nil {
			rec.SetError(fmt.Errorf("grouping LLM returned empty response"), duration)
		}
		return nil, usage, fmt.Errorf("grouping LLM returned empty response")
	}

	groups, err = parseGroupingResponse(content, diffs)
	if rec != nil {
		if err != nil {
			rec.SetError(fmt.Errorf("grouping response parse failed: %w", err), duration)
		} else {
			rec.SetResponse(resp, duration)

View on GitHub (pinned to 5cf97d0d15)

Solutions

  1. Unwrap the error to see the provider/HTTP cause (401/429/timeout).
  2. Fix LLM configuration (API key, model, endpoint) and verify with a single small request.
  3. For rate limits or timeouts, retry with backoff or reduce MaxTokens/group size.
  4. Check network egress (proxy, firewall, DNS) if errors are connection-level.

Example fix

// before: 'grouping LLM call: 429 too many requests'
ocr review  # immediate retry after burst
// after: wait/backoff, or lower concurrency, then re-run
sleep 30 && ocr review --resume
Defensive patterns

Strategy: retry

Validate before calling

// pre-flight: cheap completion to validate key/endpoint before grouping
if err := pingLLM(client, model); err != nil { return err }

Try / catch

groups, usage, err := callGroupingLLM(ctx, diffs, client, model, task, maxTokens, opts)
if err != nil {
    if isTransient(err) { // 429/timeout/network
        time.Sleep(backoff)
        groups, usage, err = callGroupingLLM(ctx, diffs, client, model, task, maxTokens, opts)
    }
}

Prevention

When it happens

Trigger: groupDiffs → callGroupingLLM when the LLM client returns an error: auth failure, network error, rate limit, timeout, or context cancellation during the grouping request.

Common situations: Invalid API key, provider outage, request exceeding timeout, 429 rate limit on repos with many changed files, proxy blocking the API host.

Related errors


AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02). Data as JSON: /api/errors/2b87413cb33aacaa. Report an issue: GitHub.