A well-integrated LLM solves tasks that used to require human reading and judgment: answering questions from documents, classifying tickets, extracting data from text and executing actions in systems. Poorly integrated, it invents answers and produces unpredictable cost. The difference lies in the engineering around the model.
We have hands-on experience: customer service with AI agents on WhatsApp; and our own platform, AgentHub, which supports products for clinics, insurance brokers, real estate agencies and condominiums.
RAG in practice
RAG has four stages, and each one can fail.
1. Ingestion. We clean and split documents into passages with size and overlap tuned to the content. We keep metadata: source, date, area, access permission. PDFs with tables and images need their own extraction.
2. Search. We combine vector similarity search with keyword search (hybrid search), because names, codes and acronyms escape vectors. Metadata filters prevent pulling a document from another client or an old version.
3. Reranking. A second pass reorders the retrieved passages by their real relevance to the question, and only the most relevant ones go to the model. This reduces cost and noise.
4. Generation with citation. The model answers only from the passages and cites the sources. When the passages do not cover the question, it says it does not know and hands off to a person.
Agents with tools
An agent combines the model with functions that read and change data: look up an order, open a ticket, book an appointment. Each tool has a validated input schema, least-privilege permission and an audit log. Sensitive actions ask for confirmation. Long flows use queues and persistent state, with the same messaging discipline we apply in RabbitMQ: retries, idempotency and a dead-letter queue.
Continuous evaluation
Without evaluation, tuning a prompt is a bet. From the start we build:
- A case set. Anonymized real questions, edge cases, abuse attempts and out-of-scope questions.
- Criteria. Factual correctness, use of the source, tone, refusal when appropriate and correct tool execution.
- Evaluators. Deterministic rules, a calibrated judge model and human sampling.
- Execution in the pipeline. On every change of prompt, model or knowledge base, the set runs and compares with the previous version. A regression blocks the deploy.
- Production monitoring. Samples of real conversations enter the set, and the set grows with use.
Cost per call
We record, per step, input and output tokens, latency and cost. The dashboard shows cost per conversation, per client, per model and per day. The levers:
- a smaller model for classification and extraction, a larger model only for hard reasoning;
- caching of answers and embeddings;
- lean context, with reranking and history summarization;
- limits per conversation and per user;
- batch processing for non-urgent tasks.
That way the monthly bill can be forecast before volume grows.
Security and privacy
Masking of personal data before sending when the case allows, access control in search, defense against prompt injection, audit logs and a retention policy. We respect privacy law, with a legal basis and consent where the law requires. Content the user types is treated as untrusted input, and never as instruction.
Working with a Brazilian team
Our engineers are based in Brazil, in time zones that overlap with the US working day, and we communicate in English.
How we deliver in weeks
- Our own boilerplates. Agent orchestration, a RAG pipeline, an evaluation and cost dashboard, WhatsApp connectors and queues already built.
- AI agents with senior review. Agents write and review code, and senior engineers approve each delivery.
- The same team from assessment to deploy. The people who understand the process build and operate the agent.
- Fixed scope after the assessment. The free assessment defines use case, sources and criteria, with a timeline of 2 to 4 weeks for an agent.
Common mistakes we fix
Passages that are too large. The model receives noise and the answer gets diluted. We tune the size per document type.
An outdated knowledge base. Old documents coexist with new ones and produce contradictory answers. Each passage has a date and version, and search prioritizes the current one.
No plan for what the agent does not know. The agent must know how to stop. We define the polite refusal, the attempt limit and the handoff to a person, with the conversation history attached.
Changing models without testing. The provider updates the model and behavior shifts. The evaluation pipeline detects the difference before the customer does.
Ignored latency. On WhatsApp or voice, seconds matter. We use streamed responses, context prefetching and smaller models in the fast steps.
When not to use an LLM
If the rule is fixed and known, ordinary code solves it with more predictability and lower cost. If an error has serious consequences and there is no human review, the LLM comes in as support, and the final decision stays with a person. We say so in the assessment, before any contract.
Related
This work is part of the AI agent development service. Request the free assessment.