Middleware
Resolve before generation, prepend the compiled provider projection, then record the finish event with the exact trace identity.
import { createViraMiddleware } from "@vira-behavior/ai-sdk";
const runtimeClient = { resolve: async (request: Parameters<typeof vira.resolve>[0]) => { const resolved = await vira.resolve(request); if (!resolved) throw new Error("VIRA_BEHAVIOR_NOT_RESOLVED"); return resolved; } };
const middleware = createViraMiddleware({ client:runtimeClient, request:resolveRequest });
// Wrap your existing language model; streaming and non-streaming calls remain native.Shadow
A shadow deployment supplies a separate execution plan. Run it out-of-band and record an immutable comparison; never replace the served response with shadow output.