alibaba/open-code-review · error
plan request: %w
Error message
plan request: %w
What it means
executeGroupPlanPhase sends the plan-stage prompt to the LLM via LLMClient.CompletionsWithCtx and wraps any client error with this message. The task record, telemetry span, and OTel span are all marked with the error first, so diagnostics exist before this surfaces. It means the plan LLM request failed — no planning output was produced for this file group.
Source
Thrown at internal/agent/agent.go:1729
ctx = llm.ContextWithSessionKey(ctx,
llm.SessionTaskKey(a.session.SessionID, string(session.PlanTask), gk))
startTime := time.Now()
reqCtx := llm.WithRequestMeta(ctx, a.newRequestMeta(gk, session.PlanTask, rec.RequestNo))
_, llmSpan := telemetry.StartLLMSpan(ctx, a.args.Model)
resp, err := a.args.LLMClient.CompletionsWithCtx(reqCtx, llm.ChatRequest{
Model: a.args.Model,
Messages: messages,
MaxTokens: a.args.Template.CompletionTokenLimit(),
})
duration := time.Since(startTime)
if err != nil {
telemetry.RecordLLMResult(llmSpan, duration, 0, err)
llmSpan.End()
rec.SetError(err, duration)
span.SetStatus(codes.Error, err.Error())
span.RecordError(err)
return "", fmt.Errorf("plan request: %w", err)
}
var totalTokens int64
if resp.Usage != nil {
totalTokens = resp.Usage.TotalTokens
}
telemetry.RecordLLMResult(llmSpan, duration, totalTokens, nil)
llmSpan.End()
rec.SetResponse(resp, duration)
a.runner.RecordUsage(resp.Usage)
fmt.Fprintf(stdout.Writer(), "[ocr] Plan completed for group %q\n", gk)
return resp.Content(), nil
}
// executeGroupReviewFilter runs the REVIEW_FILTER_TASK for a file group.
// When from is non-nil, only comments at indices >= from[path] for each path
// are candidates for filtering (per-round isolation). When from is nil, all
// comments for the group's paths are filtered (legacy full-group behavior).
func (a *Agent) executeGroupReviewFilter(ctx context.Context, g FileGroup, from map[string]int) {View on GitHub (pinned to 5cf97d0d15)
Solutions
- Inspect the wrapped cause for the HTTP status/provider message (429 vs 401 vs timeout).
- Validate API key, model name, and endpoint configuration; re-test with a minimal request.
- For 429/timeout, retry with backoff or reduce group size / token limit.
- Check proxy and TLS settings (HTTPS_PROXY, corporate CAs) when behind a corporate network.
Example fix
// before: 'plan request: 400 model max_tokens too large' MaxTokens: a.args.Template.CompletionTokenLimit() // e.g. 128000 on a 4096-limit model // after: cap the template's completion token limit to the model's allowed maximum // or switch to a model that supports the configured limit
Defensive patterns
Strategy: retry
Validate before calling
// pre-flight API key/endpoint check
resp, err := client.CompletionsWithCtx(ctx, llm.ChatRequest{Model: model, Messages: []llm.Message{llm.NewTextMessage("user", "ping")}, MaxTokens: 8})
if err != nil { return fmt.Errorf("LLM preflight failed: %w", err) } Try / catch
plan, err := executeGroupPlanPhase(ctx, g, diffs, files, rule)
if err != nil {
var retriable bool
if strings.Contains(err.Error(), "429") || strings.Contains(err.Error(), "timeout") { retriable = true }
if retriable { time.Sleep(backoff); plan, err = executeGroupPlanPhase(...) }
} Prevention
- Validate API keys and model limits (max_tokens vs model cap) before runs.
- Configure client timeouts and retry-with-backoff for 429/5xx.
- Reduce group size or token limits for large diffs to stay under rate limits.
- Check proxy/CA configuration on corporate networks.
When it happens
Trigger: Calling the review pipeline when the plan-stage CompletionsWithCtx call returns an error: invalid API key, rate limit (429), timeout, context deadline exceeded, context cancelled, network failure, or model returned an error response.
Common situations: Expired/rotated API key, hitting provider rate limits on large groups, proxy/firewall blocking the endpoint, MaxTokens above the model's limit causing a 400, transient provider outage.
Related errors
- llm request failed: %w
- grouping LLM call: %w
- scan failed: %w
- all %d file review(s) failed — check your LLM configuration
- resolve LLM endpoint: %w
AI-assisted analysis of alibaba/open-code-review@5cf97d0d15 (2026-09-02).
Data as JSON: /api/errors/f88e06a99b25d3c6.
Report an issue: GitHub.