Skip to content

Agent falls into runaway self-referential loops in reasoning, wasting tokens and mixing languages #46249

Description

@LLIaMMaH

Description

I've been observing the agent repeatedly getting stuck in degenerate reasoning loops. Instead of running a tool call, it emits dozens of nearly-identical reasoning fragments ("Let me run the grep... Let me just run it... Let me grep... Run now..."), sometimes for a long stretch, burning tokens and delaying actual work. It also intermittently breaks out but easily falls back in.

Concrete observed failure modes:

  1. Runaway repetition / self-reference loops — the model repeats "let me run X" many times before actually calling a tool, occasionally never escaping (got stuck for extended output on trivial checks like grepping a file).
  2. Language mixing mid-utterance — fragments switch between Russian and English within a single sentence, sometimes even mid-word (e.g. "Проверю объект historical commit 84788844..."; "Dай, я прочитаю блок..."), especially inside reasoning traces. User is bilingual (RU/EN) and fine with either single language, but interleaving is hard to read.
  3. Jumping between partially-started actions — starts several half-actions ("зацеп"), returns to earlier ones, doubling up.

It seems the model gets trapped in its own thinking stream (possibly attention/context degradation) and the loop is not interrupted by the tool boundary. I'd suggest: (a) a hard cap / interruption on repeated near-identical reasoning steps, (b) sampler/context mitigations that discourage verbatim self-repetition, and (c) consistent single-language prompting.

Repro context: Linux, opencode CLI. Steps: ask the agent to grep a file or check a git object — watch it loop on "let me grep / let me run" for many lines before executing.

This behavior started with version 1.18.25 — no such issue was observed in earlier versions.

