How to Save AI Tokens Without Losing Important Context

Tokens run out faster than you expect, especially in long coding or research sessions. This guide covers prompt trimming, focused retrieval, concise handoffs, and keeping durable project state outside the conversation.

Updated 5 min read

Every message in a conversation costs tokens, including all the messages before it. A long session accumulates history fast, and once the context window fills, older messages drop out or the session stops being usable. The goal is not to use as few tokens as possible but to use them on the right things: the current task, the constraints that apply to it, and the facts that change the answer.

One of the biggest token wasters is re-explaining context that could live in a shared record. Tools like fenbs keep project rules and progress outside the conversation, so each session starts with a focused read rather than a full re-briefing. For Claude Code-specific tips, see reduce Claude Code token usage. For general AI prompting technique, how to use AI at work covers practical habits.

Why tokens run out faster than you expect

A context window counts all the tokens in the conversation: your messages, the model's replies, the system prompt, and any documents or code you pasted in. A 128,000-token window sounds large until a 1,000-line file, a few model replies, and a system prompt eat half of it. Long coding sessions, document analysis, and multi-step tasks are all high-token-use scenarios.

Most tools also charge per token processed, so a large context costs more on every exchange. Efficiency matters for cost as well as capability. The session that runs out of context halfway through a task is not just inconvenient; it may produce incomplete or inconsistent output.

Trim the system prompt

The system prompt sits in every request, so it is the highest-leverage place to trim. Include only the rules and instructions that genuinely change the model's behavior for this task. Remove instructions that do not apply to the current use case. Remove explanations of why a rule exists if the model does not need the explanation to follow it.

Keep the system prompt in a file or record rather than in the chat itself. That way you can update it without adding a correction message that itself uses tokens. Review it whenever the task type changes.

Use focused retrieval instead of full documents

When you need the model to work with a document, paste the relevant sections rather than the full file. A 5,000-word specification rarely has more than a few hundred words that are relevant to the current task. Find them and include only those.

For codebases, paste the functions or classes directly affected by the task. Give the model a summary of the broader structure if it needs that context, but do not paste the entire codebase. The model does not need to see every file to change one function.

If your tool supports file reads, ask the model to request the files it needs rather than including everything at the start. A model that asks for specific files uses fewer tokens and makes it easier to see what it actually needed.

Write concise handoffs

A handoff between sessions does not need to reproduce the conversation. It needs to tell the next session what was decided, what was completed, and what comes next. Three to five sentences per task is usually enough. A handoff that reads like a compressed chat log uses the same tokens for less value.

Write the handoff in a format the assistant can read quickly: the task, the current status, any constraints that apply, and the next step. Keep it in an external record rather than at the top of each new conversation. A record the model reads once at the start is more efficient than one it re-reads every time you open a new tab.

Avoid copying full outputs into the handoff. Reference them by location instead: "the API contract is in api-spec.json, section 3" costs far fewer tokens than pasting the full spec.

Keep durable project state outside the conversation

Some context belongs in the conversation and some belongs outside it. The current task, the last few steps of reasoning, and the output you are working toward belong in the conversation. The project rules, the architecture decisions, and where things stood before the current task belong in a durable external record.

When the model reads the external record at the start of a session, it gets the standing context in a single, focused read. When it saves progress at the end, the record stays current. The next session reads the updated record rather than re-reading the previous conversation. That is where the token savings compound over time.

How fenbs helps

Start each session with focused context, not a full re-briefing

Connect fenbs over MCP and ask the assistant to read the AI context at the start of each session: Rules first, then Where we left off. The rules are short. The handoff is concise. The model has what it needs in a fraction of the tokens a full re-briefing would cost. Add project context notes for facts the model needs in every session.

Create a free account

Free for one person · No credit card · Works with Claude, ChatGPT, Cursor and more

Reuse good prompts instead of rewriting them

If you have a prompt that reliably produces the output you need for a recurring task, save it. Writing a new version from scratch each time costs your own time and produces inconsistent results. A saved prompt you can paste or reference is a small upfront investment that compounds over many uses.

In fenbs, Skills and prompts is a shared library any connected assistant can list and read. A developer who figures out the right prompt for a code review check can save it where a teammate's assistant can use it too. That removes duplication at the team level, not just for one person.

How to do this with fenbs

  1. Create a free account. Add a project for the work you want to carry across sessions.
  2. Write standing rules in Decisions and rules: the constraints that apply to every session. Keep them short. Each word in a rule is a word the model reads on every session start.
  3. At the end of each session, ask the assistant to save a concise Where we left off: current task status, next step, and any open constraints. Not a chat transcript; three to five sentences per task.
  4. Connect your assistant over MCP from Integrations. Ask it to read the project context at the start of each session instead of re-explaining the project in the chat.
  5. Save prompts that worked well to Skills and prompts. Reference them by name in future sessions rather than pasting the full text each time.

Questions people ask.

What uses the most tokens in a typical AI session?

Pasted documents and long conversation history are usually the biggest uses. Every message in the history is re-sent with each new request. A full document pasted in one message stays in the context for the rest of the session. Use focused retrieval and summarize history when it grows long.

Does a longer system prompt always cost more?

Yes. The system prompt is included in every request. A 500-token system prompt on 100 requests costs 50,000 tokens from the system prompt alone. Trim it to the instructions that actually change behavior. Remove anything the model would do anyway without being told.

What is the difference between a context window and a token limit?

The context window is the maximum number of tokens the model can process in one request, including the conversation history, system prompt, and any documents you include. A token limit may refer to the per-request context window or to a quota on total usage per day or month, depending on the service.

How do I handle a session that runs out of context before the task is done?

Save progress on what was completed, start a new session, and read the saved progress at the start. Include only the facts needed to continue: the current task, what was done, and what comes next. Do not paste the entire previous conversation. A clean handoff is more useful than a compressed history.

Can I reduce token usage by changing the model?

Switching to a model with a larger context window gives more room before the window fills. Switching to a cheaper or faster model reduces cost per token. Neither change fixes a prompt that includes unnecessary context. Address the prompt first; then choose the model that fits the remaining needs.

More in Agent harness (for developers)

All Agent harness (for developers) articles

Start with one thing.

Free for one person · No credit card · Works with Claude, ChatGPT, Cursor and more

There is nothing to set up first. Write one line and you’ve started.