DEV Community

Cover image for AI agent implementation: an acceptance check for your first agent task
MatIntellect
MatIntellect

Posted on Edited on Originally published at matintellect.com AI-assisted

AI agent implementation: an acceptance check for your first agent task

Problem: the first agent task in a business is often accepted on gut feeling, and errors only surface weeks later. Result: a tiny acceptance harness that compares an agent's structured output with hand-labelled expectations, including the case where the agent should say information is missing. Stack: Python 3.10+ standard library (tested on 3.15.2). Boundaries: the harness does not call a model; you paste the agent's outputs in. It checks extraction, not writing quality

AI-generated illustration of starting with one agent task

Choosing the task to test

I recommend starting implementation with one boring task that has a clear input and a clear output. Email triage is a good example: input is an email, output is a list of requests. It is also easy to label by hand, which is exactly what an acceptance check needs

The task definition the agent receives has four parts: where data comes from, what to output, what not to do (no replies to clients) and how to handle ambiguity (flag it, do not guess). The last part is what most first implementations forget, so the harness tests it explicitly

Input, processing, output

Input: a list of cases. Each case has the email, the set of requests a human expects, an optional flag saying the agent should report missing information, and the agent's actual output

Processing: compare sets of requests, report anything missing or invented, and check the needs_info flag where it is expected

Output: one line per case and a pass count

Labelling real examples before automation

The example

The three cases below are hand-written teaching data, not real client email. The agent outputs are also written by hand to show each failure type

cases = [
    {"email": "Hi, can you move our call to Friday and resend the invoice?",
     "expected": {"move call to friday", "resend invoice"},
     "agent": {"requests": ["move call to friday", "resend invoice"], "needs_info": False}},
    {"email": "Please send the contract. Also, what about the date we discussed?",
     "expected": {"send contract"}, "expect_needs_info": True,
     "agent": {"requests": ["send contract"], "needs_info": False}},
    {"email": "Could you add two more seats to our plan?",
     "expected": {"add two seats"},
     "agent": {"requests": [], "needs_info": False}},
]

def check(case):
    got = set(case["agent"]["requests"])
    problems = [f"missing: {r}" for r in sorted(case["expected"] - got)]
    problems += [f"invented: {r}" for r in sorted(got - case["expected"])]
    if case.get("expect_needs_info") and not case["agent"]["needs_info"]:
        problems.append("should have flagged missing information")
    return problems

passed = 0
for i, case in enumerate(cases, 1):
    problems = check(case)
    print(f"case {i}: " + ("ok" if not problems else "; ".join(problems)))
    passed += not problems
print(f"passed {passed} of {len(cases)}")
Enter fullscreen mode Exit fullscreen mode

Output, exactly as printed when I ran it:

case 1: ok
case 2: should have flagged missing information
case 3: missing: add two seats
passed 1 of 3
Enter fullscreen mode Exit fullscreen mode

Case 2 is the important one. The agent extracted the explicit request but silently ignored a reference to a date that is not in the email. In production that is how wrong assumptions reach a client

Design notes

Normalise before comparing. Real outputs vary in wording. In practice you either constrain the agent to a fixed vocabulary of request types or normalise with a mapping table before comparison; free-text equality, as in the example, is only good enough for a demo

Keep the labelled set small but nasty. Ten real emails with two or three hard ones are more useful than a hundred easy ones. Include an email with a request hidden in the middle and one with an attachment that changes the meaning

Treat corrections as data. When a reviewer corrects the agent, add that email to the cases. In my own setup every correction also becomes a written rule the agent reads next time, and over 134 days of running my personal agent, those rules did more for accuracy than anything else

Where this comes from

The harness is a stripped-down version of how I accept work from my own agents. My personal agent Jes runs 10 scheduled jobs on her own and hands tasks to 7 other bots. None of those jobs went unattended on day one. Each started as a draft that I checked, and each moved forward only after the same kind of correction stopped coming back

The part that took longest was not the model. It was writing down what a correct result looks like, so that a check like the one above has something to compare against. If two people on the team would label the same email differently, the agent cannot pass, and that disagreement is the real finding of the test

Two practical habits follow from this. First, label cases before you look at the agent output, otherwise you will unconsciously accept whatever it produced. Second, keep the failing cases in the set after you fix them: they are the regression suite for the next prompt change or model swap

Errors, timeouts and limits

The harness cannot catch errors you did not label. It measures agreement with a human, not truth

Acceptance is not autonomy. Passing a week of daily checks lets the agent prepare drafts; it does not mean it may send them. In my setup, messages to clients, spending, deletions and publishing always wait for an explicit yes

Timeline expectations: a first agent for one clear task took one to two weeks in my projects, including memory, approval rules, a schedule and testing on real data

Reviewing results at a desk

Reproduce it

  1. Save the code as acceptance.py
  2. Run python3 acceptance.py
  3. Confirm the four output lines above
  4. Set needs_info to true in case 2 and add "add two seats" to case 3, run again and check that it reports passed 3 of 3

The non-technical side of choosing and rolling out the first task is in AI agent implementation: where to start

Top comments (0)