mirror of https://github.com/aliasrobotics/cai.git
Merge branch 'fix_pentestperf' into '0.4.0'
fix pentesperf See merge request aliasrobotics/alias_research/cai!200
This commit is contained in:
commit
88fefe9d47
|
|
@ -159,13 +159,12 @@ from cai.repl.commands.parallel import PARALLEL_CONFIGS, ParallelConfig
|
|||
from cai import is_pentestperf_available
|
||||
ctf_global = None
|
||||
messages_ctf = ""
|
||||
ctf_init=1
|
||||
previous_ctf_name = os.getenv('CTF_NAME', None)
|
||||
if is_pentestperf_available() and os.getenv('CTF_NAME', None):
|
||||
ctf, messages_ctf = setup_ctf()
|
||||
ctf_global = ctf
|
||||
if os.getenv('CTF_INSIDE', 'True').lower() == 'false':
|
||||
container_id = ""
|
||||
os.environ['CAI_ACTIVE_CONTAINER'] = container_id
|
||||
ctf_init=0
|
||||
|
||||
# NOTE: This is needed when using LiteLLM Proxy Server
|
||||
#
|
||||
|
|
@ -267,6 +266,7 @@ def run_cai_cli(starting_agent, context_variables=None, max_turns=float('inf'),
|
|||
global previous_ctf_name
|
||||
global ctf_global
|
||||
global messages_ctf
|
||||
global ctf_init
|
||||
if previous_ctf_name != os.getenv('CTF_NAME', None):
|
||||
if is_pentestperf_available():
|
||||
if ctf_global:
|
||||
|
|
@ -274,7 +274,7 @@ def run_cai_cli(starting_agent, context_variables=None, max_turns=float('inf'),
|
|||
ctf, messages_ctf = setup_ctf()
|
||||
ctf_global = ctf
|
||||
previous_ctf_name = os.getenv('CTF_NAME', None)
|
||||
|
||||
ctf_init=0
|
||||
# Check if CAI_MAX_TURNS has been updated via /config
|
||||
current_max_turns = os.getenv('CAI_MAX_TURNS', 'inf')
|
||||
if current_max_turns != str(prev_max_turns):
|
||||
|
|
@ -332,7 +332,7 @@ def run_cai_cli(starting_agent, context_variables=None, max_turns=float('inf'),
|
|||
except Exception as e:
|
||||
console.print(f"[red]Error switching agent: {str(e)}[/red]")
|
||||
|
||||
if not force_until_flag:
|
||||
if not force_until_flag and ctf_init!=0:
|
||||
# Get user input with command completion and history
|
||||
user_input = get_user_input(
|
||||
command_completer,
|
||||
|
|
@ -340,11 +340,11 @@ def run_cai_cli(starting_agent, context_variables=None, max_turns=float('inf'),
|
|||
history_file,
|
||||
get_toolbar_with_refresh,
|
||||
current_text
|
||||
) + messages_ctf
|
||||
)
|
||||
|
||||
else:
|
||||
user_input = messages_ctf
|
||||
if os.getenv('CTF_INSIDE', 'True').lower() == 'false':
|
||||
user_input += ctf_global.get_ip()
|
||||
ctf_init=1
|
||||
idle_time += time.time() - idle_start_time
|
||||
|
||||
# Stop measuring user idle time and start measuring active time
|
||||
|
|
@ -651,7 +651,7 @@ def run_cai_cli(starting_agent, context_variables=None, max_turns=float('inf'),
|
|||
history_context.append({"role": "user", "content": user_input})
|
||||
conversation_input = history_context
|
||||
else:
|
||||
conversation_input = user_input
|
||||
conversation_input = messages_ctf + user_input
|
||||
|
||||
# Process the conversation with the agent - with parallel execution if enabled
|
||||
if parallel_count > 1:
|
||||
|
|
|
|||
Loading…
Reference in New Issue