Duty Log: Ten-Minute Token Preflight Before Send
The request is ready, but the send button can wait ten minutes. A token preflight checks whether the payload fits, leaves room for the answer, and avoids paying to transmit context that adds no value. The goal is not a perfect cost forecast. It is a repeatable check that catches oversized requests before they become runtime surprises.
First two minutes: capture what will actually leave
Start with the complete request your application will submit, not just the latest user message. Include system instructions, retained conversation history, retrieved passages, tool definitions, and tool results. A short question attached to a long conversation can still produce a large input.
Take this snapshot after templates, retrieval, and middleware have finished assembling the payload. Counting an earlier draft misses the material your framework adds later. Avoid copying production secrets into public counting tools; run checks locally or use an authorized counting service.
- Include every message that will be sent again, even if the user saw it several turns ago.
- Include tool schemas and structured-output definitions when the API accepts them as part of the request.
- Record images, audio, and other non-text inputs separately because a text tokenizer cannot fully account for them.
Next two minutes: choose a counter for the target model
Tokens are not words, characters, or bytes. Punctuation, source code, whitespace, and language all affect segmentation. A character-based estimate can be a rough warning signal, but it should not decide whether a request close to the context limit is safe.
Prefer a provider-supported counting method for the exact target model and request format, when available. Otherwise, use a compatible local tokenizer and mark the result as an estimate. A tokenizer that counts plain text does not necessarily account for message framing, tool definitions, or provider-added overhead.
If you switch between Claude Haiku 4.5 and Gemini 2.5 Flash, rerun the check using the appropriate counting method. Do not assume that identical text produces identical counts across model families. Also confirm whether your chosen API route exposes a counting operation; an OpenAI-compatible interface does not by itself guarantee one.
Middle two minutes: reserve space for the response
Write down three values: estimated input tokens, your requested output allowance, and the selected model's documented context limit. Check the model's separate maximum output allowance as well. Use current documentation for the exact model and route rather than a remembered limit from a related model.
As a conservative preflight rule, require estimated input plus reserved output plus an uncertainty margin to fit within the documented context budget. Follow model-specific rules where they differ. Some reasoning models also account for internal reasoning within generation limits or billing, so visible answer length may not describe the whole output budget.
Make the uncertainty margin configurable. If counting is approximate or the request includes tools or media, leave more room or use a more authoritative counter. Do not treat a fixed percentage as a universal safety guarantee.
Following two minutes: trim context with a clear rule
If the request is too large, remove low-value material before reducing the space needed for a useful answer. Drop duplicate retrieved passages, exclude irrelevant tool output, and keep only conversation history that supports the current task.
Summarize older context deliberately, preserving decisions, constraints, and unresolved questions. Blindly chopping the oldest characters can remove instructions or break structured content. Count again after every transformation. For large documents, selecting relevant sections is often more useful than forcing everything into one request.
Final two minutes: send once and compare the receipt
Log the model identifier, counting method, estimated input, output allowance, and actual usage returned by the API. Investigate differences before trusting the same estimate in a batch job. Keep sensitive payload content out of routine logs.
For cost checks, use current route pricing and distinguish ordinary input, cached input where applicable, and output. A token estimate alone is not a bill.
Relay365 fits teams routing requests across multiple model families on a pay-as-you-go basis. Its API base is https://api.api365relay.com; OpenAI clients add /v1. Keep preflight checks tied to the selected model rather than the shared client interface. Create a Relay365 account when you are ready to test this workflow with your actual payloads.
The shift handoff is simple: capture, count, reserve, trim, and compare. Make those checks a request gate, not a debugging ritual after an avoidable failure.
Further desk bulletins
| Date | Bulletin title | Filed under | Language |
|---|---|---|---|
| 2026-10-29 | Desk Log: Ten Minutes on Invoices, Refunds and Credit | Spend watch | EN |
| 2026-10-29 | Duty Log: Ten Minutes to Fence In Agent Spend | Spend watch | EN |
| 2026-10-29 | Shift Note: Cut Repeat-Prompt Costs in Ten Minutes | Spend watch | EN |
| 2026-10-29 | Shift note: a ten-minute wallet and pass check | Spend watch | EN |
| 2026-10-29 | Duty Log: Ten-Minute Token Invoice Reconciliation | Spend watch | EN |
| 2026-10-28 | Desk log: first token arrived, answer still running | Spend watch | EN |
Curious how it runs on your own code? Sign up →