Most RAG demos stop at one chatbot answering questions over one document set. That is the easy part.
The harder question is what happens when you ship more than one agent. Your support agent needs patience and plain language. Your sales engineer needs outcome framing. Your solutions engineer needs exact names and limits. If each agent owns its own retrieval stack, you get three vector stores to keep in sync and three places for answers to drift apart.
This Telnyx code example shows the fix on Edge Compute: build the retrieval layer once as a shared actor, and let every agent personality answer from the same embedded corpus.
The code example is here:
https://github.com/team-telnyx/telnyx-code-examples/tree/main/rag-corpus-shared-across-agents
You need a Telnyx account and the code sample. Deployed functions need no API key — inference and storage run through pre-authenticated platform bindings.
What This Example Builds
The sample is a Node.js and TypeScript app running on Telnyx Edge Compute, with two actor types.
The first is CorpusAgent. There is exactly one actor instance per corpus id, and it owns the retrieval layer:
ingest(document)
-> chunk text (size + overlap knobs)
-> TELNYX.ai.openai.embeddings.createEmbeddings({ model, input })
-> store chunks(id, doc, ord, text, embedding) in per-actor SQL
search(query)
-> embed the query
-> rank stored chunks by cosine similarity
-> return top-K with doc name and score
The vectors live in the actor's own SQLite. Every row keeps its source document, so every answer can cite where it came from.
The second is PersonaAgent. One durable actor per (corpus, persona) pair:
support -> patient, plain language, step by step
sales -> outcome framing, confident
engineer -> exact names, limits, no marketing
Each persona actor holds its own conversation history through the SDK MessageLog. Ask a follow-up and it knows what you talked about — but the facts it reasons over always come from the same shared corpus.
The Demo
The sample ships with a demo page and a knowledge base of real Telnyx platform docs (Edge Compute, Inference, Voice API).
Ask:
How do I deploy an edge function?
as the Support Agent and you get a numbered walkthrough. Ask the same question as the Sales Engineer and the same retrieval results come back wrapped in outcome framing. Ask as the Solutions Engineer and you get exact command names, no marketing.
Same sources. Same scores. Three different voices.
SOURCES
knowledge/edge-compute.txt 0.912
knowledge/inference.txt 0.821
knowledge/voice-api.txt 0.769
There is a second demo beat that buyers notice: switch the corpus id to a name with no documents, ask again, and the agent says plainly that no matching documents were found. It does not improvise.
Why This Shape
Three reasons this architecture holds up past the demo.
First, one retrieval layer to maintain. Chunking knobs, embedding model, similarity ranking — all of it lives in one actor. When you improve retrieval, every persona gets smarter at once.
Second, the facts cannot drift. The corpus actor is the single source of truth. Personas differ in voice, not in facts. If an answer cites a source, every persona citing that source is working from the same text.
Third, it is all platform primitives. Per-actor SQLite for the vector store, the pre-authenticated TELNYX binding for embeddings and chat, a Cloud Storage bucket binding for document ingestion. Deployed functions hold no API keys because the platform authenticates the bindings.
Scale Notes
At sample scale, the actor scans its chunk rows and ranks by cosine in TypeScript — instant for a demo corpus and honest about what it does. When a corpus outgrows that, swap the search for the managed ai.embeddings.similaritySearch API and Telnyx ranks the bucket server-side. The actor interface stays the same.
Run It
git clone https://github.com/team-telnyx/telnyx-code-examples.git
cd telnyx-code-examples/rag-corpus-shared-across-agents
npm install
npm run local:dev
Seed the docs, ask the same question as all three personas, then ask a follow-up and watch one persona remember its own conversation while all of them read the same knowledge base.
The full walkthrough, including the Cloud Storage ingestion path and the deployed demo, is in the example's README and GUIDE:
https://github.com/team-telnyx/telnyx-code-examples/tree/main/rag-corpus-shared-across-agents