## TL;DR
Stop carrying the whole run in the conversation and move state into tools and storage. The agent overflows because it accumulates every hire record, log, and page it has seen while trying to create the ServiceNow onboarding ticket. Restructure so each hire is processed in a fresh bounded step, reference data is fetched on demand and summarized, and progress lives in a run store the agent reads back in small pieces.

```text
agent context overflow during create the ServiceNow onboarding ticket: context limit error
```

## Use this when
- The run fails with a context or token limit error partway through create the ServiceNow onboarding ticket, later for larger cohorts.
- The agent trace shows long accumulated histories, pasted tables, or full page contents retained across steps.
- Short single-hire runs of the same workflow succeed reliably.

## Not for this skill when
- A single hire with one huge source document overflows alone. Split that document handling instead of the whole run design.
- The error is a provider outage mislabelled as a limit. Check provider status before redesigning.

## Steps
1. Measure the growth: from the run trace, estimate how much context each hire adds, including tool outputs the agent keeps, and identify the bulkiest contributors such as full directory listings, verbose API responses, or screenshots described in text. Verify: the top context contributors per hire are named with rough sizes
2. Externalize run state: write per-hire status, identifiers, and decisions to a run store such as a table or file the workflow owns, and have the agent read back only the current hire slice instead of remembering the cohort. Verify: the agent completes a hire using only the stored slice plus its instructions
3. Process hires in bounded units: one hire, or a small fixed batch, per agent invocation with a fresh context, orchestrated by a simple loop outside the model that tracks overall progress and handles retries. Verify: a multi-hire test run completes with flat per-invocation context use
4. Shrink tool outputs at the source: request only needed fields from lookups, summarize long lists with counts and the relevant rows, and store large artefacts as references the agent opens only when a decision truly needs them. Verify: sample tool outputs are visibly smaller with no decision-relevant loss
5. Resume the failed cohort with the new structure and confirm the run completes create the ServiceNow onboarding ticket for every hire, then check output quality on the last hires equals the first, since quiet degradation is the overflow failure mode that does not crash. Verify: first and last hire results pass the same spot checks
6. Set a cohort sizing rule in the runbook from the measured per-hire cost, with headroom, and add a context-use warning in run reporting before the hard limit so growth is caught as a trend. Verify: the sizing rule and the warning both exist

## Why it happens
Agent context is a finite working memory, and provisioning runs are naturally unbounded: every hire, lookup, and verification adds text the agent keeps carrying. Designs that let the conversation itself be the database guarantee overflow at some cohort size, usually mid-run on the busiest hiring day. The model does not need to remember the cohort; it needs the current hire, the rules, and a reliable place to put results. External state, bounded invocations, and lean tool outputs are the standard architecture for long agent work, and they also improve consistency because each hire gets the agent full attention.

## Variants and edge cases
### Reference data is the bulk, not hires
Load catalogues such as app or license lists as searchable tool data the agent queries per decision instead of pasting them into context.

### History needed for audit, not for decisions
Keep the full trace in run logs outside the model context; the agent needs conclusions, not its own transcript.

### Overflow at the verification step
Verification that re-reads everything the run produced doubles the load. Verify from the target system state per hire at completion time instead.

Compatibility: Applies to LLM agent provisioning workflows processing cohorts of hires. Requires workflow orchestration and run storage access.

## Provenance

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