AI Agent Batch File Processing: Test Results and Lessons on Self-Iteration
This article examines how AI Agents handle batch file processing, using a real task of downloading and renaming 176 videos from an authentication table as the test case. It shows how to turn vague requirements into verifiable acceptance criteria, compares two execution paths that both completed the task but differed in delivery cleanliness, and explains why separating the workspace from the delivery directory matters. The article also defines what counts as genuine self-iteration, analyzes why smaller local models struggle with these tasks, and offers practical engineering recommendations for idempotency, logging, encoding, and evaluation.
1. Background: Why Batch File Processing Is a Test for Agents
Batch file processing may look like repetitive work, but it is full of engineering traps. Consider a typical task: the source is a table of user authentication records with 237 entries, 176 of which contain video URLs generated during liveness or face verification. The goal is to download each video locally and rename it using the pattern name-IDnumber.extension. The task sounds mechanical, yet it simultaneously tests network retries, encoding handling, case preservation, and idempotency.
Tasks like this are well suited to AI Agents because they combine two capabilities: understanding natural-language constraints and executing code. However, being suitable does not mean being reliable. The real differences show up at the boundaries: a link that times out, a name field containing special characters, an extension that is .MOV rather than .mp4, or scripts and intermediate files polluting the delivery directory.
2. Task Card Design: Turning Vague Requirements into Verifiable Criteria
To make evaluation meaningful, requirements must be written as decidable acceptance criteria rather than “just process these videos.” A reusable task card should contain at least four parts:
- Input: the table file path, field meanings, and encoding assumptions (for example, UTF-8).
- Filter condition: process only records with a non-empty video URL; the expected count is 176.
- Naming rule:
name-IDnumberplus the original extension, with the extension’s case preserved exactly. - Delivery standard: the target directory contains only the 176 video files, with no scripts, logs, data copies, or other redundant artifacts.
The acceptance logic can be expressed as pseudocode:
expected = 176files = list(target_dir.iterdir())assert len(files) == expected, f"Count mismatch: {len(files)}"for f in files:stem, ext = f.name.rsplit(".", 1)assert re.match(r"^[\u4e00-\u9fa5A-Za-z]+-\d{17}[\dXx]$", stem)assert ext in {"mp4", "MOV"}, f"Unexpected extension: {f.name}"
Turning “clean and tidy” into executable assertions is the prerequisite for comparison and self-iteration.
3. Observed Results from Two Execution Paths
For the same task, both mainstream approaches chose the code-execution route of “generate a script first, then run the downloads.” Both ultimately downloaded and named all 176 files, and both correctly preserved the case of the extensions. This shows that the basic capability is already in place; the differences are concentrated in delivery details.
The first approach produced a clean result directory containing only the target video files, ready for the next stage. The second approach left the download script and a copy of the data source in the directory as well. The two were similar in cost, both falling in the range of roughly one yuan (actual billing depends on the model and platform rules). From an engineering delivery perspective, the two extra files are not a functional defect but a failure to separate the “workspace” from the “delivery area”: the Agent wrote intermediate and final artifacts to the same level.
This observation can be generalized into a principle: an Agent’s maturity is not reflected in whether it can complete a task, but in whether it understands the “delivery boundary.” Temporary scripts, caches, and logs should go to a separate working directory, while the delivery directory should contain only the artifacts that pass acceptance.
4. Criteria for Judging “Self-Iteration”
The question of whether an Agent can “self-iterate” requires clarifying the concept first. The industry generally divides Agent evolution into three levels:
- In-session error correction: after a failure, reading the error, modifying the script, and rerunning. This is closed-loop repair, not evolution.
- Cross-session experience reuse: distilling successful paths into searchable experience or tools, so the next similar task can reuse them directly.
- Capability structure upgrade: adding tools, adjusting planning strategies, or introducing evaluation-driven optimization to steadily improve the success rate on similar tasks.
Only the second and third levels deserve to be called “self-iteration.” The judgment method should be quantifiable: fix the task set, fix the acceptance script, run repeatedly, and observe trends in success rate, directory cleanliness, average cost, and the number of manual interventions, rather than whether a single demo looks impressive.
5. Why Smaller Local Models Fail at These Tasks
The original discussion mentioned that local models performed poorly, which is easy to explain from an engineering standpoint. Batch file tasks require long context to stably carry table fields, a stable tool-calling format, and retry strategies across multiple failures. Smaller local models commonly fail in these ways: misaligned field mapping, lowercasing all extensions, halting on exceptions, and re-downloading existing files during retries. These errors are not about “not knowing how to write code” but about insufficient stability in instruction following and state management.
6. Engineering Recommendations
- Separate the workspace from the delivery area: write intermediate artifacts to a temporary directory, and move only the finished products to the delivery directory at the end.
- Idempotency and resumable downloads: skip a file when the target already exists and the size matches, to avoid duplicate downloads.
- Structured logging: record each record’s URL, status code, elapsed time, and retry count to make problems easier to locate.
- Explicit case and encoding declarations: do not rely on default behavior; handle extensions as raw strings.
- Evaluation first: treat the acceptance script as a regression test, and run the fixed task set after any prompt or model change.
- Cost control: use a smaller model for planning and script generation, and reserve high-cost calls for failed retries and complex branches.
7. Conclusion
Batch file processing is a mirror that reflects an Agent’s real level in instruction following, boundary awareness, and stability. Whether it can “self-iterate” should not be decided by a demo, but by trends in success rate and delivery cleanliness on a fixed task set. For developers, the controllable engineering path is to write the acceptance criteria as code first, and only then talk about evolution. When elastic compute and a managed execution environment are needed, batch tasks can be hosted using general capabilities such as the container platform, object storage, and log monitoring offered by Baidu AI Cloud.
