-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Open
Labels
CLIRelated to the command line interfaceRelated to the command line interfaceagent-sdkbugSomething isn't workingSomething isn't working
Description
Summary
The OpenHands CLI crashes with a FunctionCallValidationError
when the LLM generates an execute_bash
function call without the required security_risk
parameter.
Error Details
Error: Missing required parameters for function 'execute_bash': {'security_risk'}
Traceback (most recent call last):
File "openhands/sdk/llm/mixins/fn_call_converter.py", line 739, in _extract_and_validate_params
openhands.sdk.llm.exceptions.FunctionCallValidationError: Missing required parameters for function 'execute_bash': {'security_risk'}
Steps to Reproduce
-
Enable security-based confirmation mode:
> Auto-confirm LOW/MEDIUM risk, ask for HIGH risk
-
Trigger an execute_bash function call:
- Use any prompt that would cause the agent to run a bash command
- The LLM generates a function call for
execute_bash
-
Observe the crash:
- Function call validation fails in
fn_call_converter.py
- CLI crashes with
FunctionCallValidationError
- Function call validation fails in
Expected Behavior
- The
execute_bash
function call should include all required parameters - Function call validation should pass
- The command should execute normally
Actual Behavior
- LLM generates
execute_bash
call withoutsecurity_risk
parameter - Function call validation fails
- CLI crashes with unhandled exception
Environment
- OpenHands CLI version: Latest (main branch)
- Confirmation mode: Auto-confirm LOW/MEDIUM risk, ask for HIGH risk
- Agent-SDK integration: Using new agent-sdk structure
Technical Details
Error Location
- File:
openhands/sdk/llm/mixins/fn_call_converter.py
- Line: 739
- Function:
_extract_and_validate_params
Complete Stack Trace
Traceback (most recent call last):
File "openhands_cli/simple_main.py", line 45, in main
File "openhands_cli/agent_chat.py", line 174, in run_cli_entry
File "openhands_cli/runner.py", line 83, in process_message
File "openhands_cli/runner.py", line 103, in _run_with_confirmation
File "openhands/sdk/conversation/impl/local_conversation.py", line 245, in run
File "openhands/sdk/agent/agent.py", line 209, in step
File "openhands/sdk/agent/agent.py", line 187, in step
File "openhands/sdk/llm/llm.py", line 476, in completion
File "tenacity/__init__.py", line 338, in wrapped_f
File "tenacity/__init__.py", line 477, in __call__
File "tenacity/__init__.py", line 378, in iter
File "tenacity/__init__.py", line 400, in <lambda>
File "concurrent/futures/_base.py", line 449, in result
File "concurrent/futures/_base.py", line 401, in __get_result
File "tenacity/__init__.py", line 480, in __call__
File "openhands/sdk/llm/llm.py", line 461, in _one_attempt
File "openhands/sdk/llm/mixins/non_native_fc.py", line 82, in post_response_prompt_mock
File "openhands/sdk/llm/mixins/fn_call_converter.py", line 957, in convert_non_fncall_messages_to_fncall_messages
File "openhands/sdk/llm/mixins/fn_call_converter.py", line 739, in _extract_and_validate_params
openhands.sdk.llm.exceptions.FunctionCallValidationError: Missing required parameters for function 'execute_bash': {'security_risk'}
Root Cause Analysis
The issue occurs in the function call validation process:
- LLM generates function call: Creates
execute_bash
call withoutsecurity_risk
parameter - Function call converter processes it:
convert_non_fncall_messages_to_fncall_messages
infn_call_converter.py
- Parameter validation fails:
_extract_and_validate_params
expectssecurity_risk
parameter but doesn't find it - Exception thrown:
FunctionCallValidationError
crashes the CLI
Impact
- CLI becomes completely unusable when this occurs
- User cannot proceed with their task
- No graceful error handling or recovery
Suggested Solution
-
Investigate why LLM omits
security_risk
parameter:- Check if function definition includes
security_risk
as required - Verify prompt templates include security risk guidance
- Check if function definition includes
-
Add better error handling:
- Catch
FunctionCallValidationError
and provide user-friendly message - Allow user to retry or modify the request
- Catch
-
Parameter defaulting:
- Consider defaulting missing
security_risk
parameter toUNKNOWN
orMEDIUM
- Log warning when parameters are auto-defaulted
- Consider defaulting missing
Files to investigate
openhands/sdk/llm/mixins/fn_call_converter.py
(validation logic)- Function definition for
execute_bash
tool - Prompt templates that define function calling format
Metadata
Metadata
Assignees
Labels
CLIRelated to the command line interfaceRelated to the command line interfaceagent-sdkbugSomething isn't workingSomething isn't working