-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Description
Describe the bug and reproduction steps
When using the OpenHands CLI (V1), the agent crashes with a RuntimeError during execution:
RuntimeError: LLM provided a security_risk but no security analyzer is configured - THIS SHOULD NOT HAPPEN!
This error occurs in the openhands-sdk package when the LLM returns a security_risk
parameter in its response, but the conversation doesn't have a security analyzer configured.
Reproduction Steps
- Install OpenHands CLI V1
- Configure and run the CLI agent
- During agent execution, the error occurs when the LLM tries to take an action
Root Cause
Based on code analysis:
- The CLI's
setup_conversation()
function inopenhands-cli/openhands_cli/setup.py
conditionally includes a security analyzer based on theinclude_security_analyzer
parameter - When confirmation mode is disabled (NeverConfirm policy), the security analyzer is removed via
toggle_confirmation_mode()
inrunner.py
- However, the LLM may still return
security_risk
parameters in its tool call responses - The openhands-sdk expects that if
security_risk
is present, a security analyzer must be configured, otherwise it raises this RuntimeError
This appears to be related to the recent changes in commit 9fe4e9715
("CLI(V1): Fix confirmation mode breaking on weaker models").
Suggested Fix
The issue can be resolved in one of these ways:
- SDK-side fix: Modify the openhands-sdk to gracefully handle cases where
security_risk
is provided but no analyzer is configured (e.g., treat it as UNKNOWN or ignore it) - CLI-side fix: Ensure the security analyzer is always initialized, even when confirmation mode is disabled, but configure it to not prompt the user
- LLM prompt fix: Update the system prompt to explicitly instruct the LLM not to return
security_risk
parameters when the security analyzer is not enabled
OpenHands Installation
CLI
OpenHands Version
Latest (commit 22f67d3 or later with CLI V1 support)
Model Name
Not specified in the error report, but appears to affect multiple models
Operating System
Linux (from the traceback path /home/xingyaow/.cache/uv/...
)
Logs, Errors, Screenshots, and Additional Context
Full Error Traceback
Error: LLM provided a security_risk but no security analyzer is configured - THIS SHOULD NOT HAPPEN!
Traceback (most recent call last):
File "/home/xingyaow/.cache/uv/archive-v0/4O2s5H4GUkriWq5g6YjrC/lib/python3.12/site-packages/openhands_cli/simple_main.py", line 45, in main
run_cli_entry(resume_conversation_id=args.resume)
File "/home/xingyaow/.cache/uv/archive-v0/4O2s5H4GUkriWq5g6YjrC/lib/python3.12/site-packages/openhands_cli/agent_chat.py", line 173, in run_cli_entry
runner.process_message(message)
File "/home/xingyaow/.cache/uv/archive-v0/4O2s5H4GUkriWq5g6YjrC/lib/python3.12/site-packages/openhands_cli/runner.py", line 83, in process_message
self._run_with_confirmation()
File "/home/xingyaow/.cache/uv/archive-v0/4O2s5H4GUkriWq5g6YjrC/lib/python3.12/site-packages/openhands_cli/runner.py", line 103, in _run_with_confirmation
self.conversation.run()
File "/home/xingyaow/.cache/uv/archive-v0/4O2s5H4GUkriWq5g6YjrC/lib/python3.12/site-packages/openhands/sdk/conversation/impl/local_conversation.py", line 245, in run
self.agent.step(self._state, on_event=self._on_event)
File "/home/xingyaow/.cache/uv/archive-v0/4O2s5H4GUkriWq5g6YjrC/lib/python3.12/site-packages/openhands/sdk/agent/agent.py", line 226, in step
action_event = self._get_action_event(
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/xingyaow/.cache/uv/archive-v0/4O2s5H4GUkriWq5g6YjrC/lib/python3.12/site-packages/openhands/sdk/agent/agent.py", line 353, in _get_action_event
raise RuntimeError(
RuntimeError: LLM provided a security_risk but no security analyzer is configured - THIS SHOULD NOT HAPPEN!
Related Files
openhands-cli/openhands_cli/setup.py
- Handles security analyzer initializationopenhands-cli/openhands_cli/runner.py
- Manages confirmation mode togglingopenhands-cli/pyproject.toml
- SDK dependency at commit189979a5013751aa86852ab41afe9a79555e62ac
Impact
This bug makes the CLI unusable for affected users, as it causes the agent to crash during execution, preventing any work from being completed.