{"record":{"id":"e292fbfde2bfcd70","repo":"vercel/ai","slug":"harnessid-has-no-in-flight-acp-turn-to-continue","errorCode":null,"errorMessage":"${harnessId} has no in-flight ACP turn to continue.","messagePattern":"(.+?) has no in-flight ACP turn to continue\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/harness-acp/src/v1/acp-v1-harness.ts","lineNumber":1522,"sourceCode":"        skills: options.skills,\n        abortSignal: options.abortSignal,\n      });\n      if (options.responseFormat?.type === 'json') {\n        if (options.responseFormat.schema == null) {\n          throw unsupported({\n            harnessId,\n            message: `${harnessId} requires a JSON schema for structured output.`,\n          });\n        }\n        if (outputSchemaMapping == null) {\n          throw unsupported({\n            harnessId,\n            message: `${harnessId} does not support structured output through ACP.`,\n          });\n        }\n      }\n      if (!turnInFlight) {\n        throw new Error(`${harnessId} has no in-flight ACP turn to continue.`);\n      }\n      if (lossyRerun) {\n        if (latestTurnStartConfig == null || latestACPSessionId == null) {\n          throw new Error(\n            `${harnessId} cannot perform lossy ACP rerun without persisted start configuration and an ACP session identifier.`,\n          );\n        }\n        assertRecoveryToolCatalog({\n          persisted: latestTurnStartConfig.tools,\n          current: options.tools ?? [],\n        });\n      }\n      return wireTurn({\n        emit: options.emit,\n        abortSignal: options.abortSignal,\n        start: () => {\n          if (!lossyRerun) return;\n          const turnStartConfig = latestTurnStartConfig!;","sourceCodeStart":1504,"sourceCodeEnd":1540,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/harness-acp/src/v1/acp-v1-harness.ts#L1504-L1540","documentation":"doContinueTurn can only resume a turn that is currently in flight. If turnInFlight is false — no turn was started, or the previous turn already completed — there is nothing to continue, so the harness throws. Continuation is meant for resuming an interrupted/incomplete turn, not for starting new work.","triggerScenarios":"Calling continueTurn (doContinueTurn) on a session where no promptTurn is active: before any prompt, after the previous turn finished normally, or after the session was created fresh.","commonSituations":"Retry logic that calls continueTurn after a turn already completed; confusing continueTurn with promptTurn for new prompts; calling continueTurn twice; calling it on a newly created session assuming a turn is pending.","solutions":["Use promptTurn to start a new turn instead of continueTurn when no turn is in flight.","Only call continueTurn when a prior turn was interrupted (e.g. after suspend/process loss) and is still logically open.","Track turn state in your app (a boolean set on turn start, cleared on done/error) and call continueTurn only when it is true.","If continuing after recovery, confirm the recovery path actually left a turn in flight rather than replaying it to completion."],"exampleFix":"// before\nawait session.continueTurn({}); // throws when no turn is open\n// after\nif (turnOpen) {\n  await session.continueTurn({});\n} else {\n  await session.promptTurn({ prompt });\n}","handlingStrategy":"validation","validationCode":"let turnOpen = false;\n// set true when promptTurn starts streaming, false on done/error\nif (!turnOpen) { await session.promptTurn({ prompt }); } else { await session.continueTurn({}); }","typeGuard":null,"tryCatchPattern":"try {\n  await session.continueTurn({});\n} catch (e) {\n  if (e instanceof Error && e.message.includes('no in-flight ACP turn')) {\n    await session.promptTurn({ prompt: originalPrompt });\n  } else throw e;\n}","preventionTips":["Track turn state (open/closed) in app code and clear it on done/error events","Use continueTurn only for interrupted turns, never for new prompts","Never call continueTurn twice for the same interruption"],"tags":["acp","turn-state","continue","session-state"],"backgroundTag":"no-in-flight-turn","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}