↓ Skip to main content

Cutting the Cost of Chat Assistants: Caching and Summaries

·2486 words·12 mins·Mathusuthan

A chat assistant sends the whole conversation to the model again on every turn. So each turn costs more than the turn before it, and a long session costs much more than its replies suggest. This post shows where that cost comes from, and what caching and summaries save, and lose.

What kind of application is this ?
#

This archetype is a conversation. A person asks a question, the assistant answers, and the person asks the next question. The assistant must remember what was said before. It usually also has a fixed set of instructions, for example a policy handbook, that it uses for every answer.

A model does not remember anything between calls. To “remember”, the application sends the conversation so far with each new message. This is a stateful session: the state is the conversation, and the application carries it from turn to turn.

The deck gives three use cases. The first prompt is the one the NovaMart lab used. I wrote the other two for this post.

1

IT and HR service desk

Help an employee fix several problems in one chat: a locked laptop, a VPN error, a payroll question. Give the policy, the command and the support queue for each.

Input (turn 1 of 10)

"Today is my first day back after parental leave. Okta Verify blocked every internal app with ERR_DEVICE_POSTURE_STALE_90D. Does this error wipe my disk? Which queue handles it?"

Prompt (shortened)

[IT and HR handbook, about 9,900 tokens]
Ground every answer strictly in the Policy IDs, CLI commands, SLA durations, and ticket queue names above. Keep turns 1–9 between 110 and 180 words.

Output (shortened)

- No wipe: ERR_DEVICE_POSTURE_STALE_90D never
  triggers a disk wipe (IT-SEC-SOP-101 §1.1).
- Fix: nm-cli okta reattest --device-serial …
- Queue and SLA: IT-IAM-FASTPASS, P2 30 min.

2

Consumer dialogue

Help a shopper find a product, change a booking or fix an account problem, over several messages.

Input (turn 3)

"OK, the blue one in size M then. Can it still arrive before Saturday if I order now?"

Prompt written for this post

You are a shopping assistant for NovaMart. Use the catalog and delivery rules below. Use what the customer said earlier in this chat. Keep each reply under 80 words.

Output written for this post

Yes. The blue jacket in M is in stock in Pune.
Order before 6 PM today for Friday delivery.

3

Field operations assistant

Guide a technician through a repair, step by step. Each answer depends on what the technician found in the last step.

Input (turn 4)

"The fan spins now, but the error light still blinks twice."

Prompt written for this post

You help technicians repair NovaMart cold-storage units. Use the service manual below. Give one step at a time, and remember the results of earlier steps.

Output written for this post

Two blinks with a working fan means the
temperature sensor. Check connector J4.

How I tested it. In the NovaMart lab, I built an IT and HR service desk with a policy handbook of about 9,900 tokens. NovaMart is a made-up retailer, and all of its data is synthetic. I wrote two scripted sessions of ten turns each. In the first, an employee comes back from parental leave and has a laptop lockout, a VPN error and a payroll problem. In the second, a new engineer needs production access, has an expense on hold and asks about relocation tax. Turn 10 of each session asks for a summary of everything solved. I ran each session three times with each design, on Claude Sonnet 5.5: 12 sessions in total. This is a small sample, so read the results as what I saw in one lab, not as a benchmark.

The token profile and cost dynamics
#

The deck gives this profile for the archetype:

INPUT PER TURN
1,000 to 25,000+ tokens
Chat history and the session’s context
OUTPUT PER TURN
150 to 600 tokens
Short replies and guided steps
PER SESSION
10,000 to 40,000+ tokens
The deck calls this “session token dynamics”
WHAT DRIVES COST
History compounds
Every turn reads all earlier turns again

“History compounds” means this. On turn 1, the model reads the instructions and one message. On turn 2, it reads the instructions, message 1, reply 1 and message 2. On turn 10, it reads everything from turns 1 to 9 again, and then turn 10. You pay for all of that input on every turn.

So the cost of one turn grows in a straight line. But the cost of the whole session is the sum of all turns, and that sum grows much faster: double the turns and you pay about four times the input. This is called quadratic context growth.

Here is a real session from the NovaMart lab, without any lever. Select a turn to see what the employee asked, what the assistant answered, and how much the model had to read.

One session, full history on every turn (Sonnet 5.5)

Employee's message

Assistant's reply

Recorded session 1, first of three runs. The handbook part is about 9,870 tokens: the size the lab cached in the other design.

Each reply is short: about 400 to 1,000 tokens. But the model reads 10,600 tokens on turn 1 and 22,000 on turn 10. Over the ten turns, this session billed about 165,000 input tokens for about 6,200 output tokens. The replies are not the problem. The re-reading is.

The chart shows the average of all six sessions for each design. Use the buttons to change between the size of each turn, the cost of each turn, and the total cost so far.

Turn by turn, average of six sessions

Lower is better

Show as a table

Sonnet 5.5, cold cache. With the lever, turn 1 includes writing the cache, and turns 5 and 8 include the summary call that runs before them.

Without the lever, the context grew by about 1,250 tokens on every turn, from 10,600 to 21,900. That is inside the deck’s band of 10,000 to 40,000+ tokens. But the bill counts every turn, so one session billed 163,000 input tokens on average.

The deck’s chart shows 1,200 tokens at turn 1 and 25,000+ at turn 10. The lab started much higher, at 10,600, because the handbook is sent on every turn. It ended lower, at 21,900, because ten turns is still early in a session.

The architectural lever
#

The deck’s lever for this archetype is: “Enable prefix context caching and sliding-window memory summarization to prevent quadratic session cost.” It has two parts. They fix two different problems.

1. Cache the part that never changes
#

