TL;DR
CLEAR (Context Augmentation from Contrastive Learning of Experience via Agentic Reflection) is a novel framework that trains a lightweight model to generate task-specific hints for LLM agents. By analyzing past successful and failed trajectories using contrastive learning and optimizing via reinforcement learning, CLEAR significantly boosts agent performance without modifying the weights of the underlying (and often expensive or closed-source) execution LLM.
What Problem Does This Paper Address?
While Large Language Model (LLM) agents excel at sequential decision-making, they often struggle with complex, knowledge-intensive tasks because they rely heavily on static parametric knowledge. Existing context engineering techniques like Retrieval-Augmented Generation (RAG) or prompt optimization attempt to fix this by retrieving past experiences or using general-purpose playbooks.
However, these approaches introduce a major bottleneck: the retrieved context is often raw and unadapted, forcing the execution agent to spend its own limited reasoning capacity figuring out how to apply past lessons to a new situation. This problem worsens when using weaker or closed-source models where weight-level fine-tuning is impossible. CLEAR addresses this by shifting the adaptation burden away from the execution agent and into a dedicated, trainable Context Augmentation Model (CAM).
Methods
CLEAR introduces a three-phase training pipeline to build the Context Augmentation Model (CAM):
- Agentic Reflection via Contrastive Learning (Phase 0): The system runs training tasks multiple times to collect a diverse set of successful and failed execution trajectories. A reflection agent, equipped with a shell tool to efficiently parse large log files, performs a contrastive analysis comparing what worked versus what failed for the exact same task. It distills these insights into high-quality, task-specific instructions.
- Supervised Fine-Tuning (Phase 1): These distilled instructions are paired with their initial task descriptions to form an SFT dataset. A smaller, open-source LLM (specifically Qwen-32B) is fine-tuned on this data to initialize the CAM.
- Reinforcement Learning via GRPO (Phase 2): To directly align the CAM with the execution agent's success, the CAM is further optimized using Group Relative Policy Optimization (GRPO). The frozen execution agent runs the task using the CAM's generated context, and the final environment reward is fed back to update only the CAM's parameters.
At inference time, the pipeline is straightforward: a new task query is fed into the CAM, which generates an optimized context snippet. This snippet is appended directly to the prompt of the execution agent.
Datasets
The authors evaluated CLEAR on two prominent agent benchmarks:
- AppWorld: A complex benchmark testing interactive coding agents that control web applications via APIs. Testing was performed on the official, disjoint
TEST-Nsplit. - WebShop-40k: A customized variant of the WebShop e-commerce benchmark. Due to Docker image size constraints within their high-concurrency environment (Amazon Bedrock AgentCore), the authors downsampled the product catalog to 40,000 items and filtered the tasks to ensure ground-truth items remained present.
Key Insights and Ideas
- Contrastive Reflection is Superior: Reflecting on a single trajectory provides a narrow, noisy view. By forcing the reflection agent to explicitly contrast successful runs against failed ones for the same task, it extracts significantly cleaner, more actionable strategic insights.
- Parametric Context Generation Beats Retrieval: Instead of searching a database for the nearest-neighbor past experience (as in RAG), the CAM internalizes strategic patterns within its weights, mapping new tasks directly to tailored hints.
- Remarkable Model Transferability: One of the most surprising findings was that a CAM trained entirely on trajectories and feedback from Claude-Sonnet-4 generalized remarkably well to a completely different execution model (DeepSeek-V3.1) at test time without any retraining.
Key Results
CLEAR consistently outperformed vanilla baselines, standard RAG, and state-of-the-art prompt optimization methods like Agentic Context Engineering (ACE).
- AppWorld: Using Claude-Sonnet-4 as the execution agent, CLEAR boosted the Task Goal Completion (TGC) rate from 72.62% to 81.15% and Scenario Goal Completion (SGC) from 52.38% to 66.67%, outperforming both RAG and ACE.
- WebShop-40k: CLEAR improved the average task reward from 0.68 to 0.74.
- DeepSeek Transferability: When evaluating the weaker DeepSeek-V3.1 model on AppWorld, standard RAG and ACE actually degraded performance compared to the baseline (likely due to the added reasoning clutter). In contrast, the Claude-trained CLEAR CAM successfully improved DeepSeek's TGC by 1.68% and SGC by 5.35%.
Limitations and Future Work
- Downsampled Benchmarks: The evaluation on WebShop was restricted to a 40k item subset due to infrastructure image size limits, meaning performance on massive, million-scale retrieval environments remains unverified.
- Latency Overhead: Invoking the CAM adds a modest latency penalty (averaging 1.2 seconds per task invocation), and because the agent performs better, it tends to take slightly more environment turns, increasing overall execution time.
- Future Directions: The authors suggest exploring how this framework scales to even smaller, edge-deployable CAMs and testing its limits across a broader variety of multi-modal agent environments.
Summary updated