The Real Fullstack

The Overflowing Context

The rules are in the system prompt. Why does the assistant act as if it never read them?

مهندس9 دقيقةمختبر تصحيح الأخطاءمختبر الأداء
llmragvector-dbpython

لم يُترجم هذا التحدي إلى العربية بعد. أنت تقرأ النسخة الإنجليزية.

المهمة:Find why the model ignores its rules, then bring each prompt back inside a deliberate token budget with the best evidence first.السياق · أهداف التعلّم ▾

Fernpost's support assistant retrieves 40 chunks per question “to be safe” and sends the whole chat history. Prompts reach 41,000 tokens against a 32,768 limit; the client library truncates from the start — where the system rules are. Costs tripled and answers ignore the citation rules.

المهمة: Find why the model ignores its rules, then bring each prompt back inside a deliberate token budget with the best evidence first.

أهداف التعلّم

  • Treat the context window as a budget, not a bucket.
  • Rerank and keep few, relevant chunks.
  • Never let a client silently truncate the system instructions.
المحاكاةمحاكاة
customerassistant backendvector DBLLM
تشغيل المحاكاة
BUDGET = 8_000                       # tokens for retrieved contextrules = load_system_rules()           # always sent, never truncatedcandidates = vector_db.search(query, k=40)ranked = reranker.rank(query, candidates)[:6]      # best evidence first, few chunkscontext = fit_to_budget(ranked, BUDGET, count_tokens)history = summarize(chat_history, max_tokens=1_000)prompt = [system(rules), *history, user(question, context)]assert count_tokens(prompt) < MODEL_LIMIT - MAX_OUTPUT   # fail loudly instead of silently truncating

تبسيط

Three symptoms with deterministic fixes. Real budgets depend on the model's limits and the output length you reserve. نموذج تعليمي — الأرقام توضّح سلوكًا وليست قياسات أداء.

المفاهيم

مفيد قبل هذا التحدي

تحديات ذات صلة

المراجع