Overview
Pensar Apex is built on an autonomous agent architecture powered by large language models. Rather than following rigid scripts, the tool uses AI agents that reason about targets, plan testing strategies, and execute security assessments adaptively. At the core is the OffensiveSecurityAgent harness, a general-purpose agent framework that manages the interaction between AI models and security testing tools. Specialized agents extend this harness with domain-specific behavior for different phases of testing.Agent Harness
TheOffensiveSecurityAgent class provides the foundation for all testing agents:
Key Features
Tool Management
The harness owns tool creation and activation. Specialized agents declare which tools they need via the
activeTools array.Streaming Architecture
Agents start streaming immediately on construction. Consume via callbacks,
for await, or raw stream access.Typed Results
Use
resolveResult or responseSchema to get strongly-typed outputs from agent runs.Approval Gates
Optional operator approval for tool calls enables human-in-the-loop workflows.
Agent Input Configuration
All agents accept a common input structure:Specialized Agents
Pensar Apex includes four specialized agent types, each optimized for a specific phase of security testing:Attack Surface Agent
Purpose: Discover and map the entire attack surface of a target Location:src/core/agents/specialized/attackSurface/
AttackSurfaceResult
- Discovered assets (domains, services, endpoints)
- Identified authentication flows
- Prioritized targets for deep testing
- Attack surface analysis report
Authentication Agent
Purpose: Handle authentication and session management Location:src/core/agents/specialized/authenticationAgent/
AuthenticationResult
- Success status
- Authentication strategy used
- Exported cookies and headers
- Session persistence data
The authentication agent never sees raw credentials. It uses a
CredentialManager that resolves credential IDs to secrets at execution time, keeping sensitive data out of agent prompts and logs.Pentest Agent
Purpose: Perform targeted vulnerability testing against specific endpoints Location:src/core/agents/specialized/pentest/
PentestResult
- Discovered vulnerabilities
- Proof-of-concept scripts
- Evidence and impact analysis
- Remediation guidance
Offensive Security Agent (General)
Purpose: Orchestrate complex workflows and delegate to specialized agents Location:src/core/agents/offSecAgent/
The base OffensiveSecurityAgent can be used directly for custom workflows that don’t fit the specialized agent patterns. It has access to all tools and can:
- Orchestrate multi-phase testing campaigns
- Delegate to specialized agents via
delegate_to_auth_subagent - Run custom testing methodologies
- Integrate with external tools and services
Agent Communication
Agents communicate through several mechanisms:Parent-Child Delegation
Parent agents can spawn specialized child agents:Shared State
Agents share state through the session:- Findings Registry: Prevents duplicate vulnerability reports across agents
- Credential Manager: Secure credential sharing without exposing secrets
- Session Storage: Persistent files (POCs, screenshots, reports)
Stream Events
Agents emit typed stream events that can be consumed by parents:Agent Lifecycle
- Construction: Agent is instantiated with input configuration
- Tool Creation: Harness builds the toolset based on
activeTools - Stream Start: AI SDK stream begins immediately
- Agent Loop: Model reasons, calls tools, receives results, continues
- Stop Condition: Agent stops when condition is met (tool call, step count, etc.)
- Result Resolution:
resolveResultorresponseSchemaproduces typed output
Usage Example
Here’s how to use the specialized agents:Best Practices
Choose the Right Agent
Choose the Right Agent
- Use AttackSurfaceAgent for reconnaissance and discovery
- Use AuthenticationAgent for login flows and session management
- Use PentestAgent for targeted vulnerability testing
- Use base OffensiveSecurityAgent only for custom workflows
Manage Agent State
Manage Agent State
- Share
FindingsRegistryacross agents to prevent duplicate reports - Use
CredentialManagerfor secure credential handling - Store session data in the session directory for persistence
Handle Stream Events
Handle Stream Events
- Always consume agent streams (callbacks,
for await, or.consume()) - Forward subagent events to parent consumers when orchestrating
- Handle errors gracefully with
onErrorcallbacks
Control Agent Execution
Control Agent Execution
- Use
stopWhenconditions to prevent infinite loops - Leverage
abortSignalfor user-initiated cancellation - Set up
approvalGatefor human-in-the-loop workflows
Related Resources
Attack Surface Discovery
Learn how agents map your application’s attack surface
Findings & Reports
Understand vulnerability findings and deduplication
API Reference
Complete API documentation for all agent classes
Tool System
Explore the tools available to agents

