fix: handle session.status cooldown retries in runtime fallback#2368
Open
code-yeongyu wants to merge 7 commits intodevfrom
Open
fix: handle session.status cooldown retries in runtime fallback#2368code-yeongyu wants to merge 7 commits intodevfrom
code-yeongyu wants to merge 7 commits intodevfrom
Conversation
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <[email protected]>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <[email protected]>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <[email protected]>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <[email protected]>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <[email protected]>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <[email protected]>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <[email protected]>
There was a problem hiding this comment.
2 issues found across 8 files
Confidence score: 3/5
- There is some merge risk because both findings are medium severity (6/10) with high confidence (9/10), indicating concrete behavior gaps rather than speculative nits.
- In
src/hooks/runtime-fallback/event-handler.ts, not clearing the session-status retry key aftersession.idle/session.stop/session.errorcan cause retry deduplication to leak across requests in the same session, leading to incorrect retry handling. - In
src/shared/retry-status-utils.ts, the regex currently misses:in the character class, so model IDs containing colons (such as Ollama-style IDs) may not be matched correctly and can break retry-status detection for those models. - Pay close attention to
src/hooks/runtime-fallback/event-handler.tsandsrc/shared/retry-status-utils.ts- retry-key lifecycle and model-ID parsing need fixes to avoid request-level retry regressions.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/hooks/runtime-fallback/event-handler.ts">
<violation number="1" location="src/hooks/runtime-fallback/event-handler.ts:38">
P2: Clear the session status retry key when a request completes (`session.idle`, `session.stop`, `session.error`) to avoid incorrectly deduplicating retry events across different requests in the same session.</violation>
</file>
<file name="src/shared/retry-status-utils.ts">
<violation number="1" location="src/shared/retry-status-utils.ts:17">
P2: Add `:` to the regex character class to correctly match model IDs that contain colons (e.g., Ollama models).</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| @@ -6,9 +6,11 @@ import { extractStatusCode, extractErrorName, classifyErrorType, isRetryableErro | |||
| import { createFallbackState, prepareFallback } from "./fallback-state" | |||
There was a problem hiding this comment.
P2: Clear the session status retry key when a request completes (session.idle, session.stop, session.error) to avoid incorrectly deduplicating retry events across different requests in the same session.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/hooks/runtime-fallback/event-handler.ts, line 38:
<comment>Clear the session status retry key when a request completes (`session.idle`, `session.stop`, `session.error`) to avoid incorrectly deduplicating retry events across different requests in the same session.</comment>
<file context>
@@ -33,6 +35,7 @@ export function createEventHandler(deps: HookDeps, helpers: AutoRetryHelpers) {
sessionRetryInFlight.delete(sessionID)
sessionAwaitingFallbackResult.delete(sessionID)
helpers.clearSessionFallbackTimeout(sessionID)
+ sessionStatusHandler.clearRetryKey(sessionID)
SessionCategoryRegistry.remove(sessionID)
}
</file context>
| } | ||
|
|
||
| export function extractRetryStatusModel(message: string): string | undefined { | ||
| return message.match(/model\s+([a-z0-9._/-]+)(?=\s+(?:are|is)\b)/i)?.[1]?.toLowerCase() |
There was a problem hiding this comment.
P2: Add : to the regex character class to correctly match model IDs that contain colons (e.g., Ollama models).
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/shared/retry-status-utils.ts, line 17:
<comment>Add `:` to the regex character class to correctly match model IDs that contain colons (e.g., Ollama models).</comment>
<file context>
@@ -0,0 +1,51 @@
+}
+
+export function extractRetryStatusModel(message: string): string | undefined {
+ return message.match(/model\s+([a-z0-9._/-]+)(?=\s+(?:are|is)\b)/i)?.[1]?.toLowerCase()
+}
+
</file context>
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.
Summary
session.statusretry events through runtime fallback so cooldown retry loops can switch to the next fallback modelmodel-fallbackfrom handlingsession.statuswhenruntime_fallbackis enabled and dedupe retry updates by attempt, model, and retry classTesting
bun testbun run typecheckbun run buildSummary by cubic
Handle provider cooldown auto-retry signals from session.status via runtime fallback to switch to the next model immediately and avoid countdown spam. Also gate model-fallback when runtime_fallback is enabled.
New Features
Bug Fixes
Written for commit b1946a6. Summary will update on new commits.