A support agent under a token budget
Per-request extras that give way by priority, a skill load that evicts an older one, and the same load refused.
A support agent's request carries stable parts (instructions, the voice skill, the catalog) and per-request parts (today's date, the customer's order history, a policy snippet). The budget decides what gives way.
The registry
skills = context.load_skills(
"../quickstart/skills",
tools=[lookup_order, issue_refund, search_docs],
instructions="You are the support agent for Acme Outfitters. Resolve the customer's issue in as few turns as possible.",
budget=550, # input tokens Context may use per request
)const skills = await loadSkills("../quickstart/skills", {
tools: [lookupOrder, issueRefund, searchDocs],
instructions:
"You are the support agent for Acme Outfitters. Resolve the customer's issue in as few turns as possible.",
budget: 550, // input tokens Context may use per request
});Per-request extras
Extras go in the turn tier, after everything cacheable. Lower priority gives way first: truncated at a paragraph
boundary, then dropped. truncate: false keeps a section whole. Every decision is in prompt.dropped.
order_history = [f"Order A-{1000 + i}: delivered, total ${40 + i}." for i in range(12)]
session = skills.session()
prompt = session.prompt(
"My order A-1001 arrived damaged.",
extra=[
context.ExtraSection("date", "Today is 2026-11-25.", truncate=False), # never cut, never dropped
context.ExtraSection("order_history", "\n\n".join(order_history), priority=20), # gives way first
context.ExtraSection("policy", "Damaged items: refund without a return.", priority=60),
],
)
print(prompt.explain())
print(prompt.dropped) # [Dropped(id='order_history', action='truncated', tokens_saved=...)]const orderHistory = Array.from({ length: 12 }, (_, i) => `Order A-${1000 + i}: delivered, total $${40 + i}.`);
const session = skills.session();
const prompt = session.prompt("My order A-1001 arrived damaged.", {
extra: [
{ id: "date", text: "Today is 2026-11-25.", truncate: false }, // never cut, never dropped
{ id: "order_history", text: orderHistory.join("\n\n"), priority: 20 }, // gives way first
{ id: "policy", text: "Damaged items: refund without a return.", priority: 60 },
],
});
console.log(prompt.explain());
console.log(prompt.dropped); // [{ id: "order_history", action: "truncated", tokens_saved: ... }]Here the order history is cut to fit and the date and policy survive. Skills are never cut or dropped at prompt time: a skill's instructions and its tools must agree.
A load that does not fit
Loads are checked before anything changes. By default the lowest-priority, least recently loaded skills that the
model loaded are unloaded to make room, and listed in evicted; a router or trigger load is policy and is never
evicted. Their tools unbind at once; the
instructions of a skill the model loaded stay in the transcript and stay counted, and evicting it frees only its tool
schemas. Skills loaded from code are never evicted.
# By default a load that does not fit unloads older model, router and trigger loads, lowest priority first.
await session.call("load_skill", name="docs")
loaded = await session.call("load_skill", name="refunds")
print(loaded.load.evicted if loaded.load else None) # ['docs']: its tools unbind at once
session.prompt() # the model's next step
print(session.prompt().tool_names) # ['load_skill', 'lookup_order', 'issue_refund']// By default a load that does not fit unloads older model, router and trigger loads, lowest priority first.
await session.call("load_skill", { name: "docs" });
const loaded = await session.call("load_skill", { name: "refunds" });
console.log(loaded.load?.evicted); // ["docs"]: its tools unbind at once
session.prompt(); // the model's next step
console.log(session.prompt().toolNames); // ["load_skill", "lookup_order", "issue_refund"]Refusing instead
With on_over_budget="reject" (onOverBudget: "reject") nothing is unloaded and the load is refused. The model has
no tool to unload a skill, so the refusal tells it what it can do: continue with what is loaded. When a load from code
does not fit, the message (read by your code, which can call unload) names the skill to unload.
# on_over_budget="reject" keeps what is loaded; the model reads why, and what it can do (it cannot unload).
strict = skills.configure(on_over_budget="reject").session()
await strict.call("load_skill", name="docs")
refused = await strict.call("load_skill", name="refunds")
print(
refused.content
) # Loading refunds needs 220 tokens; only 176 are free. Continue with the skills already loaded.// on_over_budget "reject" keeps what is loaded; the model reads why, and what it can do (it cannot unload).
const strict = skills.configure({ onOverBudget: "reject" }).session();
await strict.call("load_skill", { name: "docs" });
const refused = await strict.call("load_skill", { name: "refunds" });
console.log(refused.content); // Loading refunds needs 220 tokens; only 176 are free. Continue with the skills already loaded.