mirror of
https://github.com/usestrix/strix.git
synced 2026-08-28 05:25:00 +00:00
feat: add error handling for headless mode in agent execution and improve CLI on scan failures
This commit is contained in:
parent
cf1d43706a
commit
6a84ea94fa
2 changed files with 25 additions and 1 deletions
|
|
@ -221,6 +221,22 @@ class BaseAgent(metaclass=AgentMeta):
|
|||
error_msg = str(e)
|
||||
error_details = getattr(e, "details", None)
|
||||
self.state.add_error(error_msg)
|
||||
|
||||
if self.non_interactive:
|
||||
self.state.set_completed({"success": False, "error": error_msg})
|
||||
if tracer:
|
||||
tracer.update_agent_status(self.state.agent_id, "failed", error_msg)
|
||||
if error_details:
|
||||
tracer.log_tool_execution_start(
|
||||
self.state.agent_id,
|
||||
"llm_error_details",
|
||||
{"error": error_msg, "details": error_details},
|
||||
)
|
||||
tracer.update_tool_execution(
|
||||
tracer._next_execution_id - 1, "failed", error_details
|
||||
)
|
||||
return {"success": False, "error": error_msg}
|
||||
|
||||
self.state.enter_waiting_state(llm_failed=True)
|
||||
if tracer:
|
||||
tracer.update_agent_status(self.state.agent_id, "llm_failed", error_msg)
|
||||
|
|
|
|||
|
|
@ -134,8 +134,16 @@ async def run_cli(args: Any) -> None: # noqa: PLR0915
|
|||
console.print()
|
||||
with console.status("[bold cyan]Running penetration test...", spinner="dots") as status:
|
||||
agent = StrixAgent(agent_config)
|
||||
await agent.execute_scan(scan_config)
|
||||
result = await agent.execute_scan(scan_config)
|
||||
status.stop()
|
||||
|
||||
if isinstance(result, dict) and not result.get("success", True):
|
||||
error_msg = result.get("error", "Unknown error")
|
||||
console.print()
|
||||
console.print(f"[bold red]❌ Penetration test failed:[/] {error_msg}")
|
||||
console.print()
|
||||
sys.exit(1)
|
||||
|
||||
except Exception as e:
|
||||
console.print(f"[bold red]Error during penetration test:[/] {e}")
|
||||
raise
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue