#Hi, I have an error

1 messages · Page 1 of 1 (latest)

gaunt crescent
#

i need help

zenith yoke
#

This is a Hermes gateway bug, not a Qwen/OpenRouter problem.

Your traceback shows the gateway crashing with:

UnboundLocalError: cannot access local variable 'message' where it is not associated with a value

That means the request is failing before it even reaches the model provider cleanly. So the LM Studio / Gemma testing was probably just incidental timing, not the real root cause.

If you need the bot back up right now, the quickest workaround is to try a fresh session with /reset or restart the gateway, but the real fix needs a code patch in gateway/run.py.

Also, the Telegram fallback IP and DM-style session ID in the log are not ideal to post publicly, but they are not as sensitive as an API key or token. Still better to redact them when sharing screenshots to reduce any possible attack vectors. Not a big deal though.

#

a more technical answer:
The traceback shows run.py blowing up with:

UnboundLocalError: cannot access local variable 'message' where it is not associated with a value
And the code confirms it:

_run_agent(...) is called with message=message_text in gateway/run.py
but later inside run_sync() it does agent.run_conversation(message, ...) in gateway/run.py
there is no guaranteed local message there, only message_text
the only place message gets assigned is inside the pending-model-note branch in gateway/run.py, so if that branch does not run, it crashes

gaunt crescent
#

python3 << 'EOF'
with open('/home/rain2510/hermes-agent/gateway/run.py', 'r') as f:
content = f.read()

Fix: replace message with message_text in the problematic spots

old = ''' _msn = _pending_notes.pop(session_key, None) if session_key else None
if _msn:
message = _msn + "\n\n" + message
_approval_session_key = session_key or ""
_approval_session_token = set_current_session_key(_approval_session_key)
register_gateway_notify(_approval_session_key, _approval_notify_sync)
try:
result = agent.run_conversation(message, conversation_history=agent_history, task_id=session_id)'''

new = ''' _msn = _pending_notes.pop(session_key, None) if session_key else None
if _msn:
message_text = _msn + "\n\n" + message_text
_approval_session_key = session_key or ""
_approval_session_token = set_current_session_key(_approval_session_key)
register_gateway_notify(_approval_session_key, _approval_notify_sync)
try:
result = agent.run_conversation(message_text, conversation_history=agent_history, task_id=session_id)'''

if old in content:
content = content.replace(old, new)
with open('/home/rain2510/hermes-agent/gateway/run.py', 'w') as f:
f.write(content)
print("✅ Fix applied!")
else:
print("❌ Pattern not found")
EOF

#

would it be the solution?

zenith yoke
#

seems like it

#

if you get that working smoothly, i'd see if you can open a pr for it. seems like a legit bug.

gaunt crescent
#

I have tried, nothing still with the same bug

lament silo
zenith yoke
#

hmm.
Their second patch still fails because of Python scoping rules:

inside run_sync(), the line message_text = _msn + "\n\n" + message_text makes message_text a local variable in that function
then Python sees the right-hand-side message_text as a read of that same local before it has been assigned
so you just get the same bug with a different variable name

gaunt crescent
#

yes several times but nothing

gaunt crescent
zenith yoke
#

wheel of ai answers, turn turn turn. teach us the lessons that we must learn!
something like this maybe?

gaunt crescent
#

oh yes I already saw the code error looking at your image thank you very much it helps me a lot the capture was a direct error thank you very much broder

zenith yoke
#

awesome. lmk if you try another fix and get things working / what the fix looks like for you.

gaunt crescent
#

I tried several solutions, but in the end, all I had to do for the 6463 and 6480p models was fix the “message.”

#

thk bro

zenith yoke
#

thank you!

lament silo
#

sorry what was the fix though?

zenith yoke
#

Yeah. What he's saying is a little garbled, but he almost certainly means "the fix was around lines 6463 and 6480-ish in run.py, and the problem was the message variable.". @gaunt crescent, can you confirm the full fix?

gaunt crescent
#

Yes, the solution is already done, thank you very much.

zenith yoke
#

I believe we're looking to make this fix available for everyone, so that others don't run into the same issue. can you make a pr for this or explain what changes were made on your local machine for a fix?
Alternatively:
If you're not comfortable making a pr, can you confirm that this is the right fix for the issue? If so, I can go ahead and make a pr to get it fixed upstream.