{"record":{"id":"2a1aaf74843e8b03","repo":"vxcontrol/pentagi","slug":"wait-cancelled-the-assistant-session-was-interru","errorCode":null,"errorMessage":"wait cancelled — the assistant session was interrupted while waiting for the automation","messagePattern":"wait cancelled — the assistant session was interrupted while waiting for the automation","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"backend/pkg/tools/flow_manager.go","lineNumber":594,"sourceCode":"\tif !isRunning {\n\t\treturn fmt.Sprintf(\n\t\t\t\"The automation is not currently running — no task has status 'running'. \"+\n\t\t\t\t\"Call %s with detail='summary' to assess the current flow state before proceeding.\",\n\t\t\tGetFlowStatusToolName), nil\n\t}\n\n\twaitCtx, waitCancel := context.WithTimeout(ctx, timeout)\n\tdefer waitCancel()\n\n\tif err := t.handler(waitCtx); err != nil {\n\t\tif errors.Is(err, context.DeadlineExceeded) {\n\t\t\treturn fmt.Sprintf(\n\t\t\t\t\"The automation task is still running after waiting %s. \"+\n\t\t\t\t\t\"Call %s with detail='running' to see what the agent is doing right now.\",\n\t\t\t\ttimeout, GetFlowStatusToolName), nil\n\t\t}\n\t\tif errors.Is(err, context.Canceled) {\n\t\t\treturn \"\", fmt.Errorf(\n\t\t\t\t\"wait cancelled — the assistant session was interrupted while waiting for the automation\")\n\t\t}\n\t\treturn \"\", fmt.Errorf(\"wait for flow completion failed: %w\", err)\n\t}\n\n\treturn fmt.Sprintf(\n\t\t\"The automation task has completed. \"+\n\t\t\t\"Call %s with detail='summary' to see the final status and results.\",\n\t\tGetFlowStatusToolName), nil\n}\n\n// stopFlowTool implements stop_flow.\ntype stopFlowTool struct {\n\tflowID  int64\n\tdb      database.Querier\n\thandler func(ctx context.Context, reason string) error\n}\n","sourceCodeStart":576,"sourceCodeEnd":612,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/flow_manager.go#L576-L612","documentation":"While the tool was polling for flow completion, the wait returned context.Canceled — meaning the surrounding assistant session context was cancelled, not that the flow failed. The tool translates this into a distinct, human-readable message so the agent/user knows the wait itself was interrupted rather than the automation.","triggerScenarios":"Calling wait_flow_completion and then the parent context is cancelled before the flow finishes: the user aborts the run, the client disconnects, the session times out, or the framework cancels in-flight tool calls during shutdown.","commonSituations":"User presses stop/cancel in the UI while a long wait is in progress; HTTP/WebSocket client disconnects; server graceful shutdown cancels active goroutines; an outer timeout cancels the tool context.","solutions":["Re-issue the wait_flow_completion call in a new session if the flow is still expected to finish.","Use get_flow_status to check the current state of the automation before waiting again.","Avoid cancelling the session/parent context while a wait is in flight, or use a shorter timeout so the wait returns the 'still running' result instead.","If cancellations are frequent, increase the client's request timeout or disconnect handling window."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const out = await tool.call('wait_flow_completion', { timeout: 120 });\n} catch (err) {\n  if (String(err).includes('wait cancelled')) {\n    // session was interrupted: check state and re-wait in a fresh session\n    const status = await tool.call('get_flow_status', { detail: 'running' });\n  }\n}","preventionTips":["Don't cancel the session while a wait is active","Set a wait timeout shorter than the session lifetime so it returns normally","On cancel, always re-check flow status before re-issuing","Handle client disconnects gracefully to avoid killing active waits"],"tags":["context","cancellation","timeout","tool-call"],"backgroundTag":"context-canceled","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}