CodeAct is the name Executable Code Actions Elicit Better LLM Agents gives to using executable Python code to consolidate a large language model agent’s actions into a unified Action-Space. It is proposed against the common arrangement in which an agent is prompted to produce actions by generating JSON or text in a pre-defined format — an arrangement the paper describes as limited by a constrained action space, such as the scope of the pre-defined tools, and by restricted flexibility, such as an inability to compose multiple tools.
Usage
CodeAct is paired with an integrated Python interpreter. With one in place, the paper states that CodeAct can execute code actions and dynamically revise prior actions or emit new actions upon new observations, through multi-turn interactions — so the code is not only the notation for an action but the thing that runs, and its result feeds the next turn.
When It Applies
The approach applies to agents that act by calling tools and operating on an environment, and it assumes two things are available: a Python interpreter the agent’s output can be executed by, and a model able to emit code as its action format. Where those hold, the paper’s argument is that one action space subsumes what a fixed tool schema would have to enumerate, because composing several tools is ordinary code rather than a capability the format has to provide for.
Its standing is that of a proposal with a reported comparison behind it rather than a settled convention. The paper reports an analysis of 17 LLMs on API-Bank and a newly curated benchmark in which CodeAct outperforms widely used alternatives by up to 20% higher success rate, and the same authors go on to finetune CodeActAgent on CodeActInstruct, a dataset of 7k multi-turn interactions using CodeAct. The work was accepted by ICML 2024.