# A customer-support agent grounded in your docs



Learn how to build a RAG-based support agent using Podstack’s serverless GPU inference to provide accurate, documentation-grounded technical answers.



Agents · 2026-11-20 · 3 min read



Modern customer support has moved beyond simple keyword matching. Today, developers need agents that not only understand natural language but are strictly grounded in technical documentation to prevent "hallucinations." Building a Retrieval-Augmented Generation (RAG) system is the standard approach, but the challenge lies in deploying the inference and embedding logic without managing complex infrastructure.

In this guide, we will build a production-ready support agent grounded in a custom documentation set. We will use a vector database for storage and Podstack to handle the heavy lifting of GPU-accelerated inference for both embeddings and response generation.

## The Architecture of a Grounded Agent

A grounded agent operates in three distinct phases:
1.  **Ingestion:** Your documentation (Markdown, PDF, or HTML) is broken into chunks and converted into high-dimensional vectors using an embedding model.
2.  **Retrieval:** When a user asks a question, the system converts that query into a vector and finds the most relevant chunks in your documentation.
3.  **Generation:** The relevant chunks are passed to a Large Language Model (LLM) as context, instructing it to answer using *only* the provided information.

## Setting Up Your Environment

To follow along, you will need a Podstack account. We will use the Podstack API to deploy our inference functions. First, authenticate your environment:

```text
Podstack does not ship a command-line interface. Use the console, the Python package `podstack-sdk`, or the API at https://podstack.ai/api/v1 with a `ps_live_` key.
```

We will use two models: `bge-small-en-v1.5` for lightweight, fast embeddings and `Llama-3-8B-Instruct` for the final response generation.

## Implementing the RAG Logic

The core of our agent is a Python function that manages the flow. We can deploy this as a Podstack Function, which gives us the benefit of per-second billing—we only pay for the GPU time used during the actual inference.

Here is a simplified implementation of the grounding logic:

```python
import podstack
from qdrant_client import QdrantClient

# Initialize Podstack clients for serverless inference
llm = podstack.Inference(model="llama-3-8b-instruct")
embedder = podstack.Inference(model="bge-small-en-v1.5")

def support_agent(user_query: str):
    # 1. Embed the user query
    query_vector = embedder.embed(user_query)
    
    # 2. Retrieve relevant docs (Assuming a pre-filled Qdrant collection)
    client = QdrantClient("http://your-vector-db:6333")
    search_result = client.search(
        collection_name="docs",
        query_vector=query_vector,
        limit=3
    )
    
    context = "\n".join([res.payload['text'] for res in search_result])
    
    # 3. Generate grounded response
    system_prompt = f"""
    You are a technical support agent. Use the following documentation to answer:
    {context}
    If the answer is not in the context, say you don't know. Do not make up facts.
    """
    
    response = llm.complete(
        prompt=user_query,
        system=system_prompt,
        temperature=0.2
    )
    
    return response.text
```

## Practical Tips for Production

### 1. Chunking Strategy
Don't just split by character count. Use "recursive character splitting" that respects headers and code blocks. If a code snippet is split in half, the LLM will lose the context of the implementation, leading to broken support advice.

### 2. The "I Don't Know" Threshold
When retrieving context from your vector store, check the similarity score. If the highest score is below a certain threshold (e.g., 0.7), the user is likely asking something outside your documentation. In these cases, bypass the LLM and direct them to a human agent immediately to save on inference costs.

### 3. Latency Optimization
For a support chat, latency is king. Using Podstack’s serverless endpoints allows you to stream the LLM response. By setting `stream=True` in your inference call, you can show the user the response word-by-word, significantly improving the perceived speed of the agent.

## Deploying to Podstack

The beauty of this workflow is that you don't need to configure CUDA versions or manage Docker images for your GPU nodes. You can deploy your entire support logic as a Podstack Function.

To deploy the logic we wrote above, simply use the API:

```text
Podstack does not ship a command-line interface. Use the console, the Python package `podstack-sdk`, or the API at https://podstack.ai/api/v1 with a `ps_live_` key.
```

This command wraps your Python script into a scalable endpoint. Podstack will automatically spin up the necessary GPU resources when a request comes in and spin them down immediately after, ensuring you aren't paying for idle time while waiting for customers to type.

## Closing

Building a grounded customer support agent ensures your AI stays helpful and accurate. By offloading the embedding and generation tasks to Podstack, you gain access to high-performance GPUs on a per-second basis, making it cost-effective to scale from a few beta users to thousands of concurrent support tickets. 

Whether you are using on-demand GPUs for periodic document re-indexing or serverless endpoints for real-time chat, Podstack provides the infrastructure to keep your agents responsive and your documentation useful.
