[Bug] Agent output enters an infinite repetition loop that runs for ~10 minutes with no circuit breaker — only a manual abort stops it #2848
Codingendless
started this conversation in
General
Replies: 1 comment
|
确认当前只有“重复工具调用提醒”,没有针对模型文本流退化重复的保护。这个行为不应直接写进 agent-loop;按现有架构,更适合做一个可配置的 llm/stream middleware 插件。 建议实现独立的 output-repetition guard:
Provider 的 frequency/presence/repetition penalty 只能作为可选能力,DeepSeek 思考模式和许多兼容网关并不保证支持,不能替代 harness 级熔断。有限的 adapter 默认 maxTokens 与提前 compaction 也应保留,但两者只是第二道防线。 回归测试应覆盖:同一句话采用不同 chunk 切分仍触发、长重复字符/句子、合法重复代码不触发、触发后 upstream return() 被调用、只有一个 error finish、无 assistant/message 持久化,以及用户手动 abort 仍保持最高优先级。 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
When an agent's context gets very large (long-running session plus a broad "verify everything after an upgrade" task), the model can enter a degenerate repetition loop: it streams the same sentence over and over as assistant text chunks. DSH has no repetition guard or circuit breaker, so the loop runs until max_tokens is hit or the user manually aborts. In our case it streamed about 420,000 characters of identical text over 10 full minutes.
Environment
Reproduction (what we observed in the session log)
The archived session (a plugin project workspace) had:
Evidence in the log: the step produced text-chunks events forever, with no finish chunk, no stop reason, and no assistant/message - just endless identical text deltas.
A related failure appeared in the same project's other session: turn 23 sent 467,456 input tokens and immediately hit max-tokens with 1 output token (empty text). Both failures point to context saturation plus model degeneration, with no harness-level protection.
Root cause (from code inspection)
Searching the DSH and pi-ai stack for frequency_penalty, presence_penalty, repetition_penalty, or any "N consecutive identical chunks - abort" logic returns nothing. The only "repeat" handling in dsh-agent is about status transitions and dispatcher dedup - nothing about degenerate model output.
So the only exit conditions are:
Neither is a reasonable guardrail for a stuck model.
Suggested fix (any of, ideally a combination)
Notes
All reactions