ContextReference

Events

Every load, unload and prompt assembly is a core event, so Viewport Evals sees it in trajectories with no setup.

Context emits to core's ambient sink: inside a trace() scope, or a Viewport Evals run, these land in the trajectory. Every API that emits also accepts an explicit sink and an on_event / onEvent listener.

type: skill_load        # one per skill per load attempt; dependencies first (via: requires)
skill: refunds
tools: [lookup_order, issue_refund]
tokens: 220             # content as placed plus newly bound tool schemas
via: model              # always | model | router | trigger | requires | manual
status: loaded          # loaded | already_loaded | over_budget | not_found | not_allowed
hash: sha256:...
evicted: []
type: skill_unload
skill: docs
reason: evicted         # manual | evicted | dependency
type: context_assembly  # one per session.prompt()
tokens: 450
budget: { input_tokens: 8000 }
sections: [{ id: catalog, tokens: 305 }, ...]
dropped: []
cache_prefix_hash: sha256:...

Every tool call through session.call is also recorded as a core tool_call, including refused ones (with the error).

OpenTelemetry (TypeScript)

@viewportai/context/otel turns these into spans with the API only (no SDK installed by us): viewport.context.assemble with viewport.context.tokens, viewport.context.budget.tokens, viewport.context.over_budget, viewport.context.dropped and viewport.context.prefix.static, and viewport.context.skill.load with the skill, via, tokens and status. Nothing logs instructions or tool arguments.

On this page