Hi, I ran into what looks like a recursion bug while trying /reflect.
I'm using OpenCode 1.18.1 on Windows with opencode-hermes commit 204fc281. The command returned ok, but it seemed to keep running, so I checked hermes-state.json.
The background reflect session had called hermes_nudge_now again, which created another background session. That session did the same thing. In this run, the chain reached eight levels and the titles looked like this:
<session>#reflect
<session>#reflect#reflect
<session>#reflect#reflect#reflect
...
Here is a shortened version of the event log with the session IDs removed:
{"event":"tool","sid":"<main>"}
{"event":"bg_created","sid":"<main>","bg":"<bg-1>","title":"...#reflect"}
{"event":"tool","sid":"<bg-1>"}
{"event":"bg_created","sid":"<bg-1>","bg":"<bg-2>","title":"...#reflect#reflect"}
{"event":"tool","sid":"<bg-2>"}
{"event":"bg_created","sid":"<bg-2>","bg":"<bg-3>","title":"...#reflect#reflect#reflect"}
Most of these sessions eventually returned step1_result: ["none"], so the chain stopped, but each one still created a session and made another model call.
My guess is that this happens because the experimental.chat.system.transform hook adds the "call hermes_nudge_now when the user says reflect" instruction to the internal reflector sessions too. The reflector prompt itself contains words such as "reflector" and "reflection".
There is already a prefix check in chat.message, but it did not prevent the background session from becoming mainId in this run.
I expected one /reflect call to create or reuse one background session. Internal reflector sessions probably should not be able to invoke hermes_nudge_now.
A guard against session IDs stored in bgSessionIds, both when injecting the instruction and when executing the tool, might prevent this. Restricting the trigger to the /reflect command would also avoid matching the reflector's own prompt.
I can provide the longer anonymized event log if it would help.
Hi, I ran into what looks like a recursion bug while trying
/reflect.I'm using OpenCode 1.18.1 on Windows with opencode-hermes commit
204fc281. The command returnedok, but it seemed to keep running, so I checkedhermes-state.json.The background reflect session had called
hermes_nudge_nowagain, which created another background session. That session did the same thing. In this run, the chain reached eight levels and the titles looked like this:Here is a shortened version of the event log with the session IDs removed:
Most of these sessions eventually returned
step1_result: ["none"], so the chain stopped, but each one still created a session and made another model call.My guess is that this happens because the
experimental.chat.system.transformhook adds the "call hermes_nudge_now when the user says reflect" instruction to the internal reflector sessions too. The reflector prompt itself contains words such as "reflector" and "reflection".There is already a prefix check in
chat.message, but it did not prevent the background session from becomingmainIdin this run.I expected one
/reflectcall to create or reuse one background session. Internal reflector sessions probably should not be able to invokehermes_nudge_now.A guard against session IDs stored in
bgSessionIds, both when injecting the instruction and when executing the tool, might prevent this. Restricting the trigger to the/reflectcommand would also avoid matching the reflector's own prompt.I can provide the longer anonymized event log if it would help.