plandex-ai/plandex · error

context body is too large: %d

Error message

context body is too large: %d

What it means

UpdateContexts validates every incoming UpdateContextParams body and returns this error if any single context body exceeds shared.MaxContextBodySize (25MB). This is a per-context cap applied before any database writes.

Source

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

	if params.ContextsById == nil {
		contextsById = make(map[string]*Context)
	} else {
		contextsById = params.ContextsById
	}

	var totalContextCount int
	var totalBodySize int64

	for _, context := range contextsById {
		totalContextCount++
		totalBodySize += context.BodySize
	}

	for id, params := range *req {
		size := int64(len(params.Body))

		if size > shared.MaxContextBodySize {
			return nil, fmt.Errorf("context body is too large: %d", size)
		}

		if context, ok := contextsById[id]; ok {
			totalBodySize += size - context.BodySize
		} else {
			totalContextCount++
			totalBodySize += size
		}
	}

	if totalContextCount > shared.MaxContextCount {
		return nil, fmt.Errorf("too many contexts to update (found %d, limit is %d)", totalContextCount, shared.MaxContextCount)
	}

	if totalBodySize > shared.MaxContextBodySize {
		return nil, fmt.Errorf("total context body size exceeds limit (size %.2f MB, limit %d MB)", float64(totalBodySize)/1024/1024, int(shared.MaxContextBodySize)/1024/1024)
	}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Reduce the single context body below 25MB (trim, compress, or chunk the content).
  2. Split the file across multiple contexts or reference it by path/URL instead of inlining.
  3. Add client-side size validation before calling UpdateContexts.
  4. Exclude generated/binary files from automatic context syncing.

Example fix

// before
UpdateContexts(orgId, planId, branch, map[string]*shared.UpdateContextParams{
    id: {Body: string(giantFileBytes)}, // 60MB
})
// after
if int64(len(giantFileBytes)) > shared.MaxContextBodySize {
    giantFileBytes = truncateOrSummarize(giantFileBytes)
}
Defensive patterns

Strategy: validation

Validate before calling

for id, p := range req {
    if int64(len(p.Body)) > shared.MaxContextBodySize {
        return fmt.Errorf("context %s body is %d bytes, over %d limit", id, len(p.Body), shared.MaxContextBodySize)
    }
}

Type guard

func bodyWithinLimit(p *shared.UpdateContextParams) bool { return p != nil && int64(len(p.Body)) <= shared.MaxContextBodySize }

Try / catch

_, err := UpdateContexts(orgId, planId, branch, &req)
if err != nil && strings.Contains(err.Error(), "context body is too large") {
    // shrink or split the offending body and retry
}

Prevention

When it happens

Trigger: Calling UpdateContexts with a request map containing one entry whose params.Body length exceeds 25MB (25*1024*1024 bytes).

Common situations: Updating a context with the full contents of a large build artifact, video, dataset, or concatenated log file; a client bug uploading an entire directory as one body; user dragging a huge file into the plan context.

Related errors


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