Documentation
¶
Index ¶
- type Agent
- type Case
- type CaseResult
- type Expectation
- type MaxLatency
- type Metric
- type OutputContains
- type OutputRegex
- type Result
- type RunReport
- type Runner
- type ServerCheck
- type ServerSuite
- type Suite
- type ToolCall
- type ToolCallCheck
- type ToolCorrectness
- type ToolOutcome
- type ToolServer
- type ToolsListCheck
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
Agent is the only contract the assay core depends on. Any agent — ADK, MCP, or anything else — is evaluated by wrapping it in an adapter that satisfies this interface. The core never imports a framework; it only knows this.
type Case ¶
type Case struct {
Name string
Input string
Expectation Expectation
}
Case is a single evaluation scenario: an input to send the agent and the expectations its result is scored against.
type CaseResult ¶
type CaseResult struct {
Case Case
Scores map[string]float64 // metric name -> score
Details map[string]string // metric name -> human-readable detail
Score float64 // mean of the metric scores
Err error
}
CaseResult is the outcome of running one case: its per-metric scores and the averaged case score. Err is set if the agent itself failed.
type Expectation ¶
type Expectation struct {
Tools []string // expected tool names (for ToolCorrectness)
OutputSubstr []string // substrings expected in Output
OutputRegex []string // regex patterns Output should match
MaxLatencyMS int64 // latency ceiling in milliseconds (0 = no check)
}
Expectation describes what a single case expects. Fields left empty are simply not checked by the metrics that read them.
type MaxLatency ¶
type MaxLatency struct{}
MaxLatency is a pass/fail check on run duration.
func (MaxLatency) Name ¶
func (MaxLatency) Name() string
func (MaxLatency) Score ¶
func (MaxLatency) Score(result Result, exp Expectation) (float64, string)
type Metric ¶
type Metric interface {
// Name identifies the metric in reports.
Name() string
// Score returns a value in [0,1] plus a short human-readable detail.
Score(result Result, exp Expectation) (score float64, detail string)
}
Metric scores one aspect of a Result against a case's expectations. Every metric — including future ones like an LLM judge — satisfies this same interface, which is what keeps the runner agnostic to what it's scoring.
func DefaultMetrics ¶
func DefaultMetrics() []Metric
DefaultMetrics returns the standard v1 metric set.
type OutputContains ¶
type OutputContains struct{}
OutputContains scores how many expected substrings appear in Output.
func (OutputContains) Name ¶
func (OutputContains) Name() string
func (OutputContains) Score ¶
func (OutputContains) Score(result Result, exp Expectation) (float64, string)
type OutputRegex ¶
type OutputRegex struct{}
OutputRegex scores how many expected patterns match Output.
func (OutputRegex) Name ¶
func (OutputRegex) Name() string
func (OutputRegex) Score ¶
func (OutputRegex) Score(result Result, exp Expectation) (float64, string)
type Result ¶
Result is what an agent returns from a single run: its final text output, the trace of tools it called, and how long the run took.
type RunReport ¶
type RunReport struct {
Results []CaseResult
Score float64 // mean of all case scores
Threshold float64
Passed bool
}
RunReport is the outcome of running a whole suite.
func RunServer ¶
func RunServer(ctx context.Context, ts ToolServer, suite ServerSuite) RunReport
RunServer executes every check against the ToolServer and aggregates scores into the same RunReport shape the agent runner produces — so the existing reporters (WriteText / WriteJSON) work unchanged.
type Runner ¶
type Runner struct {
Metrics []Metric
}
Runner evaluates an Agent against a Suite using a fixed set of metrics.
type ServerCheck ¶
type ServerCheck interface {
Name() string
Run(ctx context.Context, ts ToolServer) (score float64, detail string)
}
ServerCheck scores one aspect of a ToolServer. Each check performs its own operation against the server (list or call) and returns a score in [0,1].
type ServerSuite ¶
type ServerSuite struct {
Threshold float64
Checks []ServerCheck
}
ServerSuite is a named set of checks with a pass threshold in [0,1].
func LoadServerSuite ¶
func LoadServerSuite(path string) (ServerSuite, error)
LoadServerSuite reads a YAML file into a ServerSuite of checks.
type Suite ¶
Suite is a named collection of cases with a pass threshold in [0,1]. A run passes when its aggregate score meets or exceeds Threshold.
type ToolCall ¶
ToolCall records a single tool invocation: the tool's name and the arguments the agent chose to pass it.
type ToolCallCheck ¶
type ToolCallCheck struct {
Tool string
Args map[string]any
ExpectNoError bool // outcome.IsError must be false
ResultContains []string // substrings expected in outcome.Text
MaxLatencyMS int64 // 0 = no latency check
}
ToolCallCheck calls one tool and asserts on the outcome.
func (ToolCallCheck) Name ¶
func (c ToolCallCheck) Name() string
func (ToolCallCheck) Run ¶
func (c ToolCallCheck) Run(ctx context.Context, ts ToolServer) (float64, string)
type ToolCorrectness ¶
type ToolCorrectness struct {
Ordered bool // if true, call order must match expectation order
}
ToolCorrectness scores whether the agent called the expected tools. In its simplest form it checks set membership (did each expected tool get called, ignoring order and extras).
func (ToolCorrectness) Name ¶
func (ToolCorrectness) Name() string
func (ToolCorrectness) Score ¶
func (m ToolCorrectness) Score(result Result, exp Expectation) (float64, string)
type ToolOutcome ¶
type ToolOutcome struct {
IsError bool // the server reported the tool call as failed
Text string // concatenated text content from the response
Latency time.Duration // wall-clock time for this call
}
ToolOutcome is the normalized result of a single tool call, flattened from whatever the underlying protocol returns into what checks need to inspect.
type ToolServer ¶
type ToolServer interface {
// ListTools returns the names of the tools the server exposes.
ListTools(ctx context.Context) ([]string, error)
// CallTool invokes one tool by name with the given arguments.
CallTool(ctx context.Context, name string, args map[string]any) (ToolOutcome, error)
}
ToolServer is the contract for evaluating a tool-exposing server (e.g. an MCP server) directly, with no LLM. An adapter (e.g. the mcp package) wraps a live server connection and satisfies this interface; the core never imports an MCP SDK, so it stays protocol-agnostic.
type ToolsListCheck ¶
type ToolsListCheck struct {
Expected []string
}
ToolsListCheck verifies the server exposes the expected tools.
func (ToolsListCheck) Name ¶
func (ToolsListCheck) Name() string
func (ToolsListCheck) Run ¶
func (c ToolsListCheck) Run(ctx context.Context, ts ToolServer) (float64, string)
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
fakeagent
Package fakeagent provides an in-memory Agent implementation for tests.
|
Package fakeagent provides an in-memory Agent implementation for tests. |
|
faketoolserver
Package faketoolserver provides an in-memory ToolServer for tests.
|
Package faketoolserver provides an in-memory ToolServer for tests. |