openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Local LLM provider rises CallExpression

Open Begalov opened this issue 1 month ago • 4 comments

Openhuman installed with powershell setted up fork of llama.cpp from https://github.com/PrismML-Eng/Bonsai-demo as custom provider and LM studio with ornith-1.0-9b as custom then native LM Studio provider, with both providers Openhuman recives model list but then getting the error in chat:

Something went wrong

The AI provider is temporarily unavailable. Please try again later.

LM Studio and llama.cpp output this:

Engine protocol predict request returned 500: {"error":{"code":500,"message":"\n------------\nWhile executing CallExpression at line 85, column 32 in source:\n...first %}↵            {{- raise_exception('System message must be at the beginnin...\n                                           ^\nError: Jinja Exception: System message must be at the beginning.","type":"server_error"}}. Error Data: n/a, Additional Data: n/a

Openrouter as provider works fine.

v0.64.15, Windows 11 Pro 25H2, desktop

Also I use LM Studio with Require Authentication API key but Openhuman not offering to input it.

Begalov avatar Oct 11 '26 11:10 Begalov

Local LLM providers (LM Studio, custom llama.cpp fork) return 500 from the engine with a Jinja exception 'System message must be at the beginning', so chats fail with 'The AI provider is temporarily unavailable' even though model listing works; OpenRouter is unaffected, suggesting OpenHuman builds a malformed message sequence (e.g. system message not first or duplicated). Secondary report: no UI to enter an API key for LM Studio servers that require authentication.

Labelled priority: p2.

tinysweeper avatar Oct 11 '26 15:10 tinysweeper

Thanks for the detailed report and the server output, which made this easy to trace.

From the code on main, OpenHuman can send the system prompt as two consecutive system messages (a stable part and a per-turn part). Some messages added mid-conversation also go out as system messages. Strict chat templates like the one your model uses only accept one system message, and only at the very start, so LM Studio and llama.cpp reject the request. OpenRouter applies its own template, which is why it works there. The fix is to merge those into a single leading system message for local OpenAI-compatible providers. I haven't run your exact model, so if you can share which chat template it ships with (or the model's base family), that would help confirm.

You're also right about the API key. The backend can already send a Bearer key to LM Studio (local_ai.api_key), but the settings screen only shows the key field for OMLX. We'll track both here.

M3gA-Mind avatar Oct 19 '26 06:10 M3gA-Mind

Picking this one up. Starting with the missing API key field for LM Studio, then I will look at the system message part.

obchain avatar Oct 19 '26 08:10 obchain

Thanks again for the server output. An update from current main:

  • Fixed: when you use LM Studio through its built-in provider (Settings → AI), OpenHuman now merges the system prompt into a single system message, which avoids that template error. This came with #8179.
  • Not fixed yet: adding the same server as a custom OpenAI-compatible provider still sends two system messages.
  • Not fixed yet: LM Studio has no API key field. #8107 is the open PR for the key. If you can, please try the built-in LM Studio provider on the latest release and tell us whether the error is gone.

M3gA-Mind avatar Nov 16 '26 16:11 M3gA-Mind