Deprecated: Using null as an array offset is deprecated, use an empty string instead in /home/u876752588/domains/capria.vc/public_html/wp-content/plugins/jet-engine/includes/components/blocks-views/dynamic-content/manager.php on line 113
1. Stop unqualified traffic at the edge
What it is. Add a pre-screen step before the main pipeline. It decides whether to answer from a stocked response, route to a lightweight lookup, or pass to the full LLM workflow only when needed.
Why does it work? Most token waste comes from trivial greetings, duplicate questions, or requests that don’t need reasoning.
A tiny classifier (rules + embeddings or a small model) labels each request: “FAQ,” “needs retrieval,” or “needs generation.”
- If “FAQ,” return a cached answer.
- If “needs retrieval,” fetch a doc snippet directly.
- Only send to the long agentic path when the label is “needs generation.”
Example: User types “How do I reset my password?” Pre-screen matches an FAQ. You display the verified answer immediately. The LLM never runs. Tokens saved.
Note: Keep the pre-screen stateless and cheap. A simple cosine-similarity match against 50–200 normalized FAQs is often enough.
2) Cache answers that do not change often
What to cache. Documentation-type answers, policy explanations, deterministic how-to steps, anything retrieved from your own docs. Do not cache results that depend on user state or external API mutations.
Quality control. Seed the cache with human-reviewed answers; optionally collect thumbs-up feedback. Do not rely only on end-user voting to validate truth.
Key idea.
Key = normalized question + doc version hash
Value = approved answer + metadata (owner, last reviewed, sources)
Example. “Change billing email” → returns curated steps from the latest Billing doc. If the doc updates, the hash changes and you invalidate stale entries automatically.
3) Make prompts smaller and stricter
Principle. Treat prompts like code. Version them, shorten them carefully, and only keep trims that pass tests. Try the trimmed prompt across multiple models and keep whichever holds quality with fewer tokens.
Before.
“Write a comprehensive, friendly, empathetic, highly detailed explanation including background and best practices.”
After.
“Answer in ≤120 words. Use 3 bullets. Reference 2 doc titles.”
Why does it work for everyone?
Shorter instructions reduce input and, more importantly, constrain output length and style.
Tip: Maintain an A/B suite of 100–200 real tasks. Ship a prompt only if it wins on both quality and token SLOs.
4) Control outputs, not just inputs
Core idea. Output tokens balloon costs. Ask the model to return references to content, not the content itself, then let your app assemble the final text.
RAG pattern.
Prompt: “Return JSON of {answers:[{chunk_id:string, reason:string}]}. Do not include chunk text.”The client fetches chunks by
chunk_id from storage and renders them. The model writes 80 tokens instead of 800.
OCR pattern.
Prompt the vision model for exactly the fields you need.
Prompt: “Return JSON with invoice_number, date, total, tax_id only.”
No prose, no redundant descriptions.
Non-tech view. You ask the assistant for index cards of where to look, not full printouts. Your UI pulls the exact lines later, so you don’t pay the model to retype long passages.
5) Fix agent loops and orchestration chatter
The problem. Agents can get stuck “thinking” and re-asking tools, burning tokens and time. Teams in your notes flagged loop detection and depth control as a core need.
Tighten the loop.
- One-shot prompting per subtask.
- Give each agent a very small job description and cap it at three things max.
- Validate outputs against a JSON schema. If invalid, retry once with the error message. If still invalid, abort and escalate.
Human-readable example. Instead of “Summarize this PDF, extract tables, compute KPIs, write an email,” split into:
- Extract tables,
- Compute KPIs,
- Draft a 120-word email using KPI JSON.
Instrumentation.
Track per-turn tool calls, tokens, and success. Alert when an agent hits the cap.
6) Prefer deterministic paths over LLM reasoning
Use LLMs to choose an endpoint, not to build the answer. Your meeting notes called out the choice between querying a database via APIs versus letting the model write SQL. Prefer prebuilt APIs where possible to control cost and correctness.
Example.
Don’t ask the model to “craft SQL to fetch last 30-day orders.” Ask it to pick between /orders?range=30d and /orders?range=7d, then call the chosen API. Tokens near zero, accuracy high.
7) Testing and acceptance criteria
How this becomes business-ready.
Teams in your notes target 90–95% accuracy before production and use manual validation plus simple outcome metrics.
Ship with SLOs.
- Token SLOs: “Median tokens per resolved request ≤ X; P95 ≤ Y.”
- Quality SLOs: accuracy on a golden set, bounce rate for outbound agents, human-flag rate.
Rollout plan.
Shadow → canary → 100% with dashboards showing token spend by stage and cache hit rate. (This mirrors the “control over outcomes and costs” theme in your meeting notes.)
Quick recipes you can copy
A) Intake triage rule
If query cosine-matches any of top 100 FAQs above 0.75, serve cached answer; else forward to planner.
B) Cache write policy
Miss path: full pipeline runs, answer is reviewed once by an internal owner, then saved with a doc version hash. Expire entries when docs change.
C) Prompt length contract
“Respond in ≤120 words, 3 bullets, end with 1 action step.” Keep a test set; only adopt the trimmed prompt if quality holds.
D) RAG contract
“Return only chunk IDs and reasons, not text. JSON schema: …” Client assembles the final view from storage.
E) Agent guardrails
Each task: max 3 tool calls. One retry on schema-invalid. Then bail with a crisp error to a human queue.
F) Deterministic first
Prefer /api/* over model-generated SQL. Let the LLM choose the endpoint only.
A simple mental model for non-technical readers
Think of the assistant as a call center with three desks.
- Reception desk filters “hello” and FAQs so experts don’t get interrupted.
- The filing desk fetches known documents and answers from drawers already labeled.
- Only the expert desk writes new answers, and it does so with short notes and pointers, not long essays.
This keeps service fast and consistent while cutting the time and money you spend on each request.
If you want, we can turn this into a one-page checklist for your team and a 10-slide internal deck with before/after token numbers and example prompts.
