mirror of https://github.com/aliasrobotics/cai.git
ctrl in no stream fixed
This commit is contained in:
parent
770f6b0ac0
commit
dad91d79cb
|
|
@ -702,7 +702,20 @@ def run_cai_cli(starting_agent, context_variables=None, max_turns=float('inf')):
|
|||
start_idle_timer()
|
||||
|
||||
except KeyboardInterrupt:
|
||||
# No need to clean up streaming context as model handles it
|
||||
print("\n\033[91mKeyboard interrupt detected\033[0m")
|
||||
|
||||
if hasattr(agent, 'model'):
|
||||
from cai.sdk.agents.models.openai_chatcompletions import _Converter
|
||||
if hasattr(_Converter, 'recent_tool_calls'):
|
||||
for call_id, call_info in _Converter.recent_tool_calls.items():
|
||||
# Add a tool response indicating the interruption
|
||||
tool_msg = {
|
||||
"role": "tool",
|
||||
"tool_call_id": call_id,
|
||||
"content": "Operation interrupted by user",
|
||||
}
|
||||
add_to_message_history(tool_msg)
|
||||
|
||||
pass
|
||||
except Exception as e:
|
||||
import traceback
|
||||
|
|
|
|||
|
|
@ -1260,7 +1260,11 @@ def run_command(command, ctf=None, stdout=False, # pylint: disable=too-many-arg
|
|||
stop_active_timer()
|
||||
start_idle_timer()
|
||||
return result
|
||||
|
||||
except Exception as KeyboardInterrupt:
|
||||
# Ensure we switch back to idle mode if any unexpected error occurs
|
||||
stop_active_timer()
|
||||
start_idle_timer()
|
||||
return "User interrupted execution pressing ctrl+c"
|
||||
except Exception as e:
|
||||
# Ensure we switch back to idle mode if any unexpected error occurs
|
||||
stop_active_timer()
|
||||
|
|
|
|||
Loading…
Reference in New Issue