eval

package
v0.1.34 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 30 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package eval runs versioned MCP workflows against model runtimes and checks their functional outcomes against explicitly approved regression baselines.

Index

Constants

View Source
const GraderVersion = "mcp-outcomes-v2"
View Source
const Version = 1

Variables

This section is empty.

Functions

func CheckBaseline

func CheckBaseline(b Baseline, suite Suite, g Generation, repeat int) error

CheckBaseline validates compatibility before spending model calls on a test.

func Compare

func Compare(b Baseline, r Report, model string) ([]string, error)

func Export

func Export(r Report, dir string) error

Export creates a local comparison dataset, preserving failed trials and raw request/response traces. No credentials are stored. An explicitly selected Laya origin is recorded.

func Hash

func Hash(value any) string

func ReadJSON

func ReadJSON(path string, value any) error

func Scores

func Scores(r Report, model string) map[string]Score

func ValidateReport

func ValidateReport(r Report) error

ValidateReport recomputes grades instead of trusting editable saved scores.

func WriteJSON

func WriteJSON(path string, value any) error

WriteJSON refuses to replace an existing run or approved baseline.

Types

type Baseline

type Baseline struct {
	LayaMode      string           `json:"laya_mode,omitempty"`
	LayaEnabled   bool             `json:"laya_enabled,omitempty"`
	Version       int              `json:"version"`
	Grader        string           `json:"grader"`
	SuiteHash     string           `json:"suite_hash"`
	SourceRunHash string           `json:"source_run_hash"`
	Model         string           `json:"model"`
	Generation    Generation       `json:"generation"`
	Cases         map[string]Score `json:"cases"`
}

func CreateBaseline

func CreateBaseline(r Report, model string) (Baseline, error)

type Case

type Case struct {
	DecisionSchema       map[string]any `json:"decision_schema,omitempty" yaml:"decision_schema,omitempty"`
	ExpectedToolSequence []ToolRef      `json:"expected_tool_sequence,omitempty" yaml:"expected_tool_sequence,omitempty"`
	ID                   string         `json:"id" yaml:"id"`
	AgentID              string         `json:"agent_id" yaml:"agent_id"`
	Skills               []string       `json:"skills" yaml:"skills"`
	Task                 string         `json:"task" yaml:"task"`
	Tools                []FixtureTool  `json:"tools" yaml:"tools"`
	Checks               []Check        `json:"checks" yaml:"checks"`
	ConsistencyPaths     []string       `json:"consistency_paths" yaml:"consistency_paths"`
	RequiredBridgeCalls  []string       `json:"required_bridge_calls,omitempty" yaml:"required_bridge_calls,omitempty"`
	ForbiddenTools       []string       `json:"forbidden_tools,omitempty" yaml:"forbidden_tools,omitempty"`
	MaxBytes             int            `json:"max_bytes,omitempty" yaml:"max_bytes,omitempty"`
}

type Check

type Check struct {
	Path   string `json:"path" yaml:"path"`
	Equals any    `json:"equals" yaml:"equals"`
}

type FixtureCall

type FixtureCall struct {
	Started    time.Time           `json:"started"`
	DurationMS int64               `json:"duration_ms"`
	Response   *sdk.CallToolResult `json:"response,omitempty"`
	Server     string              `json:"server"`
	Tool       string              `json:"tool"`
	Arguments  map[string]any      `json:"arguments"`
	Matched    bool                `json:"matched"`
}

type FixtureTool

type FixtureTool struct {
	Server      string         `json:"server" yaml:"server"`
	Name        string         `json:"name" yaml:"name"`
	Description string         `json:"description" yaml:"description"`
	InputSchema map[string]any `json:"input_schema" yaml:"input_schema"`
	Arguments   map[string]any `json:"arguments" yaml:"arguments"`
	Response    map[string]any `json:"response" yaml:"response"`
	IsError     bool           `json:"is_error,omitempty" yaml:"is_error,omitempty"`
	Required    bool           `json:"required" yaml:"required"`
}

