fix: restore remote conversation recovery and clean obsolete agents
Wait for model delivery acknowledgements before completing remote prompts and preserve completed outcomes when idle Runtime cleanup fails. Explicit messages after an unknown outcome now open a fresh binding with history instead of reusing the failed session; recovery remains attach-only. Run obsolete payload cleanup through the current Agent after activation, retaining history and unresolved process ownership. Live legacy daemons and shared Runtime versions remain deferred. Includes focused regressions, local OpenCode simulation, and isolated Linux validation evidence. Typecheck and lint passed; the full test run timed out. Release note: Remote conversations can continue after an uncertain result, and completed answers no longer fail solely because Runtime cleanup fails. Updates remove verified inactive Agent payloads and owned orphan processes while retaining active or uncertain installations and conversation history.
This commit is contained in:
@@ -1746,6 +1746,31 @@ export class AcpRemoteRuntime implements AgentRuntime {
|
||||
signal: AbortSignal
|
||||
): Promise<SessionRecord> {
|
||||
let current = this.sessions.get(conversationId)
|
||||
if (current && request.remoteRecoveryOnly === true && !(
|
||||
current.binding.state === 'prompt-running' &&
|
||||
current.binding.activePromptOperationId === request.requestId
|
||||
)) {
|
||||
throw new RemotePromptRecoveryUnavailableError(
|
||||
'没有可安全附加的远端 Agent 请求,且恢复不会重放任务'
|
||||
)
|
||||
}
|
||||
if (current?.binding.state === 'prompt-running' &&
|
||||
this.options.modelProfile !== undefined &&
|
||||
current.binding.activePromptOperationId !== request.requestId) {
|
||||
throw new Error('当前对话仍有 Agent 托管请求,必须先恢复或取消原请求')
|
||||
}
|
||||
if (current && current.binding.state !== 'ready' &&
|
||||
current.binding.state !== 'prompt-running') {
|
||||
// Let cold-open retire an unusable binding before starting a new request.
|
||||
this.sessions.delete(conversationId)
|
||||
this.contexts.delete(conversationId)
|
||||
await this.awaitLocalOperation(
|
||||
'关闭结果未知会话通道',
|
||||
this.closeContext(current.context),
|
||||
signal
|
||||
).catch(() => undefined)
|
||||
current = undefined
|
||||
}
|
||||
if (current?.binding.state === 'ready' && this.options.runtimeId === 'continue' &&
|
||||
this.options.modelProfile !== undefined) {
|
||||
// Continue keeps native history in process memory; seed the next process
|
||||
|
||||
Reference in New Issue
Block a user