Has anyone seen this error in 0.57? Seems to be fi...
# questions
f
Has anyone seen this error in 0.57? Seems to be fixed by refreshing the page but comes up consistently UI Error
RuntimeError: There was an unexpected error while running the agent: KeyError. You can refresh the page or ask the agent to try again.
Terminal Log Error
Copy code
13:24:01 - openhands:ERROR: agent_controller.py:365 - [Agent Controller 50e60a7285514096b0cb5f63a9021fd3] Error while running the agent (session ID: 50e60a7285514096b0cb5f63a9021fd3): 'command'. Traceback: Traceback (most recent call last):
  File "/Users/jwillard/Workspace/OpenHands/openhands/controller/agent_controller.py", line 363, in _step_with_exception_handling
    await self._step()
  File "/Users/jwillard/Workspace/OpenHands/openhands/controller/agent_controller.py", line 870, in _step
    action = self.agent.step(self.state)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jwillard/Workspace/OpenHands/openhands/agenthub/codeact_agent/codeact_agent.py", line 221, in step
    response = self.llm.completion(**params)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jwillard/Workspace/OpenHands/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 338, in wrapped_f
    return copy(f, *args, **kw)
           ^^^^^^^^^^^^^^^^^^^^
  File "/Users/jwillard/Workspace/OpenHands/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 477, in __call__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jwillard/Workspace/OpenHands/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 378, in iter
    result = action(retry_state)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/jwillard/Workspace/OpenHands/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 400, in <lambda>
    self._add_action_func(lambda rs: rs.outcome.result())
                                     ^^^^^^^^^^^^^^^^^^^
  File "/Users/jwillard/.local/share/uv/python/cpython-3.12.11-macos-aarch64-none/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/jwillard/.local/share/uv/python/cpython-3.12.11-macos-aarch64-none/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/jwillard/Workspace/OpenHands/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 480, in __call__
    result = fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/jwillard/Workspace/OpenHands/openhands/llm/llm.py", line 348, in wrapper
    convert_non_fncall_messages_to_fncall_messages(
  File "/Users/jwillard/Workspace/OpenHands/openhands/llm/fn_call_converter.py", line 892, in convert_non_fncall_messages_to_fncall_messages
    params = _extract_and_validate_params(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jwillard/Workspace/OpenHands/openhands/llm/fn_call_converter.py", line 677, in _extract_and_validate_params
    if 'enum' in matching_tool['parameters']['properties'][param_name]:
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'command'

13:24:01 - openhands:WARNING: agent_controller.py:386 - [Agent Controller 50e60a7285514096b0cb5f63a9021fd3] Unknown exception type while running the agent: KeyError.
13:24:01 - openhands:INFO: agent_controller.py:637 - [Agent Controller 50e60a7285514096b0cb5f63a9021fd3] Setting agent(CodeActAgent) state from AgentState.RUNNING to AgentState.ERROR
13:24:01 - openhands:INFO: agent_controller.py:637 - [Agent Controller 50e60a7285514096b0cb5f63a9021fd3] Setting agent(CodeActAgent) state from AgentState.ERROR to AgentState.ERROR
13:24:01 - openhands:ERROR: session.py:433 - Agent status error: RuntimeError: There was an unexpected error while running the agent: KeyError. You can refresh the page or ask the agent to try again.
13:24:01 - openhands:ERROR: session.py:345 - Agent status error: RuntimeError: There was an unexpected error while running the agent: KeyError. You can refresh the page or ask the agent to try again.
c
What LLM are you using?
f
Sonnet 3.5
c
Do you have native function calling disabled? If so, may I ask why?
If not, this looks like a bug, we should have it enabled for 3.5
(you could set it explicitly, with
LLM_NATIVE_TOOL_CALLING=true
env var)
f
How would I check if it is disabled? I do not see the LLM_NATIVE_TOOL_CALLING env var in either the runtime or my terminal where OH is running (I am running the web UI on Mac+Firefox)
c
@nutritious-balloon-65098 verify for what models exactly is native_tool_calling disabled, and if it’s Sonnet 3.5 then that’s a bug, propose a PR with the fix
n
I'm on it! can track my progress here.
c
@flaky-postman-41333 Could you maybe start OH with it set to true?
n
Summary of work What you asked: • Verify exactly which models have native tool calling disabled, and if Sonnet 3.5 is one of them, propose a PR with the fix. What I found: • Native tool calling defaults are defined centrally in openhands/llm/model_features.py via FUNCTION_CALLING_PATTERNS. • Before my change, Sonnet 3.5 was enabled for the dashed naming (claude-3-5-sonnet*), but NOT for the dotted naming (claude-3.5-sonnet*). • Result: If you used a dotted Sonnet 3.5 model name, native tool calling was disabled by default. This explains the reported KeyError: 'command' when tool emulation was attempted. What I changed: • Added the missing dotted pattern to enable native tool calling for Sonnet 3.5: ◦ File: openhands/llm/model_features.py ◦ Inserted: 'claude-3.5-sonnet*' into FUNCTION_CALLING_PATTERNS • Commit: llm(model_features): enable native tool calling for Anthropic Claude 3.5 Sonnet dot-notation models by adding 'claude-3.5-sonnet*' to FUNCTION_CALLING_PATTERNS ◦ Co-authored-by: openhands <openhands@all-hands.dev> Checks: • Focused, minimal change (1-line addition). • No unrelated edits. • Backend pre-commit checks ran and passed before committing changes. • Committed cleanly. Next steps: • I pushed the change to a new branch and opened a draft PR for your review: ◦ Branch: fix/sonnet35-native-tools ◦ PR: https://github.com/All-Hands-AI/OpenHands/pull/11156 • Please let me know if you want me to: ◦ Mark the PR ready for review, or ◦ Make any additional adjustments (e.g., add a small unit test mirroring the Gemini 2.5 function-calling test), or ◦ Keep it as a draft for now. Answer to “for what models exactly is native tool calling disabled?”: • By default, native tool calling is enabled only for models that match FUNCTION_CALLING_PATTERNS (Anthropic Sonnet/Haiku, Sonnet 4 and Opus 4, OpenAI gpt-4o family, select o-series and gpt-5, Gemini 2.5 Pro, Kimi K2, Qwen3 coder, DeepSeek Chat). • For all other models not matching those patterns, it’s disabled by default unless you explicitly set LLM_NATIVE_TOOL_CALLING=true. With my change, both dashed and dotted Sonnet 3.5 variants are now enabled by default. <sub>View full conversation</sub>
f
@calm-artist-7206 How do I enable it? I'm not seeing it in the configuration
c
Ahh, you’re using it via proxy. That means that maybe you could name it anything, right? If you name it claude-3-5-sonnet, it should just work. (unfortunately, we do some string-matching voodoo here)
There is no option in the web UI, but maybe you could, alternatively, start the server with a command line that contains this env var? Or if it’s via docker run, then add a line to that command, another ‘-e LLM_NATIVE…’
f
Thank you, I will try the rename in the proxy
c
We also merged a fix in OpenHands, though I’m not sure when we make a new release with it
🙏 1
f
This issue still seems to persist in 0.59 > Ahh, you’re using it via proxy. That means that maybe you could name it anything, right? If you name it claude-3-5-sonnet, it should just work. I've found that this doesn't work for my case, I get errors like
Copy code
litellm.exceptions.APIConnectionError: litellm.APIConnectionError: BedrockException - {"message":"You invoked an unsupported model or your request did not allow prompt caching. See the documentation for more information."}. Received Model Group=claude-3-5-sonnet
Available Model Group Fallbacks=None LiteLLM Retried: 1 times, LiteLLM Max Retries: 2
Litellm indicates model names must be in this list: https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json , and I've found that to be necessary...
c
I’m confused by the error, which shows Bedrock, and the screenshot, which doesn’t have a name with
bedrock
🤔
f
The model id has bedrock but model name does not, this is the litellm config
Copy code
model_list:
  - model_name: anthropic.claude-3-5-sonnet-20241022 # user-facing 
    litellm_params:
      model: bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0
      aws_access_key_id: "os.environ/AWS_ACCESS_KEY_ID"
      aws_secret_access_key: "os.environ/AWS_SECRET_ACCESS_KEY"
      aws_session_token: "os.environ/AWS_SESSION_TOKEN"
      aws_region_name: us-west-2
c
We should have an alternative to this model-name-matching, the alternative is to set this in the terminal when running the web UI via `make run`:
LLM_NATIVE_TOOL_CALLING=true make run
Or via
docker run
, add a line to the command,
-e LLM_NATIVE_TOOL_CALLING=true
Ah!
But then, the actual model name, the one that litellm needs to send request to, has dot, right?
That is, the “model” in params, I think
What about:
Copy code
litellm_params:
      model: bedrock/anthropic.claude-3.5-sonnet-20241022-v2:0
      aws_access_key_id: "os.environ/AWS_ACCESS_KEY_ID"
      aws_secret_access_key: "os.environ/AWS_SECRET_ACCESS_KEY"
      aws_session_token: "os.environ/AWS_SESSION_TOKEN"
      aws_region_name: us-west-2
f
^ That also doesn't work because it won't string match
Copy code
litellm.exceptions.BadRequestError: litellm.BadRequestError: Error code: 400 - {'error': {'message': 'litellm.BadRequestError: BedrockException - {"message":"The provided model identifier is invalid."}. Received Model Group=anthropic.claude-3-5-sonnet-20241022\nAvailable Model Group Fallbacks=None', 'type': None, 'param': None, 'code': '400'}}
c
Sorry, that seems to mean the Bedrock name is not correct?
f
Right, I assume you only changed
bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0
to
bedrock/anthropic.claude-3.5-sonnet-20241022-v2:0
in the
model:
field?
c
Please let me take a step back here: So we have two options: 1) adjust litellm / openhands to match, so that tool use is enabled • the “model_name” (user-facing) name doesn’t have to be strictly the provider name, so maybe we can assign the name that fits this mess • the “model” (provider-facing) has to be the one in Bedrock list 2) try to use the env var, as above, to simply “force” tool use for 3.5, no matter if we didn’t recognize it by default
You’re right, I think, “model” is provider-given, right
The reason I said that, is that I used litellm proxy where the “user facing” name, the name used in applications, had “bedrock/“, so I got confused why it wouldn’t
f
Mostly yes, but changing the "model_name" does not appear to not flexible in my tests (see previous error). I very much appreciate the assistance. I will try the env var!
c
That’s a very confusing error. I have seen before that Bedrock is iffy with prompt caching (it used to require to apply to them, etc, not sure if they still do, and had 400 errors if it was disabled…)
Yes… I don’t know the explanation here, but a possible explanation is that litellm recognizes models that support prompt caching by the same “model name”, and then maybe it doesn’t here, so it doesn’t send some header or some other transformation it should do
(TBH what we try to do for the proxies we use for openhands is to use the same name (including prefix) for the configurations; simpler to manage/remember, too. For example I’m just setting
litellm_proxy/openai/gpt-5
)
f
Ah shoot the env var ``LLM_NATIVE_TOOL_CALLING=true make run` also does not fix the error, strangely it's pulling a parameter name that is nowhere in the code (but is related to the OH dialogue content and connected MCP tools)
Copy code
Traceback (most recent call last):
  File "/Users/jwillard/Workspace/OpenHands/openhands/controller/agent_controller.py", line 371, in _step_with_exception_handling
    await self._step()
  File "/Users/jwillard/Workspace/OpenHands/openhands/controller/agent_controller.py", line 878, in _step
    action = self.agent.step(self.state)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jwillard/Workspace/OpenHands/openhands/agenthub/codeact_agent/codeact_agent.py", line 219, in step
    response = self.llm.completion(**params)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jwillard/Workspace/OpenHands/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 338, in wrapped_f
    return copy(f, *args, **kw)
           ^^^^^^^^^^^^^^^^^^^^
  File "/Users/jwillard/Workspace/OpenHands/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 477, in __call__
    do = self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jwillard/Workspace/OpenHands/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 378, in iter
    result = action(retry_state)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/jwillard/Workspace/OpenHands/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 400, in <lambda>
    self._add_action_func(lambda rs: rs.outcome.result())
                                     ^^^^^^^^^^^^^^^^^^^
  File "/Users/jwillard/.local/share/uv/python/cpython-3.12.11-macos-aarch64-none/lib/python3.12/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/jwillard/.local/share/uv/python/cpython-3.12.11-macos-aarch64-none/lib/python3.12/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/Users/jwillard/Workspace/OpenHands/.venv/lib/python3.12/site-packages/tenacity/__init__.py", line 480, in __call__
    result = fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/jwillard/Workspace/OpenHands/openhands/llm/llm.py", line 351, in wrapper
    convert_non_fncall_messages_to_fncall_messages(
  File "/Users/jwillard/Workspace/OpenHands/openhands/llm/fn_call_converter.py", line 892, in convert_non_fncall_messages_to_fncall_messages
    params = _extract_and_validate_params(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/jwillard/Workspace/OpenHands/openhands/llm/fn_call_converter.py", line 677, in _extract_and_validate_params
    if 'enum' in matching_tool['parameters']['properties'][param_name]:
                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
KeyError: 'hypothesis_updates'
c
Could you please tell if your OH is updated? I think the latest version is 0.59
f
Yes I am on 0.59
c
😓 Maybe my fix didn't make it in. Could you please tell the model name now, as set in OH window? Maybe, if you want, we could hack it in directly for now. Soon, we'll upgrade OH to V1, and this kind of issue will look very different.
f
The model name is
litellm_proxy/anthropic.claude-3-5-sonnet-20241022
I think a hack would be nice for now, and looking forward to v1 UI release
c
Please let's try to add exactly this: "`anthropic.claude-3-5-sonnet-20241022"` here https://github.com/All-Hands-AI/OpenHands/blob/6f2f85073d16ee44743d6203dc9909dacdc2ae37/openhands/llm/model_features.py#L72
f
Sure I can try that. Will that update with a new
make run
or do i need to rebuild the sandbox container with that change? (I just see there is a version of the openhands code in the container at
/openhands/code/
that doesn't update with this change)