TL;DR

Code as Agent Harness (arXiv 2605.18747) là một survey từ Stanford University, Meta, và University of Illinois Urbana-Champaign định nghĩa lại role của code trong hệ thống AI agentic. Thay vì code chỉ là target output mà LLM phải sinh ra, nó trở thành operational substrate - nền tảng toàn bộ hệ thống: cách agent suy luận, thực thi, mô hình hóa môi trường, và xác minh tiến trình.

Framework tổ chức harness thành 3 layer liên kết:

  • Harness Interface: Code for Reasoning, Acting, Environment Modeling
  • Harness Mechanisms: Planning, Memory, Tool Use, Plan-Execute-Verify loop
  • Multi-Agent Orchestration: Shared code artifacts để coordination

Kết quả: Alibaba Cloud's LingmaAgent xử lý 16.9% lỗi tự động + 43.3% với hỗ trợ con người tại sản xuất, chứng minh quy trình này vượt trội so với purely textual reasoning. Roadmap tiếp theo là xây dựng harness engineering như một ngành kỹ thuật, không chỉ prompt tuning.

Tại Sao Code Trở Thành Infrastructure?

Trước đây, các framework AI agent coi code như là end product - thứ mà LLM phải sinh ra đúng. Chain-of-thought thuần dùng ngôn ngữ tự nhiên cho toàn bộ quá trình suy luận, nhưng điều này gây ra 2 vấn đề chính:

  • Không thể xác minh: Suy luận dạng text khó kiểm chứng - LLM có thể commit logic errors và không ai (kể cả harness) biết được
  • Không có state dẫn định: Mỗi step mất đi tiến trình trước đó; không có "bộ nhớ thực thi" để track progress qua long-horizon tasks

Code-as-agent-harness giải quyết bằng cách biến code thành medium kết nối model với môi trường. Code là executable (nên harness có thể verify kết quả), inspectable (traces và logs là readable), và stateful (progress persist qua steps).

3-Layer Kiến Trúc Harness

Architecture của Code-as-Agent Harness
Ba layer liên kết: Interface - Mechanisms - Orchestration

Layer 1: Harness Interface

Nơi code kết nối agent với 3 vai trò chính:

  • Code for Reasoning: Externalize logic thành executable programs thay vì text. Ví dụ: thay vì "Agent suy luận X => Y => Z", agent viết code để compute Z, harness chạy nó, capture output, và feedback lỗi ngay lập tức
  • Code for Acting: High-level intent => grounded executable ops. Một command "click button" trở thành Playwright script, "update database" trở thành SQL statement - cái mà harness có thể verify, audit, và rollback
  • Code for Environment: Environment state không còn implicit trong text observations. Thay vào đó, repositories, tests, traces, simulators là structured, queryable code artifacts mà agent có thể inspect & modify

Layer 2: Harness Mechanisms

Làm cho agent reliable qua multiple steps:

  • Plan-Execute-Verify (PEV) Loop: Agent externalize intended trajectory => execute trong sandbox => verify output qua deterministic sensors (linters, tests, static analyzers)
  • Memory & Context Engineering: Manage mutable state across long interactions - working memory (active context), semantic memory (repo evidence), experiential memory (past solutions), long-term memory (validated knowledge)
  • Tool Use & Governance: Governed access tới APIs, execution environments, verification tools - với explicit permission tiers từ read-only tới full-access production commands
  • Agentic Harness Engineering (AHE): Evolution Agents analyze telemetry từ failed trajectories, propose harness mutations (bộ tool mới, retrieve policy tốt hơn, linter thêm), verify qua regression suites trước khi deploy

Layer 3: Orchestration Multi-Agent

Scaling từ single-agent tới multi-agent ecosystems. Thay vì coordinate qua conversational agreement (LLM 1 nói "OK", LLM 2 nói "tôi đồng ý"), agents modify shared code artifacts & rely trên execution feedback - pass/fail tests, runtime errors, coverage gaps - để converge on solution. Roles: planner, coder, reviewer, tester, security agent - mỗi cái modified cùng một repository & verify lẫn nhau qua objective signals.

Benchmark & Production Deployments

