{"record":{"id":"8601887196c4cede","repo":"vxcontrol/pentagi","slug":"failed-to-get-ask-advice-handler-w","errorCode":null,"errorMessage":"failed to get ask advice handler: %w","messagePattern":"failed to get ask advice handler: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/providers/assistant.go","lineNumber":165,"sourceCode":"\t\treturn fmt.Errorf(\"failed to get assistant use agents: %w\", err)\n\t}\n\n\tmsgChain, err := ap.fp.DB().GetMsgChain(ctx, ap.msgChainID)\n\tif err != nil {\n\t\tlogger.WithError(err).Error(\"failed to get primary agent msg chain\")\n\t\treturn fmt.Errorf(\"failed to get primary agent msg chain %d: %w\", ap.msgChainID, err)\n\t}\n\n\tvar chain []llms.MessageContent\n\tif err := json.Unmarshal(msgChain.Chain, &chain); err != nil {\n\t\tlogger.WithError(err).Error(\"failed to unmarshal primary agent msg chain\")\n\t\treturn fmt.Errorf(\"failed to unmarshal primary agent msg chain %d: %w\", ap.msgChainID, err)\n\t}\n\n\tadviser, err := ap.fp.GetAskAdviceHandler(ctx, nil, nil)\n\tif err != nil {\n\t\tlogger.WithError(err).Error(\"failed to get ask advice handler\")\n\t\treturn fmt.Errorf(\"failed to get ask advice handler: %w\", err)\n\t}\n\n\tcoder, err := ap.fp.GetCoderHandler(ctx, nil, nil)\n\tif err != nil {\n\t\tlogger.WithError(err).Error(\"failed to get coder handler\")\n\t\treturn fmt.Errorf(\"failed to get coder handler: %w\", err)\n\t}\n\n\tinstaller, err := ap.fp.GetInstallerHandler(ctx, nil, nil)\n\tif err != nil {\n\t\tlogger.WithError(err).Error(\"failed to get installer handler\")\n\t\treturn fmt.Errorf(\"failed to get installer handler: %w\", err)\n\t}\n\n\tmemorist, err := ap.fp.GetMemoristHandler(ctx, nil, nil)\n\tif err != nil {\n\t\tlogger.WithError(err).Error(\"failed to get memorist handler\")\n\t\treturn fmt.Errorf(\"failed to get memorist handler: %w\", err)","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/providers/assistant.go#L147-L183","documentation":"PerformAgentChain wraps the error from fp.GetAskAdviceHandler(ctx, nil, nil), which constructs the `ask_advice` tool handler. Construction failed, so the agent chain cannot be assembled with its toolset.","triggerScenarios":"The handler factory fails while wiring its tools: required tool config/env missing (e.g. search provider keys), Docker client unavailable, database/template lookups error, or provider context invalid.","commonSituations":"Missing env vars for tools the advice handler depends on; Docker socket not mounted; template/prompt records absent in DB after a fresh install; nil flowProvider fields passed to the assistant.","solutions":["Read the wrapped error in logs to see which tool/config the handler failed on.","Set the required tool env vars (search keys, Docker socket) per .env.example and restart.","Verify prompt/template rows exist (run migrations, installer wizard).","Confirm the flow's provider was fully initialized before building the assistant."],"exampleFix":"// before\nadviser, err := ap.fp.GetAskAdviceHandler(ctx, nil, nil)\nif err != nil {\n    return fmt.Errorf(\"failed to get ask advice handler: %w\", err)\n}\n// after\nadviser, err := ap.fp.GetAskAdviceHandler(ctx, &taskID, &subtaskID)\nif err != nil {\n    return fmt.Errorf(\"failed to get ask advice handler: %w\", err) // inspect wrapped cause: usually missing tool config\n}","handlingStrategy":"try-catch","validationCode":"if os.Getenv(\"SEARXNG_URL\") == \"\" && os.Getenv(\"TAVILY_API_KEY\") == \"\" {\n    return errors.New(\"no search backend configured: ask-advice handler will fail to init\")\n}\nif _, err := net.Dial(\"unix\", \"/var/run/docker.sock\"); err != nil {\n    return fmt.Errorf(\"docker socket unavailable: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"adviser, err := ap.fp.GetAskAdviceHandler(ctx, nil, nil)\nif err != nil {\n    logger.WithError(err).Error(\"ask advice handler init failed\")\n    return fmt.Errorf(\"failed to get ask advice handler: %w\", err)\n}","preventionTips":["Complete all tool env vars from .env.example before first run","Mount the Docker socket with correct permissions","Seed prompt/template DB records via migrations","Run the installer wizard on fresh deployments"],"tags":["tools","configuration","handler-init"],"backgroundTag":"tool-handler-init-failed","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}