plandex-ai/plandex · error

map total size is too large: %d

Error message

map total size is too large: %d

What it means

After path-count validation, UpdateContexts sums the byte length of all parts in context.MapParts and rejects the update if the total exceeds shared.MaxContextBodySize (25MB). This prevents the combined map body from blowing past context body limits downstream.

Source

Thrown at app/server/db/context_helpers_update.go:308

				for _, path := range params.RemovedMapPaths {
					delete(context.MapParts, path)
					delete(context.MapShas, path)
					delete(context.MapTokens, path)
					delete(context.MapSizes, path)
				}

				if len(context.MapParts) > shared.MaxContextMapPaths {
					errCh <- fmt.Errorf("map has too many paths: %d", len(context.MapParts))
					return
				}

				totalMapSize := 0
				for _, part := range context.MapParts {
					totalMapSize += len(part)
				}
				if totalMapSize > shared.MaxContextBodySize {
					errCh <- fmt.Errorf("map total size is too large: %d", totalMapSize)
					return
				}

				context.Body = context.MapParts.CombinedMap(context.MapTokens)
				newNumTokens := shared.GetNumTokensEstimate(context.Body)
				tokenDiff := newNumTokens - oldNumTokens

				mu.Lock()
				tokenDiffsById[id] = tokenDiff
				aggregateTokensDiff += tokenDiff
				totalTokens += tokenDiff
				if planConfig.AutoLoadContext {
					totalMapTokens += tokenDiff
				} else {
					totalPlannerTokens += tokenDiff
				}
				mu.Unlock()

View on GitHub (pinned to e2d772072e)

Solutions

  1. Trim the mapped path set or per-file excerpts so total size stays under 25MB
  2. Prune unchanged/stale parts from the context before updating
  3. Raise map detail only for files the plan actually needs; use shallow summaries elsewhere
  4. Verify client-side pre-checks (context_load.go checks totalMapSize before sending) are enabled

Example fix

// before
// send all parts regardless of total size
// after
const maxTotal = 25 * 1024 * 1024
if totalSize(mapBodies) > maxTotal {
    mapBodies = truncateToBudget(mapBodies, maxTotal)
}
Defensive patterns

Strategy: validation

Validate before calling

const maxTotal = 25 * 1024 * 1024
total := 0
for _, part := range allParts {
    total += len(part)
}
if total > maxTotal {
    return fmt.Errorf("map total %d exceeds 25MB budget", total)
}

Try / catch

err := updateContexts(req)
if err != nil && strings.Contains(err.Error(), "map total size is too large") {
    return fmt.Errorf("shrink the map (fewer paths or smaller excerpts) and retry: %w", err)
}

Prevention

When it happens

Trigger: A map context update where the merged MapParts total size > 25MB — many medium files each under the 500KB per-part cap but collectively exceeding the aggregate limit.

Common situations: Mapping thousands of sizable files (source dumps, datasets); accumulated parts never pruned as files grow across repeated updates; misconfigured clients that skip total-size checks the CLI performs before sending.

Related errors


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