I'm exploring OpenHands with V1 SDK (OpenHands at ...
# questions
w
I'm exploring OpenHands with V1 SDK (OpenHands at V1 branch), and observed that tool calling failed more oftenly with DeepSeek. Specifically I have encountered two kinds of issues: 1. LLM does not provide
security_risk
for tools. a. This could be because the IN_CONTEXT_LEARNING_EXAMPLE ignored this parameter. 2. LLM filled parameter with wrong format, like
view_range
. And in my own practical experiences, it would be efficient to add a retry mechanism for such errors. i.e. LLM: Wrong tool call message TOOL: You missed
security_risk
parameter LLM: Correct tool call message Should I add an issue and try this method in agent-sdk?
c
the V1 SDK is in agent-SDK actually, V1 branch i believe only contains with the CLI
we will remove all the agent components from v1 branch very soon, and it will directly imports the agent from agent-SDK repo
šŸ‘ 1
w
Understood. I'm only testing with CLI on V1 branch, and this problem I think directly comes from agent-SDK. Below is a stacktrace:
Copy code
Error starting agent chat: Missing required parameters for function 'str_replace_editor': {'security_risk'}
Traceback (most recent call last):
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/openhands_cli/simple_main.py", line 30, in main
    run_cli_entry()
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/openhands_cli/agent_chat.py", line 142, in run_cli_entry
    runner.process_message(message)
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/openhands_cli/runner.py", line 75, in process_message
    self._run_without_confirmation()
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/openhands_cli/runner.py", line 79, in _run_without_confirmation
    self.conversation.run()
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/openhands/sdk/conversation/impl/local_conversation.py", line 236, in run
    self.agent.step(self._state, on_event=self._on_event)
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/openhands/sdk/agent/agent.py", line 206, in step
    raise e
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/openhands/sdk/agent/agent.py", line 180, in step
    response = self.llm.completion(
               ^^^^^^^^^^^^^^^^^^^^
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/openhands/sdk/llm/llm.py", line 440, in completion
    resp = _one_attempt()
           ^^^^^^^^^^^^^^
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 338, in wrapped_f
    return copy(f, *args, **kw)
           ^^^^^^^^^^^^^^^^^^^^
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 477, in __call__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 378, in iter
    result = action(retry_state)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 400, in <lambda>
    self._add_action_func(lambda rs: rs.outcome.result())
                                     ^^^^^^^^^^^^^^^^^^^
  File "/Users/yangxiao/miniforge3/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/yangxiao/miniforge3/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 480, in __call__
    result = fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/openhands/sdk/llm/llm.py", line 425, in _one_attempt
    resp = self.post_response_prompt_mock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/openhands/sdk/llm/mixins/non_native_fc.py", line 82, in post_response_prompt_mock
    fn_msgs: list[dict] = convert_non_fncall_messages_to_fncall_messages(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/openhands/sdk/llm/mixins/fn_call_converter.py", line 957, in convert_non_fncall_messages_to_fncall_messages
    params = _extract_and_validate_params(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/openhands/sdk/llm/mixins/fn_call_converter.py", line 739, in _extract_and_validate_params
    raise FunctionCallValidationError(
openhands.sdk.llm.exceptions.FunctionCallValidationError: Missing required parameters for function 'str_replace_editor': {'security_risk'}
Traceback (most recent call last):
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/bin/openhands-cli", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/openhands_cli/simple_main.py", line 30, in main
    run_cli_entry()
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/openhands_cli/agent_chat.py", line 142, in run_cli_entry
    runner.process_message(message)
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/openhands_cli/runner.py", line 75, in process_message
    self._run_without_confirmation()
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/openhands_cli/runner.py", line 79, in _run_without_confirmation
    self.conversation.run()
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/openhands/sdk/conversation/impl/local_conversation.py", line 236, in run
    self.agent.step(self._state, on_event=self._on_event)
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/openhands/sdk/agent/agent.py", line 206, in step
    raise e
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/openhands/sdk/agent/agent.py", line 180, in step
    response = self.llm.completion(
               ^^^^^^^^^^^^^^^^^^^^
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/openhands/sdk/llm/llm.py", line 440, in completion
    resp = _one_attempt()
           ^^^^^^^^^^^^^^
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 338, in wrapped_f
    return copy(f, *args, **kw)
           ^^^^^^^^^^^^^^^^^^^^
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 477, in __call__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 378, in iter
    result = action(retry_state)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 400, in <lambda>
    self._add_action_func(lambda rs: rs.outcome.result())
                                     ^^^^^^^^^^^^^^^^^^^
  File "/Users/yangxiao/miniforge3/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/yangxiao/miniforge3/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 480, in __call__
    result = fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/openhands/sdk/llm/llm.py", line 425, in _one_attempt
    resp = self.post_response_prompt_mock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/openhands/sdk/llm/mixins/non_native_fc.py", line 82, in post_response_prompt_mock
    fn_msgs: list[dict] = convert_non_fncall_messages_to_fncall_messages(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/openhands/sdk/llm/mixins/fn_call_converter.py", line 957, in convert_non_fncall_messages_to_fncall_messages
    params = _extract_and_validate_params(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yangxiao/git/OpenHands_local/openhands-cli/.venv/lib/python3.12/site-packages/openhands/sdk/llm/mixins/fn_call_converter.py", line 739, in _extract_and_validate_params
    raise FunctionCallValidationError(
openhands.sdk.llm.exceptions.FunctionCallValidationError: Missing required parameters for function 'str_replace_editor': {'security_risk'}
IMHO the problem will still be existing, even if you guys remove all the agent components from this branch? Since the problem sits inside SDK itself.
c
cc @quick-window-91705 sounds like we might need the ability to explictly disable LLM risk analyzer, otherwise OSS models will have this issue
q
Ah got it I think the CLI can handle it, but the preset including the LLM risk analyzer by default is reasonable imho Will add better error handling around this so that users are aware they can turn of the analyzer
c
the preset including the LLM risk analyzer by default is reasonable imho
when we include the default, we will always send ask LLM to predict this field, and when they are not present, the pydantic validation will yell at us
so i think what we really need is a way to not putting the analyzer in šŸ˜ž
q
hmm we go back to the original issue where the agent is immutable and we can't toggle confirmation mode on mid conversation i actually think this should be less of a problem since we're able to stop the agent, restart the session with changes to the agent, and resume wdyt? its a bit of overhead of clients of sdk but necessary now imo
is there a reason why we can't wrap this error and send it back to the llm? separately we'd have to handle this error regardless, since users may turn on confirmation mode without realizing the llm model doesn't output risk
c
i actually think this should be less of a problem since we're able to stop the agent, restart the session with changes to the agent, and resume
wdyt? its a bit of overhead of clients of sdk but necessary now imo
Yes, maybe we should just do this nod and make changes to the system prompt and eat a little cost here
is there a reason why we can't wrap this error and send it back to the llm?
when llm is a bit too weak to realize that šŸ˜… there isn't too much thing we can do here
šŸ‘ 1
c
šŸ¤” I think the user should be able to toggle confirmation mode and continue the conversation normally. IMHO this is a simple feature that maybe can be offered or not by some client applications, like CLI, but the SDK should support it. Is this really the case that it depends on Agent, can't we just flip in the Conversation running state?
c
the user should be able to toggle confirmation mode and continue the conversation normally
when you remove the llm security analyzer, you update the system prompt, and it invalidate all the caches
but if we persist the setting, it should actually be ok
won't be too expensive unless the user keep switching the mode in the same convo
q
@nutritious-balloon-65098 please open a github issue for this following the issue templates for the repo be concise in describing the problem statement, and proposed fix
n
I'm on it! Rohit Malhotra can track my progress here.
Summary I successfully created a GitHub issue for the DeepSeek tool calling problems in the V1 SDK as requested. Issue Created: #11256 - "[Bug]: DeepSeek LLM fails tool calling due to missing security_risk parameter in V1 SDK" Link: https://github.com/All-Hands-AI/OpenHands/issues/11256 What I accomplished: āœ… Followed the repository's issue template - Used the bug_template.yml format with all required fields āœ… Concise problem statement - Clearly described the two main issues: • Missing
security_risk
parameter causing
FunctionCallValidationError
• Wrong parameter formats (e.g.,
view_range
) āœ… Included reproduction steps - Detailed how to reproduce with DeepSeek + V1 SDK CLI āœ… Added full stack trace - Included the complete error traceback you provided āœ… Proposed practical fix - Suggested retry mechanism with error feedback to LLM, plus options to disable risk analyzer for struggling models The issue is now open with the "bug" label and ready for the OpenHands team to review. This should help improve compatibility with open-source models like DeepSeek that don't follow tool calling schemas as precisely as commercial models. No code changes were made - this was purely an issue creation task using the GitHub API. <sub>View full conversation</sub>