Các số liệu thực tế:

  • Alibaba LingmaAgent: 16.9% in-house software issues xử lý tự động, 43.3% với human intervention tại Alibaba Cloud - production-scale deployment
  • QualityFlow: Imagined Execution (LLM simulate Python interpreter step-by-step) đạt 98%+ precision & recall trên MBPP benchmark, với 75-84% problems converge sau call đầu tiên
  • MLE-bench (Kaggle 75 competitions): OpenAI o1-preview + Weco AIDE tree-search agent đạt 16.9% bronze medal rate - khoảng 3x tốt hơn agent tốt thứ hai
  • Berkeley A-Lab (Autonomous Chemistry): Tổng hợp 41 novel inorganic compounds từ danh sách 58 trong 17 ngày hoạt động liên tục
  • El Agente Q (Computational Chemistry): 87%+ task success qua 6 university-level benchmarks, emit transparent action traces

Production GUI/OS Agents: Anthropic Claude Computer Use (beta), OpenAI Operator, Google Project Mariner, ByteDance UI-TARS-desktop, Zhipu AutoGLM, Tencent AppAgent - toàn bộ deploy 2025-2026, chứng tỏ code-as-harness pattern chuyển từ lab sang production nhanh chóng.

So Sánh với Cách Tiếp Cận Cũ

Khía Cạnh Cách Tiếp Cận Cũ Code-as-Agent-Harness
Vai trò Code Target artifact LLM sinh ra Operational substrate toàn hệ thống
Suy luận Chain-of-thought text thuần Externalize thành executable code, verify bằng interpreters
Planning Linear decomposition outline Harness-level control: search-based, structure-grounded, orchestration-based
Memory Conversational history scratchpad Structured system component: working/semantic/experiential/long-term memory
Multi-Agent Coordination Message-passing + conversational agreement Artifact-mediated communication, execution-based objective signals
Environment Opaque external process Explicitly modeled repositories, traces, tests, simulators

5 Lĩnh Vực Ứng Dụng Chính

  1. Autonomous Coding Assistants: Claude Code, GitHub Copilot, Alibaba LingmaAgent - xử lý repository-level workflows, pull requests, CI/CD feedback, production issue resolution
  2. GUI/OS Automation: Screenshot in => Playwright/shell commands out - từ web browsing tới enterprise data pipelines (BigQuery, dbt, Airbyte)
  3. Scientific Discovery: AI Scientist, ChemCrow, Virtual Lab - hypothesis generation => protocol execution => analysis qua executable pipelines. Virtual Lab designed 92 SARS-CoV-2 nanobodies, 2 cái validated binding
  4. Embodied Agents & Robotics: Generate control policies, multi-robot coordination, transfer across hardware
  5. Personalization & Recommenders: User preference state maintained via code, feedback loops update policies dynamically qua A/B tests

Thách Thức & Roadmap

Những vấn đề còn mở:

  • Oracle Adequacy Crisis: Benchmark chỉ measure end-task success, không phải harness quality. Tests có thể incomplete, simulators hide real-world risks
  • Semantic Verification: Execution feedback tạo false confidence - green tests ≠ correctness. Cần epistemically aware verification stacks (property-based testing, fuzzers, security scanners)
  • Transactional Shared State: Multi-agent systems bị "belief state divergence" - agent A plan từ old snapshot khi agent B test phiên bản mới. Cần semantic conflict resolution
  • Human-in-the-Loop Safety: Safety không thể delegate tới prompts. Cần multi-tier permissions + auditable approval logs
  • Regression-Free Harness Evolution: Evolution Agents có thể self-optimize, nhưng risk overfitting, weakening safety. Cần change contracts & canary deployments
  • Multimodal Grounding: GUI/embodied agents manage massive visual data, cần context compression + grounding contracts

Roadmap 2026+: Shift từ prompt engineering sang harness engineering như một science. Xây dựng systems là executable (code-based decisions), inspectable (auditable traces), stateful (persistent across agents), governed (permissions + accountability).

Kết

Code as Agent Harness đánh dấu bước chuyển hướng trong AI agentic: từ "hãy sinh ra code đúng" sang "code là cơ sở hạ tầng để agent thực thi, suy luận, & xác minh". Không phải code là cuối cùng - nó là medium qua đó agents coordinate, learn, & adapt long-horizon behaviors.

Với Alibaba Cloud, Google, Anthropic, OpenAI, Meta tất cả đang deploy systems này, era tiếp theo không phải là "better models" mà là "better harnesses" - richer planning, verification, memory, safety governance. Harness engineering, không prompt engineering, sẽ là bottleneck & frontier tiếp theo.

Đọc full paper: via arXiv 2605.18747