Papers › Agent-R: Training Language Model Agents to Reflect via Iterative Self-Training

Agent-R: Training Language Model Agents to Reflect via Iterative Self-Training

20 Jan 2025arXiv:2501.11425archive 2025-07-28

Siyu Yuan, Zehui Chen, Zhiheng Xi, Junjie Ye, Zhengyin Du, Jiecao Chen

Large Language Models (LLMs) agents are increasingly pivotal for addressing complex tasks in interactive environments. Existing work mainly focuses on enhancing performance through behavior cloning from stronger experts, yet such approaches often falter in real-world applications, mainly due to the inability to recover from errors. However, step-level critique data is difficult and expensive to collect. Automating and dynamically constructing self-critique datasets is thus crucial to empowering models with intelligent agent capabilities. In this work, we propose an iterative self-training framework, Agent-R, that enables language Agent to Reflect on the fly. Unlike traditional methods that reward or penalize actions based on correctness, Agent-R leverages MCTS to construct training data that recover correct trajectories from erroneous ones. A key challenge of agent reflection lies in the necessity for timely revision rather than waiting until the end of a rollout. To address this, we introduce a model-guided critique construction mechanism: the actor model identifies the first error step (within its current capability) in a failed trajectory. Starting from it, we splice it with the adjacent correct path, which shares the same parent node in the tree. This strategy enables the model to learn reflection based on its current policy, therefore yielding better learning efficiency. To further explore the scalability of this self-improvement paradigm, we investigate iterative refinement of both error correction capabilities and dataset construction. Our findings demonstrate that Agent-R continuously improves the model's ability to recover from errors and enables timely error correction. Experiments on three interactive environments show that Agent-R effectively equips agents to correct erroneous actions while avoiding loops, achieving superior performance compared to baseline methods (+5.59%).

PaperPDFCodeCode Syntology ran

In Syntology Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, Syntology's MCP tool lists every function and class Syntology harvested from this paper and whether it ran (how to connect): get_harvested_code_for_paper(arxiv_id="2501.11425")

Code

Syntology Ran 6 of 11 code samples harvested from 1 repository linked to this paper; 5 have no recorded run. Of those that ran: 6 ran with no contract checked.

By repository: official repository: 11 samples from 1 repository, 6 ran. The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

bytedance/agent-r officialmentioned in papermentioned on GitHubApache-2.0 report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

Code Syntology ran Syntology

11 samples harvested; 6 ran; 0 honoured the contract we drafted; 5 have no recorded run. Read from Syntology's graph 2026-09-24; that is when this build read the record, not when the samples ran.

6ran
5unverified

Licence: 0 of the 11 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from bytedance/agent-r. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself; “our draft was wrong” and “fixture could not drive it” are failures of Syntology's instrument, not of the code.

Each sample ends with its code_sha256, Syntology's identity for that exact code. An agent fetches the stored sample with Syntology's MCP tool get_code(code_sha256="…") (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples from a repository marked official are listed first. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of four reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; or the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar). Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

clean bytedance/agent-r/mcts_utils/sciworld/data_utils_sw.py official repository ran fingerprinted Apache-2.0 (permissive) · 44320b583dfcfb30 · report
clean_look bytedance/agent-r/mcts_utils/sciworld/eval_utils_sw.py official repository ran fingerprinted Apache-2.0 (permissive) · 1f706832c8a6cfa6 · report
find_non_alpha_index bytedance/agent-r/mcts_utils/sciworld/eval_utils_sw.py official repository ran fingerprinted Apache-2.0 (permissive) · 2e2114f582089313 · report
is_action_failed bytedance/agent-r/mcts_utils/sciworld/eval_utils_sw.py official repository ran Apache-2.0 (permissive) · d3708c14e4ebb83f · report
read_json bytedance/agent-r/mcts_utils/llm_server.py official repository ran Apache-2.0 (permissive) · fc1433d5441ae6d6 · report
read_jsonline bytedance/agent-r/mcts_utils/llm_server.py official repository ran Apache-2.0 (permissive) · 66af883835d43b5c · report
find_leaf_paths bytedance/agent-r/path_collection.py official repository unverified Apache-2.0 (permissive) · aa7f0424abfd1dc9 · report
get_last_processed_index bytedance/agent-r/mcts_utils/llm_server.py official repository unverified Apache-2.0 (permissive) · 3267d566c3f09e5d · report
get_real_task_id bytedance/agent-r/mcts_utils/sciworld/data_utils_sw.py official repository unverified Apache-2.0 (permissive) · a42373c7254c4594 · report
node_avg_value bytedance/agent-r/path_collection.py official repository unverified Apache-2.0 (permissive) · 1e1d935fc3c062b8 · report
sanitizeStr bytedance/agent-r/mcts_utils/sciworld/data_utils_sw.py official repository unverified Apache-2.0 (permissive) · a3d1f7c9f307b55f · report

Tasks

Language ModelingLanguage Modelling

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections