fix: add session loop diagnostics#204
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (12)
🧰 Additional context used📓 Path-based instructions (2)packages/opencode/**/*.ts📄 CodeRabbit inference engine (packages/opencode/AGENTS.md)
Files:
packages/opencode/test/**/*.test.{ts,tsx}📄 CodeRabbit inference engine (packages/opencode/test/AGENTS.md)
Files:
🧠 Learnings (22)📓 Common learnings📚 Learning: 2026-04-20T14:36:31.032ZApplied to files:
📚 Learning: 2026-04-20T14:36:31.032ZApplied to files:
📚 Learning: 2026-04-20T14:36:31.032ZApplied to files:
📚 Learning: 2026-04-20T14:36:31.032ZApplied to files:
📚 Learning: 2026-04-20T14:36:31.032ZApplied to files:
📚 Learning: 2026-04-20T14:36:31.032ZApplied to files:
📚 Learning: 2026-04-22T09:32:54.556ZApplied to files:
📚 Learning: 2026-04-20T14:36:31.032ZApplied to files:
📚 Learning: 2026-04-20T14:36:04.113ZApplied to files:
📚 Learning: 2026-04-23T15:25:31.118ZApplied to files:
📚 Learning: 2026-04-20T14:36:31.032ZApplied to files:
📚 Learning: 2026-04-23T08:51:00.819ZApplied to files:
📚 Learning: 2026-04-20T14:36:04.113ZApplied to files:
📚 Learning: 2026-04-20T14:36:04.113ZApplied to files:
📚 Learning: 2026-04-20T14:36:21.288ZApplied to files:
📚 Learning: 2026-04-20T14:36:21.288ZApplied to files:
📚 Learning: 2026-04-20T14:36:21.288ZApplied to files:
📚 Learning: 2026-04-20T14:36:21.288ZApplied to files:
📚 Learning: 2026-04-20T14:36:21.288ZApplied to files:
📚 Learning: 2026-04-20T14:36:21.288ZApplied to files:
📚 Learning: 2026-04-20T14:36:21.288ZApplied to files:
🔇 Additional comments (21)
📝 WalkthroughWalkthroughA new Changes
Sequence DiagramsequenceDiagram
participant PromptLoop as Prompt Loop
participant SessionProc as SessionProcessor
participant Diagnostics as SessionDiagnostics
participant AssistantMsg as Prior Messages
participant MetadataMgr as Part Metadata
PromptLoop->>SessionProc: Start/Resume tool call
SessionProc->>AssistantMsg: Fetch prior assistant messages
AssistantMsg-->>SessionProc: Return tool part records
SessionProc->>Diagnostics: observeToolCall(sessionID, tool, input, records)
Diagnostics->>Diagnostics: Compute input fingerprint<br/>Increment repeat count
Diagnostics-->>SessionProc: Return observed diagnostics
SessionProc->>MetadataMgr: Merge diagnostics into part metadata
PromptLoop->>Diagnostics: consumeReminders(messages, parentID)
Diagnostics->>AssistantMsg: Scan for matching pending reminders
Diagnostics->>MetadataMgr: Mark reminders as injected
Diagnostics-->>PromptLoop: Return reminder text + updated messages
PromptLoop->>PromptLoop: Append reminder text to user message
PromptLoop->>PromptLoop: Persist updated diagnostic parts
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Code Review
This pull request introduces a new SessionDiagnostics module designed to detect and handle 'doom loops' by tracking repeated tool inputs and error fingerprints. It replaces the previous threshold logic in SessionProcessor with a more sophisticated hashing and normalization approach, injecting system reminders when repetitions are detected. Additionally, the PR refactors service dependencies in the session processor and includes new unit and integration tests. I have no feedback to provide as there were no review comments to assess.
Summary
Add lightweight session diagnostics for repeated tool behavior:
Why
Issue #133 identified sessions where models repeatedly called the same tool input or retried the same failing tool pattern. This keeps V1 small: it observes and nudges the model without blocking tools, asking the user, adding model-specific rules, or changing normal exploration behavior.
Related Issue
Closes #133
How To Verify
Final full package result:
Also ran:
Screenshots or Recordings
Not applicable. This is harness/session behavior with no visible UI change.
Checklist
dev, and my PR title and commit messages use Conventional Commits in EnglishMaintainer labeling requested: type fix, scope opencode/session, priority based on issue #133.
Summary by CodeRabbit
Release Notes