arXiv:2610.18216cs.CLOct 2026

Manuscript Offprint

arXiv:2610.18216

TextualRL: Textual Reinforcement Learning for Context Management

Tianyu Huai, Jie Zhou, Bo Mao, Qin Chen, Liang He, Xipeng Qiu

ABSTRACT

LLM agents can adapt to task feedback by revising the textual context that guides their behavior, without changing their model parameters. However, turning execution rewards into reusable context updates is challenging: individual trajectories offer limited comparative evidence about what to change, while task-specific fixes may overgeneralize when incorporated into a shared context. We introduce TextualRL, a gradient-free reinforcement learning framework that treats a group of rollouts from the same task under the same context, rather than an isolated trajectory, as the unit of policy critique. Groupwise Policy Critique contrasts successful and failed rollouts within a task; when outcomes are uniform, it draws on cross-task evidence to identify behaviors worth preserving or formulate repair hypotheses. Cross-Group Policy Update reviews the resulting proposals against evidence pooled across groups, including observations that yield no proposed edit, to refine their content and applicability. Reviewed proposals form a bounded textual patch, with adoption of the candidate context determined by held-out validation rewards. Together, these components establish a reward-driven policy optimization loop in which multiple attempts jointly inform reusable context updates. We evaluate TextualRL with five target agents on six benchmarks. Averaged over the six benchmarks, TextualRL improves test accuracy over the base model by 24.4 and 15.3 percentage points for GPT-5.5 and Qwen3.8-27B, respectively.

1 Introduction

Reinforcement learning (RL) improves an agent's behavior through interaction and reward [1]. For LLM agents whose parameters are unavailable for optimization, textual context offers an alternative interface for adaptation: instructions and procedures condition how a fixed model interprets tasks, uses tools, and produces outputs. Reflexion [2] incorporates verbal feedback into subsequent attempts, while Agentic Context Engineering (ACE) [3] evolves contextual playbooks from execution experience. These developments motivate policy optimization in context space: the objective remains higher task reward, but the optimization variable is the context rather than the model weights.

Existing work provides several mechanisms for optimizing textual artifacts. ProTeGi [4] and TextGrad [5] use natural-language feedback to guide updates, while GEPA [6] combines reflection on execution traces with evolutionary prompt search. For agent skills, Trace2Skill [7] extracts trajectory-local lessons and hierarchically consolidates them into reusable instructions. SkillOpt [8] instead analyzes successful and failed trajectory minibatches separately, merges their proposed edits, and validates bounded skill updates. These methods establish the value of execution-driven adaptation, while highlighting an important design choice: how should trajectories be organized before their feedback is converted into a shared context update?

Group-based RL provides a useful organizing principle. Group Relative Policy Optimization (GRPO) [9] samples multiple responses to the same question and uses their relative rewards to guide parameter updates. For textual adaptation, a group of same-task rollouts likewise provides a comparison unavailable from an isolated execution: under

∗^{*}Corresponding author.

Figure

Figure 1: Conceptual comparison of parameter-space and context-space policy optimization. TextualRL uses groups of same-task rollouts and their rewards to propose textual edits ΔC\Delta C to context CC, while the target model remains frozen.

the same task and context, which behavioral differences accompany different outcomes? Comparative experience learning is also explored by ExpeL [10] and ReasoningBank's parallel MaTTS [11], which extract reusable insights or memories from alternative executions. Building on this perspective, we ask: how can groups of rewarded executions drive policy optimization when updates are made to shared textual context rather than model parameters? The goal is not merely to select a successful attempt, but to use multiple attempts to improve the policy governing future executions.

Turning grouped experience into a context update presents two challenges. First, rewards identify outcomes, not the instructions that should change. Within-task success–failure comparisons provide evidence about alternative behaviors, but this contrast disappears when every sampled rollout succeeds or every rollout fails. An analysis procedure must therefore distinguish evidence supporting preservation from evidence suggesting an unverified repair. Second, a context is shared across tasks, whereas a proposed modification may be supported only under particular conditions. Merging proposals alone cannot reveal every exception: a successful execution may require no edit while still contradicting another group’s proposed rule. Effective updates therefore require both outcome-aware policy critique and a review of the evidence that supports or limits each modification.

We introduce TextualRL, a gradient-free reinforcement learning algorithm for context management that treats same-task rollout groups as the basic unit of policy critique. As illustrated in Figure 1, each iteration collects multiple executions per task under the current context while keeping the target model frozen. Groupwise Policy Critique compares successful and failed rollouts within mixed-outcome tasks; for all-success or all-failure tasks, it uses cross-task evidence to identify behaviors worth preserving or formulate repair hypotheses, respectively. The critics return edit proposals and trajectory evidence separately, retaining observations even when no edit is proposed. Cross-Group Policy Update reviews consolidated proposals against evidence pooled across analysis groups, retaining, narrowing, or revising instructions according to their support and applicability. The reviewed edits form a bounded textual patch. A step-level validation gate accepts the candidate context only if its reward on held-out tasks exceeds the recorded reference score. The selected context then conditions subsequent rollouts, closing a reward-driven policy optimization loop without model-parameter updates. We evaluate TextualRL with five target agents across six benchmarks. Averaged over the six benchmarks, TextualRL improves test accuracy over the no-skill baseline by 24.4 and 15.3 percentage points for GPT-5.5 and Qwen3.8-27B, respectively. The corresponding gains over the best baseline are 0.9 and 3.2 percentage points.

Our contributions are threefold:

• We introduce TextualRL, a group-based algorithm for gradient-free policy optimization over the shared textual context of a frozen LLM agent.

• We develop Groupwise Policy Critique, which uses the available reward structure to combine within-task comparisons with cross-task preservation and repair analysis.

• We develop Cross-Group Policy Update, which retains evidence independently of edit proposals to review their content and applicability before bounded, validation-gated updates.

References (26)