fix(background-agent): release prompt gate before agent fallback retry
Release the model-suggestion prompt reservation before the spawner retries with the fallback agent so the immediate retry is not skipped by the gate. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import type { BackgroundTask, LaunchInput, ResumeInput } from "./types"
|
import type { BackgroundTask, LaunchInput, ResumeInput } from "./types"
|
||||||
import type { OpencodeClient, OnSubagentSessionCreated, QueueItem } from "./constants"
|
import type { OpencodeClient, OnSubagentSessionCreated, QueueItem } from "./constants"
|
||||||
import { log, getAgentToolRestrictions, createInternalAgentTextPart, promptWithRetryInDirectory } from "../../shared"
|
import { log, getAgentToolRestrictions, createInternalAgentTextPart, promptWithRetryInDirectory } from "../../shared"
|
||||||
|
import { releasePromptAsyncReservation } from "../../shared/prompt-async-gate"
|
||||||
import { applySessionPromptParams } from "../../shared/session-prompt-params-helpers"
|
import { applySessionPromptParams } from "../../shared/session-prompt-params-helpers"
|
||||||
import { subagentSessions } from "../claude-code-session-state"
|
import { subagentSessions } from "../claude-code-session-state"
|
||||||
import { getTaskToastManager } from "../task-toast-manager"
|
import { getTaskToastManager } from "../task-toast-manager"
|
||||||
@@ -182,6 +183,7 @@ export async function startTask(
|
|||||||
taskId: task.id,
|
taskId: task.id,
|
||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
|
releasePromptAsyncReservation(sessionID, "model-suggestion-retry")
|
||||||
await promptWithRetryInDirectory(client, {
|
await promptWithRetryInDirectory(client, {
|
||||||
path: { id: sessionID },
|
path: { id: sessionID },
|
||||||
body: buildFallbackBody(promptBody, FALLBACK_AGENT, {
|
body: buildFallbackBody(promptBody, FALLBACK_AGENT, {
|
||||||
@@ -320,6 +322,7 @@ export async function resumeTask(
|
|||||||
taskId: task.id,
|
taskId: task.id,
|
||||||
})
|
})
|
||||||
try {
|
try {
|
||||||
|
releasePromptAsyncReservation(sessionID, "model-suggestion-retry")
|
||||||
await promptWithRetryInDirectory(client, {
|
await promptWithRetryInDirectory(client, {
|
||||||
path: { id: sessionID },
|
path: { id: sessionID },
|
||||||
body: buildFallbackBody(resumeBody, FALLBACK_AGENT, {
|
body: buildFallbackBody(resumeBody, FALLBACK_AGENT, {
|
||||||
|
|||||||
Reference in New Issue
Block a user