hermes - 💡(How to fix) Fix fix(gemini): systemInstruction missing required role field causes HTTP 500 on Gemma models

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

Without this field, Gemma models consistently return 500 Internal Server Error. Other models (Gemini 2.5 Pro/Flash) appear to be more lenient and tolerate the missing field, which is why this went undetected.

Root Cause

In gemini_native_adapter.py line ~326, the system instruction is built as:

system_instruction = {"parts": [{"text": joined_system}]}

The Gemini API requires the system instruction to include a role field:

system_instruction = {"role": "system", "parts": [{"text": joined_system}]}

Without this field, Gemma models consistently return 500 Internal Server Error. Other models (Gemini 2.5 Pro/Flash) appear to be more lenient and tolerate the missing field, which is why this went undetected.

Fix Action

Fix

Add "role": "system" to the systemInstruction dict. One-line change.

Code Example

system_instruction = {"parts": [{"text": joined_system}]}

---

system_instruction = {"role": "system", "parts": [{"text": joined_system}]}
RAW_BUFFERClick to expand / collapse

Bug

The Gemini native adapter (hermes/providers/gemini_native_adapter.py) constructs the systemInstruction field without the required "role": "system" key. This causes the Gemini API to return HTTP 500 on any request that includes a system prompt when using Gemma models (e.g. gemma-4-31b-it).

Root Cause

In gemini_native_adapter.py line ~326, the system instruction is built as:

system_instruction = {"parts": [{"text": joined_system}]}

The Gemini API requires the system instruction to include a role field:

system_instruction = {"role": "system", "parts": [{"text": joined_system}]}

Without this field, Gemma models consistently return 500 Internal Server Error. Other models (Gemini 2.5 Pro/Flash) appear to be more lenient and tolerate the missing field, which is why this went undetected.

Fix

Add "role": "system" to the systemInstruction dict. One-line change.

Verification

Tested with direct API calls:

  • Without role: HTTP 500 on Gemma 4
  • With role: HTTP 200, valid response

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix fix(gemini): systemInstruction missing required role field causes HTTP 500 on Gemma models