plandex-ai/plandex · error

error calling model: %v

Error message

error calling model: %v

What it means

Wraps any non-context-canceled error from the model request made inside buildWholeFileFallback. If the context was canceled the raw error is returned; everything else is wrapped as 'error calling model'.

Source

Thrown at app/server/model/plan/build_whole_file.go:123

		AfterReq: func() {
			fileState.builderRun.BuildWholeFileFinishedAt = time.Now()
		},

		WillCacheNumTokens:    willCacheNumTokens,
		EstimatedOutputTokens: maxExpectedOutputTokens,

		SessionId:     sessionId,
		Settings:      fileState.settings,
		OrgUserConfig: fileState.orgUserConfig,
	})

	if err != nil {
		if errors.Is(err, context.Canceled) {
			log.Printf("buildWholeFileFallback - context canceled during model request for file %s", filePath)
			return "", err
		}

		return "", fmt.Errorf("error calling model: %v", err)
	}

	fileState.builderRun.GenerationIds = append(fileState.builderRun.GenerationIds, modelRes.GenerationId)
	fileState.builderRun.BuildWholeFileFinishedAt = time.Now()

	content := modelRes.Content

	// log.Printf("buildWholeFile - %s - content:\n%s\n", filePath, content)

	wholeFile := utils.GetXMLContent(content, "PlandexWholeFile")

	if wholeFile == "" {
		log.Printf("buildWholeFile - no whole file found in response\n")
		return fileState.wholeFileRetryOrError(buildCtx, proposedContent, desc, comments, sessionId, fmt.Errorf("no whole file found in response"))
	}

	return wholeFile, nil
}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Inspect the wrapped %v cause to identify the provider failure
  2. Check API key/auth vars and model pack configuration
  3. Retry with backoff for transient network/rate-limit errors
Defensive patterns

Strategy: retry

Validate before calling

if err := validateModelConfig(authVars, settings); err != nil {
    return fmt.Errorf("model config invalid before call: %v", err)
}

Try / catch

content, err := buildWholeFileFallback(...)
var ctxErr error
if errors.Is(err, context.Canceled) {
    return err // do not retry cancellations
}
if strings.HasPrefix(err.Error(), "error calling model:") {
    // retry with backoff for transient provider failures
}

Prevention

When it happens

Trigger: The LLM API call fails: network errors, auth failures, rate limits, invalid model config, or provider 5xx — anything except context.Canceled.

Common situations: Expired/invalid API keys, provider outages, misconfigured base model config, rate limiting during heavy usage.

Related errors


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/f9f606763e9063b3. Report an issue: GitHub.