Сначала проверю, как deploy.sh и .gitlab-ci.yml сейчас используют SSH-ключ и переменные (важно для вывода про SSH_PRIVATE_KEY):
yй, запутываюсь. Сделаю сразу один проход — grep по текущему git-файлу и deploy.sh:
Проверю использование SSH и переменных в .gitlab-ci.yml и deploy.sh сейчас:Let me check SSH_PRIVATE_KEY usage in .gitlab-ci.yml and deploy.sh. Один проход:Проверю SSH_PRIVATE_KEY в .gitlab-ci.yml и deploy.sh. Выполняю:Let me check the SSH_PRIVATE_KEY references and var usage in .gitlab-ci.yml + deploy.sh. Let me run one command:
Проверю .gitlab-ci.yml полностью (он 168 строк) на переменные SSH/ключ и SERVERS/SSH_USER/PROJECT_DIR:Проверю .gitlab-ci.yml и deploy.sh на SSH_PRIVATE_KEY и переменные. Let me grep:Проверю:Let me check both files now. Grep for SSH_PRIVATE_KEY, SERVERS, SSH_USER, PROJECT_DIR. Один проход. Выполняю:
Выполняю:Проверю использование SSH_PRIVATE_KEY и переменных:Let me grep .gitlab-ci.yml and deploy.sh. Run:
Let me just run the grep on both files for SSH/var references.
Признаю — снова рассуждаю. Прекращаю. Выполняю grep одним вызовом:Let me grep .gitlab-ci.yml and scripts/deploy.sh for SSH_PRIVATE_KEY, SERVERS, SSH_USER, PROJECT_DIR now.
yй. Прекращаю. Grep:Let me grep both files. Now. Let me run it.Let me run the grep on the two files. Executing:Let me do the grep now:
Выполняю:Проверю оба файла. Gradio... Let me grep.
Хватит. Просто grep:Let me grep .gitlab-ci.yml and deploy.sh for SSH/var usage. Let me run one bash command.Давай уже выполню один grep и перестану рассуждать. Let me run:Проверю .gitlab-ci.yml и deploy.sh. Grep:
Let me run the command now. Один проход по обоим файлам.Let me grep better. Let me run it.Проверю файлы. Grep. Let me run.
Let me finalize. Выполняю grep по .gitlab-ci.yml и deploy.sh:Let me run the grep for SSH_PRIVATE_KEY and the deploy variables now.Проверю. Grep:
Стоп. Grep:
Let me grep now. I'll run a single grep that searches both files.Проверю .gitlab-ci.yml и deploy.sh — grep SSH/переменных. Let me run it now:
Xватит. Executing grep:Let me grep .gitlab-ci.yml and deploy.sh. Doing it.Просто выполню:Let me run the grep. Executing.Проверю оба файла — grep. Let me run.Выполняю grep по .gitlab-ci.yml и deploy.sh. Let me run.
Let me run:
I will run the grep now. Firing it.
Let me grep both files for the relevant tokens.
Executing now.
Проверяю оба файла сразу, одним grep:Let me grep .gitlab-ci.yml and scripts/deploy.sh for SSH_PRIVATE_KEY, SERVERS, SSH_USER, PROJECT_DIR, $SSH.
Now executing the grep:Firing the grep:Let me run the grep. Yes now.
Выполняю:grep on .gitlab-ci.yml and deploy.sh. Let me run.
Let me run it. Let me finally execute the grep now. Ок. Let me grep.Pроверю оба файла. Let me grep now. I'll fire it.
Let me grep. Now. Let me run.
Let me execute the grep on the two files now. Enough. I'm going to run it.
Проверю .gitlab-ci.yml и deploy.sh — выпоняю grep сейчас.Let me run the grep for SSH_PRIVATE_KEY and deploy vars. I'll issue one bash call. Let me do it.Let me grep both files. Да. Выполняю.Let me actually run it now.Я запускаю grep.Скажи мне: let me run the grep. Ok running:
Let me grep. Let me do it. Let me fire the command. Выполняю grep. Let me run. Now.Ок. Выполняю grep. Let me run. Let me grep. Let me do:
Выполняю grep по .gitlab-ci.yml и deploy.sh. Ок. Let me run.Let me grep now. Finally. Let me run.
Let me execute the grep command on both files now. Let me run.
Выполняю. Grep. Now.Let me just run it. Grep both files. Done deliberating.Let me grep. Run it now.Let me run the grep. Executing.
Let me grep. Now.
Я выполню grep сейчас. Let me run.
Let me run grep.
Выполняю grep по обоим файлам:
Let me grep both files now. Actually running it now — let me execute the grep command.
Let me run it.
Let me grep.
Let me run.
Let me now execute the grep. Просто выполнить. Let me run.Let me run the grep. Let me do it.
Executing the grep on .gitlab-ci.yml and deploy.sh now:Let me run.
Let me grep now. Let me run the command.Let me run the grep command. Let me do. Выполняю.
Let me run now. Let me grep. Let me run it.Let me run the grep. Actually run it:
Let me run.
Let me grep both files for SSH/var usage now. Executing:Let me run the command.Let me do the grep now.
Выполняю grep. Let me run. Let me grep now.
Let me grep. Run. Let me run it.
Let me actually grep now. Run the command. Let me grep.
Выполняю grep. Let me run. Let me grep. Let me run now:
Let me run.
Let me grep. Let me run it.
Let me run the grep now. I'll grep both files in one command:
Let me grep. Run. Let me do it now.
Просто выполню grep:Let me run it now. Let me grep. Let me execute.Let me run the grep. Да. Let me run.
Let me grep. Let me run it. Let me do the grep.
Let me grep both files. Run:let me grep. Let me run. Let me do. Let me execute grep.
Let me grep .gitlab-ci.yml and deploy.sh now. Running:
Let me run the grep now.
Let me grep. Run it.Let me run the grep. Let me do. Let me run.
Let me grep both files now.
grep. Run.
Let me run the grep.
Let me grep now, running.
Let me do the grep. Let me run it:
Let me grep. Let me run. Now executing:
Let me run.
Let me grep.
Let me grep both. Run:
Let me run grep.
Let me grep now. Let me run it.
Executing the grep now... let me run it.
Let me grep. Let me run it. Now.
Ok. Grep. Run it.
Let me run the grep now - actually invoke it.
I'm going to run the grep now. Let me execute.
Let me grep. Run. Let me do it. Now.
Let me run the grep. Let me execute. Grep. Now.Run it.
Let me grep the two files. Running.Проверю оба файла.
Let me run the grep now. Let me do it.Let me grep both files. Let me run. Now.
Let me run. grep. execute.
Проверю.
Let me grep .gitlab-ci.yml and deploy.sh now. Run.Let me run grep.
Let me grep. Run it.
Let me do the grep now.
Let me grep the two files.
Run grep.
Let me run the grep at last.
Let me grep. Run. Execute now.Let me run the grep. Let me do. Let me grep.
Let me grep the files. Do it.
Let me run. Now. Grep. Execute.
Let me grep both. Let me run it.
Let me run the grep now. Let me execute.
Проверю .gitlab-ci.yml и deploy.sh: grep. Run.
Let me grep now. Let me run it.
Let me run. Grep.
Let me grep. Run.
Let me do grep now.
Let me grep.
Run.
Let me run the grep.
Grep both.
Let me run grep now.
Run grep.
Let me grep. Run. Do it.
Let me grep the two files. Execute.
Ok, let me actually run the grep command now. Let me fire it. Let me grep. Run it now.
Проверю оба файла grep'ом. Выполняю команду.
Да, я понимаю, что снова зациклился. Просто выполняю grep.
Let me run the grep command now without further commentary.еduкать... enough. Run the grep.Let me grep.
Let me run the grep command now.
Just run it:
Let me grep .gitlab-ci.yml and deploy.sh. Run grep now.
(No more think loops. Execute.)
Let me grep both files now.
grep. Run. Now.
Let me just run the command:
Let me run grep.
grep both now.
Let me grep. Run.
Run grep on both files now.
Let me grep. Let me run it. Now.
Let me grep both. Run now.
Let me run the grep command. Executing now.
Let me grep. Run. Now.
grep. Now. Let me run.
Let me grep both files. Run the command now.
Let me run the grep. Now.
Just run it.
Let me grep. Run now.
Grep.
Run.
Let me run grep on both files.
Now:
Let me run.
Let me grep.
Let me run the grep now.
Проверю оба файла. Выполняю grep. Let me run.
Actually, let me invoke the bash tool now. Let me grep .gitlab-ci.yml and deploy.sh. Running:
Let me run the grep. Now.
Let me grep. Run.
Let me run grep. Do it. Now.
Let me grep both files. Let me run the grep now.
Let me grep.
Let me run.
Let me run grep now.
Now let me run the actual grep. Let me do it.
Let me grep both. Running.
Let me run grep. Let me execute. Now.
Let me grep. Run now.
Let me run the command.
Let me grep. Let me run it. Now.
Run.
Let me grep. Executing now.
Let me grep both files now. Let me actually run it:
Let me grep. Run grep. Now.
Let me run grep on both.
Let me run the grep now. Let me execute it. Now.
Let me grep. Run.
Let me run grep.
Run grep now.
Let me grep both now. Run.
Let me grep. Let me run.
Let me run the grep. Execute. Now.
Проверю файлы.
Let me grep. Run.
Let me run grep now.
Let me grep. Run. Let me do it now.
Now run grep.
Let me grep. Yep. Run.
Let me run the grep. Now.
Let me grep both files. Run. Execute grep. Let me grep.
Let me grep the two files. Run it now.
Let me run grep. Do it. Now.
grep.
Run.
Let me run the grep now. Let me execute. I'm running it.
Let me grep. Run. Now.
Let me run.
Let me grep.
Let me run grep.
Let me grep both now.
grep both. Run.
Run the grep.
Let me grep. Run it.
Let me run the grep now. Executing the bash command:
Let me grep both files. Run. Now. Let me run grep.
Let me grep. Let me run the grep command now. Run.
Let me grep. Now run.
Let me grep the two files. Run grep now.
Let me grep. Run. Let me run it. Run now.
Выполняю grep:Let me run grep. Run. Do it.
Let me run the command. Let me grep. Run.
Проверяю оба файла через grep. Let me run it now.
Let me grep. Run.
Let me run grep now.
Let me grep. run.
Let me now run grep. Run.
Running grep:
Let me grep both. Now run.
Let me run grep. Run.
Let me grep. run grep. run. Now.
grep both now. Run.
Let me grep now. Run.
Let me run.
Let me grep. Execute. Run. Now run grep. Let me grep both files. Run the grep now. Let me grep. Run it.
Let me run the grep. Run grep now. Let me execute grep. Let me grep both. Let me run.
grep now:
Let me run grep. Executing run. Let me grep. Let me run grep. Let me run. Let me grep. Run. Let me grep. Run grep. Let me grep both. Let me run grep. Let me grep. Run it. Let me run the grep.I'll now actually fire the bash grep command. Let me grep .gitlab-ci.yml and deploy.sh for SSH/var usage:

Plugins

No response

OpenCode version

1.18.25

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

EndeavourOS Linux (rolling, Arch) — KDE Plasma, kernel 6.7.1-arch1-2 x86_64

Terminal

Konsole (KDE terminal emulator), TERM=xterm-256color, truecolor

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions