OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

[Bug]: Using the moonshot API to call the kimi-k2-0905-preview model resulted in a BadRequestError.

Open Sparidae opened this issue 1 month ago • 5 comments

Is there an existing issue for the same bug? (If one exists, thumbs up or comment on the issue instead).

  • [x] I have checked the existing issues.

Describe the bug and reproduction steps

The verified moonshot provider model only offers kimi-k2-0711-preview, yet I was unable to successfully call this model (an error occurred during the call indicating the API key could not be verified).

Moreover, the latest kimi-k2-0905-preview model is also unavailable, so I resorted to calling the model by providing a custom base URL and model ID.

I used the configuration shown in the image below.

Image

Using the above configuration can successfully call the model, and it works fine when creating a new project for the first time. However, when I try to continue the conversation, moonshotapi throws an error, similar to the image below.

Image

This issue exists not only on openhands cloud but also in the version deployed via docker commands

OpenHands Installation

app.all-hands.dev

OpenHands Version

latest

Model Name

kimi-k2-0905-preview

Operating System

Linux

Logs, Errors, Screenshots, and Additional Context

trajectory-d1949983e22d40588727a28aacd20dd1.json

Sparidae avatar Nov 05 '25 07:11 Sparidae

@enyst this seems like agent-sdk if it works setting it but fails soon after right?

mamoodi avatar Nov 06 '25 18:11 mamoodi

:nod The error is a BadRequest when it was working, it performed some steps, so it seems like an issue with how we or litellm work with this LLM. 🤔

However, at the moment we transition to OpenHands V1, which is built on agent-sdk, but V0 wasn't. In the screenshot I see V0, so the conversations UI was working with V0 in the backend.

Sorry for the troubles @Sparidae ! I would love to know if you could run it normally with the V1 CLI, if you want to give a try perhaps?

enyst avatar Nov 06 '25 18:11 enyst

I'm a first-time uv user and hit the same import error reported in #11664 when I ran

uvx --python 3.12 openhands

I then tried the workaround from #11643

uvx --python 3.12 --from git+https://github.com/OpenHands/OpenHands@cli-fix#subdirectory=openhands-cli openhands

which got me past the initial import, but after entering my API key the CLI still crashes. Stack trace below in case it’s useful.

Given that the fix seems to be still in-flight, I’ll hold off for now and retry once the PR lands.

Thanks!

error log
uvx --python 3.12 --from git+https://github.com/OpenHands/OpenHands@cli-fix#subdirectory=openhands-cli openhands

Welcome to OpenHands! Let's configure your LLM settings.
Choose your preferred setup method:

  LLM (Basic)
> LLM (Advanced)
 
(Step 1/4) Custom Model (CTRL-c to cancel): moonshot/kimi-k2-0905-preview
(Step 2/4) Base URL (CTRL-c to cancel): https://api.moonshot.cn/v1
(Step 3/4) Enter API Key (CTRL-c to cancel): ***************************************************
(Step 4/4) Memory Condensation (CTRL-c to cancel):

> Enable
  Disable
 
Save new settings? (They will take effect after restart)

> Yes, save
  No, discard
 
