{"record":{"id":"38ad6f3ab7aa9275","repo":"vxcontrol/pentagi","slug":"failed-to-get-active-task-result-w","errorCode":null,"errorMessage":"failed to get active task result: %w","messagePattern":"failed to get active task result: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/tools/flow_manager.go","lineNumber":305,"sourceCode":"\t\t\t}\n\t\t}\n\n\t\tsb := &strings.Builder{}\n\n\t\tif activeTask != nil {\n\t\t\tfmt.Fprintf(sb, \"=== Active Task ===\\n\")\n\t\t\tfmt.Fprintf(sb, \"Task ID: %d | Status: %s | Title: %s\\n\", activeTask.ID, activeTask.Status, activeTask.Title)\n\t\t\tif activeTask.Input != \"\" {\n\t\t\t\tinput, err := t.getInputText(ctx, activeTask.Input)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn \"\", fmt.Errorf(\"failed to get active task input: %w\", err)\n\t\t\t\t}\n\t\t\t\tfmt.Fprintf(sb, \"Input:\\n%s\\n\", input)\n\t\t\t}\n\t\t\tif activeTask.Result != \"\" {\n\t\t\t\tresult, err := t.getResultText(ctx, activeTask.Result)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn \"\", fmt.Errorf(\"failed to get active task result: %w\", err)\n\t\t\t\t}\n\t\t\t\tfmt.Fprintf(sb, \"Result so far:\\n%s\\n\", result)\n\t\t\t}\n\t\t}\n\n\t\tfmt.Fprintf(sb, \"\\n=== Active Subtask ===\\n\")\n\t\tfmt.Fprintf(sb, \"Subtask ID: %d | Status: %s | Title: %s\\n\", st.ID, st.Status, st.Title)\n\t\tdescription, err := t.getDescriptionText(ctx, st.Description)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed to get subtask description: %w\", err)\n\t\t}\n\t\tfmt.Fprintf(sb, \"Description:\\n%s\\n\", description)\n\t\tif st.Result != \"\" {\n\t\t\tresult, err := t.getResultText(ctx, st.Result)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", fmt.Errorf(\"failed to get subtask result: %w\", err)\n\t\t\t}\n\t\t\tfmt.Fprintf(sb, \"Result so far:\\n%s\\n\", result)","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/flow_manager.go#L287-L323","documentation":"This error is returned by flowStatusTool.buildRunningInfo (backend/pkg/tools/flow_manager.go:305) while assembling the 'Active Task' section of the flow_status tool output for an agent. When the parent task has a non-empty Result field, the code calls getResultText, which invokes the configured LLM summarizer (t.summarizer) if the result text exceeds 2*resultLimit. If the summarizer fails (network error, provider auth failure, rate limit, context cancellation), the error is wrapped as 'failed to get active task result: %w'. It is a pass-through wrapper: the real cause is always in the wrapped summarizer error.","triggerScenarios":"Calling the flow_status tool while a subtask is running/waiting, when its parent task has a non-empty Result string longer than 2*resultLimit characters AND t.summarizer != nil, and the summarizer call fails — LLM provider timeout, invalid/unauthorized API key, quota exhaustion, malformed provider response, or the request context being cancelled mid-summarization.","commonSituations":"Expired or missing LLM provider API key in the environment; provider outage or rate limiting during a long-running flow; agent/status polling cancelled (ctx done) while summarization is in flight; misconfigured summarizer model name after a provider config change; very large task results (no summarizer configured with short limits is fine, but big results + flaky provider trigger this).","solutions":["Inspect the wrapped cause (%w) in the log to identify the summarizer failure: provider error, auth, quota, or context cancellation.","Verify the LLM provider credentials and endpoint used by the summarizer (env vars / Settings UI) and re-test the provider.","Retry the flow_status call — transient provider rate limits and network blips usually resolve on retry.","Reduce result size (shorter task results under 2*resultLimit bypass summarization entirely) or run with the summarizer disabled (t.summarizer == nil).","Check that the caller's context is not being cancelled prematurely (e.g. HTTP request timeout shorter than LLM latency)."],"exampleFix":"// before: handler request ctx with short HTTP timeout kills long LLM summarization\ncallFlowStatus(ctx) // ctx from request, 5s timeout\n\n// after: use a detached context with generous timeout for summarization\nsumCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 120*time.Second)\ndefer cancel()\ncallFlowStatus(sumCtx)","handlingStrategy":"try-catch","validationCode":"// before calling the tool, check the summarizer provider is configured and reachable\nif summarizer != nil && activeTask.Result != \"\" && len(activeTask.Result) > 2*resultLimit {\n\tif err := providerHealthCheck(ctx); err != nil {\n\t\treturn fmt.Errorf(\"summarizer provider unavailable: %w\", err)\n\t}\n}","typeGuard":"func needsSummarization(s string, limit int, hasSummarizer bool) bool {\n\treturn s != \"\" && hasSummarizer && len(s) > 2*limit\n}","tryCatchPattern":"info, err := flowStatusTool.Handle(ctx, \"flow_status\", args)\nif err != nil {\n\tvar summarizeErr *SummarizerError\n\tif errors.As(err, &summarizeErr) {\n\t\t// transient LLM provider failure — retry with backoff\n\t\tinfo, err = retryWithBackoff(ctx, 3, func() (string, error) {\n\t\t\treturn flowStatusTool.Handle(ctx, \"flow_status\", args)\n\t\t})\n\t}\n\tif err != nil {\n\t\treturn fmt.Errorf(\"flow status unavailable: %w\", err)\n\t}\n}","preventionTips":["Monitor LLM provider health/latency and alert on auth or quota failures before agents need status summarization.","Keep task results under 2*resultLimit so summarization is bypassed.","Use a context whose timeout comfortably exceeds LLM latency (e.g. context.WithoutCancel + 120s).","Configure a fallback summarizer provider for outage resilience.","Rotate API keys proactively and validate them at startup."],"tags":["go","llm-summarizer","flow-status","context-cancellation"],"backgroundTag":"llm-summarization-failed","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}