Fix guardrail init, use alias1 as default

Signed-off-by: Víctor Mayoral Vilches <v.mayoralv@gmail.com>
This commit is contained in:
Víctor Mayoral Vilches 2025-11-30 12:51:45 +01:00
parent 900c52c494
commit 6b34648245
34 changed files with 74 additions and 59 deletions

View File

@ -61,7 +61,7 @@ from cai.sdk.agents.handoffs import handoff
__path__ = pkgutil.extend_path(__path__, __name__)
# Get model from environment or use default
model = os.environ.get("CAI_MODEL", "alias0")
model = os.environ.get("CAI_MODEL", "alias1")
PATTERNS = ["hierarchical", "swarm", "chain_of_thought", "auction_based", "recursive"]

View File

@ -32,7 +32,7 @@ tools = [
load_dotenv()
model_name = os.getenv("CAI_MODEL", "alias0")
model_name = os.getenv("CAI_MODEL", "alias1")
app_logic_mapper = Agent(
name="AppLogicMapper",

View File

@ -43,7 +43,7 @@ blueteam_agent = Agent(
description="""Agent that specializes in system defense and security monitoring.
Expert in cybersecurity protection and incident response.""",
model=OpenAIChatCompletionsModel(
model=os.getenv('CAI_MODEL', "alias0"),
model=os.getenv('CAI_MODEL', "alias1"),
openai_client=AsyncOpenAI(),
),
tools=tools,

View File

@ -27,6 +27,9 @@ from cai.tools.reconnaissance.shodan import ( # pylint: disable=import-error #
from cai.agents.guardrails import get_security_guardrails
load_dotenv()
# Determine API key
api_key = os.getenv("ALIAS_API_KEY", os.getenv("OPENAI_API_KEY", "sk-alias-1234567890"))
# Prompts
bug_bounter_system_prompt = load_prompt_template("prompts/system_bug_bounter.md")
# Define tools list based on available API keys
@ -52,8 +55,8 @@ bug_bounter_agent = Agent(
input_guardrails=input_guardrails,
output_guardrails=output_guardrails,
model=OpenAIChatCompletionsModel(
model=os.getenv('CAI_MODEL', "alias0"),
openai_client=AsyncOpenAI(),
model=os.getenv('CAI_MODEL', "alias1"),
openai_client=AsyncOpenAI(api_key=api_key),
)
)

View File

@ -184,7 +184,7 @@ class CodeAgent(Agent):
def __init__( # pylint: disable=too-many-arguments,too-many-locals # noqa: E501
self,
name: str = "CodeAgent",
model: str = "alias0",
model: str = "alias1",
instructions: Union[str, Callable[[], str]] = None,
tools: List[Callable] = None,
additional_authorized_imports: Optional[List[str]] = None,

View File

@ -62,7 +62,7 @@ dfir_agent = Agent(
description="""Agent that specializes in Digital Forensics and Incident Response.
Expert in investigation and analysis of digital evidence.""",
model=OpenAIChatCompletionsModel(
model=os.getenv('CAI_MODEL', "alias0"),
model=os.getenv('CAI_MODEL', "alias1"),
openai_client=AsyncOpenAI(),
),
tools=tools,

View File

@ -43,7 +43,7 @@ def create_generic_agent_factory(
if not model_name:
# Third priority: global CAI_MODEL
model_name = os.environ.get("CAI_MODEL", "alias0")
model_name = os.environ.get("CAI_MODEL", "alias1")
api_key = os.getenv("OPENAI_API_KEY", "sk-placeholder-key-for-local-models")

View File

@ -6,7 +6,7 @@ from cai.sdk.agents import Agent, OpenAIChatCompletionsModel, handoff
from openai import AsyncOpenAI
from cai.agents.one_tool import one_tool_agent
model = os.getenv('CAI_MODEL', "alias0")
model = os.getenv('CAI_MODEL', "alias1")
# Create OpenAI client with fallback API key to prevent initialization errors
# The actual API key should be set in environment variables or .env file
@ -22,7 +22,7 @@ flag_discriminator = Agent(
4. If you do not find a flag, call `ctf_agent` to continue investigating.
""",
model=OpenAIChatCompletionsModel(
model="alias0" if os.getenv('CAI_MODEL') == "o3-mini" else model,
model="alias1" if os.getenv('CAI_MODEL') == "o3-mini" else model,
openai_client=AsyncOpenAI(api_key=api_key),
),
handoffs=[

View File

@ -223,7 +223,7 @@ injection_detector_agent = Agent(
Only flag content that contains EXPLICIT attempts to manipulate the system.""",
output_type=PromptInjectionCheck,
model=OpenAIChatCompletionsModel(
model=os.getenv('CAI_MODEL', 'alias0'),
model=os.getenv('CAI_MODEL', 'alias1'),
openai_client=AsyncOpenAI(api_key=api_key),
)
)

View File

@ -9,6 +9,9 @@ from cai.sdk.agents import Agent, OpenAIChatCompletionsModel
from cai.tools.misc.cli_utils import execute_cli_command
from cai.sdk.agents import function_tool
# Determine API key
api_key = os.getenv("ALIAS_API_KEY", os.getenv("OPENAI_API_KEY", "sk-alias-1234567890"))
def get_txt_record(domain, record_type='TXT'):
@ -115,7 +118,7 @@ dns_smtp_agent = Agent(
),
tools=[check_mail_spoofing_vulnerability, execute_cli_command],
model=OpenAIChatCompletionsModel(
model=os.getenv('CAI_MODEL', "alias0"),
openai_client=AsyncOpenAI(),
model=os.getenv('CAI_MODEL', "alias1"),
openai_client=AsyncOpenAI(api_key=api_key),
)
)

View File

@ -86,7 +86,7 @@ from cai.sdk.agents import Agent, OpenAIChatCompletionsModel
from cai.tools.misc.rag import add_to_memory_semantic, add_to_memory_episodic
# Get model from environment or use default
model = os.getenv('CAI_MODEL', "alias0")
model = os.getenv('CAI_MODEL', "alias1")
def get_previous_steps(query: str) -> str:

View File

@ -43,7 +43,7 @@ memory_analysis_agent = Agent(
for security assessment, vulnerability discovery, and runtime behavior analysis.""",
tools=functions,
model=OpenAIChatCompletionsModel(
model=os.getenv('CAI_MODEL', "alias0"),
model=os.getenv('CAI_MODEL', "alias1"),
openai_client=AsyncOpenAI(),
)
)

View File

@ -76,7 +76,7 @@ network_security_analyzer_agent = Agent(
description="""Agent that specializes in network security analysis.
Expert in monitoring, capturing, and analyzing network communications for security threats.""",
model=OpenAIChatCompletionsModel(
model=os.getenv('CAI_MODEL', "alias0"),
model=os.getenv('CAI_MODEL', "alias1"),
openai_client=AsyncOpenAI(),
),
tools=tools,

View File

@ -9,7 +9,7 @@ from cai.util import create_system_prompt_renderer
from cai.agents.guardrails import get_security_guardrails
# Get model from environment or use default
model_name = os.getenv('CAI_MODEL', "alias0")
model_name = os.getenv('CAI_MODEL', "alias1")
# NOTE: This is needed when using LiteLLM Proxy Server
#

View File

@ -15,7 +15,7 @@ parallel_agents:
unified_context: false
- name: bug_bounter_agent
model: alias0
model: alias1
prompt: "Search for bugs and create detailed reports"
unified_context: false

View File

@ -21,7 +21,10 @@ from cai.util import load_prompt_template, create_system_prompt_renderer
from cai.agents.guardrails import get_security_guardrails
load_dotenv()
model_name = os.getenv("CAI_MODEL", "alias0")
model_name = os.getenv("CAI_MODEL", "alias1")
# Determine API key
api_key = os.getenv("ALIAS_API_KEY", os.getenv("OPENAI_API_KEY", "sk-alias-1234567890"))
# Prompts
redteam_agent_system_prompt = load_prompt_template("prompts/system_red_team_agent.md")
# Define tools list based on available API keys
@ -48,7 +51,7 @@ redteam_agent = Agent(
output_guardrails=output_guardrails,
model=OpenAIChatCompletionsModel(
model=model_name,
openai_client=AsyncOpenAI(),
openai_client=AsyncOpenAI(api_key=api_key),
),
)

View File

@ -68,7 +68,7 @@ replay_attack_agent = Agent(
description="""Agent that specializes in network replay attacks and counteroffensive techniques.
Expert in packet manipulation, traffic replay, and protocol exploitation.""",
model=OpenAIChatCompletionsModel(
model=os.getenv('CAI_MODEL', "alias0"),
model=os.getenv('CAI_MODEL', "alias1"),
openai_client=AsyncOpenAI(),
),
tools=tools,

View File

@ -31,7 +31,7 @@ reporting_agent = Agent(
description="""Agent that generates reports in html.""",
tools=functions,
model=OpenAIChatCompletionsModel(
model=os.getenv('CAI_MODEL', "alias0"),
model=os.getenv('CAI_MODEL', "alias1"),
openai_client=AsyncOpenAI(),
)
)

View File

@ -17,6 +17,9 @@ from cai.tools.reconnaissance.exec_code import ( # pylint: disable=import-error
load_dotenv()
# Determine API key
api_key = os.getenv("ALIAS_API_KEY", os.getenv("OPENAI_API_KEY", "sk-alias-1234567890"))
# Load the triage agent system prompt
retester_system_prompt = load_prompt_template("prompts/system_triage_agent.md")
@ -36,8 +39,8 @@ retester_agent = Agent(
eliminating false positives.""",
tools=tools,
model=OpenAIChatCompletionsModel(
model=os.getenv('CAI_MODEL', "alias0"),
openai_client=AsyncOpenAI(),
model=os.getenv('CAI_MODEL', "alias1"),
openai_client=AsyncOpenAI(api_key=api_key),
)
)

View File

@ -44,7 +44,7 @@ reverse_engineering_agent = Agent(
like Ghidra, Binwalk, and various binary analysis utilities.""",
tools=functions,
model=OpenAIChatCompletionsModel(
model=os.getenv('CAI_MODEL', "alias0"),
model=os.getenv('CAI_MODEL', "alias1"),
openai_client=AsyncOpenAI(),
)
)

View File

@ -43,7 +43,7 @@ subghz_sdr_agent = Agent(
automotive, industrial, and wireless security applications.""",
tools=functions,
model=OpenAIChatCompletionsModel(
model=os.getenv('CAI_MODEL', "alias0"),
model=os.getenv('CAI_MODEL', "alias1"),
openai_client=AsyncOpenAI(),
)
)

View File

@ -11,14 +11,17 @@ from openai import AsyncOpenAI
from cai.util import load_prompt_template, create_system_prompt_renderer
import os
# Determine API key
api_key = os.getenv("ALIAS_API_KEY", os.getenv("OPENAI_API_KEY", "sk-alias-1234567890"))
thought_agent_system_prompt = load_prompt_template("prompts/system_thought_router.md")
# Thought Process Agent for analysis and planning
thought_agent = Agent(
name="ThoughtAgent",
model=OpenAIChatCompletionsModel(
model=os.getenv('CAI_MODEL', "alias0"),
openai_client=AsyncOpenAI(),
model=os.getenv('CAI_MODEL', "alias1"),
openai_client=AsyncOpenAI(api_key=api_key),
),
description="""Agent focused on analyzing and planning the next steps
in a security assessment or CTF challenge.""",

View File

@ -7,7 +7,7 @@ from cai.tools.reconnaissance.generic_linux_command import null_tool
from cai.util import load_prompt_template, create_system_prompt_renderer
load_dotenv()
model_name = os.getenv("CAI_MODEL", "alias0")
model_name = os.getenv("CAI_MODEL", "alias1")
# Load prompt
use_case_agent_system_prompt = load_prompt_template("prompts/system_use_cases.md")

View File

@ -42,7 +42,7 @@ wifi_security_agent = Agent(
Specializes in wireless attacks, password recovery, and communication disruption.""",
tools=functions,
model=OpenAIChatCompletionsModel(
model=os.getenv('CAI_MODEL', "alias0"),
model=os.getenv('CAI_MODEL', "alias1"),
openai_client=AsyncOpenAI(),
)
)

View File

@ -20,7 +20,7 @@ Environment Variables
within container (default: "true")
CAI_MODEL: Model to use for agents
(default: "alias0")
(default: "alias1")
CAI_DEBUG: Set debug output level (default: "1")
- 0: Only tool outputs
- 1: Verbose debug output
@ -79,36 +79,36 @@ Usage Examples:
# Run against a CTF
CTF_NAME="kiddoctf" CTF_CHALLENGE="02 linux ii" \
CAI_AGENT_TYPE="one_tool_agent" CAI_MODEL="alias0" \
CAI_AGENT_TYPE="one_tool_agent" CAI_MODEL="alias1" \
CAI_TRACING="false" cai
# Run a harder CTF
CTF_NAME="hackableii" CAI_AGENT_TYPE="redteam_agent" \
CTF_INSIDE="False" CAI_MODEL="alias0" \
CTF_INSIDE="False" CAI_MODEL="alias1" \
CAI_TRACING="false" cai
# Run without a target in human-in-the-loop mode, generating a report
CAI_TRACING=False CAI_REPORT=pentesting CAI_MODEL="alias0" \
CAI_TRACING=False CAI_REPORT=pentesting CAI_MODEL="alias1" \
cai
# Run with online episodic memory
# registers memory every 5 turns:
# limits the cost to 5 dollars
CTF_NAME="hackableII" CAI_MEMORY="episodic" \
CAI_MODEL="alias0" CAI_MEMORY_ONLINE="True" \
CAI_MODEL="alias1" CAI_MEMORY_ONLINE="True" \
CTF_INSIDE="False" CTF_HINTS="False" \
CAI_PRICE_LIMIT="5" cai
# Run with custom long_term_memory interval
# Executes memory long_term_memory every 3 turns:
CTF_NAME="hackableII" CAI_MEMORY="episodic" \
CAI_MODEL="alias0" CAI_MEMORY_ONLINE_INTERVAL="3" \
CAI_MODEL="alias1" CAI_MEMORY_ONLINE_INTERVAL="3" \
CAI_MEMORY_ONLINE="False" CTF_INSIDE="False" \
CTF_HINTS="False" cai
# Run with parallel agents (3 instances)
CTF_NAME="hackableII" CAI_AGENT_TYPE="redteam_agent" \
CAI_MODEL="alias0" CAI_PARALLEL="3" cai
CAI_MODEL="alias1" CAI_PARALLEL="3" cai
"""
# Load environment variables from .env file FIRST, before any imports
@ -441,7 +441,7 @@ def run_cai_cli(
turn_count = 0
idle_time = 0
console = Console()
last_model = os.getenv("CAI_MODEL", "alias0")
last_model = os.getenv("CAI_MODEL", "alias1")
last_agent_type = os.getenv("CAI_AGENT_TYPE", "one_tool_agent")
parallel_count = int(os.getenv("CAI_PARALLEL", "1"))
use_initial_prompt = initial_prompt is not None
@ -549,7 +549,7 @@ def run_cai_cli(
idle_start_time = time.time()
# Check if model has changed and update if needed
current_model = os.getenv("CAI_MODEL", "alias0")
current_model = os.getenv("CAI_MODEL", "alias1")
# Check for agent-specific model override
agent_specific_model = os.getenv(f"CAI_{last_agent_type.upper()}_MODEL")
if agent_specific_model:
@ -1047,7 +1047,7 @@ def run_cai_cli(
custom_name = f"{agent_display_name} #{idx}"
# Determine model
model_to_use = config.model or os.getenv("CAI_MODEL", "alias0")
model_to_use = config.model or os.getenv("CAI_MODEL", "alias1")
# Create and store the instance
# No shared_message_history - each agent gets its own isolated copy
@ -1106,7 +1106,7 @@ def run_cai_cli(
custom_name = agent_display_name
# Determine which model to use
model_to_use = config.model or os.getenv("CAI_MODEL", "alias0")
model_to_use = config.model or os.getenv("CAI_MODEL", "alias1")
# Create agent instance with the determined model
# Each agent gets its own isolated history from PARALLEL_ISOLATION
@ -1125,7 +1125,7 @@ def run_cai_cli(
AGENT_MANAGER.set_parallel_agent(agent_id, instance_agent, agent_display_name)
# Ensure the model is properly set for the agent and all handoff agents
model_to_use = config.model or os.getenv("CAI_MODEL", "alias0")
model_to_use = config.model or os.getenv("CAI_MODEL", "alias1")
if model_to_use:
update_agent_models_recursively(instance_agent, model_to_use)
@ -1871,7 +1871,7 @@ def main():
agent.model.suppress_final_output = False # Changed to False to show all agent messages
# Ensure the agent and all its handoff agents use the current model
current_model = os.getenv("CAI_MODEL", "alias0")
current_model = os.getenv("CAI_MODEL", "alias1")
update_agent_models_recursively(agent, current_model)
# Run the CLI with the selected agent and optional initial prompt

View File

@ -521,7 +521,7 @@ class CompactCommand(Command):
# Pass the compact model if set
if self.compact_model:
# Temporarily override the model for this operation
original_model = os.environ.get("CAI_MODEL", "alias0")
original_model = os.environ.get("CAI_MODEL", "alias1")
os.environ["CAI_MODEL"] = self.compact_model
try:
result = MEMORY_COMMAND_INSTANCE.handle_save([memory_name], preserve_history=False)

View File

@ -46,7 +46,7 @@ ENV_VARS = {
6: {
"name": "CAI_MODEL",
"description": "Model to use for agents",
"default": "alias0"
"default": "alias1"
},
7: {
"name": "CAI_DEBUG",

View File

@ -1144,7 +1144,7 @@ Model: {get_compact_model() or os.environ.get("CAI_MODEL", "gpt-4")}
from cai.repl.commands.compact import get_compact_model, get_custom_prompt
# Create summary agent
model_name = get_compact_model() or os.environ.get("CAI_MODEL", "alias0")
model_name = get_compact_model() or os.environ.get("CAI_MODEL", "alias1")
# Use custom prompt if set, otherwise use default
custom_prompt = get_custom_prompt()

View File

@ -36,15 +36,15 @@ def get_predefined_model_categories() -> Dict[str, List[Dict[str, str]]]:
return {
"Alias": [
{
"name": "alias0",
"name": "alias1",
"description": (
"Best model for Cybersecurity AI tasks"
)
},
{
"name": "alias0-fast",
"name": "alias1-fast",
"description": (
"Fast version of alias0 for quick tasks"
"Fast version of alias1 for quick tasks"
)
}
],

View File

@ -649,7 +649,7 @@ class ParallelCommand(Command):
console.print("[yellow]No parallel configurations to override[/yellow]")
return False
global_model = os.getenv("CAI_MODEL", "alias0")
global_model = os.getenv("CAI_MODEL", "alias1")
count = 0
for config in PARALLEL_CONFIGS:

View File

@ -260,7 +260,7 @@ class QuickstartCommand(Command):
console.print(" [yellow]1.[/yellow] Run: [bold green]/model-show[/bold green] to see all available models")
console.print(" [yellow]2.[/yellow] Run: [bold green]/model-show supported[/bold green] to see only models with function calling support")
console.print(" [yellow]3.[/yellow] Select a model: [bold green]/model <model-name>[/bold green]")
console.print("\n[dim]Note: The default model 'alias0' requires configuration. Please select a specific model.[/dim]")
console.print("\n[dim]Note: The default model 'alias1' requires configuration. Please select a specific model.[/dim]")
else:
console.print(
Panel(

View File

@ -348,7 +348,7 @@ def display_quick_guide(console: Console):
)
# Get current environment variable values
current_model = os.getenv('CAI_MODEL', "alias0")
current_model = os.getenv('CAI_MODEL', "alias1")
current_agent_type = os.getenv('CAI_AGENT_TYPE', "one_tool_agent")
config_text = Text.assemble(
@ -413,19 +413,19 @@ def display_quick_guide(console: Console):
Text.assemble(
("🔒 Security-Focused AI Framework\n\n", "bold white"),
"For optimal cybersecurity AI performance, use\n",
("alias0", "bold green"),
("alias1", "bold green"),
" - specifically designed for cybersecurity\n"
"tasks with superior domain knowledge.\n\n",
("alias0", "bold green"),
("alias1", "bold green"),
" outperforms general-purpose models in:\n",
"• Vulnerability assessment\n",
"• Penetration testing and bug bounty\n",
"• Security analysis\n",
"• Threat detection\n\n",
"Learn more about ",
("alias0", "bold green"),
("alias1", "bold green"),
" and its privacy-first approach:\n",
("https://news.aliasrobotics.com/alias0-a-privacy-first-cybersecurity-ai/", "blue underline")
("https://news.aliasrobotics.com/alias1-a-privacy-first-cybersecurity-ai/", "blue underline")
),
title="[bold yellow]🛡️ Alias0 - best model for cybersecurity [/bold yellow]",
border_style="yellow",

View File

@ -2699,7 +2699,7 @@ class OpenAIChatCompletionsModel(Model):
# Determine provider based on model string
model_str = str(kwargs["model"]).lower()
if "alias" in model_str and "alias0.5" not in model_str: # NOTE: exclude alias0.5
if "alias" in model_str and "alias1.5" not in model_str: # NOTE: exclude alias1.5
kwargs["api_base"] = "https://api.aliasrobotics.com:666/"
kwargs["custom_llm_provider"] = "openai"
kwargs["api_key"] = os.getenv("ALIAS_API_KEY", "REDACTED_ALIAS_KEY")
@ -2815,7 +2815,7 @@ class OpenAIChatCompletionsModel(Model):
elif "gemini" in model_str:
kwargs.pop("parallel_tool_calls", None)
elif "qwen" in model_str or ":" in model_str:
# Handle Ollama-served models with custom formats (e.g., alias0)
# Handle Ollama-served models with custom formats (e.g., alias1)
# These typically need the Ollama provider
litellm.drop_params = True
kwargs.pop("parallel_tool_calls", None)

View File

@ -2211,7 +2211,7 @@ def update_agent_streaming_content(context, text_delta, token_stats=None):
footer_stats.append(f"${session_total_cost:.4f}", style="bold magenta")
# Add context usage indicator
model_name = context.get("model", os.environ.get("CAI_MODEL", "alias0"))
model_name = context.get("model", os.environ.get("CAI_MODEL", "alias1"))
context_pct = input_tokens / get_model_input_tokens(model_name) * 100
if context_pct < 50:
indicator = "🟩"