@oiyonet/eval-harness
v1.0.0
Published
Deterministic, zero-dependency local evaluation & assertion harness for AI agent responses, tool calls, and structured outputs.
Maintainers
Readme
@oiyonet/eval-harness
Deterministic, zero-dependency local evaluation & assertion harness for AI agent responses, tool calls, and structured JSON outputs.
Why agent-eval-harness?
Testing autonomous AI agent outputs with traditional assertions (assert.strictEqual) fails because natural language generation is non-deterministic. Conversely, using "LLM-as-a-judge" (calling GPT-4 or Claude to evaluate outputs) is slow (5-10 seconds per test), expensive, flakier, and introduces rate-limit bottlenecks in CI.
agent-eval-harness provides a sub-millisecond, zero-dependency deterministic evaluation suite:
- Prompt Adherence & Text Rubrics: Checks required/forbidden keywords, any-of sets, length constraints, regex matching, Markdown header formatting, and fenced JSON.
- Semantic JSON Validator: Ultra-light schema assertions (types, ranges, enums, array lengths, regex) without heavy validator dependencies.
- Agent Tool Call Verifier: Ensures autonomous agents invoked the intended tool with valid, non-empty arguments.
- Dual CLI & MCP: Run evaluations in CI via
agent-evalor allow agents to self-evaluate in test-driven agent workflows viaagent-eval-mcp.
1. Quick Start (CLI)
# Evaluate agent text output against a rubric
npx agent-eval check --text "summary.md" --rubric "rubric.json"
# Validate structured JSON response from an LLM
npx agent-eval json --data "result.json" --schema "schema.json"2. MCP Server Configuration
Add agent-eval-mcp to your agent configuration (~/.claude/settings.json, Cursor MCP settings, or Antigravity config):
{
"mcpServers": {
"eval-harness": {
"command": "npx",
"args": ["-y", "agent-eval-harness"]
}
}
}Available MCP Tools:
evaluate_text_quality- Evaluates text against prompt rubric rules (required/forbidden keywords, length bounds, regex, formatting).
evaluate_semantic_json- Validates agent structured JSON outputs against schema rules.
evaluate_tool_call- Validates whether an agent selected the expected tool and provided valid argument types.
3. Programmatic Usage (Node.js / TypeScript)
import {
evaluateTextQuality,
evaluateSemanticJson,
evaluateToolCall,
} from 'agent-eval-harness';
// 1. Text Rubric Evaluation
const agentResponse = `
## Executive Summary
The security audit passed with zero vulnerabilities detected in the repository.
`;
const rubricReport = evaluateTextQuality(agentResponse, {
requiredKeywords: ['security audit', 'vulnerabilities'],
forbiddenKeywords: ['hallucination', 'bypass'],
minLength: 30,
requireMarkdownHeaders: true,
});
console.log('Passed:', rubricReport.pass); // true
console.log('Score:', rubricReport.score); // 100
// 2. Structured JSON Evaluation
const jsonReport = evaluateSemanticJson(
{ score: 98, status: 'approved' },
{
required: ['score', 'status'],
properties: {
score: { type: 'number', min: 0, max: 100 },
status: { type: 'string', enum: ['approved', 'rejected'] },
},
}
);
console.log('JSON Valid:', jsonReport.pass); // true
// 3. Tool Call Assertion
const toolReport = evaluateToolCall(
{ name: 'create_issue', arguments: { title: 'Bug fix' } },
{
expectedTool: 'create_issue',
requiredArgs: ['title'],
}
);
console.log('Tool Call Correct:', toolReport.pass); // trueLicense
MIT © OIYO Lab
