fix(prompt-retry): preserve peer prompt reservations

This commit is contained in:
YeonGyu-Kim
2026-05-19 12:00:01 +09:00
parent b53a8b5e09
commit dfc2e8e4ae
3 changed files with 49 additions and 6 deletions
+6 -2
View File
@@ -8,6 +8,7 @@ import {
import {
dispatchInternalPrompt,
releasePromptAsyncReservation,
type InternalPromptDispatchResult,
} from "./prompt-async-gate"
type Client = ReturnType<typeof createOpencodeClient>
@@ -97,9 +98,10 @@ export async function promptWithModelSuggestionRetry(
): Promise<void> {
const timeoutMs = options.timeoutMs ?? PROMPT_TIMEOUT_MS
const timeoutContext = createPromptTimeoutContext(args, timeoutMs)
let promptResult: InternalPromptDispatchResult | undefined
try {
const promptResult = await dispatchInternalPrompt({
promptResult = await dispatchInternalPrompt({
mode: "async",
client,
sessionID: args.path.id,
@@ -123,7 +125,9 @@ export async function promptWithModelSuggestionRetry(
if (timeoutContext.wasTimedOut()) {
throw new Error(`promptAsync timed out after ${timeoutMs}ms`)
}
releasePromptAsyncReservation(args.path.id, "model-suggestion-retry")
if (promptResult?.status === "failed") {
releasePromptAsyncReservation(args.path.id, "model-suggestion-retry")
}
throw error
} finally {
timeoutContext.cleanup()