Code Generation

The capability of LLMs to produce executable code in programming languages (primarily Python). A foundational capability for REPL-based agents like Recursive Language Models (RLMs).

Overview

Code generation is the ability of an LLM to write syntactically correct, semantically meaningful code in response to natural language prompts. This capability is essential for:

  • REPL-based agents (e.g., recursive-language-model) where the LLM writes Python code to manipulate external state
  • Program-aided language models (pal-program-aided-language-models) where code is used as an intermediate reasoning step
  • Tool-use agents where the LLM generates code to call APIs or functions

Role in RLM Architecture

In the Recursive Language Model (RLM) paradigm (recursive-language-model), code generation is the primary action space. The LLM does not produce natural language responses directly; instead, it writes Python code that:

  1. Explores the prompt variable (prompt.find(), prompt.split(), slicing)
  2. Calls sub_RLM() recursively on prompt slices
  3. Builds intermediate results in REPL variables
  4. Assigns the final answer to Final

This requires the LLM to have strong code-generation capabilities — specifically, the ability to write correct Python with proper syntax, control flow, and function calls.

Implications

Model capability requirement: RLMs and similar REPL-based architectures require base models with strong code-generation skills. The paper evaluates on GPT-5 and Qwen3-Coder-480B-A35B, both of which excel at code generation.

Syntax errors as failure mode: The paper notes that Qwen3-Coder has higher syntax error rates in RLM trajectories, which propagate through recursive calls and degrade performance. This highlights that code-generation reliability is a key bottleneck for REPL-based agents.

Training transfer: The RLM-Qwen3-8B fine-tuning experiment shows that code-generation patterns for REPL interaction can be learned from distilled trajectories (1,000 samples), improving performance by 28% median.

Sources

1

Footnotes

  1. raw/prompts/articles/recursive-language-models-arxiv-2512-24601v3.md ↩