5 ways to keep it tight:
Keep it lean.
Retrieve just in time, only when needed.
Compact long histories near the limit.
Keep structured notes outside the window.
Hand work to sub-agents with clean windows.
In Anthropic's retrieval tests, adding a reranker cut failed retrievals from 2.9% to 1.9%, at some extra latency.
You'll find it in Elasticsearch, Weaviate, Pinecone and Cohere Rerank.
Search wide, then rerank. Send only the best.
Fusion (RRF) merges the two ranked lists by position, so there are no weights to tune.
Then a reranker reads the query and each document together and reorders them. Search wide, then keep only the best few.
Tips that hold up:
Keep metadata like source and headings with every chunk.
Add a short line of context to each chunk.
Test chunk sizes with evals on real queries.
Skip chunking for short, self-contained items.
No chunk size fits every corpus. Measure, then tune.
Document-specific: Markdown by headings, code by functions, tables kept whole.
Parent-child: search small, precise chunks, then hand the LLM the bigger section they belong to.
So stack the defenses:
Least-privilege tools.
A human confirms risky actions.
Treat untrusted content as data, not commands.
Filter inputs and outputs.
Monitor and red-team.
No defense is complete. Layer them, limit the damage.
What attackers aim for: stealing data, triggering actions you never asked for, leaking the system prompt, or skewing the answer.
It's hard because LLMs don't separate instructions from data. There's no complete fix like there is for SQL injection.
Stay safe:
Run it in a sandbox.
Keep sensitive accounts out.
Allowlist the sites.
Have a human approve important actions.
Treat screen text as data, never instructions.
Let it click. You approve what matters.
Where it helps: forms and data entry, testing app flows, research across sites.
What to know: it's slower than you, it can misclick, it assumes things worked, and text on a page can trick it.