Evals

API

Every public name in viewportai.evals and @viewportai/evals, side by side, with the modules and subpaths they live in.

Python is viewportai.evals (PyPI viewport-evals); TypeScript is @viewportai/evals (npm). Concepts and names match; each language keeps its own idiom (snake_case and keyword arguments in Python, camelCase and option objects in TypeScript). Wire data, such as expect: blocks, verdicts and reports, uses the same snake_case keys in both.

Parity table

ConceptPythonTypeScript
Capture a runwith trace() as t: / async with trace() as t:const t = await trace(fn, options?)
Trace optionssink, fixture, mode, instrument, pricing, judge, assertions, replay, allow_empty, input, clock, patch, ids, storesink, fixture, mode, instrument, pricing, judge, assertions, replay, allowEmpty, clock, patch, ids, store
The resultTraceTrace
Tool called?t.called("x", a=1) returns a truthy Checkt.called("x", { a: 1 }) returns a boolean
Full expectationst.meets({...}), await t.ameets({...}) return a Checkawait t.meets({...}) returns a Check
Invariantst.upholds(invs) (a truthy Check), t.violations(invs), violations(invs, trajectory), load_invariants(path), parse_invariants_file, Invariant, Violation, InvariantLoadError, InvariantWarningt.upholds(invs), t.violations(invs), violations(invs, trajectory), loadInvariants(path), loadInvariantsSync, parseInvariantsFile, InvariantLoadError
Worldsworld(name, state=) with @w.tool, w.create(seed), w.extend(...), World, WorldInstance, WorldError, WorldChange, WorldFaultdefineWorld({ name, state }).tool(name, spec, fn), w.create(seed), w.extend({ name }), World, WorldInstance, WorldError
World packsviewportai.evals.worlds: crm, calendar, payments, inbox@viewportai/evals/worlds: crm, calendar, payments, inbox, packs
Simulated clocksimulated_clock(start), SimulatedClock, current_simulated_clock(), trace(clock=, patch=)simulatedClock(start), SimulatedClock, currentSimulatedClock(), trace(fn, { clock, patch })
Production replayimport_traces, parse_traces, sample_traces, redact_trajectory, ImportedTrace, RecordedTools (serve with core's tool_server)importTraces, parseTraces, sampleTraces, redactTrajectory, langfuseTraces, langsmithTraces, braintrustTraces, RecordedTools (serve with core's withToolServer)
Behavior difft.diff(baseline), trajectory_diff(a, b), format_diff, TrajectoryDifft.diff(baseline), trajectoryDiff(a, b), formatDiff
Simulated usersconverse(agent, user), run_cases(..., user=), viewportai.evals.simulate: Conversation, UserTurn, openevals_userconverse(agent, user, options), runCases(cases, { user, maxTurns }), Conversation, UserTurn, openevalsUser
Model matrix and flakesrun_cases(..., models=, repeat=), CaseInput.modelrunCases(cases, { models, repeat }), CaseInput.model
Test fixturetrajectory and clock (pytest fixtures)none; call trace() in the test
Assertion matchersplain assert on the TracetoHaveCalledTool, toHaveModelCalls, toBeWithinBudget, toHaveRequestedApproval, toHaveLoadedSkill, toUphold, toMeet from @viewportai/evals/vitest
Repeated runs@pytest.mark.viewport(runs=, pass_threshold=, min_passes=)repeat({ runs, passThreshold, minPasses }, fn), throws RepeatError
YAML cases as testscollected automatically by the pytest plugindescribeCases(globs, options?) from @viewportai/evals/vitest/cases
Load casesload_cases(globs, cwd=), parse_case_file(text, file), find_case_files, is_case_document, CaseFileWarningloadCases(globs, { cwd, onWarning }), loadCasesSync, parseCaseFile(text, file), isCaseDocument
Run casesrun_cases(cases, config=, mode=, ci=, concurrency=, store=, reporters=, results=), run_case, arun_cases, arun_case, RunOptions (every field optional)runCases(cases, { config, mode, ci, concurrency, store, clock, ids, signal, onCaseStart, onCaseDone, reporters, results }), runCase
Evaluate a trajectoryevaluate(expect, trajectory, ctx), aevaluateevaluate(expect, trajectory, ctx) (async)
Config file[tool.viewport.evals] in pyproject.tomlviewport.config.ts, key evals
Build config in coderesolve_config(agent=, agents=, cases=, ...), load_config()defineConfig({ evals }), resolveConfig(config), loadConfig(), validateConfig, configFromEnv
Register an agentagent = "module:attr" in config, or @agent / @agent("name")agent / agents in config
Agent inputCaseInput (prompt, history, context, session, case_id, turn, worlds, event, episode, model)CaseInput (prompt, history, context, session, caseId, turn, worlds, event, episode, model, signal)
Assertion plugin@assertion("name"), returning bool or OutcomedefineAssertion({ options, check }), registered under assertions
Judgesllm_judge(complete=), judge(rubric, threshold=)llmJudge({ complete, prompt? }), judgePrompt, judge(rubric, { threshold })
Matcher helpersequals lt lte gt gte contains not_contains icontains starts_with ends_with regex len_ is_ exists jsonpath json_schema any_of all_of not_ fields judgesame in camelCase, len, is, not, plus the m namespace
Fixture storesFileFixtureStore(root=None), MemoryFixtureStore, FixtureStore protocolfileFixtureStore, fileFixtureStoreAt(root), memoryFixtureStore, FixtureStore, fixturePathFor, parseFixture, formatFixture
PricesDEFAULT_PRICES, ModelPriceDEFAULT_PRICES, ModelPrice, mergePrices, trajectoryCost
Adaptersinstrument(option)instrument(option), AUTO_INSTRUMENT
ErrorsViewportEvalsError, FixtureError, ConfigError, CaseLoadErrorsame, plus ReplayMissError
Version__version__version in package.json

