fix(todo-continuation): gate idle prompts
This commit is contained in:
@@ -21,7 +21,7 @@ import {
|
|||||||
getAgentConfigKey,
|
getAgentConfigKey,
|
||||||
normalizeAgentForPromptKey,
|
normalizeAgentForPromptKey,
|
||||||
} from "../../shared/agent-display-names"
|
} from "../../shared/agent-display-names"
|
||||||
import { isSessionActive } from "../shared/session-idle-settle"
|
import { promptAsyncAfterSessionIdle } from "../shared/prompt-async-gate"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
CONTINUATION_PROMPT,
|
CONTINUATION_PROMPT,
|
||||||
@@ -166,11 +166,6 @@ ${todoList}`
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await isSessionActive(ctx.client, sessionID)) {
|
|
||||||
log(`[${HOOK_NAME}] Skipped injection: session is active before prompt`, { sessionID })
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (injectionState) {
|
if (injectionState) {
|
||||||
injectionState.inFlight = true
|
injectionState.inFlight = true
|
||||||
}
|
}
|
||||||
@@ -190,17 +185,33 @@ ${todoList}`
|
|||||||
: undefined
|
: undefined
|
||||||
const launchVariant = model?.variant
|
const launchVariant = model?.variant
|
||||||
|
|
||||||
await ctx.client.session.promptAsync({
|
const promptResult = await promptAsyncAfterSessionIdle({
|
||||||
path: { id: sessionID },
|
client: ctx.client,
|
||||||
body: {
|
sessionID,
|
||||||
agent: launchAgent ?? promptAgent,
|
source: HOOK_NAME,
|
||||||
...(launchModel ? { model: launchModel } : {}),
|
settleMs: 0,
|
||||||
...(launchVariant ? { variant: launchVariant } : {}),
|
input: {
|
||||||
...(inheritedTools ? { tools: inheritedTools } : {}),
|
path: { id: sessionID },
|
||||||
parts: [createInternalAgentContinuationTextPart(prompt)],
|
body: {
|
||||||
|
agent: launchAgent ?? promptAgent,
|
||||||
|
...(launchModel ? { model: launchModel } : {}),
|
||||||
|
...(launchVariant ? { variant: launchVariant } : {}),
|
||||||
|
...(inheritedTools ? { tools: inheritedTools } : {}),
|
||||||
|
parts: [createInternalAgentContinuationTextPart(prompt)],
|
||||||
|
},
|
||||||
|
query: { directory: ctx.directory },
|
||||||
},
|
},
|
||||||
query: { directory: ctx.directory },
|
|
||||||
})
|
})
|
||||||
|
if (promptResult.status === "failed") {
|
||||||
|
throw promptResult.error
|
||||||
|
}
|
||||||
|
if (promptResult.status !== "dispatched") {
|
||||||
|
log(`[${HOOK_NAME}] Injection skipped by promptAsync gate`, { sessionID, status: promptResult.status })
|
||||||
|
if (injectionState) {
|
||||||
|
injectionState.inFlight = false
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
log(`[${HOOK_NAME}] Injection successful`, { sessionID })
|
log(`[${HOOK_NAME}] Injection successful`, { sessionID })
|
||||||
if (injectionState) {
|
if (injectionState) {
|
||||||
|
|||||||
Reference in New Issue
Block a user