Most of a long prompt is repeatable background, and only a slice of it decides the next answer. Four techniques shrink the rest: reuse identical prefixes, summarise history, retrieve a few chunks, and trim logs and RTL to the failing slice.
Technique | What it saves | Main risk |
|---|---|---|
Reuse identical prefixes | Repeat tokens across calls with the same opening | Any edit to the opening can end the reuse. |
Summarise history | Long background and old turns | Details that later questions need are dropped. |
Retrieve top chunks | Whole manuals pasted for one fact | The best chunk may rank too low to be included. |
Trim to the failing slice | Passing bulk of logs and unrelated files | The error itself gets cut when the window is too tight. |
Lesson | What it covers |
|---|---|
What stays identical can be reused, with a worked saving. | |
Compression ratios and the detail a summary drops. | |
Chunking and keyword ranking with a runnable TF-IDF toy. | |
Failing slices of logs and RTL, plus cost against quality. |
Prefix reuse applies. The specification opening must stay byte-identical for the repeat to count as reuse.