AgentSPEX: An Agent SPecification and EXecution Language

Pengcheng Wang, Jerry Huang, Jiarui Yao, Rui Pan, Peizhi Niu, Yaowenqi Liu, Ruida Wang, Renhao Lu, Yuwei Guo, Tong ZhangarXiv 2026

TL;DR

AgentSPEX introduces a declarative, YAML-based specification language and execution harness that decouples LLM agent workflows from complex Python orchestration code. By making control flow, state management, and context explicit, it significantly improves agent controllability, reproducibility, and performance on long-horizon tasks.

What Problem Does This Paper Address?

Building reliable AI agents for complex, multi-step tasks (like software engineering or scientific research) is notoriously difficult. Currently, developers rely on two paradigms, both of which have major drawbacks:

  1. Reactive Prompting (e.g., ReAct): The agent is given a single system prompt and left to figure out its own sequence of tool calls and reasoning steps. This often leads to "context rot" and poor performance on long-horizon tasks because the model must track its own control flow implicitly.
  2. Python-Coupled Frameworks (e.g., LangGraph, CrewAI): These frameworks enforce structure but tightly interleave prompt logic, state management, and control flow within Python code. This creates a steep learning curve, makes agents hard to maintain or share with non-programmers, and leaves them highly sensitive to changes when underlying LLMs are upgraded.

AgentSPEX bridges this gap by providing a human-readable, executable specification language that separates the agent's structural workflow from the underlying execution code.

Methods

The authors introduce a complete ecosystem consisting of three core components:

  • The AgentSPEX Language: A lightweight, declarative vocabulary written in YAML. It supports explicit primitives for invocation (task, step), control flow (if/switch, while, for_each), composition (call to invoke submodules), concurrency (parallel/gather), and state management (set_variable, increment).
  • The Agent Harness: A robust execution environment that runs workflows inside a sandboxed Docker virtual environment. It provides access to over 50 tools via the Model Context Protocol (MCP) and features built-in durability mechanisms like state checkpointing and selective trace replay to handle API timeouts or network failures.
  • Visual Editor: A bidirectional, drag-and-drop visual interface that synchronizes a graphical flowchart view with the underlying YAML code in real-time, making agent design accessible to non-programmers.
Figure 1: An overview of the AgentSPEX Architecture.
Figure 3: Visual editor interface for a deep research agent implemented with AgentSPEX, showing synchronized graph-based and YAML-based views of a workflow with reusable submodules.

Datasets

The authors evaluated AgentSPEX across 7 established benchmarks spanning 5 distinct domains:

  • Software Engineering: SWE-Bench Verified (500 real-world GitHub issues).
  • Mathematics: AIME 2025 (30 competition-level problems).
  • Chemistry/Science: ChemBench (90-question subset), SciBench (213 college-level chemistry problems), and MMLU-Pro Stemez (216 physical chemistry problems).
  • Generative Writing: WritingBench (120-question subset evaluated via LLM-as-a-Judge).
  • Paper Understanding: ELAIPBench (403 multiple-choice questions testing deep comprehension of AI research papers).

Key Insights and Ideas

  • Offloading Control Flow Boosts Reasoning: Forcing an LLM to simultaneously reason about a problem and interpret its own complex workflow structure within a prompt degrades performance. Offloading the control flow logic to the AgentSPEX interpreter frees up the model's cognitive capacity.
  • Granular Context Management Prevents Rot: In standard ReAct setups, the entire conversation history is carried forward, leading to context degradation. AgentSPEX allows authors to explicitly control what information each step receives via context variables, which is particularly vital for document-heavy tasks.
  • Model-Version Robustness: Tightly coupled Python frameworks are fragile when underlying foundation models upgrade. Because AgentSPEX isolates prompts and control structures in declarative YAML, it exhibits remarkable stability across model iterations (e.g., upgrading from Claude-Opus-4.5 to 4.6).

Key Results

AgentSPEX achieved the highest score among compared approaches across all 7 benchmarks:

  • AIME 2025: Achieved a perfect 100.0% accuracy score (using GPT-5).
  • SWE-Bench Verified: Scored 77.1%, outperforming specialized baselines like mini-SWE-agent (76.2%) and Live-SWE-agent (74.6%).
  • Science & Paper Understanding: Showed substantial improvements over Chain-of-Thought (CoT) baselines, including a +6.5% gain on ELAIPBench and a +5.5% gain on ChemBench.
  • User Study: A study with 23 participants revealed that users strongly preferred AgentSPEX over LangGraph for readability, ease of prompting, and creating workflows from scratch.

Limitations and Future Work

While participants praised AgentSPEX's approachability, the user study noted that some developers still preferred imperative frameworks like LangGraph for building highly complex, custom multi-step workflows, expressing less initial confidence in YAML's flexibility for edge cases.

To address this, the authors point to several promising future directions:

  • Implementing formal verification of agent execution trajectories using formal languages like Lean or Isabelle.
  • Training models to automatically write and modify AgentSPEX workflow files.
  • Expanding the framework to natively support complex multi-agent orchestration patterns.

Summary updated

BibTeX
@misc{wang2026agentspex,
  author = {Pengcheng Wang and Jerry Huang and Jiarui Yao and Rui Pan and Peizhi Niu and Yaowenqi Liu and Ruida Wang and Renhao Lu and Yuwei Guo and Tong Zhang},
  title = {{AgentSPEX: An Agent SPecification and EXecution Language}},
  year = {2026},
  eprint = {2604.13346},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2604.13346},
}
Figure