AI Penetration Testing Agents Struggle with Context and State Management
A comprehensive review of recent research indicates that AI agents designed for autonomous penetration testing frequently fail due to an inability to maintain context and state across different attack stages.

A systematic review of 111 studies published between 2025 and 2026 has identified a critical limitation in current AI agents designed for autonomous penetration testing: their persistent struggle with maintaining context and state across various stages of an attack.
Researchers from California State University, San Bernardino, analyzed experimental studies to determine the capabilities required for an AI agent to conduct a complete, authorized penetration test from inception to completion. They developed a framework called the Autonomous Penetration Intelligence Stack (APIS) to categorize attack stages, including reconnaissance, asset discovery, vulnerability discovery, exploit intelligence, privilege escalation, lateral movement, and persistence, with additional layers for decision-making and defensive evaluation.
While AI agents demonstrate proficiency in executing individual stages of a penetration test, their ability to transition smoothly between these stages is severely hampered. The review highlights that success in isolated tasks does not translate to end-to-end effectiveness, with one benchmark indicating only a 31% success rate for complete pipelines. Common failures include agents relying on outdated information, misfiling data under incorrect assets or identities, and accepting plausible but incorrect proof of action success.
The primary culprit for these failures, particularly in lateral movement, is the degradation of the agent's internal "picture" of the network. This often stems from stale credentials, outdated routing information, or a general inability to update its knowledge base as the environment changes or as previous actions succeed or fail. The authors emphasize that reliable autonomous penetration testing requires agents to maintain accurate and verified knowledge of the target environment throughout the entire attack lifecycle.
Beyond state management, the review points to issues with data handling and validation. Researchers recommend that agents should meticulously record the origin and ownership of credentials and other sensitive data, along with their intended targets and expiration dates. Furthermore, it's advised that the action execution and success validation should be handled by separate models to prevent self-deception and ensure objective assessment of outcomes.
The research also calls for more robust cleanup and reporting mechanisms. Systems should be designed to revert any modifications made by the agent, such as file changes, service alterations, or policy updates, and the success of this cleanup should be verified. Evaluations should also track potential side effects like account lockouts, service disruptions, and the detection signals generated for security monitoring tools.
Persistence, a crucial aspect of advanced attacks, remains an area with limited research, with only five studies addressing it. One study noted that malicious web content could implant instructions in an agent's long-term memory, affecting subsequent sessions. For persistence to be considered successful, agents must be able to re-establish access and verify that all modifications have been properly cleaned up.
Currently, most research in this domain relies on controlled environments like capture-the-flag challenges, cyber ranges, and lab setups. The review notes a lack of testing in complex, real-world scenarios such as cloud, container, and Kubernetes environments. The authors propose a capability-maturity model for future validation and advocate for benchmarks that simulate dynamic network conditions, evolving defender tactics, and long-running campaigns to better assess AI agent capabilities.