viewport-context
Progressive skill loading and per-skill tool binding for agents (Python, import viewportai.context). The model starts
with a short catalog and one tool, load_skill; each skill's instructions and tools arrive only when it loads, inside a
token budget. The npm package @viewportai/context implements the same spec, pinned by shared conformance vectors.
pip install viewport-context # or: uv add viewport-context
Python 3.11 or newer. To build from source, see https://github.com/viewportai/context#from-source.
Quickstart
Runs with no API key. In an empty folder, install the package (see above), then create these files.
Two skills, one folder each:
skills/refunds/SKILL.md
---
name: refunds
description: Issue refunds for damaged, late or wrong orders. Use when a customer asks for money back.
tools: [lookup_order, issue_refund]
---
# Refunds
Look up the order first. Refund the order total for damaged or wrong items. Refunds over $100 need a human.
skills/docs/SKILL.md
---
name: docs
description: Answer how-to questions from the help center. Use for questions about features and settings.
tools: [search_docs]
---
# Help center
Search before you answer. If nothing matches, say so instead of guessing.
tools.py
from typing import Any
from viewportai.core import Tool
async def _lookup_order(args: dict[str, Any]) -> dict[str, Any]:
return {"order_id": args["order_id"], "status": "delivered", "total": 42.5}
async def _issue_refund(args: dict[str, Any]) -> dict[str, str]:
return {"refund_id": f"R-{args['order_id']}"}
async def _search_docs(args: dict[str, Any]) -> list[str]:
return [f"How to report {args['query']}"]
lookup_order = Tool(
name="lookup_order",
description="Look up an order by id.",
input_schema={"type": "object", "properties": {"order_id": {"type": "string"}}, "required": ["order_id"]},
execute=_lookup_order,
)
issue_refund = Tool(
name="issue_refund",
description="Refund an order, in dollars.",
input_schema={
"type": "object",
"properties": {"order_id": {"type": "string"}, "amount": {"type": "number", "minimum": 0}},
"required": ["order_id", "amount"],
},
execute=_issue_refund,
)
search_docs = Tool(
name="search_docs",
description="Search the help center.",
input_schema={"type": "object", "properties": {"query": {"type": "string"}}, "required": ["query"]},
execute=_search_docs,
)
main.py
import asyncio
from tools import issue_refund, lookup_order, search_docs
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']
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) # refused: call it in the next step
print(session.prompt().tool_names) # ['load_skill', 'lookup_order', 'issue_refund']
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.
asyncio.run(main())
Run it with python main.py.
Output:
['load_skill']
lookup_order is not available yet: the refunds skill was loaded in this same step. Read its instructions, then call lookup_order in your next step.
['load_skill', 'lookup_order', 'issue_refund']
{"order_id":"A-1001","status":"delivered","total":42.5}
search_docs is not available. Load the docs skill first.
A skill's tools become callable in the next step, once a new prompt is built, so the model reads the instructions
first; a tool called in the same step as its skill's load is refused with a message to call it next step.
Adapters (extras): viewportai.context.langgraph, .openai_agents, .claude_agent_sdk (preview), .pydantic_ai,
.anthropic,
.openai; test helpers in viewportai.context.testing and pytest fixtures (tmp_skills, skills, skill_events).
CLI
The package installs a viewport-context command that lints skills, prints per-skill token costs and shows the request
a session would send. After pip install viewport-context it is on your PATH.
viewport-context lint skills
viewport-context inspect skills
Docs, examples and the design: https://github.com/viewportai/context. License: Apache-2.0.