vxcontrol/pentagi · warning
wait cancelled — the assistant session was interrupted while
Error message
wait cancelled — the assistant session was interrupted while waiting for the automation
What it means
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.
Source
Thrown at backend/pkg/tools/flow_manager.go:594
if !isRunning {
return fmt.Sprintf(
"The automation is not currently running — no task has status 'running'. "+
"Call %s with detail='summary' to assess the current flow state before proceeding.",
GetFlowStatusToolName), nil
}
waitCtx, waitCancel := context.WithTimeout(ctx, timeout)
defer waitCancel()
if err := t.handler(waitCtx); err != nil {
if errors.Is(err, context.DeadlineExceeded) {
return fmt.Sprintf(
"The automation task is still running after waiting %s. "+
"Call %s with detail='running' to see what the agent is doing right now.",
timeout, GetFlowStatusToolName), nil
}
if errors.Is(err, context.Canceled) {
return "", fmt.Errorf(
"wait cancelled — the assistant session was interrupted while waiting for the automation")
}
return "", fmt.Errorf("wait for flow completion failed: %w", err)
}
return fmt.Sprintf(
"The automation task has completed. "+
"Call %s with detail='summary' to see the final status and results.",
GetFlowStatusToolName), nil
}
// stopFlowTool implements stop_flow.
type stopFlowTool struct {
flowID int64
db database.Querier
handler func(ctx context.Context, reason string) error
}
View on GitHub (pinned to ea665308ba)
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.
Defensive patterns
Strategy: try-catch
Try / catch
try {
const out = await tool.call('wait_flow_completion', { timeout: 120 });
} catch (err) {
if (String(err).includes('wait cancelled')) {
// session was interrupted: check state and re-wait in a fresh session
const status = await tool.call('get_flow_status', { detail: 'running' });
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- listing container directory '%s': %w
- flow %d input processing timeout: %w
- stop timed out after %s — the task may still be winding down
- task stop timeout
- failed to acquire advisory lock %q: %w
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/2a1aaf74843e8b03.
Report an issue: GitHub.