agent failed with context overflow reading 300 custom field definitions
Handles context overflow when an agent reads hundreds of field definitions: fetch only the fields the task needs, and summarize the rest. Use when describe output overflows context. Not for export file overflows.
TL;DR
Reading 300 full field definitions blows the context budget before the real work starts. Instead, fetch the field list (names and types only), select the dozen fields the task needs, and pull full definitions for just those. Describe is a menu; order from it, do not eat it whole.
Error
Context overflow: reading 300 custom field definitions exceeded the context limit.Steps
- Call describe but keep only name, type, and label per field (a compact list). Expected: the whole schema fits in a fraction of the context.
- Identify the fields the task actually needs (the mapping targets, the merge fields). Expected: a short list, usually under 20.
- Fetch full definitions only for those fields. Expected: complete metadata where it matters.
- Cache the compact schema in a file the agent can re-read selectively. Expected: later runs skip even the compact fetch.
- Refresh the cache on a schedule or on schema-change signals, not on every run. Expected: fresh enough without the cost.
When to use
- Describe output overflows context.
- An agent reads full field metadata for hundreds of fields.
- Schema exploration before a mapping task.
When not to use
- Export file overflows (different fix).
- Small objects (just read the definitions).
Tool compatibility
- Salesforce and HubSpot describe/metadata APIs.
- Agent-side schema caching.
Variant phrasings
too many field definitions for context
Fetch names first, details selectively.
describe overflowed
Compact the schema; cache it.
Why it happens
Full field definitions are verbose (picklist values, help text, permissions). Multiplied by 300 fields, they exceed any context window while the task needs a handful.
Edge cases
- Picklist values are the bulkiest part; fetch them only for picklist fields you map.
- Cached schemas go stale; version the cache and refresh on change.
- Some tasks genuinely need many fields; then do the work in code, not in context.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_AHMo8x8Z2KKT1Pw2N0NFUg