Viewport Context
Progressive skill loading, per-skill tool binding, token budgets and cache-friendly prompt assembly, for any agent stack, in Python and TypeScript.
Status: Beta. Install from npm (@viewportai/context) or PyPI (viewport-context).
Agents get worse and more expensive as you hand them more tools and instructions. Viewport Context lets an agent
start small and grow on demand. You write skills as folders with a SKILL.md. The agent sees a short catalog and one
tool, load_skill. When it loads a skill, that skill's instructions arrive and its tools become callable on the next
step, and nothing else does. Every prompt is assembled inside a token budget, in a deterministic order that keeps the
provider's prompt cache warm.
import asyncio
from tools import issue_refund, lookup_order, search_docs # core Tool values, in tools.py next to this file
from viewportai import context
async def main() -> None:
skills = context.load_skills("skills", tools=[lookup_order, issue_refund, search_docs], budget=8_000)
session = skills.session()
print(session.prompt("My order A-1001 arrived damaged.").tool_names) # ['load_skill'] 8 skills in the catalog
print(session.prompt().budget) # 450 / 8,000 tokens (ok)
await session.call("load_skill", name="refunds") # exactly what the model does
early = await session.call("lookup_order", order_id="A-1001") # same step as the load
print(early.content) # lookup_order is not available yet: the refunds skill was loaded in this same step. ...
print(session.prompt().tool_names) # ['load_skill', 'lookup_order', 'issue_refund'] the next step starts here
order = await session.call("lookup_order", order_id="A-1001")
print(order.content) # {"order_id":"A-1001","status":"delivered","total":42.5}
refused = await session.call("search_docs", query="damage")
print(refused.content) # search_docs is not available. Load the docs skill first.
print(session.prompt().explain())
asyncio.run(main())import { loadSkills } from "@viewportai/context";
import { issueRefund, lookupOrder, searchDocs } from "./tools.ts"; // defineTool({ name: "lookup_order", ... })
const skills = await loadSkills("skills", { tools: [lookupOrder, issueRefund, searchDocs], budget: 8_000 });
const session = skills.session();
console.log(session.prompt("My order A-1001 arrived damaged.").toolNames); // [ 'load_skill' ] 8 skills in the catalog
console.log(String(session.prompt().budget)); // 450 / 8,000 tokens (ok)
await session.call("load_skill", { name: "refunds" }); // exactly what the model does
const early = await session.call("lookup_order", { order_id: "A-1001" }); // same step as the load
console.log(early.content); // lookup_order is not available yet: the refunds skill was loaded in this same step. ...
console.log(session.prompt().toolNames); // [ 'load_skill', 'lookup_order', 'issue_refund' ] the next step starts here
const order = await session.call("lookup_order", { order_id: "A-1001" });
console.log(order.content); // {"order_id":"A-1001","status":"delivered","total":42.5}
const refused = await session.call("search_docs", { query: "damage" });
console.log(refused.content); // search_docs is not available. Load the docs skill first.
console.log(session.prompt().explain());Both snippets are the quickstart examples, which run in CI with no API key and assert every value their comments show.
Where to go next
- Quickstart: the same session through a real agent loop.
- Concepts: skills, loading, tool binding, budgets and prompts.
- Guides: Vercel AI SDK, LangGraph, OpenAI Agents SDK, Claude Agent SDK (preview), Pydantic AI, your own Anthropic or OpenAI loop.
- Real cases: a support agent under a token budget and stable tool names and the catalog.
- Reference: API, testing, CLI, events.