ViteHub is still experimental. Expect bugs and breaking changes.

Observability

Attach lifecycle events, model instrumentation, and eval-visible finish metadata.

observability() gives an Agent Definition one place to attach runtime telemetry. It can instrument model execution, emit lifecycle events, and provide a finish extension with invocation status, duration, and result kind.

Installation

Import the Capability factory from @vite-hub/agent/capabilities and add it to defineAgent({ capabilities }).

server/agents/support.ts
import { defineAgent } from '@vite-hub/agent'
import { observability } from '@vite-hub/agent/capabilities'

export default defineAgent({
  driver: { model },
  capabilities: [
    observability({
      onEvent: async event => writeAgentEvent(event),
    }),
  ],
})

What it adds

The Capability emits a start event before driver execution. When onEvent is configured, it also emits a finish or error event after the invocation completes. onEvent is a telemetry sink; sink failures are swallowed so observability cannot change Agent output or hide the original driver failure.

It provides an observability finish extension with { status, durationMs, resultKind } for completed invocations and { status, durationMs } for failed invocations. Agent Evals and the Agent test runner capture this finish extension automatically.

Eval assertions

Use the built-in scorer or the test callback helpers when an eval should prove the observability path is attached.

server/agents/support.eval.ts
import { defineEval, hasCapabilityExtension } from '@vite-hub/agent/eval'
import support from './support'

export default defineEval({
  agent: support,
  scorers: [
    hasCapabilityExtension('observability', 'status'),
  ],
  async test(t) {
    await t.send('Check order status')
    t.hasCapabilityExtension('observability')
  },
})

For custom checks, read observation.extensions.get('observability') or t.capabilityExtension('observability').

Driver support

Agent DriverSupport
Model-backedSupports model instrumentation, lifecycle events, and finish extensions.
Harness-backedSupports lifecycle events and finish extensions; instrumentation applies only to model-backed execution.
Custom-run-backedSupports lifecycle events and finish extensions around the custom result.

Reference

Copyright © 2026