## TL;DR

The agent loaded a 4MB spec into context, overflowed, and silently truncated it, losing the auth section. Never load the whole spec: extract the paths you need, or split the spec, or summarize it before generating.

## Error

```text
generated client has no auth code at all; the spec's securityDefinitions were in the truncated tail
```

## Steps

1. Check how much of the spec the agent actually read Expected: you confirm the truncation.
2. Extract only the paths and the auth/security sections you need Expected: the working set fits.
3. Or split the spec by tag into smaller files and process each Expected: nothing is lost.
4. Regenerate with the pruned spec and verify auth code exists Expected: the client authenticates.

## When to use

- Generated code is missing whole sections
- The spec is bigger than the agent's working memory

## When not to use

- The spec genuinely lacks auth (then it is a docs bug)
- The generator supports streaming (then use it)

## Tool compatibility

- Large-spec handling
- Code generators driven by agents

## Variant phrasings

### generated client missing auth

The spec got truncated in context. Feed the agent a pruned spec with the auth section.

### truncated swagger file

Same: split by tag or extract needed paths first.

## Why it happens

Agents read files whole by default. A 4MB JSON spec looks like 'just a file' until it eats the context window and the tail quietly disappears.

## Edge cases

- Security schemes are often defined once and referenced; keep the definitions section with any prune
- Validate the pruned spec still parses before generating

## Provenance

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