Repository navigation
Print statement was running in the shell until the tokens got exhausted #53910
Description
Activity
Thanks for reporting this, @prawinextrive! To look into it, we need a few more details:
- OpenCode version: the output of
opencode --version - Provider and model you were using when this happened
- Operating system, how you installed OpenCode, and your terminal
- What you asked for: the prompt or task that led to it, if you can share it
- What exactly repeated: did OpenCode run a shell command (bash tool) that never finished and kept printing output, or did the model keep writing or calling the same
printstatement over and over? If you can, a share link (/share) or the session export would help a lot.
You can reply here with the details, or edit the issue. If you edit it, please also leave a comment saying you've updated it, so we know when you're done.
These existing issues look related, ordered from most to least likely. Please check whether one of them already covers your problem:
- subagent: infinite loop of identical tool calls for ~50min with no loop protection, uncontrollable token burn #45442: the agent gets stuck repeating the same tool call with no loop protection, burning tokens
- big-pickle got stuck in an autoregressive loop during a brainstorming task #42956: a model gets stuck repeating its own output
- Kimi K3 via NVIDIA NIM backend infinetly stuck at !!!!!!! During thinking. #53426: a model gets stuck endlessly outputting the same characters
- Bug: OpenCode enters infinite loop after tool calls complete (Zen/big-pickle) #26220: OpenCode keeps looping after tool calls complete
- OpenCode version: the output of
Thanks for reporting this, @prawinextrive! To look into it, we need a few more details:
- OpenCode version: the output of
opencode --version - Provider and model you were using when this happened
- Operating system, how you installed OpenCode, and your terminal
- What you asked for: the prompt or task that led to it, if you can share it
- What exactly repeated: did OpenCode run a shell command (bash tool) that never finished and kept printing output, or did the model keep writing or calling the same
printstatement over and over? If you can, a share link (/share) or the session export would help a lot.
You can reply here with the details, or edit the issue. If you edit it, please also leave a comment saying you've updated it, so we know when you're done.
These existing issues look related, ordered from most to least likely. Please check whether one of them already covers your problem:
- subagent: infinite loop of identical tool calls for ~50min with no loop protection, uncontrollable token burn #45442: the agent gets stuck repeating the same tool call with no loop protection, burning tokens
- big-pickle got stuck in an autoregressive loop during a brainstorming task #42956: a model gets stuck repeating its own output
- Kimi K3 via NVIDIA NIM backend infinetly stuck at !!!!!!! During thinking. #53426: a model gets stuck endlessly outputting the same characters
- Bug: OpenCode enters infinite loop after tool calls complete (Zen/big-pickle) #26220: OpenCode keeps looping after tool calls complete
- OpenCode version: v1.18.35 (latest version)
- Provider and model Openocde/Big Pickle
- Operating system, Installed it in my mac as a desktop app.
- What you asked for: "fix_mismatched_keys and normalise_artwork_values are changed to lite now. where exactly we can change the models to lite let me know those places first. give me the function name alone. i will check and let you know." This was the exact prompt where I asked opencode to change few LLM models in code.
- What exactly repeated: In shell, I could see that print statement was running continously for an hour. This is the command:
"""$ python3 -c "print('ok')" 2>&1 | tail -1
ok
"""
- OpenCode version: the output of
Thanks for the details, @prawinextrive, that makes it much clearer.
From your description, the shell wasn't stuck. The model (Big Pickle) kept calling the same tool over and over: it ran
python3 -c "print('ok')" 2>&1 | tail -1again and again, and each run finished straight away. So this is the model getting stuck in a loop of identical tool calls, which is the same pattern as these existing reports (ordered by likelihood):- subagent: infinite loop of identical tool calls for ~50min with no loop protection, uncontrollable token burn #45442: infinite loop of identical tool calls with no loop protection, burning tokens
- Bug: OpenCode enters infinite loop after tool calls complete (Zen/big-pickle) #26220: OpenCode keeps looping after tool calls complete (also Zen/Big Pickle)
- big-pickle got stuck in an autoregressive loop during a brainstorming task #42956: Big Pickle stuck repeating its own output
You're on v1.18.35, which is OpenCode v1. v1 now only gets fixes for critical bugs (data loss, security problems, or breakage with no workaround). You can stop a looping session yourself to end it, so this is unlikely to be fixed in v1. If you can, please try OpenCode v2 (the
@opencode/clipackage,opencodecommand). If it also happens there, or you think this should count as critical, reply here and we'll take another look. It may also help to try a different model for this kind of task, since these loops depend a lot on the model.Thanks for the details, @prawinextrive, that makes it much clearer.
From your description, the shell wasn't stuck. The model (Big Pickle) kept calling the same tool over and over: it ran
python3 -c "print('ok')" 2>&1 | tail -1again and again, and each run finished straight away. So this is the model getting stuck in a loop of identical tool calls, which is the same pattern as these existing reports (ordered by likelihood):- subagent: infinite loop of identical tool calls for ~50min with no loop protection, uncontrollable token burn #45442: infinite loop of identical tool calls with no loop protection, burning tokens
- Bug: OpenCode enters infinite loop after tool calls complete (Zen/big-pickle) #26220: OpenCode keeps looping after tool calls complete (also Zen/Big Pickle)
- big-pickle got stuck in an autoregressive loop during a brainstorming task #42956: Big Pickle stuck repeating its own output
You're on v1.18.35, which is OpenCode v1. v1 now only gets fixes for critical bugs (data loss, security problems, or breakage with no workaround). You can stop a looping session yourself to end it, so this is unlikely to be fixed in v1. If you can, please try OpenCode v2 (the
@opencode/clipackage,opencodecommand). If it also happens there, or you think this should count as critical, reply here and we'll take another look. It may also help to try a different model for this kind of task, since these loops depend a lot on the model.The thing is I tried to stop it three times but the same issue happened 4th time as well which exhausted my token usage. I don't know what you will consider as an emergency or an issue. It would be better if some human replied to my queries rather than a clanker bot.
Sorry about the lost tokens, @prawinextrive, that's frustrating.
Stopping the session does end each loop, but it starts again because the same model (Big Pickle) gets stuck the same way on that prompt when you rerun it. Big Pickle has been reported looping like this before (#26220, #42956), and #45442 covers OpenCode having no protection against repeated identical tool calls.
Some things that should help right now:
- Switch to a different model for this task. These loops depend heavily on the model, so this is the most reliable workaround.
- Start a fresh session instead of continuing the one that looped. Once the repeated tool calls are in the conversation history, the model is more likely to keep copying them.
- Upgrade to OpenCode v2 (the
@opencode/clipackage,opencodecommand). That's where development happens now.
Since this is on v1 (1.18.35) and has workarounds, it's unlikely to be fixed there. If you see the same looping on v2, please reply here with the version and model and we'll look at it again.
Closing this as not planned. It's on OpenCode v1 (1.18.35), which now only gets fixes for critical bugs. The repeated
print('ok')calls came from the model (Big Pickle) getting stuck in a tool-call loop, and switching models or starting a fresh session works around it.The general looping problem is tracked in #45442, with related Big Pickle reports in #26220 and #42956. If you see the same thing on OpenCode v2 (
@opencode/cli), please open a new issue or comment here with the version and model, and we'll take another look. Thanks for reporting it, @prawinextrive.
Description
Pretty much the title. I dont know why but this had happened twice before as well. Please check the attached screenshot for more details.
Plugins
No response
OpenCode version
v1.18.35
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
MacOS Golden Gate 27.0.1 (26A434)
Terminal
No response