The context brief
veya_context is the read an agent should make first. It returns a small projection of the running screen, not the full snapshot: failing signals with evidence, source-linked components, business state, diagnostics, recent events, and an explicit account of what did not fit.
Use veya_inspect when the brief is not enough. The snapshot carries the full component tree, bounds, props and every diagnostic entry.
Start with the brief, then ask for detail
The brief is designed to be cheap to read and cheap to repeat. The full snapshot is the escape hatch, not the default.
Baseline and diff
Without since, veya_context returns a baseline: the current brief. With the cursor from a previous response, it returns a diff: only what moved since that cursor. Both documents carry the current failing signals.
{
"tool": "veya_context",
"arguments": {}
}{
"tool": "veya_context",
"arguments": { "since": "ctx_7" }
}A baseline has baseline: true and components, state, diagnostics and events. A diff has baseline: false, since, and changes.components, changes.state and changes.events.
Without a sessionId, veya_context reads the newest agent session; pass the human session id to read the human window. page.mode reports which one the document came from.
What the document contains
| Field | Baseline | Diff | Meaning |
|---|---|---|---|
cursor | yes | yes | Cursor for the next call. |
generatedAt | yes | yes | When the brief was compiled. |
baseline | true | false | Which document you are reading. |
baselineReason | optional | no | cursor_unavailable when the supplied cursor could not be found. |
since | no | yes | The cursor you passed. |
budget | yes | yes | maxBytes, usedBytes and truncated. |
page | yes | yes | Snapshot time, URL, route, title, mode, viewport, channel status and the last probe viewport when one exists. |
signals | yes | yes | Current failing signals with evidence. |
components | yes | no | Flat, pre-order component outlines with parentId and source. |
state | yes | no | Business state, packed by top-level state id. |
diagnostics | yes | no | Counters, failed and slow requests, errors and performance. |
events | yes | no | Recent event summaries. |
changes.components | no | yes | added, removed and changed components. |
changes.state | no | yes | { path, previous, current } entries. |
changes.events | no | yes | Event summaries since since. |
omitted | yes | yes | How many candidates were left out, by section. |
next | yes | yes | Tool calls that return what was left out. |
Baseline example
One entry per array is shown; real responses may contain more.
{
"protocolVersion": "0.1",
"sessionId": "ses_1",
"cursor": "ctx_7",
"generatedAt": 1796145600000,
"baseline": true,
"budget": { "maxBytes": 8192, "usedBytes": 3184, "truncated": true },
"page": {
"capturedAt": 1796145599000,
"url": "http://127.0.0.1:5173/",
"route": "/",
"title": "Workspace",
"mode": "human",
"viewport": { "width": 1440, "height": 900, "dpr": 2 },
"channel": { "runtime": true, "cdp": true },
"probe": { "width": 390, "height": 844 }
},
"signals": [
{
"id": "R004-fail-0",
"rule": "R004",
"severity": "high",
"status": "fail",
"title": "Stuck loading",
"summary": "RevenueChart stayed in a loading state after a request failed",
"fixHint": "Give the request an error branch so the component leaves its loading state.",
"detectedAt": 1796145599000,
"evidence": {
"componentId": "dashboard.revenue",
"source": { "file": "src/App.tsx", "line": 38 }
}
}
],
"components": [
{
"id": "dashboard.revenue",
"type": "RevenueChart",
"name": "RevenueChart",
"purpose": "Show the revenue trend for the current quarter",
"role": "content",
"status": "mounted",
"visible": true,
"dataStatus": "loading",
"source": { "file": "src/App.tsx", "line": 38 }
}
],
"state": { "dashboard": { "projectCount": 0, "dialogOpen": false } },
"diagnostics": {
"errors": [],
"consoleErrors": 1,
"failedRequests": [
{
"requestId": "req_1",
"url": "/api/revenue",
"method": "GET",
"status": 500,
"durationMs": 12
}
],
"slowRequests": [],
"pendingRequests": 1
},
"events": [
{
"seq": 41,
"t": 1796145599000,
"type": "network.request.failed",
"traceId": "trc_1",
"summary": "GET /api/revenue failed with 500"
}
],
"omitted": {
"components": 6,
"state": 0,
"events": 12,
"signals": 0,
"diagnostics": 0
},
"next": [
{
"tool": "veya_inspect",
"arguments": { "sessionId": "ses_1" },
"reason": "Full component tree with bounds and props"
}
]
}Diff example
{
"protocolVersion": "0.1",
"sessionId": "ses_1",
"cursor": "ctx_9",
"generatedAt": 1796145610000,
"baseline": false,
"since": "ctx_7",
"budget": { "maxBytes": 8192, "usedBytes": 1204, "truncated": false },
"page": {
"capturedAt": 1796145609000,
"url": "http://127.0.0.1:5173/",
"route": "/",
"title": "Workspace",
"mode": "human",
"viewport": { "width": 1440, "height": 900, "dpr": 2 },
"channel": { "runtime": true, "cdp": true }
},
"signals": [],
"changes": {
"components": {
"added": [],
"removed": [],
"changed": [
{
"id": "dashboard.projects",
"type": "ProjectList",
"status": "mounted",
"visible": true,
"dataStatus": "ready",
"source": { "file": "src/App.tsx", "line": 55 }
}
]
},
"state": [
{
"path": "dashboard.dialogOpen",
"previous": false,
"current": true
}
],
"events": [
{
"seq": 44,
"t": 1796145609000,
"type": "state.changed",
"traceId": "trc_9",
"summary": "dashboard.dialogOpen: false → true"
}
]
},
"omitted": {
"components": 0,
"state": 0,
"events": 0,
"signals": 0,
"diagnostics": 0
},
"next": []
}The budget
The budget is UTF-8 bytes of compact JSON, not tokens. The default is 8192 bytes, the minimum is 1024 and the maximum is 65536.
{
"tool": "veya_context",
"arguments": { "maxBytes": 4096 }
}budget.usedBytes is the exact byte size of the document. veya_context returns compact JSON, so this is the tool payload. The HTTP response wraps the document in { "context": ... } and the console pretty-prints it for reading; those add a small framing cost outside the budget. budget.truncated is true when anything was left out. omitted counts what did not fit. next lists the tool calls that return it, in priority order.
The compiler packs in this order:
- Current failing signals.
- Components that are failing, loading, disabled, invisible or missing a source.
- Business state.
- Diagnostics.
- Primary-action and navigation components.
- Recent events.
- The remaining components.
When a single candidate does not fit, it is skipped and the packer tries smaller candidates. A single oversized value never breaks the document.
Asking for more
Raise maxBytes for a larger brief, or follow next: veya_inspect for the full component tree, veya_events for the event payloads, veya_state for the whole state map, and veya_signals for passing signals.
Cursor lifetime
A cursor is opaque and session-scoped. It points at a snapshot in the hub's bounded history, 32 snapshots by default. It is not an event sequence and it is not an MCP session.
- Reading
veya_contextdoes not create a new history point. The console can poll the brief without invalidating an agent's cursor. - A page reload creates a new session with new cursors.
- After the hub restarts, or after more than 32 newer snapshots, an old cursor is unavailable.
- An unavailable cursor returns a baseline with
baselineReason: "cursor_unavailable". It is not an error; continue with the newcursor.
Signals and probes
The brief reports current failing signals, in both baseline and diff mode. It does not diff signals. To compare two moments, compare two briefs or call veya_signals.
veya_context never resizes the window that owns the session and never probes. Layout rules (R005, R006) use the last probe in the session; page.probe tells you which viewport that was. Call veya_signals with a viewport when you need a fresh layout and accessibility check.
Components and events
Components are a flat, pre-order projection. parentId keeps the hierarchy without nesting arrays. bounds, props and children are omitted to keep the brief small; source is always present, and source: null is a fact from the build.
Events are summaries, not payloads. Keep the traceId and seq for follow-up. For one causal chain, call veya_trace; for raw events, call veya_events.
Through HTTP
curl -s 'http://127.0.0.1:7317/v1/sessions/<sessionId>/context?maxBytes=4096'
curl -s 'http://127.0.0.1:7317/v1/sessions/<sessionId>/context?since=ctx_7'The response is { "context": ContextDocument | null }. A session answers null until its first snapshot arrives.
Limits
- Signals are current findings; they are not a delta.
- Component sibling reordering is not reported.
- Only the last 32 snapshots are addressable; older cursors fall back to a baseline.
- The brief has no screenshots, bounds, props or full event payloads.
- A page without the runtime has no snapshot and no brief.
- A pass in the brief's signals means the rule found nothing in the evidence it had; it is not a guarantee.