UNPKG

@adonis-agora/agent

Version:

Governed, durable-backed AI agent (chat + tool-calling + governance) for AdonisJS — part of the Agora ecosystem.

42 lines • 2.18 kB
import type { RunSampleSource } from './sample-source.js'; import type { ScoreStore } from './score-store.js'; import type { Scorer } from './types.js'; export interface LiveScoringOptions { source: RunSampleSource; scorers: Scorer[]; store: ScoreStore; /** * Fraction of finished runs to score, `0..1`. Default `1`. Turn it down for a scorer that costs * money per run — a trend needs a representative sample, not every row. */ sampleRate?: number; /** Sampler; injectable so a test can pin the decision. */ random?: () => number; now?: () => Date; /** Told about anything that went wrong. Default: swallowed — a score is never worth a log storm. */ onError?: (error: unknown) => void; } /** The handle {@link attachLiveScoring} returns. */ export interface LiveScoring { /** Detach the subscription. In-flight scoring already started still settles. */ dispose(): void; /** Resolves once every scoring started so far has settled — what a test awaits. */ settled(): Promise<void>; } /** * Score runs as they finish, by listening to `agora:agent:run.finished`. * * Opt-in: nothing calls this for you. And deliberately NOT inline in the turn — a scorer wired into * the agent loop would add its latency to every message a user sends, and a model-graded one would * double the cost of the product. This runs AFTER the run has already finished and reported so, on a * diagnostics subscriber, in a detached promise. There is no code path from a scorer back into the * turn: the run has settled and its stream has closed before the first scorer is called, and every * failure below is caught and handed to `onError`. A scorer cannot fail a turn because by the time * it runs there is no turn left to fail. * * It still costs real work per run, so the offline {@link import('./evaluate.js').runEvaluation} * batch remains the default path — reach for this when you want a dashboard that moves within the * hour, and prefer the `rule`/`statistical` scorers here. */ export declare function attachLiveScoring(options: LiveScoringOptions): LiveScoring; //# sourceMappingURL=live-scoring.d.ts.map