## TL;DR
Do not paste a 500-table schema into the prompt: fetch the catalog in pages, keep a compact index of table names with column counts and owners, and pull full column detail only for the tables the current task touches. Schema-first filtering turns an impossible prompt into a handful of small lookups.

```text
context overflow failure agent couldn't fit schema for 500 tables in prompt error
```

## Use this when
- The check or run fails with this symptom: the agent cannot fit the schema for 500 tables into its context.
- You are working on an agent generating queries or checks across a large warehouse schema and the failure repeats on the same data or configuration.
- You need the failing rows, rule, or stage isolated before changing thresholds or code.

## Not for this skill when
- A task that genuinely needs one table's full DDL, where the fix is fetching that table alone rather than paging the catalog.
- The error text names a different tool, stage, or root cause. Match the verbatim error first and use that skill.

## Steps
1. Query the information schema for a table index only: name, schema, column count, and row estimate, in pages. Verify: the index for all 500 tables fits in a compact list
2. Select candidate tables for the task by name, owner, or tag before fetching any column detail. Verify: a short candidate list is chosen from the index
3. Fetch full column definitions only for candidate tables, one or two at a time. Verify: column detail calls are scoped to named tables
4. Cache the index and fetched schemas with a timestamp, and refresh only when a task reports a missing table. Verify: repeat tasks reuse the cache instead of re-reading the catalog

## Variant phrasings
### agent context overflow 500 table schema
The table-count phrasing.
### schema too large for agent prompt warehouse
The prompt-size phrasing.
### agent cannot load full warehouse catalog into context
The catalog phrasing.

Compatibility: Agent frameworks introspecting warehouse schemas across Snowflake, BigQuery, or Postgres

## Why it happens
A full catalog dump scales with every table and column in the warehouse, so it exceeds the context window long before the agent reaches the few tables the task needs. The information the agent needs first is an index, not the schemas themselves.

## Edge cases / pitfalls
- Very wide tables can still overflow on their own; page columns for tables with hundreds of fields.
- Views that expand to base-table columns can double-count; index views separately from tables.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_6BN94nswfEaD_eLUlQML6w
