AI Engineer Portal
Your personal operating system for career transition.
Exercise
Agent evaluation harness
Agent Evaluation Harness
Building an agent is one thing; knowing whether it actually works is another. An evaluation harness runs an agent against a suite of test cases and scores it on multiple dimensions: correctness (did it get the right answer?), efficiency (how many steps did it take?), and cost (how many tokens did it use?).
What you are building
Create an EvalHarness class that:
- Defines test cases — each case has an input, expected output, and optional metadata (max steps, category).
- Runs the agent — executes the agent function for each test case, capturing the result, step trace, and token usage.
- Scores correctness — uses a configurable scoring function (exact match, fuzzy match, or LLM-as-judge).
- Scores efficiency — compares actual steps taken against a baseline or maximum.
- Scores cost — tracks total tokens and computes cost based on a pricing table.
- Produces a report — aggregate scores by category, overall pass rate, and per-case details.
Why this matters
Without systematic evaluation, agent development is guesswork. You change a prompt and hope it helps. An eval harness turns agent development into engineering: make a change, run the suite, see exactly what improved and what regressed. This is the single most important infrastructure investment in any agent project.
Every serious AI engineering team has an eval harness. The patterns here apply whether you are using a framework or building from scratch.
Constraints
- Test cases are defined as dicts/dataclasses, not hardcoded.
- The harness must be agent-agnostic — it accepts any callable with the right signature.
- Scoring functions are pluggable (passed in, not hardcoded).
- The report must include both aggregate and per-case results.
- Support timeout per test case.
Agents / advanced / Step 7 of 8
Agent architecture patterns
Focus on explicit control surfaces — function schemas, state machines, and structured outputs. Agents are most useful when the task requires dynamic tool selection or multi-step reasoning. Start with the simplest pattern (single tool call) before reaching for ReAct loops.
- - Tools return structured, typed responses
- - Agent completes the task within a bounded number of steps
- - All tool calls include error handling and retries
- - Memory/state management prevents unbounded context growth
- - Tool schemas validate inputs and handle errors gracefully
- - Agent loop has explicit termination conditions
- - State is serializable and inspectable between steps
- - Cost and token usage are tracked per invocation
- - Fallback behavior exists for tool call failures
Practice
Generate a variation
Generate a new exercise variation to deepen understanding or practice a related concept.
Attempt history
Recent submissions
Before you submit, decide what a strong answer should make obvious to the reviewer.
No attempts yet.