Benchmarking the Self-Improvement Capability of AI Agents in Batch File Tasks

    A concrete batch-file workflow — downloading 176 identity-verification videos and renaming them under strict rules — is a revealing test of AI Agent capability. This article outlines a task-card methodology, five quantifiable evaluation dimensions (completeness, naming fidelity, suffix case consistency, directory cleanliness, and cost/reproducibility), compares two execution routes with real-world results, and explains why "one-shot success" differs from genuine self-improvement. Includes a vendor-neutral reference script and guidance for building a repeatable benchmark.

    1. Why Batch File Processing Is a Litmus Test for Agents

    Imagine a user identity verification spreadsheet with 237 records, 176 of which contain video URLs generated during liveness/facial-recognition authentication. The task: download each video and rename it to the pattern “Name-IDNumber.extension”. Doing this manually means 176 clicks plus 176 renames — an entire afternoon, and mistakes are almost guaranteed.

    This kind of task is a classic sample for observing AI Agents for three reasons:

    • Long pipeline: Read structured data → parse row by row → make network requests → write to disk → rename → verify. A break in any link causes silent gaps.
    • Fine-grained constraints: File extension casing must be preserved exactly (the dataset contains both lowercase and uppercase suffixes), the naming separator is fixed, and no “normalization” of names is allowed.
    • Rigorous acceptance criteria: Results are countable, comparable, and verifiable. There is no vague “looks about right” zone.

    In other words, it doesn’t test whether the model can write code. It tests whether the Agent has the planning, execution, self-checking, and wrap-up capabilities needed for long-horizon tasks.

    2. Task Card: Turning a Verbal Request into a Verifiable Specification

    The first step in evaluation isn’t choosing tools — it’s writing a clear task card. A vague description inevitably produces incomparable results. A proper task card contains at least four sections:

    1. Input: A structured data file (with name, phone number, ID number, and video URL columns), with mixed protocols and file formats in the URLs.
    2. Actions: Only process records where the video URL is non-empty; download one by one; preserve each source file’s original extension and its casing.
    3. Output: The target directory must contain only deliverable files, named strictly as Name-IDNumber.extension.
    4. Acceptance: Count verification (should be 176), naming spot-checks plus full regex validation, suffix case consistency validation, and a check that the count of non-deliverable files in the directory is zero.

    The fourth item is the most critical. Most evaluations end up inconclusive because they only check “how many files were downloaded” and never check “what else is left in the directory.”

    3. Five Quantifiable Dimensions

    Replace subjective impressions with a scorecard, recording each item independently:

    • Completeness: successful files / files to process, target 100%, with failures explicitly listed rather than silently skipped.
    • Naming fidelity: full regex match rate, e.g., a whitelist pattern like ^[^\\/:*?"<>|]+-\d{17}[\dXx]\.(mp4|MOV) (extend per actual format).
    • Suffix case consistency: compare each source URL suffix with the on-disk suffix; any casing difference counts as a failure.
    • Directory cleanliness: the count of non-deliverable files in the target directory. Scripts, logs, temp files, and copies of the data source all count as contamination.
    • Cost and reproducibility: model-call cost and wall-clock time per run, plus the variance across three repeated runs.

    The last item is often ignored, yet it is the dividing line between “capability” and “luck.”

    4. Two Typical Execution Routes and the Measured Differences

    When the same task card is handed to two implementation routes, the results diverge in interesting ways.

    Route A: Generate a script in one shot, then execute. The Agent produces a complete script first, runs it, then self-checks. Measured result: all 176 files delivered, naming and suffix casing fully preserved, and the target directory contains only the 176 deliverables — no leftover scripts, logs, or data copies. The delivery is a finished product, ready for the next stage. Cost was on the order of one RMB per run, using a general-purpose, cost-effective reasoning-tier model.

    Route B: Also code-execution-centric, but missing the wrap-up stage. File count, naming, and suffixes were all correct, but the target directory contained two extra files: the download script and a copy of the source data. Functionally flawless, but short of the delivery standard — a production scenario would require an additional cleanup step.

    The difference isn’t “can it do the job” but whether it treats “cleaning up the scene” as part of the task. Engineering-wise, this maps to a well-known principle: intermediate artifacts belong in a separate workspace, and the delivery directory only accepts final outputs.

    5. A Key Distinction: One-Shot Success Is Not Self-Improvement

    The most commonly confused point in discussions like this is equating “the task was done well” with “the Agent can self-improve and evolve.” These two claims must be argued separately.

    • In-task self-correction: noticing a timed-out URL or an anomalous suffix during execution and retrying or adjusting strategy. This is a feedback loop within a single session — a necessary condition, but it only proves robustness.
    • Cross-task self-improvement: distilling experience into reusable memory or rules (e.g., “the delivery directory must stay clean” or “never normalize suffix casing”) that automatically apply in the next different but related task, without the user repeating instructions. That is evolution.

    To verify the latter, the evaluation design must be upgraded: run the same Agent through three consecutive tasks from the same family (different data source, different naming rules, different storage location), and observe whether the second and third runs produce fewer errors and require fewer human prompts. A perfect 176/176 on a single run only proves it didn’t drop the ball this time.

    6. Why Local Small-Parameter Models Consistently Fail

    A stable finding in testing: locally deployed small-parameter models generally could not close the loop on this task. The reasons are straightforward:

    • Long-horizon tool orchestration requires stable multi-step state retention; small models tend to lose original constraints (like “preserve casing”) after step ten.
    • Generating a runnable script demands precise syntax and edge-case handling, and their self-repair after errors is weak.
    • They lack reliable retry strategies — a network hiccup interrupts the run, with no failure report at the end.

    The conclusion is not “local models are useless,” but that task complexity must match model capability: short pipelines with strong constraints and enumerable work suit local small models; long pipelines requiring self-planning and self-repair belong on more capable cloud inference services, routed through a unified model-invocation interface for controlled switching. On Baidu AI Cloud, this shape is typically served by a container platform for the execution sandbox, object storage for deliverables, and logging and monitoring services for audit trails and failure alerts — a combination of generic capabilities rather than proprietary interfaces.

    7. A Reusable Reference Implementation

    Below is a vendor-neutral reference script. It highlights three engineering points: temp-directory isolation, atomic writes, and manifest validation.

    1. import csv, os, re, shutil, tempfile, urllib.request, hashlib
    2. SRC = "user_verifi.csv" # Data source is read-only; never copy it into the delivery directory
    3. OUT = "deliverables" # Delivery directory; only final outputs allowed here
    4. NAME_RE = re.compile(r"^[^-\\/:*?\"<>|]+-\d{17}[\dXx]\.(mp4|MOV)$")
    5. os.makedirs(OUT, exist_ok=True)
    6. manifest, failed = [], []
    7. with tempfile.TemporaryDirectory() as work: # All intermediate artifacts stay in the workspace
    8. with open(SRC, newline="", encoding="utf-8") as f:
    9. rows = [r for r in csv.DictReader(f) if r["video_url"].strip()]
    10. for i, r in enumerate(rows, 1):
    11. url = r["video_url"].strip()
    12. ext = os.path.splitext(url.split("?")[0])[1] # Preserve original casing
    13. fname = f"{r['name']}-{r['id_no']}{ext}"
    14. tmp = os.path.join(work, f"{i}.part")
    15. try:
    16. with urllib.request.urlopen(url, timeout=60) as resp, open(tmp, "wb") as w:
    17. shutil.copyfileobj(resp, w)
    18. if not NAME_RE.match(fname):
    19. raise ValueError(f"naming violation: {fname}")
    20. os.replace(tmp, os.path.join(OUT, fname)) # Atomic write
    21. manifest.append((fname, hashlib.md5(open(os.path.join(OUT, fname),'rb').read()).hexdigest()))
    22. except Exception as e:
    23. failed.append((fname, str(e))) # Failures must be reported explicitly
    24. print(f"ok={len(manifest)} failed={len(failed)} extra={len(os.listdir(OUT)) - len(manifest)}")

    os.replace guarantees no half-written files; the failure list guarantees no silently dropped data; the final self-check line prints the success count, failure count, and extra-file count together, turning “directory cleanliness” into an assertable metric.

    8. Turning the Evaluation into a Sustainable Benchmark

    A one-off comparison is just an anecdote. Real conclusions require benchmarking:

    • Run three times, recording mean success rate and variance;
    • Use a fixed scorecard, scoring each of the five dimensions as 0/1 or proportional, then aggregate with weights;
    • Normalize cost to a “per thousand files” basis to avoid sample-size distortion;
    • Build a failure sample set, turning timed-out URLs, anomalous suffixes, and duplicate records into regression cases;
    • Run cross-task transfer tests to verify the “experience reuse” claim from Section 5.

    9. Compliance and Security Baselines

    This task involves ID numbers and facial-recognition videos — highly sensitive personal data. Whichever technical route you choose, the following are non-negotiable: the data source must have explicit authorization and a lawful basis for processing; data in transit and at rest must be encrypted; delivery directories and shared locations require access control and least privilege; deliverables are retained for the minimum necessary period and destroyed on schedule; logs must never print ID numbers or directly accessible video URLs in plaintext (mask or digest them instead). No matter how elegant the automation, it cannot substitute for this layer of constraint.

    10. Conclusion

    Batch file processing is a mirror. What it reflects isn’t the model’s prose, but the Agent’s planning completeness, constraint retention, and wrap-up discipline. In testing, the gap between the two routes was just two extra files in the delivery directory — yet that alone determined whether human intervention was needed. As for whether the Agent can truly self-improve, that demands a stricter experimental design: cross-task, repeatable, with demonstrably reused experience. A single perfect run is only the entry ticket.