{"record":{"id":"bd507678841d3a56","repo":"vxcontrol/pentagi","slug":"failed-to-put-input-for-subtask-d-w","errorCode":null,"errorMessage":"failed to put input for subtask %d: %w","messagePattern":"failed to put input for subtask (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/controller/subtask.go","lineNumber":271,"sourceCode":"\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to set subtask %d result: %w\", stw.subtaskCtx.SubtaskID, err)\n\t}\n\n\treturn nil\n}\n\nfunc (stw *subtaskWorker) PutInput(ctx context.Context, input string) error {\n\tif stw.IsCompleted() {\n\t\treturn fmt.Errorf(\"subtask has already completed\")\n\t}\n\n\tif !stw.IsWaiting() {\n\t\treturn fmt.Errorf(\"subtask is not waiting, run first\")\n\t}\n\n\terr := stw.subtaskCtx.Provider.PutInputToAgentChain(ctx, stw.subtaskCtx.MsgChainID, input)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to put input for subtask %d: %w\", stw.subtaskCtx.SubtaskID, err)\n\t}\n\n\t_, err = stw.subtaskCtx.MsgLog.PutSubtaskMsg(\n\t\tctx,\n\t\tdatabase.MsglogTypeInput,\n\t\tstw.subtaskCtx.TaskID,\n\t\tstw.subtaskCtx.SubtaskID,\n\t\t\"\", // thinking is empty because this is input\n\t\tinput,\n\t)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to put input for subtask %d: %w\", stw.subtaskCtx.SubtaskID, err)\n\t}\n\n\tstw.mx.Lock()\n\tdefer stw.mx.Unlock()\n\n\tstw.waiting = false","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/controller/subtask.go#L253-L289","documentation":"After passing the state guards, PutInput pushes the user input into the LLM agent message chain via Provider.PutInputToAgentChain. If that provider call fails, the error is wrapped as 'failed to put input for subtask %d'. The input never reached the chain, so the subtask stays Waiting and Run can later resume it.","triggerScenarios":"PutInputToAgentChain fails because the message-chain store is unavailable, the chain for MsgChainID was deleted (e.g. flow replacement), or the provider rejects the input (empty string, chain in an unexpected internal state).","commonSituations":"Postgres/vector-store outage during user input submission; concurrent flow restart deleting the msg chain while the user was typing an answer; provider implementation bug or mismatched MsgChainID after a DB restore.","solutions":["Inspect the wrapped provider error; if it's a DB error check connectivity/migrations first.","Retry PutInput with backoff — the subtask remains Waiting so a retry is safe from the chain's perspective.","Verify the MsgChainID still exists (flow not replaced/deleted); if the chain is gone, abandon this worker and create a new subtask.","Reject empty input at the caller before invoking PutInput."],"exampleFix":"// before\nif err := worker.PutInput(ctx, input); err != nil {\n\treturn err\n}\n// after\nvar err error\nfor i := 0; i < 3; i++ {\n\tif err = worker.PutInput(ctx, input); err == nil {\n\t\tbreak\n\t}\n\ttime.Sleep(time.Duration(1<<i) * time.Second)\n}\nreturn err","handlingStrategy":"retry","validationCode":"// basic sanity before pushing input into the chain\nif strings.TrimSpace(input) == \"\" {\n\treturn fmt.Errorf(\"input must not be empty\")\n}\nif worker.GetMsgChainID() == 0 {\n\treturn fmt.Errorf(\"subtask has no message chain\")\n}","typeGuard":null,"tryCatchPattern":"if err := worker.PutInput(ctx, input); err != nil {\n\tif isContextErr(err) {\n\t\ttime.Sleep(backoff)\n\t\treturn worker.PutInput(ctx, input) // safe: subtask still Waiting\n\t}\n\treturn err\n}","preventionTips":["Retry idempotently — the subtask stays Waiting when the chain write fails.","Check DB/chain-store health before resuming interactive flows.","Verify the flow was not replaced/deleted (MsgChainID still valid).","Reject empty input at the API layer."],"tags":["go","provider","message-chain","retryable"],"backgroundTag":"agent-chain-input-failed","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}