The handbook and the rules are the same on every turn. They are the start, or prefix, of every request. With context caching, the provider keeps that prefix ready after the first request. Later requests that start with the same prefix read it from the cache, at a much lower price.

Price, $ per million tokensNormal inputCache writeCache read
Claude Sonnet 5.52.002.500.10
Claude Haiku 5.50.100.1250.01

The first request writes the cache, and that costs 25% more than normal input. Every later request reads it at 95% less on Sonnet (90% less on Haiku). In the lab, turn 1 cost more with caching ($0.040 against $0.031). Turn 2 cost much less ($0.011 against $0.030).

A cache only lives for a short time, usually a few minutes after its last use. If one person chats slowly, the cache can expire, and the next turn writes it again. This is a cold cache. In a busy service desk, many sessions share the same handbook, so the cache stays warm. I show both prices below.

2. Summarise the older turns
#

Caching makes the handbook cheap, but the conversation still grows on every turn. A sliding-window summary stops that growth. The assistant keeps only the latest turns word for word. It replaces the older turns with a short summary.

In the lab, the assistant held up to four turns word for word. Before turns 5 and 8, a separate model call replaced all but the latest turn with a summary of at most 14 short items. The cost of that summary call is included in every number below.

Select a turn to compare what the model reads in each design.

What the model reads on one turn

Without Full history, no cache

Turns sent word for word

With Cached handbook and summaries

Turns sent word for word, or as a summary

Show the summary the model reads

Recorded session 1, first of three runs, Sonnet 5.5, cold cache. The summary size is the length of the summary call's answer. The lab ran this archetype on Sonnet 5.5 only, so there is no model switch here.

The bar on the right stays short. With the lever, the context reached 14,800 tokens at turn 10, against 21,900 without. It grew by about 290 tokens per turn instead of 1,250. And most of what remains is the cached handbook, which costs 5% of the normal price.

3. What the summary loses
#

A summary is shorter because it leaves things out. The question is which things. I measured quality in three ways, against an answer key written from the handbook and the scripted messages:

  • Answers grounded: does each reply in turns 1 to 9 give the right policy, queue, command and figures?
  • Details in the final summary: how many details from turns 1 to 9 appear in the turn-10 summary?
  • Recall questions: after turn 10, six short questions per session, each about one detail the employee said once, for example a serial number or an invoice number.

Quality without and with the lever

Higher is better

Six sessions per design. Scoring is exact matching against the answer key, so a correct answer in other words can be missed.

Three points stand out:

  • The answer to the current question did not change. Both designs gave 205 of 207 checked facts in turns 1 to 9. The handbook is always there, and so is the latest turn.
  • Exact details from older turns were lost. Recall fell from 36 of 36 to 2 of 36. Details from turns 1 to 3 in the final summary fell from 37 of 51 to 24 of 51. Details from turns 7 to 9, which were still word for word, did not fall (29 and 30 of 45).
  • The assistant did not make up the missing details. In 33 of the 34 misses, it said that the detail was not in its memory and told the employee where to find it. In one, it gave an estimate and said so ($1,780 against $1,775). It never stated a wrong value as fact.

Here are the six recall questions from session 1:

Recall questions after turn 10, session 1

Recorded answers, first of three runs. The summary kept the laptop serial number. It also held the FileVault slot ID after the first summary, but dropped it in a later one.

So the lever has a real cost in memory. For a service desk, that can be fine if the details are also stored in a ticket. If your users come back to exact numbers from early in the chat, write a summary that always keeps every ID, number and date the user gives. The lab did not test that design.

Which part saves the money? The lab also ran the cache alone, with the full conversation and no summaries. It cut the cost by 40%, from $398.68 to $239.66 per 1,000 sessions, and it changed no quality measure: recall stayed at 36 of 36. Adding the summaries cut another 11% and lost the recall. If exact recall matters, start with the cache alone.

The cost savings
#

The chart starts with the full history and no cache. Each step adds one part of the lever. Select a step to see what it saves and what it costs in recall.

Cost of 1,000 ten-turn sessions, step by step

Lower is better

Show as a table

Average of six sessions per design, including the summary calls. "Warm" prices the cache write as a cache read, as in a busy service desk where the handbook is already cached; it is calculated from the same runs. The Haiku 5.5 prices apply Haiku's rate card to the same token counts. The lab did not run this archetype on Haiku, so its quality is not known.

The two parts of the lever together cut the cost by 47% on a cold cache, from $398.68 to $212.45 per 1,000 sessions, and by 53% on a warm cache, to $188.78. The deck says the lever “prevents quadratic session cost”. In the lab, it did: the context per turn stopped growing in a straight line and moved up and down in a small band.

The savings are smaller than in the classification archetype, for two reasons. The output is not the problem here, so there is nothing to cut there. And ten turns is still early. The longer the session, the more the full history costs, and the more the lever saves. The lab did not run longer sessions.

A smaller model is a separate lever. At Haiku 5.5 prices, the same token counts cost about 95% less. But I did not run these sessions on Haiku, so I do not know if its answers would be as good.

Cost Estimator
#

Use this calculator for your own assistant. It starts with Haiku 5.5 prices and the token counts measured in the lab. Change the prices to the rates of the model that you use.

Chat session cost estimator

Prices, $ per million tokens
Your sessions
Your lever: cache and summaries

Turns held word for word: up to 4, then all but the latest go into the summary, as in the lab.

Defaults are lab averages: a 9,868-token cached prefix, 766 tokens on turn 1, 1,247 tokens added per turn, 726 output tokens per turn, and summary calls of 5,442 input and 519 output tokens. This is a simple model of the lab's design. With Sonnet 5.5 prices and these defaults, it gives $397 and $207 per 1,000 sessions, close to the measured $398.68 and $212.45. Longer sessions than ten turns were not measured.