{"record":{"id":"2b26ffe1728a05f7","repo":"vxcontrol/pentagi","slug":"failed-to-submit-flow-input-w","errorCode":null,"errorMessage":"failed to submit flow input: %w","messagePattern":"failed to submit flow input: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/tools/flow_manager.go","lineNumber":770,"sourceCode":"\t\t\t\t\t\"then retry %s. Use %s to confirm the flow is 'waiting' before retrying\",\n\t\t\t\tStopFlowToolName, SubmitFlowInputToolName, GetFlowStatusToolName,\n\t\t\t), nil\n\t\t}\n\t\t// A missing message chain means the waiting subtask's execution context was lost\n\t\t// (most likely after a system restart or database cleanup while the subtask was at an ask checkpoint).\n\t\t// The subtask can no longer be resumed; the flow must be stopped and restarted.\n\t\tif strings.Contains(err.Error(), \"no rows in result set\") {\n\t\t\treturn \"\", stateGuard(fmt.Errorf(\n\t\t\t\t\"the waiting subtask's execution context is no longer available in the database — \"+\n\t\t\t\t\t\"this typically happens after a system restart when the subtask was paused at an ask checkpoint. \"+\n\t\t\t\t\t\"Recovery: (1) call %s to cancel the stale task; \"+\n\t\t\t\t\t\"(2) call %s with a fresh description of what to do next; \"+\n\t\t\t\t\t\"if the flow already has planned subtasks that should still run, \"+\n\t\t\t\t\t\"use %s to inspect the remaining plan and %s to patch it before resuming\",\n\t\t\t\tStopFlowToolName, SubmitFlowInputToolName,\n\t\t\t\tGetFlowStatusToolName, PatchFlowSubtasksToolName))\n\t\t}\n\t\treturn \"\", fmt.Errorf(\"failed to submit flow input: %w\", err)\n\t}\n\n\tif waitingForAsk {\n\t\treturn \"Input delivered as the answer to the waiting subtask's question. The subtask will resume execution.\", nil\n\t}\n\n\t// Input triggered task creation — wait for the generator to produce a running task.\n\treturn t.waitForTaskReady(ctx)\n}\n\n// waitForTaskReady polls GetFlowTasks every pollInterval until a running or waiting\n// task appears or pollTimeout is reached. It is called after submit_flow_input\n// triggers new task creation so the LLM gets confirmation that the generator finished.\nfunc (t *submitFlowInputTool) waitForTaskReady(ctx context.Context) (string, error) {\n\tdeadline := time.Now().Add(t.pollTimeout)\n\tticker := time.NewTicker(t.pollInterval)\n\tdefer ticker.Stop()\n","sourceCodeStart":752,"sourceCodeEnd":788,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/flow_manager.go#L752-L788","documentation":"submit_flow_input's handler returned an error that is not a timeout/cancellation, not a 'flow is running' condition, and not a lost message chain — so the tool wraps and rethrows it as 'failed to submit flow input'. The input was not accepted; the wrapped error carries the specific reason. This is the generic failure bucket for the delivery step of submit_flow_input.","triggerScenarios":"Any handler error other than the three special-cased ones: internal sendAssistantFlowInput failures, unexpected DB errors during the submit path, serialization of the message chain, etc.","commonSituations":"Backend-internal bugs in the flow input path; partial DB failures during message insertion; race conditions where the flow state changes between checks; unexpected handler implementations.","solutions":["Inspect the wrapped error (%w) for the actual cause.","Call get_flow_status to confirm the flow state before retrying.","If the flow is stuck, call stop_flow and restart with a fresh submit_flow_input.","Check backend logs around the handler call for the originating stack trace."],"exampleFix":"// before: retrying the tool repeatedly without reading the cause\nfor i := 0; i < 3; i++ { tool.Handle(ctx, \"submit_flow_input\", args) }\n// after: log/inspect the wrapped error first\nres, err := tool.Handle(ctx, \"submit_flow_input\", args)\nif err != nil {\n    log.Printf(\"submit failed, cause: %v\", err) // %w chain reveals root cause\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"_, err := tool.Handle(ctx, \"submit_flow_input\", args)\nif err != nil {\n    var wrapped interface{ Unwrap() error }\n    if errors.As(err, &wrapped) {\n        log.Printf(\"submit root cause: %v\", errors.Unwrap(err))\n    }\n    // check flow state, then decide retry vs stop_flow\n}","preventionTips":["Always unwrap and log the wrapped cause before retrying.","Keep backend logs correlated with flow IDs for triage.","Check get_flow_status after any submit failure before re-attempting.","Report persistent unclassified failures — they usually indicate backend bugs."],"tags":["flow-control","unclassified-error","database"],"backgroundTag":"unhandled-submit-error","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}