Abstract:In security testing scenarios involving large-scale assets, dynamic business logic, and compositional risks, rule-based scanners have difficulty covering unknown attack surfaces, while single large language models tend to suffer from context inflation, objective drift, and uncontrolled cost.To improve the coverage, controllability, and auditability of agent-based security testing, this paper proposes a state-space collaborative method.The method models security testing as a directed search process from known asset states to verifiable risk-evidence states, constructs five layers: task-boundary layer, shared-state layer, scheduling-control layer, execution-unit layer and safety-guard layer, and realizes closed-loop problem solving through evidence consolidation, candidate-direction ranking, budget constraints, multi-perspective evaluation, and hierarchical context compression.Experimental results and analysis show that the proposed method can transform the capabilities of large language models from single-turn question answering into continuous verification.Through shared-state, feedback control, and evidence write-back, the method supports task progression, process traceability, and result verification in complex security testing scenarios.The study provides a theoretical framework and engineering reference for the design of enterprise-level intelligent penetration testing systems.