liveBook · Manning

Token limit

As explained in Vibe Engineering

A token budget is a configured target or limit for the number of language-model tokens a task may consume.

A token limit is a configured target or ceiling for model consumption. In SQL generation, maxTokens(500) caps response length and helps prevent runaway generation and unexpected output costs, but it does not restrict the incoming prompt. section 6.2

Treat token limits as layered production guardrails:

  • Validate request size at the API boundary with character limits before constructing the model prompt. section 6.2
  • Count tokens locally with a tokenizer such as JTokkit and reject prompts exceeding a predefined budget. section 6.2
  • Constrain agent exploration, verbosity, iteration depth, and retries; filter command output and exclude irrelevant files from context. section 9.5.2

A bounded SQL-generation request

A request can combine a validated user prompt, table definitions, and recent queries, then call the model with maxTokens(500) and low temperature. The response ceiling still requires separate input-size protection.

Listing 9.6 Custom slash commands for cost-controlled agent workflows
markdown
<!-- .claude/commands/focused-refactor.md -->
# Focused Refactor
Refactor the specified function or module with these constraints:
- Read ONLY the files directly relevant to the change
- Do NOT explore the broader codebase unless explicitly needed
- Generate ONLY the changed code (diff format preferred)
- Do NOT explain changes unless asked
- Run existing tests after changes; do NOT write new tests
- If tests fail, fix the issue in max 2 iterations, then stop and report what's unresolved
- Budget: aim to complete in under 50,000 tokens total
$ARGUMENTS

Shows a reusable agent command that limits file exploration, output verbosity, retries, and total work to under 50,000 tokens. section 9.5.2

How Vibe Engineering covers it

How deep it goes
Distinguishes output caps from input budgets and gives validation, tokenization, filtering, and iteration guardrails.
Examples
Uses maxTokens(500) for SQL generation, JTokkit request counting, and a 50,000-token agent workflow target.
What it assumes
Assumes API request construction and basic prompt handling, while introducing token counting and budget enforcement.
What you can do after
Operate/configure bounded model calls and agent workflows with separate input, output, context, and iteration safeguards.
How it connects
Connects token limits with context windows, prompt construction, tokenization, output filtering, retries, and temperature.

Also explained in

Compare how 12 books explain token limit →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Vibe Engineering. The section links point to the parts of the book it draws on.