Ideas In Reach

Chapter 9 of 9started

Sessions, and spending fewer tokens

One long conversation used more than all my others together. Now a new topic gets a fresh session, and a small script tells me when.

Does this fit you?

Who it is for
Anyone who uses an AI coding helper on a subscription plan and reaches the weekly limit.
What you need
A helper that can run a small script before each prompt. Claude Code can.
Cost
Free. It saves usage.
Time
About one hour to set up. The habit takes a week.

This is the newest lesson. I kept reaching the weekly limit of my plan, and I did not know why.

What I wanted

  1. To know where the usage goes.
  2. To use less, with the same quality.
  3. To lose nothing when I close a conversation.

What we did

First we looked. One session had run for 145 hours and had grown to 966,000 tokens of context. In one week, that single session re-read about a billion tokens. All my other sessions together used less.

The reason is simple. A helper re-reads the whole conversation on every turn. So the same question costs more in a long conversation than in a short one. Nothing was wrong with the work in that session. It was only too long.

What changed:

  1. A new topic gets a new session. The knowledge lives in the notes, not in the conversation. See chapter 2.
  2. A nudge. A small script looks at the context size before each prompt. At 150,000 tokens, and then at every 100,000 after that, Alfred asks one question:
  1. The same question after a long break. After one hour of silence, the saved copy of the conversation has expired. The next turn pays for all of it again.
  2. Notes before a restart. On a yes, Alfred writes a handoff note. Then I exit and start again.
  3. Alfred never clears a session by itself. If I say no, it does not ask again until the next step.
  4. The right model for the job. The small model gets exact jobs that are easy to check. The middle model gets research and building from a plan. The large model gets design, hard bugs and the last review.
  5. No timed check loops. Alfred does not wake up every few minutes to look at a long job. A script waits and rings a doorbell.
  6. An archive. The tool deletes old sessions after 90 days. A job copies each session to a private folder first, as plain text. Text is small: 684 MB of raw session files became 6.6 MB. The search from chapter 2 covers it.

The files

The hook, in the helper’s settings file:

{
  "hooks": {
    "UserPromptSubmit": [
      { "hooks": [ { "type": "command",
          "command": "\"$CLAUDE_PROJECT_DIR\"/bin/alfred-session-nudge",
          "timeout": 5 } ] }
    ]
  }
}

The centre of the script. It reads the context size from the last line of the session’s transcript:

ASK = ("At a natural break (now, if the owner's message starts a new topic), ask in one line: "
       "\"Good time for a fresh session: want me to save notes first?\" On yes: write the handoff note "
       "(log + memory as usual), then tell the owner: \"Exit (/exit) and type alfred.\" "
       "Never clear on your own. If the owner says no, keep going and don't ask again until the next nudge.")

if ctx >= st["next"]:
    msg = f"Session check: context is {k}k tokens; every turn re-reads all of it. " + ASK
    st["next"] = ctx + 100_000
    st["idle_at"] = last_t  # one nudge per gap, not two
elif idle_min >= 60 and ctx >= 60_000 and st.get("idle_at", 0) < last_t:
    msg = (f"Session check: idle {idle_min/60:.1f} h with {k}k context, so the cache is cold "
           "and this turn re-sends it all. If the new message is a different topic, "
           "a fresh session is cheaper. " + ASK)
    st["idle_at"] = last_t

The script prints the message. The helper sees it as a note beside my prompt. The script makes no AI call, so it costs nothing.

What I learned

  1. Long is expensive. The cost of a turn grows with the conversation. I did not see this until we measured it.
  2. Measure first. One look at a week of usage found the cause. A guess would have blamed the wrong thing.
  3. A fresh start is safe when the notes are good. Chapter 2 made this chapter possible.
  4. The numbers are not in yet. I started on 2026-11-28. I will compare the weeks before and after, and write a post with the result.

Try it

Write a hook script that runs before each prompt. It reads this session's
transcript and finds the current context size. At 150,000 tokens, and at
every 100,000 after that, it tells you to ask me once: "Good time for a
fresh session: want me to save notes first?" On yes, write a handoff note.
Never clear the session yourself.

Behind this page

Why this way3 decisions

Who picks the session type?

  • A small local AI model
  • Free word rulesI picked this

On 56 real first messages, no model was clearly better than the rules. The rules are free, instant and private.

One long session, or many short ones?

  • One long session that knows everything
  • A fresh session for each topic, with notes in betweenI picked this

One long session re-read about a billion tokens in a week. Notes and a searchable archive carry the knowledge at almost no cost.

Which model is the default?

  • The largest model, always
  • The second largest; the largest only when I pick itI picked this

The weekly allowance is the limit. Most work does not need the largest model.

What we passed on4 ideas

A small AI model picks the session type

What it was
A small model reads my first message and picks the right kind of session for the work.
Why it looked good
A model can understand a request that simple word rules miss.
Why I passed
We tested it on 56 real first messages. The word rules scored 0.57. Two models scored 0.59 and 0.54. No option was clearly better than the others. The word rules are free, instant and private, so they won.
What would change my mind
A model that scores clearly higher on the same 56 messages.

Timed check loops

What it was
Alfred wakes up every few minutes to see if a long job is done.
Why it looked good
It is the simplest way to wait for something.
Why I passed
Every wake-up re-reads the whole conversation. A small script that waits, and then rings a doorbell, costs nothing while it waits.
What would change my mind
A job that needs judgement at every check, not only at the end.

A summary of every session, written by a cheap model

What it was
A small model writes a short summary of each finished session into the notes.
Why it looked good
Old sessions become short notes that are quick to read.
Why I passed
The archive is already searchable as plain text. Summaries cost usage, and a summary can be wrong. This one is marked 'maybe later'.
What would change my mind
The plain-text search stops finding things in old sessions.
Idea from
a second-brain video by Nick Saraev

The largest model for everything

What it was
Use the most capable model as the default for every session.
Why it looked good
The best answers, every time.
Why I passed
It uses the weekly allowance fastest, and most work does not need it. The largest model runs only when I pick it.
What would change my mind
A plan where usage is not the limit.
Who I learned from2 people

Nick Saraev

What they make
Practical videos about AI agents.
What I took
A second-brain video (2026-11-09) led to our recall search and our session archive.
What I passed on
From the same video: private message feeds into the notes, a search before every prompt, and a summary of every session.

Hamel Husain

What they make
Writing about evals: how to measure if an AI setup got better.
What I took
Measure before you believe. We test on real examples: 24 recall questions, and 56 real first messages for the session picker.