Documentation
¶
Overview ¶
Package runner executes a filtered set of benchmark cases against DocsGPT agents and collects a structured, JSON-serializable result tree.
Each case resolves its own effective settings (target, agent, model, base URL, timeout, repeat/min_pass) from the suite defaults plus runtime overrides, sends its question(s) through the chosen wire protocol (internal/bench/target), evaluates the answer with internal/bench/assert (and, optionally, the LLM-as-judge in internal/bench/judge), and reports a per-run/per-case verdict.
Index ¶
Constants ¶
const ( EventCaseStart = "case_start" EventRunDone = "run_done" EventCaseDone = "case_done" EventGolden = "golden" // record mode: a golden.json was written (Msg = path) EventModel = "model" // RunMatrix: a model's run starts (Msg = model, Run = 1-based index) )
Event types emitted through Options.OnEvent.
const SchemaVersion = 2
SchemaVersion is stamped into every SuiteResult so persisted run history and external consumers can detect format changes.
1: initial format
2: model, first_output_ms, cost_usd, judge {score,reasoning}, turns,
error_response, frames; answer target; matrix documents
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CaseResult ¶
type CaseResult struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Tags []string `json:"tags,omitempty"`
Target string `json:"target"`
Model string `json:"model,omitempty"` // effective model ("" = agent default)
Status Status `json:"status"`
SkipReason string `json:"skip_reason,omitempty"`
Runs []*RunResult `json:"runs,omitempty"`
PassedRuns int `json:"passed_runs"`
RequiredPass int `json:"required_pass"`
Repeat int `json:"repeat"`
DurationMS int64 `json:"duration_ms"`
}
CaseResult aggregates one case across its (possibly repeated) runs.
type ErrorResponse ¶
type ErrorResponse struct {
Status int `json:"status,omitempty"`
Message string `json:"message,omitempty"`
}
ErrorResponse is the server error a negative case asserted against.
type Event ¶
type Event struct {
Type string `json:"type"`
Case string `json:"case"`
Msg string `json:"msg,omitempty"`
Run int `json:"run,omitempty"`
}
Event is one live-progress notification. OnEvent is invoked serially even when cases run concurrently, so callbacks need not be reentrant.
type JudgeResult ¶
type JudgeResult struct {
Score float64 `json:"score"`
MinScore float64 `json:"min_score"`
Reasoning string `json:"reasoning,omitempty"`
Model string `json:"model,omitempty"`
}
JudgeResult is the recorded LLM-as-judge verdict for one run.
type KeyResolver ¶
KeyResolver maps an agent reference (a key name from the config, or a literal API key) to its key value and a human-readable display name.
type Options ¶
type Options struct {
Suite *spec.Suite
Cases []*spec.Case // pre-filtered; empty is an error
ResolveKey KeyResolver
BaseURL string // config base URL; lowest URL precedence
URLOverride string // --url; wins over case/suite/config
AgentOverride string // --key; wins over case/suite agent and agent_id
// Token is the personal access token (--token > DOCSGPT_TOKEN > config).
// It authenticates agent_id runs (scope chat:run), their attachment
// uploads, and the /api/models pricing fetch. Runs that use an agent API
// key are unaffected by it.
Token string
// AgentIDOverride (--agent-id) runs every case against this agent id with
// the token; mutually exclusive with AgentOverride.
AgentIDOverride string
ModelOverride string // --model / --matrix entry; wins over case/suite model
TargetOverride string // --target
WebhookURLOverride string // --webhook-url; wins over case/suite webhook_url
Concurrency int // resolved by the caller (flag > suite config > 1)
RepeatOverride int // 0 = defer to spec
MinPassOverride int // 0 = defer to spec
TimeoutOverride time.Duration
PollIntervalOverride time.Duration // --poll-interval; 0 = defer to spec
RunTag string // --run-tag / bench.yaml run_tag
FailFast bool
UpdateGolden bool // `bench record`/--update: overwrite golden.json from run 1
NoPricing bool // skip the /api/models pricing fetch (tests, offline)
Judge *spec.JudgeAgent // resolved default judge agent (may be nil)
OnEvent func(Event) // nil-safe live progress callback
}
Options configures a single Run.
type RunResult ¶
type RunResult struct {
Index int `json:"index"`
Status Status `json:"status"`
Error string `json:"error,omitempty"`
Assertions []assert.Result `json:"assertions,omitempty"`
Answer string `json:"answer,omitempty"`
Usage *target.Usage `json:"usage,omitempty"`
LatencyMS int64 `json:"latency_ms"`
FirstOutputMS int64 `json:"first_output_ms,omitempty"` // time to first token; 0 = not observed
CostUSD *float64 `json:"cost_usd,omitempty"` // usage × pricing; nil when unknown
SourceCount int `json:"source_count"`
ToolCalls []string `json:"tool_calls,omitempty"`
Frames []string `json:"frames,omitempty"` // stream target: SSE frame types seen
Judge *JudgeResult `json:"judge,omitempty"` // recorded verdict (score + reasoning verbatim)
ErrorResponse *ErrorResponse `json:"error_response,omitempty"` // negative cases: the server error asserted on
Turns []*TurnResult `json:"turns,omitempty"` // multi-turn cases: every turn (Answer = last)
}
RunResult is one execution of a case: the answer, its assertions, and stats.
type SuiteResult ¶
type SuiteResult struct {
SchemaVersion int `json:"schema_version"`
Suite string `json:"suite"`
Dir string `json:"dir"`
AgentLabel string `json:"agent_label"`
Target string `json:"target"`
Model string `json:"model,omitempty"` // effective model when every case shares one; "mixed" otherwise
RunTag string `json:"run_tag,omitempty"`
StartedAt time.Time `json:"started_at"`
DurationMS int64 `json:"duration_ms"`
Cases []*CaseResult `json:"cases"`
Totals Totals `json:"totals"`
}
SuiteResult is the top-level, JSON-serializable outcome of a Run.
func Run ¶
func Run(ctx context.Context, opts Options) (*SuiteResult, error)
Run executes opts.Cases with a worker pool of opts.Concurrency and returns a fully populated SuiteResult. Per-case problems (missing agent, upload failures, target errors) are captured in the result tree, not returned as an error; Run only errors on invalid Options.
type Totals ¶
type Totals struct {
Pass int `json:"pass"`
Fail int `json:"fail"`
Skip int `json:"skip"`
Error int `json:"error"`
}
Totals counts case statuses.
type TurnResult ¶
type TurnResult struct {
Index int `json:"index"`
Question string `json:"question"`
Answer string `json:"answer,omitempty"`
ConversationID string `json:"conversation_id,omitempty"`
LatencyMS int64 `json:"latency_ms"`
FirstOutputMS int64 `json:"first_output_ms,omitempty"`
Usage *target.Usage `json:"usage,omitempty"`
Assertions []assert.Result `json:"assertions,omitempty"` // per-turn expect only
}
TurnResult is one turn of a multi-turn run.