Overview
The Agents API provides the foundation for building autonomous security testing agents. The BaseAgent class handles the agent lifecycle, tool execution, and interaction with the LLM.
BaseAgent
The base class for all Strix agents. Manages the agent loop, tool execution, and state management.
Constructor
from strix.agents import BaseAgent
agent = BaseAgent(config: dict[ str , Any])
Configuration dictionary for the agent. LLM configuration for the agent
Existing agent state to restore from
Maximum number of iterations before stopping
Name of the LLM configuration
local_sources
list[dict[str, str]]
default: "[]"
Local source directories to mount in the sandbox
Whether to run in non-interactive mode
Properties
The name of the agent class
Maximum number of iterations allowed
Current agent state including messages and context
The LLM instance used by the agent
Agent configuration dictionary
Methods
agent_loop
async def agent_loop ( task : str ) -> dict[ str , Any]
Runs the main agent loop until completion or max iterations.
The task for the agent to accomplish
Final result containing success status and any output
Example:
agent = BaseAgent({
"llm_config" : llm_config,
"max_iterations" : 100
})
result = await agent.agent_loop( "Scan example.com for vulnerabilities" )
print (result) # {'success': True, ...}
cancel_current_execution
def cancel_current_execution () -> None
Cancels the currently running execution task.
Example:
agent.cancel_current_execution()
set_agent_identity
def set_agent_identity ( agent_name : str | None , agent_id : str | None ) -> None
Sets the agent’s identity metadata.
Human-readable agent name
AgentState
Manages the state of an agent including messages, context, and execution status.
Constructor
from strix.agents.state import AgentState
state = AgentState(
agent_name: str = "Strix Agent" ,
max_iterations: int = 300
)
agent_name
str
default: "'Strix Agent'"
Name of the agent
Maximum iterations allowed
Properties
Unique identifier (auto-generated)
Parent agent ID for sub-agents
Docker container ID for the sandbox
Whether the task is completed
Additional context storage
Methods
add_message
def add_message (
role : str ,
content : Any,
thinking_blocks : list[dict[ str , Any]] | None = None
) -> None
Adds a message to the conversation history.
Message role: “user” or “assistant”
thinking_blocks
list[dict[str, Any]] | None
Optional thinking blocks from reasoning models
increment_iteration
def increment_iteration () -> None
Increments the iteration counter.
set_completed
def set_completed ( final_result : dict[ str , Any] | None = None ) -> None
Marks the agent as completed.
get_conversation_history
def get_conversation_history () -> list[dict[ str , Any]]
Returns the full conversation history.
List of message dictionaries
get_execution_summary
def get_execution_summary () -> dict[ str , Any]
Returns a summary of the agent’s execution.
Dictionary containing agent_id, task, iteration count, completion status, etc.
Example:
state = AgentState( agent_name = "Scanner" , max_iterations = 50 )
state.add_message( "user" , "Find vulnerabilities in the API" )
state.increment_iteration()
if state.iteration >= state.max_iterations:
state.set_completed({ "success" : False , "reason" : "max_iterations" })
summary = state.get_execution_summary()
print (summary[ "iteration" ]) # Current iteration count
Usage Example
import asyncio
from strix.agents import BaseAgent
from strix.llm import LLMConfig
async def main ():
# Configure LLM
llm_config = LLMConfig(
model_name = "claude-3-5-sonnet-20241022" ,
scan_mode = "standard"
)
# Create agent
agent = BaseAgent({
"llm_config" : llm_config,
"max_iterations" : 100 ,
"non_interactive" : True
})
# Run agent
result = await agent.agent_loop(
"Scan the web application at https://example.com"
)
print ( f "Success: { result.get( 'success' ) } " )
print ( f "Iterations: { agent.state.iteration } " )
if __name__ == "__main__" :
asyncio.run(main())