Spell Correction
How Typos Inflate AI Agent Costs
A typo costs more than embarrassment. Misspelled words fall out of the tokenizer's vocabulary and shatter into two to four times as many tokens, and in agent workflows a misspelled identifier or path can cause a failed tool call — which means a full retry loop billed on top of the original attempt. Fixing typos before the prompt is sent is the cheapest optimization there is.
Cost #1: Typos Break Tokenization
Subword tokenizers price text by how familiar it is. Correctly spelled common words match the vocabulary whole: "authentication" is one or two tokens. Misspell it and the greedy matcher can't find the long entry, so the word shatters into fragments:
"authentication" → 1-2 tokens
"authetnication" → 4-5 tokens ("aut", "et", "n", "ication")
"the" → 1 token
"teh" → 2 tokens
"function" → 1 token
"funciton" → 3 tokens
A single transposition typically doubles or triples that word's cost. Sprinkle a handful of typos through a long prompt and you've added a measurable surcharge — while simultaneously making the text statistically weirder and marginally harder for the model to read. (Why fragmentation happens is covered in Tokenization 101.) Models are good at guessing what you meant, but you're paying extra tokens for the privilege of making them guess.
Cost #2: Typos Break Tool Calls
In chat, a typo is a few wasted tokens. In an agent session, it can be a wasted turn — and turns are expensive, because each one re-bills the whole context. The failure chain looks like this:
- You ask the agent to "update the confg file" or reference
src/utls/parser.js. - The agent takes the string literally — agents often should, since odd names are frequently real — and calls a tool: reads the wrong path, greps for the misspelled symbol, runs a command with a bad flag.
- The tool fails or returns nothing. The error output lands in context. The agent reasons about the failure, retries with a variation, maybe searches the codebase to figure out what you meant.
That recovery loop typically costs one to three extra model turns, each carrying your full conversation history as re-billed input, plus the failed tool output that now sits in the window for the rest of the session (see the context window diet for why stale output keeps costing). A one-character typo in a file path can easily burn 10,000+ tokens of recovery — the single worst cost-per-character ratio in AI usage.
Cost #3: Ambiguity Compounds
There's a quieter third cost. When a prompt mixes typos with intentional oddities — real variable names like usr_cnt, real flags like -rf, project-specific jargon — the model has to decide which unusual strings are mistakes and which are meaningful. Every typo you send erodes its confidence about the strings that matter, occasionally producing "corrections" of things that were correct. Clean input keeps the signal unambiguous: anything unusual that remains is intentional.
The Fix: Correct Before You Send
Fixing typos after the model has misread them costs a round trip. Fixing them before the prompt is sent costs nothing, which is why spell correction is the first stage of Terse's optimization pipeline — it runs in every mode, including the gentlest:
- Prose gets corrected. Terse's spell-correction layer fixes natural-language typos on-device before the text leaves your machine, using a Norvig-style statistical corrector backed by the system dictionary.
- Code is protected. Identifiers, paths, quoted strings, and anything inside backticks are never "corrected" —
usr_cntstaysusr_cnt. A spellchecker that rewrites variable names would create the exact failed-tool-call problem it's meant to prevent, so the protected-region rules matter as much as the dictionary. - Corrections are visible. The before/after diff shows every change, so a "fix" you didn't want is a one-click revert rather than a silent mutation.
For Claude Code and other agent tools, the payoff is doubled: corrected prompts tokenize cheaper going in, and correctly spelled identifiers and paths mean tool calls succeed on the first attempt instead of the third. Cheap insurance against the most expensive kind of typo.
Fix Typos Before They're Billed
Terse corrects prompt typos on-device before sending — cheaper tokenization in, fewer failed tool calls out. Code and identifiers are never touched. Free to start.
Download TerseFrequently Asked Questions
How much does a typo cost in tokens?
A misspelled word typically tokenizes into 2-4x as many tokens as its correct form, because it no longer matches the tokenizer's vocabulary whole. In agent sessions the real cost is larger: a typo in a file path or identifier can trigger failed tool calls and retry turns worth thousands of tokens.
Do AI models understand prompts with typos?
Usually yes for prose — models are robust readers. But you pay extra tokens for fragmented words, and in agent workflows a misspelled path or symbol is often taken literally, causing wrong or failed tool calls rather than a graceful guess.
Won't a spellchecker break my variable names and commands?
Not a prompt-aware one. Terse only corrects natural-language regions and treats code, identifiers, file paths, quoted strings, and backticked text as immutable — and shows a diff of every correction so nothing changes silently.
Further Reading
- Terse Blog — all token optimization guides
- Tokenization 101 — why misspellings fragment
- Context Window Diet — what failed-call output costs downstream
- Spell Correction in Terse — the pipeline's first stage