type Generation

type Generation struct {
	Temperature float64 `json:"temperature"`
	MaxTokens   int     `json:"max_tokens"`
}

type Grade

type Grade struct {
	Metrics           []MetricResult  `json:"metrics"`
	Passed            bool            `json:"passed"`
	Checks            map[string]bool `json:"checks"`
	SemanticSignature string          `json:"semantic_signature,omitempty"`
}

func GradeTrial

func GradeTrial(c Case, t Trial) Grade

type MetricResult

type MetricResult struct {
	Name      string  `json:"name"`
	Score     float64 `json:"score"`
	Threshold float64 `json:"threshold"`
	Passed    bool    `json:"passed"`
	Reason    string  `json:"reason"`
}

type ModelCall

type ModelCall struct {
	Started    time.Time             `json:"started"`
	Request    runtime.ChatRequest   `json:"request"`
	Response   *runtime.ChatResponse `json:"response,omitempty"`
	Error      string                `json:"error,omitempty"`
	DurationMS int64                 `json:"duration_ms"`
}

type Options

type Options struct {
	LayaMode   string
	LayaURL    string
	Models     []string
	Repeat     int
	Timeout    time.Duration
	Generation Generation
	OnTrial    func(Trial) error
}

type Report

type Report struct {
	LayaMode   string         `json:"laya_mode,omitempty"`
	LayaURL    string         `json:"laya_url,omitempty"`
	Version    int            `json:"version"`
	Grader     string         `json:"grader"`
	Suite      Suite          `json:"suite"`
	SuiteHash  string         `json:"suite_hash"`
	Build      buildinfo.Info `json:"build"`
	Engine     runtime.Engine `json:"engine"`
	Models     []string       `json:"models"`
	Repeat     int            `json:"repeat"`
	Generation Generation     `json:"generation"`
	Started    time.Time      `json:"started"`
	Completed  bool           `json:"completed"`
	Trials     []Trial        `json:"trials"`
}

func Run

Run exercises the production run_agent MCP adapter and agent loop. Only the model endpoint is live: downstream MCP tools are isolated HTTP replay servers.

type Score

type Score struct {
	Trials      int     `json:"trials"`
	Passed      int     `json:"passed"`
	PassRate    float64 `json:"pass_rate"`
	Consistency float64 `json:"consistency"`
}

type Suite

type Suite struct {
	Version     int    `json:"version" yaml:"version"`
	ID          string `json:"id" yaml:"id"`
	License     string `json:"license" yaml:"license"`
	Description string `json:"description" yaml:"description"`
	Cases       []Case `json:"cases" yaml:"cases"`
}

func LoadSuite

func LoadSuite(path string) (Suite, error)

func (Suite) Validate

func (s Suite) Validate() error

type ToolRef

type ToolRef struct {
	Server string `json:"server" yaml:"server"`
	Tool   string `json:"tool" yaml:"tool"`
}

type Trial

type Trial struct {
	Routing        bool                     `json:"routing,omitempty"`
	Routes         []app.RouteDecision      `json:"routes,omitempty"`
	Recommendation *app.RecommendationTrace `json:"recommendation,omitempty"`
	MCPResponse    *sdk.CallToolResult      `json:"mcp_response,omitempty"`
	CaseID         string                   `json:"case_id"`
	Model          string                   `json:"model"`
	Repetition     int                      `json:"repetition"`
	DurationMS     int64                    `json:"duration_ms"`
	Calls          []ModelCall              `json:"calls"`
	ToolCalls      []FixtureCall            `json:"tool_calls"`
	Result         result.RunResult         `json:"result"`
	MCPError       bool                     `json:"mcp_error"`
	Error          string                   `json:"error,omitempty"`
	Grade          Grade                    `json:"grade"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL