Executable Code Actions Elicit Better LLM Agents

Xingyao Wang, Yangyi Chen, Lifan Yuan, Yizhe Zhang, Yunzhu Li +2 more
2/12/2026

No official code found. Best implementation: xingyaoww/code-act (1,700 stars, MIT, last commit 2024-05-23). 1 more below.

Abstract

Large Language Model (LLM) agents, capable of performing a broad range of actions, such as invoking tools and controlling robots, show great potential in tackling real-world challenges. LLM agents are typically prompted to produce actions by generating JSON or text in a pre-defined format, which is usually limited by constrained action space (e.g., the scope of pre-defined tools) and restricted flexibility (e.g., inability to compose multiple tools). This work proposes to use executable Python code to consolidate LLM agents' actions into a unified action space (CodeAct). Integrated with a Python interpreter, CodeAct can execute code actions and dynamically revise prior actions or emit new actions upon new observations through multi-turn interactions. Our extensive analysis of 17 LLMs on API-Bank and a newly curated benchmark shows that CodeAct outperforms widely used alternatives (up to 20% higher success rate). The encouraging performance of CodeAct motivates us to build an open-source LLM agent that interacts with environments by executing interpretable code and collaborates with users using natural language. To this end, we collect an instruction-tuning dataset CodeActInstruct that consists of 7k multi-turn interactions using CodeAct. We show that it can be used with existing data to improve models in agent-oriented tasks without compromising their general capability. CodeActAgent, finetuned from Llama2 and Mistral, is integrated with Python interpreter and uniquely tailored to perform sophisticated tasks (e.g., model training) using existing libraries and autonomously self-debug.

View on arXivView PDF

Code Implementations(2)

xingyaoww/code-actCommunity100%
MIT

Official Repo for ICML 2024 paper "Executable Code Actions Elicit Better LLM Agents" by Xingyao Wang, Yangyi Chen, Lifan Yuan, Yizhe Zhang, Yunzhu Li, Hao Peng, Heng Ji.

1,700146CSS, HTMLJan 13, 20242 years agoMIT
llmllm-agentllm-finetuningllm-framework
epfLLM/Megatron-LLMCommunity100%

distributed trainer for LLMs

59087C, C++Jul 28, 20232 years agoNOASSERTION

Similar Papers

Cite this paper

@article{wang2026executable,
  title  = {Executable Code Actions Elicit Better LLM Agents},
  author = {Xingyao Wang and Yangyi Chen and Lifan Yuan and Yizhe Zhang and Yunzhu Li and Hao Peng and Heng Ji},
  year   = {2026},
  eprint = {2402.01030},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2402.01030},
  journal = {ICML 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2402.01030.svg)](https://codeofpaper.com/paper/2402.01030)

Discussion