fix(delegation): replace message-count-stability polling with native finish-based completion detection
Sync task completion was fragile — detecting premature stability during brief idle periods between tool calls. Now mirrors opencode's native SessionPrompt.loop() logic: checks assistant finish reason is terminal (not tool-calls/unknown) and assistant.id > user.id. Also switches sync prompt sender from blocking HTTP (promptSync) to async fire-and-forget (promptAsync) to avoid JSON parse errors in ACP.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { DelegateTaskArgs, OpencodeClient } from "./types"
|
||||
import { isPlanFamily } from "./constants"
|
||||
import { promptSyncWithModelSuggestionRetry } from "../../shared/model-suggestion-retry"
|
||||
import { promptWithModelSuggestionRetry } from "../../shared/model-suggestion-retry"
|
||||
import { formatDetailedError } from "./error-formatting"
|
||||
|
||||
export async function sendSyncPrompt(
|
||||
@@ -17,7 +17,7 @@ export async function sendSyncPrompt(
|
||||
): Promise<string | null> {
|
||||
try {
|
||||
const allowTask = isPlanFamily(input.agentToUse)
|
||||
await promptSyncWithModelSuggestionRetry(client, {
|
||||
await promptWithModelSuggestionRetry(client, {
|
||||
path: { id: input.sessionID },
|
||||
body: {
|
||||
agent: input.agentToUse,
|
||||
|
||||
Reference in New Issue
Block a user