How can enterprise engineering teams stop paying for redundant LLM context and force web agents to retain only the data that improves decision-making? The standard approach of selecting agent context through semantic relevance—using tools like BM25 retrieval—fails to guarantee that retrieved memories actually help the agent execute multi-step tasks. In practice, the memories most semantically similar to a current state often bloat the context window without improving action accuracy, driving up token costs across long execution traces. Shifting from semantic relevance to marginal decision utility lowers inference expenses while preventing autonomous web agents from degrading over long horizons.
Building dependable long-horizon web agents requires tackling delayed threats and compounding historical errors. In September 2026, research into persistent AI memory vulnerabilities demonstrated how multi-step attack trajectories exploit long-term context retention across enterprise setups. As the analysis by a team at the University of Calgary demonstrated, examining 2,614 simulated multi-step attack trajectories against memory-enabled LLM agents across four threat vectors—chain poisoning, policy rewriting, backdoor triggering, and slow drift—highlights these risks. Managing what an agent retains over long operational sequences is therefore both a cost imperative and an architectural stability requirement.
Quantifying Decision Utility Through Counterfactuals
To address this architectural bottleneck, researchers Quanjiang Guo, Qianyang Zhu, Ben Zhang, Jinchuan Zhang, Ke Yan, and Zhao Kang from UESTC, alongside Sijie Wang from Nanyang Technological University, introduced MemCredit. MemCredit is a decision-centric memory framework that shifts memory selection from semantic relevance to decision utility. Instead of assuming that semantically related text is useful, MemCredit estimates the state-, reference-context-, and policy-conditional marginal contribution of individual memories through controlled counterfactual interventions. It then distills these intervention-derived credits into a lightweight utility estimator.
"Existing methods primarily optimize storage, retrieval, or compression, but the memories most semantically relevant to the current state are not necessarily those that most improve the agent's action," as the authors noted.
This counterfactual approach reveals that memory utility in long-horizon tasks is highly sparse. This statistic directly refutes the common assumption that higher semantic retrieval recall leads to better decisions. Most retrieved context functions as dead weight, inflating compute costs without impacting the agent's choice of action.
Retaining High Recall While Budgeting Tokens
At inference time, MemCredit uses semantic relevance only for high-recall candidate generation. Predicted utility then arbitrates which candidate memories are retained under a fixed token budget, without modifying the underlying agent policy or requiring additional environment interaction. By decoupling candidate retrieval from token allocation, system architects can strictly bound context budgets without sacrificing operational performance.
MemCredit achieves the highest task score while maintaining strict token limits across extended evaluation horizons.
This reduction directly shifts the unit economics of autonomous web agents. As the evaluation on ALFWorld and WebShop against representative memory baselines demonstrates, MemCredit holds success rates at 86.57% against 65.67% for BM25 under a strict historical memory limit of 500 tokens.
As enterprise LLM deployments scale from simple single-turn prompts to long-horizon web agents, context window management becomes a primary cost driver. Filtering historical interactions by predicted decision utility rather than text similarity breaks the linear coupling between trajectory length and inference overhead. Systems that replace traditional retrieval with lightweight utility estimators reduce token consumption while maintaining execution accuracy across complex tasks.
Against the field
Where engineers previously bloated an agent's context window with semantically close data via tools like BM25, MemCredit now discards that paid ballast in favor of action-specific utility. In early September, an [evolving library after a five-iteration warm-up] (ref:1) demonstrated evaluator score improvements of up to 18.6 percentage points, yet accumulating context indefinitely remains constrained by risks like chain poisoning and operational degradation. Calculating the marginal contribution of each memory through counterfactual interventions proves far more practical than purchasing redundant tokens in the hope of better accuracy. Enterprise systems paid for broad semantic recall for years, only to learn that agent decisions hinge on an extremely sparse fraction of those memories.
Our stories: Persistent Memory for UI Agents Cuts Token Burn and Latency (September 8).