fix(processor): fix doom loop detection scope and filter order#25255
Open
qz1543706741 wants to merge 1 commit intoanomalyco:devfrom
Open
fix(processor): fix doom loop detection scope and filter order#25255qz1543706741 wants to merge 1 commit intoanomalyco:devfrom
qz1543706741 wants to merge 1 commit intoanomalyco:devfrom
Conversation
Contributor
|
The following comment was made by an LLM, it may be inaccurate: The search results show PR #25255 (the current PR) and related PRs about doom loop optimization. Let me verify if any of these are actual duplicates by checking PRs #20288 and #20303 which mention doom loop detection optimization: No duplicate PRs found |
Bojun-Vvibe
added a commit
to Bojun-Vvibe/oss-contributions
that referenced
this pull request
May 1, 2026
- anomalyco/opencode#25255: doom loop scope+filter-order fix (merge-as-is) - openai/codex#20577: store-history fork migration (merge-after-nits) - openai/codex#20528: skill-scoped hooks feature (merge-after-nits)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #25254
Type of change
What does this PR do?
Fixes two bugs in the doom loop detection logic in
packages/opencode/src/session/processor.ts.Bug 1 — detection scope limited to current message only
MessageV2.parts(ctx.assistantMessage.id)only returns parts from the current assistant message. When a model repeats the same tool call across multiple messages in a session (e.g. three separate turns each callingread_filewith the same path), the doom loop is never detected because each individual message has fewer thanDOOM_LOOP_THRESHOLDmatching parts.Fix: use
MessageV2.filterCompactedEffect(ctx.sessionID)to search all messages since the last user turn, collecting matching tool parts across message boundaries.Bug 2 — slice before filter inverts the logic
Taking the last N parts first (which may include text or reasoning parts) and then checking whether all N match means that if any non-tool part appears in the tail,
everyreturns false and the doom loop check silently passes. The correct order is: filter matching tool parts first, then check if the count reaches the threshold.Fix: introduced
recentMatchingToolPartswhich filters bytool + JSON(args)first, then slices toDOOM_LOOP_THRESHOLD.How did you verify your code works?
Reviewed the diff against
upstream/dev.MessageV2.filterCompactedEffectandProcessorContext.sessionIDare both present in the current codebase. No new dependencies introduced.Screenshots / recordings
N/A — logic-only change with no UI impact.
Checklist