Your agent rebuilds an expensive document-embedding index from scratch on every run, even when the documents…
Your agent rebuilds an expensive document-embedding index from scratch on every run, even when the documents haven’t changed.
- APersist the index and rebuild it only when the documents change
- BKeep rebuilding it every run to be safe
- CMove the rebuild onto a faster model
- DStore the raw user question in memory instead
Answer: A
Persist the index and rebuild it only when the documents change
Why
Stable, expensive-to-produce results should be persisted and reused; recompute only what is cheap or volatile. Rebuilding unchanged data every run just burns time and money.
- MemoryYour agent keeps its long-term memory in one global store.
- MemoryYour agent saved a user’s shipping address a year ago and now answers a delivery question with it - but the user moved months ago.
- MemoryLong-term memory filled up with one-off details («asked about invoice #412»), and retrieval now returns noise.
- MemoryA long-running assistant needs to remember facts across many sessions.
More on Way of the Agent
- Course programThe first three modules are free: start in the browser or the app, no card needed.
- Library: guides, skills and promptsReady prompt templates, grouped into collections.
- AI ChroniclesSourced stories from the history of AI.
- ConceptsPlain-language explainers of agent engineering.
- Learn AI agentsApps and courses for learning AI agents, compared honestly.
Real situations from building agents - with the answer and why.
Solve a new one every day on the Path