Loading by glob keeps only case files: a $schema naming the case schema, or a top-level input or cases. Other YAML under evals/ is skipped by the pytest plugin, load_cases / loadCases and both CLIs; one that looks like a mistyped case (inputs:, or expect without input) warns not a case file?. A file given by path always loads, so its errors show.

The pytest plugin collects every case file the cases globs match. When your cases need setup pytest does not do (a database, a launched worker), turn collection off with collect = false under [tool.viewport.evals] and run them with viewport-evals run or run_cases, or narrow it with collect = ["evals/golden/**/*.yaml"]. collect only affects the pytest plugin; the CLI and run_cases still use cases. In TypeScript, YAML cases become tests only where you call describeCases, so there is nothing to turn off.

config is optional everywhere: without it, run_cases reads the nearest pyproject.toml and runCases loads viewport.config.* from the working directory, as the CLI does. reporters get every hook in order (on_run_start, on_case_done, on_run_end, plus the live hooks of results_reporter), and results=True / results: true writes the results directory to the config's results_dir (or pass a directory). Both are off by default in code; the CLI and the pytest plugin turn results on outside CI.

Both re-export Viewport Core's emit and its tool helpers (tool in Python, defineTool and Tool in TypeScript). TypeScript also exports the replay internals (ReplaySession, withReplay), the dedupe helpers (dedupeEvents, dedupeModelCalls, dedupeToolCalls), setTraceFixtureResolver for other test runners, the run helpers defaultMode, isCi, MODES and requiredPasses, and every reporter. Python exposes trace_fixture(path, id) to point trace() scopes at a fixture file outside pytest.

Modules and subpaths

PurposePythonTypeScript
Main APIviewportai.evals@viewportai/evals
Test helpersviewportai.evals.testing@viewportai/evals/testing
Test runnerpytest_plugin (loaded by pytest's entry point, never imported by the main module)@viewportai/evals/vitest (setup file), @viewportai/evals/vitest/cases
Reportersviewportai.evals.reporters@viewportai/evals
Results directoryviewportai.evals.results@viewportai/evals/results
World packsviewportai.evals.worlds@viewportai/evals/worlds
Simulated usersviewportai.evals.simulate (also converse from the main module)@viewportai/evals
Anthropic SDKviewportai.evals.anthropic: wrap(client)@viewportai/evals/anthropic: wrap(client)
OpenAI SDKviewportai.evals.openai: wrap(client)@viewportai/evals/openai: wrap(client)
LangGraphviewportai.evals.langgraph: ViewportCallbackHandler, auto_instrument@viewportai/evals/langgraph: viewportCallbacks, ViewportCallbackHandler, autoInstrument
OpenAI Agents SDKviewportai.evals.openai_agents: ViewportProcessor, auto_instrument@viewportai/evals/openai-agents: viewportProcessor, autoInstrument
Claude Agent SDKviewportai.evals.claude_agent_sdk: query, capture@viewportai/evals/claude-agent-sdk: query, capture
Vercel AI SDKnone@viewportai/evals/ai-sdk: viewportTelemetry, captureMiddleware, autoInstrument
OpenTelemetryviewportai.evals.otel: span_processor, import_otlp, otlp_spans@viewportai/evals/otel: spanProcessor, importOtlp, otlpSpans
JSON Schemasviewport-evals schema@viewportai/evals/schemas/*, viewport-evals schema

Testing helpers

PythonTypeScriptWhat it is
script(*steps, model=)script(...steps, { model })a scripted model; targets below
tool_call(name, **args)toolCall(name, args)a turn that calls one tool
tool_error(name, raw)toolError(name, raw)a turn whose arguments are not valid JSON (invalid_tool_call)
reply(text)reply(text)a turn that answers and stops
turn(*steps)turn(...steps)several calls in one turn (parallel tool calls)
when(test, step)when(test, step)a turn served only when test(request) holds
.anthropic(), .async_anthropic(), .openai(), .async_openai().anthropic(), .openai(), .fetch()real SDK clients served by the script
.langgraph(), .openai_agents().langgraph(), .openaiAgents(), .aiSdk()framework models
.serve(), .claude_agent_sdk()serveScript(script), .claudeAgentSdk()the script over HTTP on 127.0.0.1
.assert_consumed(), .requests, .served.assertConsumed(), .requests, .servedchecks and inspection
fake_tool(name, returns=, raises=, handler=)fakeTool(name, { returns, raises, handler })a recorded tool with scripted behavior and a calls log
fake_judge([...])fakeJudge([...])a judge with scripted verdicts and a requests log
MemoryFixtureStorememoryFixtureStore()an in-memory fixture store
FakeClock, SequentialIds, trajectory(), collect(), normalizesamedeterministic building blocks from Viewport Core

Scripted usage is computed when you omit it (a deterministic estimate, the same in both languages) and can be set per turn with usage=. Running past the end of a script raises evals.script_exhausted with the unexpected request. Fakes emit their own model_call events, so a test with an unwrapped fake client is still captured.

On this page