plandex-ai/plandex · error
map is too large: %d
Error message
map is too large: %d
What it means
LoadContexts returns this when the total size of a map-mode context's bodies exceeds shared.MaxContextBodySize (25MB). Even if each entry is under the 500KB single-input cap, the sum of all map bodies for one context must stay below 25MB.
Source
Thrown at app/server/db/context_helpers_load.go:181
} else {
log.Println("Using map bodies for", contextParams.FilePath)
mappedFiles = contextParams.MapBodies
// check size and num path limits - these should be getting enforced by the client, so just error out if exceeded
if len(mappedFiles) > shared.MaxContextMapPaths {
return nil, nil, fmt.Errorf("map has too many paths: %d", len(mappedFiles))
}
totalMapSize := 0
for _, body := range mappedFiles {
numBytes := len(body)
totalMapSize += numBytes
if numBytes > shared.MaxContextMapSingleInputSize {
return nil, nil, fmt.Errorf("map input %s is too large: %d", contextParams.FilePath, numBytes)
}
}
if totalMapSize > shared.MaxContextBodySize {
return nil, nil, fmt.Errorf("map is too large: %d", totalMapSize)
}
}
var mapShas map[string]string
var mapTokens map[string]int
var mapSizes map[string]int64
if params.CachedMapsByPath != nil && params.CachedMapsByPath[contextParams.FilePath] != nil {
mapShas = params.CachedMapsByPath[contextParams.FilePath].MapShas
mapTokens = params.CachedMapsByPath[contextParams.FilePath].MapTokens
mapSizes = params.CachedMapsByPath[contextParams.FilePath].MapSizes
} else {
mapShas = contextParams.InputShas
mapTokens = contextParams.InputTokens
mapSizes = contextParams.InputSizes
}
View on GitHub (pinned to e2d772072e)
Solutions
- Trim mapped files to the most relevant subset so the total is under 25MB.
- Split the map into several map contexts each under the cap.
- Use raw file contexts selectively instead of one giant map.
- Confirm client-side total-size enforcement matches shared.MaxContextBodySize.
Example fix
// before
bodies := collectAllMapped() // total 40MB
// after
if totalSize(bodies) > shared.MaxContextBodySize {
bodies = trimToBudget(bodies, shared.MaxContextBodySize)
} Defensive patterns
Strategy: validation
Validate before calling
total := 0
for _, body := range mapBodies { total += len(body) }
if int64(total) > shared.MaxContextBodySize {
return fmt.Errorf("map total %d exceeds %d; split or trim", total, shared.MaxContextBodySize)
} Type guard
func withinMapTotalLimit(m map[string]string) bool {
total := 0
for _, b := range m { total += len(b) }
return int64(total) <= shared.MaxContextBodySize
} Prevention
- Track cumulative map size while building bodies, not after
- Trim to the most relevant files when nearing the 25MB budget
- Split oversized maps into several contexts
When it happens
Trigger: Calling LoadContexts with contextParams.MapBodies whose summed byte length exceeds 25MB, while all individual entries remain under 500KB.
Common situations: Mapping a moderately large directory with many ~100-400KB files; cumulative growth of a map context over many syncs; a client update that raised per-file caps but not total caps.
Related errors
- map has too many paths: %d
- map input %s is too large: %d
- total context size is too large: %d
- too many contexts to update (found %d, limit is %d)
- connection to plan stream timed out due to missing heartbeat
AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05).
Data as JSON: /api/errors/2d90f6528221de7c.
Report an issue: GitHub.