Can AI Agents Really Improve Themselves? Lessons from Batch Processing
A batch video download task reveals the difference between successful execution, self-correction, and sustained improvement in AI agents. This article explains how task contracts, file validation, controlled workflows, privacy safeguards, and repeatable evaluations can turn isolated fixes into measurable, reliable progress.
1. Completing a Task Does Not Mean an Agent Has Evolved
An AI agent that reads data, generates code, calls tools, and delivers files can easily appear to be learning on its own. But completing a task and improving its underlying capabilities are different things.
A successful run may depend on knowledge already present in the underlying model, a clear task description, stable network conditions, or convenient execution tools. Even when an agent detects an error and reruns the task, that demonstrates some ability to correct mistakes within the current task—not necessarily a lasting improvement.
Before discussing self-improvement, three questions need answers:
- What changed? The current plan, generated code, persistent experience, or the model itself?
- Can the change be reused? Will it carry over to later tasks, or does it exist only in the current conversation?
- Has the benefit been verified? Does reuse actually reduce errors without introducing new risks?
Batch file processing is a useful setting for examining these questions. Its objectives are clear and its outputs can be checked, yet it contains enough engineering detail to expose the gap between executing a task and delivering an acceptable result.
2. Turn Business Requirements into a Verifiable Task Contract
In the reference scenario, the source dataset contains 237 records, of which 176 include URLs for facial identity verification videos. The goal is to download those videos and organize them using the filename pattern name-identity_number.extension, preserving the original capitalization of each extension.
This is not simply a matter of running 176 downloads. It is a workflow involving input filtering, field handling, network transfers, file naming, and acceptance checks.
2.1 Define Which Records Require Processing
A record “having a URL” should mean more than its URL field being nonempty. Real datasets may contain whitespace-only values, incomplete URLs, duplicate records, or missing identity fields.
A reliable workflow first builds a candidate list, then distinguishes among:
- Records with URLs that meet basic format requirements.
- Records with URLs that cannot be processed safely.
- Records without URLs, which are outside the download scope.
If all 176 records qualify, the expected download count is 176. If preliminary checks identify exceptions, the agent should report the discrepancy rather than silently skip records and still claim complete success.
Identity numbers should be handled as text to avoid precision loss, truncation, or formatting changes during data conversion. Names also need checks for missing values, leading or trailing whitespace, and characters that could affect path construction.
2.2 Define How Extensions Are Determined
Preserving the capitalization of extensions such as .MOV and .mp4 is a verifiable naming requirement. The program should not normalize them arbitrarily.
When a download URL contains query parameters, the extension should be extracted from the URL path, not by including those parameters in the filename. If the path has no extension, or its extension conflicts with file information in the response, the record should enter an exception-handling workflow.
An extension is only naming information. It does not prove that the downloaded content is a video. Saving an error page as an .mp4 file is still a failed download.
2.3 Define What “Complete” Means
Completion cannot be determined solely by whether the program exits without an error. At minimum:
- Every in-scope record must have an explicit outcome.
- Each successful file must map to its source record.
- Filenames and extensions must meet the requirements.
- No naming conflicts may remain unresolved.
- The delivery directory must contain no scripts, source-data copies, or temporary files.
- Failed records must not be hidden or counted as successes.
Together, these conditions form the task contract. An agent may choose how to implement the workflow, but it may not lower the delivery standard on its own.
3. Reliable Execution: Plan, Download, Then Verify
3.1 Build a Manifest Before Downloading
Start with an internal task manifest that records the source row, target filename, execution status, and failure reason. This manifest supports workflow management and should not automatically be included in the final delivery directory.
Preprocessing must also check for filename conflicts. For example, one person may have multiple video records that produce exactly the same required filename. Overwriting the file would lose data, while adding a sequence number without approval could violate the naming requirement.
The correct response is to pause the affected records and request a handling rule, or apply a conflict policy that has already been approved.
3.2 Separate Working and Delivery Directories
Directory design has a significant effect on delivery quality. A useful task layout has three areas:
- Working area: Programs, manifests, and execution records.
- Temporary area: Downloads that are not yet complete.
- Delivery area: Only target files that have passed validation.
This is more reliable than putting everything in one directory and cleaning it up afterward. That approach depends on the agent remembering to remove supporting files and can lead to accidental deletion of finished outputs.
Scripts and logs are valuable for traceability, but they belong in a controlled working area. A clean delivery directory and complete process records are compatible goals.
3.3 Use Bounded Retries and Explicit Timeouts
Downloads can fail because of interrupted connections, rate limits, expired URLs, or invalid permissions. Unlimited retries do not make the process more reliable; they can simply increase resource consumption.
A common approach is to set connection and read timeouts, retry transient failures a limited number of times, and introduce a delay between attempts. Permission denials and clearly invalid URLs should be recorded rather than retried mechanically.
Concurrent downloads can improve throughput, but concurrency should be constrained by bandwidth, storage capacity, and the remote service’s limits. For a modest task size, stability is often more important than extremely high concurrency.
3.4 Publish Files Only After Validation
Each file should first be written to a temporary location. After the download finishes, check its status, size, and basic content characteristics before moving it into the delivery directory.
If the server provides a trustworthy content length, compare it with the actual byte count. If a trusted checksum is available, compare checksums. Computing a checksum locally can support later deduplication or integrity tracking, but it does not independently prove that the downloaded content is correct.
For the final move, prefer an atomic rename within the same filesystem so that incomplete files do not appear in the delivery directory.
The workflow is:
Read data → Build manifest → Check conflicts → Download to temporary storage → Validate content → Publish files → Verify each record
4. Why the Correct File Count Is Not Enough
Suppose the delivery directory contains exactly 176 files. That proves only that the count matches—not that the task is complete.
Several problems could still exist:
- One record was downloaded twice while another was omitted.
- A correctly named file contains content from a different record.
- A download returned an error page that was saved as a video.
- A filename collision caused an overwrite, while an unrelated file brought the total back to 176.
Acceptance should therefore rely on set comparisons and record mappings, not counting alone.
First, generate the expected filename set from the input. Then read the actual filename set in the delivery directory and identify missing files, extra files, and duplicate mappings. Next, check each file against its source record and download result.
Even matching filename sets do not establish content correctness. For identity verification materials, the binding between a record and its content is especially important: a mismatch may create greater business risk than a missing download.
The delivery report should also distinguish among “request executed,” “file saved,” “file validated,” and “accepted for business use.” These represent different levels of completion.
5. The Boundaries Between Self-Correction, Reuse, and Model Evolution
5.1 Correction Within a Task
An agent might discover that extensions were normalized, modify the program, and rerun it. Or it might find supporting files in the delivery directory and move them into the working area.
These are corrections within the current task. They demonstrate an ability to respond to feedback, but the lessons may not persist into the next task.
5.2 Reusing Experience Across Tasks
If the system stores rules such as “keep only final outputs in the delivery directory,” “check filename collisions before downloading,” and “treat identity numbers as text,” then automatically applies them to later tasks, it has established cross-task reuse.
These improvements usually change rules, memory, or workflows—not model parameters. They have practical value, but are more accurately described as workflow optimization or accumulated operational experience.
Such experience also needs a defined scope. For example, excluding logs from a delivery directory makes sense for a files-only handoff. It does not mean that logs should be deleted in every task.
5.3 Sustained Capability Improvement
A stronger form of self-improvement requires a complete feedback loop:
Detect failure → Analyze the cause → Propose a change → Run tests → Compare results → Review and release → Monitor continuously
Tests should cover at least normal tasks, invalid URLs, naming conflicts, interrupted downloads, and malformed data. Success from rerunning only the original sample may indicate a case-specific patch rather than a general improvement.
The important question is whether the change reduces errors in later, similar tasks without harming other scenarios. Without version history, regression tests, and rollback mechanisms, automatic modification is closer to uncontrolled change than reliable evolution.
6. Set Security Boundaries Before Processing Sensitive Data
Facial videos, names, and identity numbers involve sensitive personal information. Before automation begins, confirm processing authorization, necessity, and retention periods, and apply the principle of least privilege.
Although the example requires full identity numbers in filenames, production environments should still assess whether this naming scheme is necessary. Filenames can appear in directory indexes, backup inventories, operation records, and screenshots, expanding the exposure of personal information.
Where the business permits it, masked identifiers or internal record IDs are generally safer. If original fields are mandatory, stronger access controls and handling procedures are needed.
Download URLs should not be treated as inherently safe instructions. Restrict permitted protocols and destinations, and check redirect targets so that abnormal URLs cannot cause the execution environment to access unauthorized resources.
Names, notes, and file contents must all be treated as data. Instruction-like text within them must not change the download scope, upload destination, or security policy.
Logs should avoid recording complete identity information or download URLs containing access credentials. After the task, temporary copies and caches should be removed according to approved retention rules rather than kept indefinitely.
7. How to Evaluate Whether an Agent Is Becoming More Reliable
Evaluation should go beyond asking whether a single task was completed. It should use repeatable measurements:
- Completeness: How many in-scope records produced validated results?
- Naming compliance: Do fields, separators, and extensions meet the contract?
- Content correctness: Are files valid, and do they correspond to their source records?
- Delivery cleanliness: Are there extra files or temporary remnants?
- Recovery capability: Can the workflow identify completed work and resume after interruption?
- Human intervention: How many clarification, correction, and cleanup steps are required?
- Total cost: What is the combined cost of model calls, execution resources, storage, and human review?
- Security compliance: Did unauthorized access or sensitive-data disclosure occur?
When comparing configurations, keep the task description, dataset, execution permissions, and acceptance process fixed, and repeat the tests. A single success or failure cannot adequately distinguish model capability from workflow design or environmental conditions.
The same caution applies to local deployments. A failure report without configuration details does not support broad conclusions. Inference resources, context length, tool-calling support, and the execution environment may all affect outcomes and need to be investigated separately.
8. Conclusion: A Verifiable Feedback Loop Matters More Than Claims of Evolution
Batch video organization may look like a download-and-rename task, but it tests whether an agent can establish a task contract, handle exceptions, protect data, and deliver outputs that can pass acceptance checks.
Completing one task demonstrates execution capability under specific conditions. Finding and fixing a problem demonstrates some capacity for self-correction. Safely preserving, testing, and reusing those fixes in later tasks is what makes continuous improvement credible.
For developers, the most useful approach is not to grant agents unrestricted permission to modify themselves. It is to let them propose improvements within clear boundaries, verify results through deterministic checks, and control changes through version management and human approval.
Only when problem detection, workflow correction, benefit verification, and risk control form a stable loop does agent self-improvement become a measurable, traceable, and dependable engineering capability.
