AI Agent Batch Tasks: Where Delivery Quality Breaks Down

    A practical test of two general-purpose AI agents and several locally deployed small models on a batch video-download and renaming task. The article compares video completeness, naming accuracy, and delivery-directory cleanliness; examines common batch-task failures; explains why the local small models did not complete the task under the test conditions; and provides an engineering checklist plus a Python validation script for safer delivery.

    1. Scope and Data Authorization

    The tasks discussed in this article involve names, ID numbers, and face-verification video URLs, which are sensitive personal information. The example data in this article has been de-identified. ID numbers use a fictitious format and do not contain real information.

    Before executing this type of task in a real environment, three conditions must be met. First, the data holder must provide explicit authorization and confirm that downloading and renaming comply with the legitimate purpose. Second, video links usually contain temporary access tokens, which can only be accessed within the authorized scope and validity period and must not be used for scraping beyond that authorization. Third, after the task is completed, source data, copies, and intermediate files must be deleted as agreed. Specific compliance requirements are subject to applicable personal information protection laws and internal enterprise policies.

    One more point: before sending ID numbers directly to a cloud model, confirm the service provider’s data processing terms. A safer approach is to give only de-identified samples to the model for script generation, then have a local script read the real data and execute the task.

    2. Task and Test Scope

    The source file is a user authentication table with 237 records, of which 176 contain video URLs. The videos are in .mp4 and .MOV formats, and the extension casing is inconsistent. The task has three requirements: download all videos; preserve the original extension casing; and name each file according to the rule “name-ID number.extension”.

    The test subjects are two general-purpose agent tools, both versions released in the first half of 2025, referred to below as Agent A and Agent B. Both used the same task description and ran independently. This article records only three results: completeness, naming accuracy, and delivery-directory state. The number of runs, retry behavior, and failure statistics for each tool were not publicly recorded, so the conclusions below apply only to this test.

    3. Comparison of the Two Agents

    Evaluation Dimension Agent A Agent B
    Video completeness All 176 downloaded successfully All 176 downloaded successfully
    Naming rule All correct All correct
    Extension casing Fully preserved Fully preserved
    Delivery directory contents Only the 176 videos Videos plus a download script and a CSV copy
    Delivery state Ready for downstream use Requires manual deletion of two extra files
    Cost per run (author’s estimate) About CNY 1 About CNY 1
    Retry and cleanup process Not recorded in source Not recorded in source

    The costs are similar, and both called a cloud LLM. This suggests that the gap mainly comes from how the agent framework defines the task boundary. Agent A treated “output a directly deliverable directory” as the task endpoint, while Agent B treated “videos downloaded and named correctly” as the endpoint.

    The two extra files account for only a small part of the delivery content, but downstream staff still need to perform additional cleanup. Each additional manual step creates another chance to delete the wrong file or miss a deletion.

    Cost figures should be treated with caution. The source did not provide token usage, number of calls, or whether retries were included, so “about CNY 1” can only be used as an order-of-magnitude reference and does not include network or storage costs.

    4. Three Most Common Batch-Task Problems

    The first is missing captures: a record fails to download, but the failure is not detected. The second is incorrect suffix changes: a script converts extensions uniformly to lowercase or uppercase, causing .MOV files to be renamed. The third is mid-run hangs: network fluctuations cause a download to hang, while the script has no timeout or retry settings.

    These three problems are common in batch tasks, and all can be checked and handled programmatically.

    5. Why Local Small Models Did Not Complete the Task

    The test also tried multiple locally deployed open-source small models, executing the same task through their respective agent frameworks. None completed it. The failures fell mainly into three categories.

    The first category is insufficient code quality. Generated scripts had syntax errors or logic defects, and the model could not correct itself to a working version after errors. The second category is unstable long-context handling. With a 237-line CSV, the model frequently made errors in field alignment, and the naming rule was applied incorrectly. The third category is a lack of task decomposition. The model tried to output all results at once instead of splitting the work into “parse, download, validate, cleanup” steps, so a mid-process failure interrupted the entire flow.

    The source did not provide model names, versions, parameter sizes, hardware configurations, or number of test runs, so this conclusion only shows that under the conditions of this test, local small models could not reliably complete this type of task. It cannot be directly inferred that all local models are incapable.

    The overall performance of an agent can be roughly understood as the combined result of model capability and framework orchestration capability. When model capability is insufficient, framework orchestration design is hard to compensate for it.

    6. Engineering Checklist

    For implementing this type of task, follow these five recommendations.

    1. Write the delivery standard into the task description. For example, explicitly state that “the output directory may contain only video files, with no scripts, logs, or copies.” If implicit cleanup requirements are not written clearly, the agent may handle them according to its own understanding.
    2. Execute scripts locally, place temporary files outside the delivery directory, and delete them after completion.
    3. Add programmatic validation to check file count, filename format, extension whitelist, and whether the files in the directory exactly match the expected set.
    4. Do not overwrite existing directories, to avoid mistakenly deleting already delivered data.
    5. Manage the output directory as sensitive data, restrict access permissions, and delete it as agreed after delivery.

    The following script relies only on the Python standard library and requires Python 3.8 or later. It assumes CSV headers for name, ID number, and video URL. Modify the constants to match your actual headers before running.

    1. import csv
    2. import os
    3. import re
    4. import shutil
    5. import sys
    6. import tempfile
    7. import time
    8. import urllib.request
    9. from urllib.parse import urlparse
    10. CSV_PATH = "users.csv"
    11. OUT_DIR = "videos_out"
    12. COL_NAME = "姓名"
    13. COL_ID = "身份证号"
    14. COL_URL = "视频地址"
    15. ALLOWED_EXT = {".mp4", ".mov"} # Compare in lowercase, preserve original case when saving
    16. MAX_RETRY = 3
    17. TIMEOUT_SEC = 30
    18. NAME_RE = re.compile(r"^[\u4e00-\u9fa5·A-Za-z]{1,30}$")
    19. ID_RE = re.compile(r"^\d{17}[\dXx]$")
    20. FILE_RE = re.compile(r"^[\u4e00-\u9fa5·A-Za-z]{1,30}-\d{17}[\dXx]\.(mp4|MP4|mov|MOV)$")
    21. def load_rows(path):
    22. """Return a list of (line number, record), keeping only rows with a video URL."""
    23. with open(path, encoding="utf-8-sig", newline="") as f:
    24. rows = []
    25. for line_no, row in enumerate(csv.DictReader(f), start=2):
    26. if (row.get(COL_URL) or "").strip():
    27. rows.append((line_no, row))
    28. return rows
    29. def get_ext(url):
    30. """Get the extension from the URL path, preserving original case."""
    31. ext = os.path.splitext(urlparse(url).path)[1]
    32. if ext.lower() not in ALLOWED_EXT:
    33. raise ValueError(f"不支持的扩展名: {ext!r}")
    34. return ext
    35. def download(url, dest):
    36. """Download with timeout and exponential backoff retries; delete partial files on failure."""
    37. for attempt in range(1, MAX_RETRY + 1):
    38. try:
    39. with urllib.request.urlopen(url, timeout=TIMEOUT_SEC) as resp:
    40. with open(dest, "wb") as out:
    41. shutil.copyfileobj(resp, out)
    42. if os.path.getsize(dest) == 0:
    43. raise IOError("下载内容为空")
    44. return
    45. except Exception:
    46. if os.path.exists(dest):
    47. os.remove(dest)
    48. if attempt == MAX_RETRY:
    49. raise
    50. time.sleep(2 ** attempt)
    51. def verify(expected_names):
    52. """Check that directory contents exactly match the expected set and naming is compliant."""
    53. actual = set(os.listdir(OUT_DIR))
    54. if actual != expected_names:
    55. extra = actual - expected_names
    56. missing = expected_names - actual
    57. print(f"校验失败 多余: {extra} 缺失: {missing}", file=sys.stderr)
    58. return False
    59. for name in actual:
    60. if not os.path.isfile(os.path.join(OUT_DIR, name)):
    61. print(f"存在非文件条目: {name}", file=sys.stderr)
    62. return False
    63. if not FILE_RE.match(name):
    64. print(f"命名不合规: {name}", file=sys.stderr)
    65. return False
    66. return True
    67. def main():
    68. rows = load_rows(CSV_PATH)
    69. if os.path.exists(OUT_DIR) and os.listdir(OUT_DIR):
    70. print(f"输出目录非空,拒绝覆盖: {OUT_DIR}", file=sys.stderr)
    71. return 1
    72. os.makedirs(OUT_DIR, exist_ok=True)
    73. tmp_dir = tempfile.mkdtemp(prefix="agent_dl_") # Temporary files outside the delivery directory
    74. expected_names, failures = set(), []
    75. try:
    76. for line_no, row in rows:
    77. try:
    78. name = row[COL_NAME].strip()
    79. id_no = row[COL_ID].strip()
    80. if not NAME_RE.match(name) or not ID_RE.match(id_no):
    81. raise ValueError("姓名或身份证号格式不合法")
    82. url = row[COL_URL].strip()
    83. ext = get_ext(url)
    84. target = f"{name}-{id_no}{ext}"
    85. if target in expected_names:
    86. raise ValueError(f"重名记录: {target}")
    87. part = os.path.join(tmp_dir, f"{line_no}.part")
    88. download(url, part)
    89. shutil.move(part, os.path.join(OUT_DIR, target))
    90. expected_names.add(target)
    91. except Exception as e:
    92. failures.append((line_no, str(e)))
    93. finally:
    94. shutil.rmtree(tmp_dir, ignore_errors=True)
    95. ok = verify(expected_names)
    96. for line_no, reason in failures:
    97. print(f"第{line_no}行失败: {reason}", file=sys.stderr)
    98. return 0 if ok and not failures else 1
    99. if __name__ == "__main__":
    100. sys.exit(main())

    Several design choices in the script are worth explaining. Temporary files are placed in the system temporary directory, so the delivery directory always contains only final files. Failure records are printed only to standard error and are not written to a log file, avoiding extra content in the directory. If any row fails, the script exits with a non-zero status, which the caller can use to trigger a rerun or manual intervention.

    7. Selection and Implementation Advice

    When choosing an agent, evaluate four aspects.

    First, look at the deliverable rather than the process. Open the output directory and check whether it contains only the final artifacts. The difference between the two agents was reflected precisely at this step.

    Second, look at behavior after failure. Give the agent a sample that will fail, and observe whether it can detect the problem, retry, and report truthfully. The source did not cover this point, so it should be tested independently before formal use.

    Third, look at data flow. Confirm how the model service provider handles input data, whether it retains training or log copies, and use that to decide which data can be sent to a cloud model.

    Fourth, look at how costs are calculated. To compare expenses, count the number of calls, token usage, retry count, and storage costs for each task, rather than looking only at the bill amount for a single run.

    Whether local deployment is feasible should be judged by the success rate on real tasks. Benchmark scores cannot replace end-to-end testing on your own data.

    8. Conclusion

    This test covered only two cloud agents and one set of local small models. The sample size is limited, and the conclusions hold only within the test scope. Both cloud agents completed video downloading and naming; the difference was whether the finish was clean. The local small models did not complete the task in this test, but the source did not disclose enough test conditions to infer the performance of other models.

    When working with agents, the clearer the task boundary and acceptance criteria, the more controllable the delivery result. Writing the delivery directory, validation rules, and data handling requirements into the task description is more effective than checking afterward.