Error: 1 validation error for LLM
extra_body
  Extra inputs are not permitted [type=extra_forbidden, input_value={'metadata': {'trace_vers..._tools_version:1.0.0']}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
Traceback (most recent call last):
  File "/home/user/.cache/uv/archive-v0/up-KMiii0oFfr_qdDMxyS/lib/python3.12/site-packages/openhands_cli/simple_main.py", line 45, in main
    run_cli_entry(resume_conversation_id=args.resume)
  File "/home/user/.cache/uv/archive-v0/up-KMiii0oFfr_qdDMxyS/lib/python3.12/site-packages/openhands_cli/agent_chat.py", line 86, in run_cli_entry
    initialized_agent = verify_agent_exists_or_setup_agent()
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.cache/uv/archive-v0/up-KMiii0oFfr_qdDMxyS/lib/python3.12/site-packages/openhands_cli/setup.py", line 49, in verify_agent_exists_or_setup_agent
    settings_screen.configure_settings(first_time=True)
  File "/home/user/.cache/uv/archive-v0/up-KMiii0oFfr_qdDMxyS/lib/python3.12/site-packages/openhands_cli/tui/settings/settings_screen.py", line 129, in configure_settings
    self.handle_advanced_settings()
  File "/home/user/.cache/uv/archive-v0/up-KMiii0oFfr_qdDMxyS/lib/python3.12/site-packages/openhands_cli/tui/settings/settings_screen.py", line 173, in handle_advanced_settings
    self._save_advanced_settings(
  File "/home/user/.cache/uv/archive-v0/up-KMiii0oFfr_qdDMxyS/lib/python3.12/site-packages/openhands_cli/tui/settings/settings_screen.py", line 203, in _save_advanced_settings
    self._save_llm_settings(custom_model, api_key, base_url=base_url)
  File "/home/user/.cache/uv/archive-v0/up-KMiii0oFfr_qdDMxyS/lib/python3.12/site-packages/openhands_cli/tui/settings/settings_screen.py", line 178, in _save_llm_settings
    llm = LLM(
          ^^^^
  File "/home/user/.cache/uv/archive-v0/up-KMiii0oFfr_qdDMxyS/lib/python3.12/site-packages/pydantic/main.py", line 250, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for LLM
extra_body
  Extra inputs are not permitted [type=extra_forbidden, input_value={'metadata': {'trace_vers..._tools_version:1.0.0']}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden
Traceback (most recent call last):
  File "/home/user/.cache/uv/archive-v0/up-KMiii0oFfr_qdDMxyS/bin/openhands", line 12, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/user/.cache/uv/archive-v0/up-KMiii0oFfr_qdDMxyS/lib/python3.12/site-packages/openhands_cli/simple_main.py", line 45, in main
    run_cli_entry(resume_conversation_id=args.resume)
  File "/home/user/.cache/uv/archive-v0/up-KMiii0oFfr_qdDMxyS/lib/python3.12/site-packages/openhands_cli/agent_chat.py", line 86, in run_cli_entry
    initialized_agent = verify_agent_exists_or_setup_agent()
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.cache/uv/archive-v0/up-KMiii0oFfr_qdDMxyS/lib/python3.12/site-packages/openhands_cli/setup.py", line 49, in verify_agent_exists_or_setup_agent
    settings_screen.configure_settings(first_time=True)
  File "/home/user/.cache/uv/archive-v0/up-KMiii0oFfr_qdDMxyS/lib/python3.12/site-packages/openhands_cli/tui/settings/settings_screen.py", line 129, in configure_settings
    self.handle_advanced_settings()
  File "/home/user/.cache/uv/archive-v0/up-KMiii0oFfr_qdDMxyS/lib/python3.12/site-packages/openhands_cli/tui/settings/settings_screen.py", line 173, in handle_advanced_settings
    self._save_advanced_settings(
  File "/home/user/.cache/uv/archive-v0/up-KMiii0oFfr_qdDMxyS/lib/python3.12/site-packages/openhands_cli/tui/settings/settings_screen.py", line 203, in _save_advanced_settings
    self._save_llm_settings(custom_model, api_key, base_url=base_url)
  File "/home/user/.cache/uv/archive-v0/up-KMiii0oFfr_qdDMxyS/lib/python3.12/site-packages/openhands_cli/tui/settings/settings_screen.py", line 178, in _save_llm_settings
    llm = LLM(
          ^^^^
  File "/home/user/.cache/uv/archive-v0/up-KMiii0oFfr_qdDMxyS/lib/python3.12/site-packages/pydantic/main.py", line 250, in __init__
    validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 1 validation error for LLM
extra_body
  Extra inputs are not permitted [type=extra_forbidden, input_value={'metadata': {'trace_vers..._tools_version:1.0.0']}}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.12/v/extra_forbidden

Sparidae avatar Nov 07 '25 07:11 Sparidae

You're right, sorry! @Sparidae

We just released agent-sdk V1 (1.0.0) yesterday, and the CLI V1 based on it about an hour ago.

enyst avatar Nov 07 '25 19:11 enyst

I think this issue still belongs to OpenHands repo. Kimi K2 support has recently been merged into the latest version of the SDK. Once the OpenHands application is switched to using V1, this issue should be resolved.

xingyaoww avatar Nov 13 '25 21:11 xingyaoww