Skip to main content
The Offensive Security Agent API provides direct access to the base agent that powers all other specialized agents in Pensar Apex.

runOffensiveSecurityAgent

Runs the general-purpose offensive security agent with a custom prompt and tools.
This is a low-level API intended for advanced use cases. Most users should use higher-level APIs like runPentestAgent or runTargetedPentestAgent.

Import

Function Signature

Parameters

OffensiveSecurityAgentInput
required
Configuration for the offensive security agent.

Return Value

StreamTextResult<ToolSet, never>
AI SDK stream result containing:
  • text: Generated text stream
  • toolCalls: Invoked tool calls
  • toolResults: Tool execution results
  • finishReason: Why the agent stopped
  • usage: Token usage statistics

Example Usage

Basic Agent Execution

Custom Tools

Provide custom tools to the agent:

Custom System Prompt

Provide custom guidance:

Processing Stream Results

Access detailed stream data:

When to Use This API

Use runOffensiveSecurityAgent when you need:
Define specialized testing workflows not covered by built-in agents.
Integrate your own security tools or APIs with the agent.
Full control over system prompts, tools, and execution flow.
Test new attack techniques or analysis approaches.
For most pentesting scenarios, use the higher-level APIs:

Limitations

This API requires:
  • Manual session management
  • Custom tool definitions
  • Understanding of agent architecture
  • Proper error handling
It does not provide:
  • Built-in attack surface discovery
  • Automatic finding deduplication
  • Report generation
  • Multi-agent orchestration

OffensiveSecurityAgent Class

Base agent class documentation

Pentest Agent

Specialized pentest agent

Agents Concept

Understanding the agent architecture

Sessions

Managing agent sessions