Most support teams still chunk long tickets into RAG fragments and lose the nuance of the full conversation. In this tutorial, I will build a single-shot support agent that ingests an entire thread history plus product documentation into one long-context request on Oxlo.ai. The result is a precise answer that references details buried thousands of tokens deep, with no vector database needed.
What you'll need
- Python 3.10 or newer
- The OpenAI SDK installed with
pip install openai - An Oxlo.ai API key from https://portal.oxlo.ai
Step 1: Connect to Oxlo.ai
I start by importing the OpenAI SDK and pointing it at Oxlo.ai. Because the platform is fully OpenAI API compatible, this is a literal drop-in replacement. I pick kimi-k2.6 for its 131K context window.
from openai import OpenAI
client = OpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")
response = client.chat.completions.create(
model="kimi-k2.6",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "ping"},
],
)
print(response.choices[0].message.content)
Step 2: Prepare the long context
Next, I define the raw text the agent will reason over. I am using a realistic multi-day support thread and a product manual excerpt. In production you would pull these from Zendesk or Confluence, but I keep everything as plain strings so the example is self-contained and runnable.
SUPPORT_THREAD = """
Customer (2024-05-01 09:12): Hi team, our nightly migration from Postgres to your warehouse failed last night. Job ID is job_99812.
Support (09:15): Thanks. I see it started at 02:00 UTC. Can you attach the full stderr log?
Customer (09:22): Attached. Last line says "RequestError: connection reset by peer".
Support (09:30): That usually signals a transient network blip. Please retry once and confirm.
Customer (09:45): Retried. Same error at the same step: "syncing table orders".
Support (10:00): I see a spike in connection attempts from your IP at 02:14. Are you using the default connection pool size of 10?
Customer (10:05): Yes, default.
Support (10:15): Increase it to 50 and retry.
Customer (10:30): Did that. It progressed further but failed at 03:00 with "RateLimitExceeded: quota breached".
Support (10:35): You are on the v2.3 API key. Default tier allows 10,000 requests per hour. Your job makes ~12,000.
Customer (10:40): We upgraded to Enterprise yesterday. Shouldn't that be higher?
Support (10:42): The billing tier updated, but the API key limit cache takes up to 24 hours to invalidate. Generate a new key in the dashboard.
Customer (11:00): New key generated. Running now.
Customer (11:30): It ran longer but failed Tuesday afternoon with "LockTimeout: could not acquire backup lock". Why Tuesday?
Support (11:35): Tuesday's failure is unrelated to the rate limit. We run a global backup snapshot every Tuesday at 14:00 UTC that locks the metastore for up to 20 minutes. Your job started at 14:05 and collided with it.
Customer (11:40): How do we avoid that?
Support (11:42): Schedule migrations outside the 14:00 to 14:30 UTC window, or use the new "resumable sync" flag in SDK v4.1.
Customer (11:50): We are on SDK v4.0.1.
Support (11:52): Upgrade to v4.1 and set resumable=true in the job config. It will pause during the lock and resume automatically.
Customer (12:00): Upgraded. Testing now.
Customer (14:00): Success. Job completed. For future reference, what is the exact retry policy recommended for resumable sync?
Support (14:05): The manual recommends exponential backoff starting at 2 seconds, doubling each attempt, with a max interval of 60 seconds and max retries of 10. If it still fails, open a priority ticket.
"""
PRODUCT_MANUAL = """
Section 4.2: Rate Limiting
Enterprise keys default to 100,000 requests per hour. After a billing tier change, generate a new API key to bypass the old cache.
Section 7.1: Backup Windows
A global metastore backup runs Tuesdays at 14:00 UTC. During this window, write locks are enforced for up to 20 minutes.
Section 8.3: Resumable Sync
Available in SDK v4.1+. When enabled, the sync engine checkpoints progress every 1,000 rows. If a LockTimeout occurs, it sleeps and retries using exponential backoff: initial_delay=2s, multiplier=2, max_delay=60s, max_retries=10.
"""
def build_user_message(context_docs, question):
return f"Context:\n\n{context_docs}\n\nQuestion: {question}"
context_docs = f"=== Support Thread ===\n{SUPPORT_THREAD}\n\n=== Product Manual ===\n{PRODUCT_MANUAL}"
Step 3: Write the system prompt
The system prompt tells the model it has the complete thread and manual in front of it, and that it must cite specifics. I keep the instructions strict to prevent hallucination.
SYSTEM_PROMPT = """You are a senior support engineer. You have the complete support thread and product manual in context. Answer the user's question using only the provided text. Cite specific details. If the answer is not present, say so clearly."""
Step 4: Run inference
Now I package the context and question into the user message and send the full payload in one shot. Because Oxlo.ai uses flat per-request pricing, the cost is the same regardless of how long the context grows.
def answer_question(context_docs, question):
user_message = build_user_message(context_docs, question)
response = client.chat.completions.create(
model="kimi-k2.6",
messages=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": user_message},
],
)
return response.choices[0].message.content
Run it
Here is the full call and the output I get back.
question = "Why did the migration fail on Tuesday and what retry policy does the manual recommend?"
print(answer_question(context_docs, question))
The migration failed on Tuesday because the global metastore backup runs every Tuesday at 14:00 UTC, enforcing write locks for up to 20 minutes. The job started at 14:05 and collided with that window.
The manual recommends using resumable sync with exponential backoff: start at 2 seconds, double each attempt, cap at 60 seconds, and stop after 10 retries.
Next steps
This pattern works for any long document stack: legal contracts, server logs, or research paper collections. Two concrete moves from here: load an entire directory of ticket exports into the context string and batch answer them, or add function calling so the agent opens a Jira ticket when it spots an unresolved bug. Either way, Oxlo.ai's flat per-request pricing keeps the bill predictable even when the context grows.
Top comments (0)