e-naxosMAF COURSE / COURS
Français

MICROSOFT AGENT FRAMEWORK · 0.16.0-rc.1

Context budget

Compare context policies while counting auxiliary calls and lost facts.

Objectives

Choose what the model needs

Cluttered context repeats history, excerpts, logs and instructions. Before choosing a larger model, identify decision-relevant evidence, corrections, prohibitions and missing information. Size measurement helps diagnosis; reduction then requires checking that those elements survived. A shorter answer may have lost the only useful constraint.

Deterministic selection and limits

string selected = string.Join('\n', corpus.Split('\n').Where(line =>
    line.StartsWith("Client :", StringComparison.OrdinalIgnoreCase)
    || line.StartsWith("Situation :", StringComparison.OrdinalIgnoreCase)
    || line.StartsWith("Impact :", StringComparison.OrdinalIgnoreCase)
    || line.StartsWith("Contrainte", StringComparison.OrdinalIgnoreCase)
    || line.StartsWith("Point métier", StringComparison.OrdinalIgnoreCase)
    || line.Contains("billing.outbound", StringComparison.OrdinalIgnoreCase)));
if (string.IsNullOrWhiteSpace(selected))
    throw new InvalidDataException("The explicit scenario filter selected no lines. No fallback.");

demos/Demo440_ContextBudget/Program.cs · L19–L27 · 9a895c94534c

Source code · Demo440 · Folder

Demo440 reads dossier_support_volumineux.txt and selects fixture-specific prefixes plus billing.outbound. Raw text and selection then go to the model. This filter is neither a universal compressor nor a RAG engine; actual SQLite vectors remain a separate topic. Empty selection is rejected without an invented fallback summary.

The program displays characters and a character/4 estimate excluding instructions and question. Provider context capacity, harness turn count and a monetary budget are different limits. Demo440 compares policies; it implements neither the historical naive/protected/report menu nor general automatic rejection based on three input-size bands.

Compare losses before savings

ContextExperiment policies; code parameters
MechanismScope
fullFull chronological assertion history
window-last-3Last three turns; earlier corrections may be lost
generated-summary-unverifiedUnverified generated summary; empty or over 700 characters rejected
bounded-user-factsExtraction and controlled memory; every extraction costs a request
NativeWindowRequest view compacted to the last three turns; source history retained

In this fixture, Reporting/PostgreSQL are corrected to Billing/SQL Server 2022 and the nightly batch must not restart. The final question asks for module, database and forbidden action. Compare answers against those facts before claiming improvement. A recent window may have removed them, a summary may misstate them, and extracted facts remain subject to memory validation.

Account for the whole pipeline

Console.WriteLine("This line filter is deterministic selection for this fixture. Native MAF compaction and history policies follow.");
await ContextExperiment.RunAsync(chat, stop.Token);
Console.WriteLine("Experiment coverage including auxiliary calls: " + JsonSerializer.Serialize(ledger.Summarize()));
Console.WriteLine("All extraction, summary and compaction calls are reported separately. No cost or savings claim; answer quality must be evaluated separately.");

demos/Demo440_ContextBudget/Program.cs · L36–L39 · 9a895c94534c

Source code · Demo440 · Folder

The ledger includes raw/selected requests, extractions, summary, comparisons and the compacted conversation. Serialized session size measures storage, not tokens. This implementation’s sliding-window compaction does not itself generate a summary; conversation turns are still observed. Other strategies can call a model and must also be counted.

For a useful comparison, record policy, data provenance, counter coverage, auxiliary requests, duration, present and missing facts, profile and repetitions. Fixed order, warmup, cache and tokenizers can bias comparison. Prompt caching is a provider possibility without hit evidence in these outputs. No savings percentage is published here.

Experiment scope

Character counts are deterministic for the distributed file; generated answers are not. Business fidelity and performance require separate evaluation. Model routing belongs to Demo480 rather than this filter. Demo440 needs no embeddings, Qdrant or Docker. Console output contains answers intended for the learner; do not confuse it with SafeSpan.

Connect measurement and fidelity

Prerequisites

Continue reading

Previous

Next

lot012-observability-1 · 2026-10-24 · 9a895c94534cd5fc6f3da883e37e5f7856e588c1