{"record":{"id":"f88e06a99b25d3c6","repo":"alibaba/open-code-review","slug":"plan-request-w","errorCode":null,"errorMessage":"plan request: %w","messagePattern":"plan request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/agent.go","lineNumber":1729,"sourceCode":"\tctx = llm.ContextWithSessionKey(ctx,\n\t\tllm.SessionTaskKey(a.session.SessionID, string(session.PlanTask), gk))\n\tstartTime := time.Now()\n\treqCtx := llm.WithRequestMeta(ctx, a.newRequestMeta(gk, session.PlanTask, rec.RequestNo))\n\n\t_, llmSpan := telemetry.StartLLMSpan(ctx, a.args.Model)\n\tresp, err := a.args.LLMClient.CompletionsWithCtx(reqCtx, llm.ChatRequest{\n\t\tModel:     a.args.Model,\n\t\tMessages:  messages,\n\t\tMaxTokens: a.args.Template.CompletionTokenLimit(),\n\t})\n\tduration := time.Since(startTime)\n\tif err != nil {\n\t\ttelemetry.RecordLLMResult(llmSpan, duration, 0, err)\n\t\tllmSpan.End()\n\t\trec.SetError(err, duration)\n\t\tspan.SetStatus(codes.Error, err.Error())\n\t\tspan.RecordError(err)\n\t\treturn \"\", fmt.Errorf(\"plan request: %w\", err)\n\t}\n\tvar totalTokens int64\n\tif resp.Usage != nil {\n\t\ttotalTokens = resp.Usage.TotalTokens\n\t}\n\ttelemetry.RecordLLMResult(llmSpan, duration, totalTokens, nil)\n\tllmSpan.End()\n\trec.SetResponse(resp, duration)\n\ta.runner.RecordUsage(resp.Usage)\n\tfmt.Fprintf(stdout.Writer(), \"[ocr] Plan completed for group %q\\n\", gk)\n\treturn resp.Content(), nil\n}\n\n// executeGroupReviewFilter runs the REVIEW_FILTER_TASK for a file group.\n// When from is non-nil, only comments at indices >= from[path] for each path\n// are candidates for filtering (per-round isolation). When from is nil, all\n// comments for the group's paths are filtered (legacy full-group behavior).\nfunc (a *Agent) executeGroupReviewFilter(ctx context.Context, g FileGroup, from map[string]int) {","sourceCodeStart":1711,"sourceCodeEnd":1747,"githubUrl":"https://github.com/alibaba/open-code-review/blob/5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f/internal/agent/agent.go#L1711-L1747","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: 'plan request: 400 model max_tokens too large'\nMaxTokens: a.args.Template.CompletionTokenLimit() // e.g. 128000 on a 4096-limit model\n// after: cap the template's completion token limit to the model's allowed maximum\n// or switch to a model that supports the configured limit","handlingStrategy":"retry","validationCode":"// pre-flight API key/endpoint check\nresp, err := client.CompletionsWithCtx(ctx, llm.ChatRequest{Model: model, Messages: []llm.Message{llm.NewTextMessage(\"user\", \"ping\")}, MaxTokens: 8})\nif err != nil { return fmt.Errorf(\"LLM preflight failed: %w\", err) }","typeGuard":null,"tryCatchPattern":"plan, err := executeGroupPlanPhase(ctx, g, diffs, files, rule)\nif err != nil {\n    var retriable bool\n    if strings.Contains(err.Error(), \"429\") || strings.Contains(err.Error(), \"timeout\") { retriable = true }\n    if retriable { time.Sleep(backoff); plan, err = executeGroupPlanPhase(...) }\n}","preventionTips":["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."],"tags":["llm","network","api","rate-limit"],"backgroundTag":"llm-request-failed","analyzedSha":"5cf97d0d15cbd41b602513c4be3bfec3cee5bf7f","analyzedAt":"2026-09-02T02:08:09.116Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}