vxcontrol/pentagi · error

failed to get active task result: %w

Error message

failed to get active task result: %w

What it means

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.

Source

Thrown at backend/pkg/tools/flow_manager.go:305

			}
		}

		sb := &strings.Builder{}

		if activeTask != nil {
			fmt.Fprintf(sb, "=== Active Task ===\n")
			fmt.Fprintf(sb, "Task ID: %d | Status: %s | Title: %s\n", activeTask.ID, activeTask.Status, activeTask.Title)
			if activeTask.Input != "" {
				input, err := t.getInputText(ctx, activeTask.Input)
				if err != nil {
					return "", fmt.Errorf("failed to get active task input: %w", err)
				}
				fmt.Fprintf(sb, "Input:\n%s\n", input)
			}
			if activeTask.Result != "" {
				result, err := t.getResultText(ctx, activeTask.Result)
				if err != nil {
					return "", fmt.Errorf("failed to get active task result: %w", err)
				}
				fmt.Fprintf(sb, "Result so far:\n%s\n", result)
			}
		}

		fmt.Fprintf(sb, "\n=== Active Subtask ===\n")
		fmt.Fprintf(sb, "Subtask ID: %d | Status: %s | Title: %s\n", st.ID, st.Status, st.Title)
		description, err := t.getDescriptionText(ctx, st.Description)
		if err != nil {
			return "", fmt.Errorf("failed to get subtask description: %w", err)
		}
		fmt.Fprintf(sb, "Description:\n%s\n", description)
		if st.Result != "" {
			result, err := t.getResultText(ctx, st.Result)
			if err != nil {
				return "", fmt.Errorf("failed to get subtask result: %w", err)
			}
			fmt.Fprintf(sb, "Result so far:\n%s\n", result)

View on GitHub (pinned to ea665308ba)

Solutions

  1. Inspect the wrapped cause (%w) in the log to identify the summarizer failure: provider error, auth, quota, or context cancellation.
  2. Verify the LLM provider credentials and endpoint used by the summarizer (env vars / Settings UI) and re-test the provider.
  3. Retry the flow_status call — transient provider rate limits and network blips usually resolve on retry.
  4. Reduce result size (shorter task results under 2*resultLimit bypass summarization entirely) or run with the summarizer disabled (t.summarizer == nil).
  5. Check that the caller's context is not being cancelled prematurely (e.g. HTTP request timeout shorter than LLM latency).

Example fix

// before: handler request ctx with short HTTP timeout kills long LLM summarization
callFlowStatus(ctx) // ctx from request, 5s timeout

// after: use a detached context with generous timeout for summarization
sumCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 120*time.Second)
defer cancel()
callFlowStatus(sumCtx)
Defensive patterns

Strategy: try-catch

Validate before calling

// before calling the tool, check the summarizer provider is configured and reachable
if summarizer != nil && activeTask.Result != "" && len(activeTask.Result) > 2*resultLimit {
	if err := providerHealthCheck(ctx); err != nil {
		return fmt.Errorf("summarizer provider unavailable: %w", err)
	}
}

Type guard

func needsSummarization(s string, limit int, hasSummarizer bool) bool {
	return s != "" && hasSummarizer && len(s) > 2*limit
}

Try / catch

info, err := flowStatusTool.Handle(ctx, "flow_status", args)
if err != nil {
	var summarizeErr *SummarizerError
	if errors.As(err, &summarizeErr) {
		// transient LLM provider failure — retry with backoff
		info, err = retryWithBackoff(ctx, 3, func() (string, error) {
			return flowStatusTool.Handle(ctx, "flow_status", args)
		})
	}
	if err != nil {
		return fmt.Errorf("flow status unavailable: %w", err)
	}
}

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Related errors


AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01). Data as JSON: /api/errors/38ad6f3ab7aa9275. Report an issue: GitHub.