vxcontrol/pentagi · error
failed to get subtask context: %w
Error message
failed to get subtask context: %w
What it means
Returned by flowStatusTool.buildRunningInfo (backend/pkg/tools/flow_manager.go:328) only in verbose mode when the active subtask has a non-empty Context field. The execution context string is run through getDescriptionText, which calls the LLM summarizer when the text exceeds 2*descriptionLimit characters; a summarizer failure is wrapped as 'failed to get subtask context: %w'. This error never occurs in non-verbose mode or when the subtask has no stored context.
Source
Thrown at backend/pkg/tools/flow_manager.go:328
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)
}
if verbose && st.Context != "" {
execContext, err := t.getDescriptionText(ctx, st.Context)
if err != nil {
return "", fmt.Errorf("failed to get subtask context: %w", err)
}
fmt.Fprintf(sb, "\nExecution context:\n%s\n", execContext)
}
if st.Status == database.SubtaskStatusWaiting {
fmt.Fprintf(sb, "\nNote: subtask is waiting for user input (ask state).\n")
fmt.Fprintf(sb, "Use %s to provide the answer and resume execution.\n", SubmitFlowInputToolName)
}
msgLimit := msgLogLimitNormal
if verbose {
msgLimit = msgLogLimitVerbose
}
msgLogs, err := t.appendSubtaskMsgLogs(ctx, st.ID, msgLimit)
if err != nil {
return "", fmt.Errorf("failed to get subtask msg logs: %w", err)
}
sb.WriteString(msgLogs)
View on GitHub (pinned to ea665308ba)
Solutions
- Inspect the wrapped cause to classify the summarizer failure (auth/quota/network/cancel).
- Re-validate provider credentials and endpoint, then retry the verbose status call.
- Retry transient failures after a short backoff (rate limits especially).
- Call flow_status with verbose=false to skip the context summarization path entirely.
- Trim stored subtask contexts below 2*descriptionLimit so no LLM call is needed.
Example fix
// before: verbose only, no fallback
execContext, err := t.getDescriptionText(ctx, st.Context)
if err != nil {
return "", fmt.Errorf("failed to get subtask context: %w", err)
}
// after: fall back to truncated raw context on summarizer failure
execContext, err := t.getDescriptionText(ctx, st.Context)
if err != nil {
log.Warn("context summarization failed; using raw truncation", "err", err)
execContext = truncateText(st.Context, descriptionLimit)
} Defensive patterns
Strategy: fallback
Validate before calling
// avoid the summarizer entirely in the common case
if verbose && st.Context != "" && len(st.Context) <= 2*descriptionLimit {
execContext := truncateText(st.Context, descriptionLimit) // no LLM call
} Type guard
func contextNeedsLLM(st database.Subtask, verbose bool, hasSummarizer bool) bool {
return verbose && st.Context != "" && hasSummarizer && len(st.Context) > 2*descriptionLimit
} Try / catch
execContext, err := getDescriptionText(ctx, st.Context)
if err != nil {
// degrade: show raw truncated context rather than failing verbose status
log.Warn("subtask context summarization failed", "err", err)
execContext = truncateText(st.Context, descriptionLimit)
} Prevention
- Use verbose=false for routine status checks; verbose context summarization is the only trigger.
- Cap stored execution context size at write time in the agent pipeline.
- Set generous timeouts on verbose calls to accommodate LLM latency.
- Verify provider keys/quota before enabling verbose debugging sessions.
- Cache summarized contexts to avoid repeated LLM calls for the same subtask.
When it happens
Trigger: flow_status tool called with verbose=true while the running/waiting subtask has st.Context set and longer than 2*descriptionLimit characters, and the summarizer fails: provider auth error, rate limit/quota, network outage, or context cancellation during the LLM call.
Common situations: Verbose status polling (debugging sessions) coinciding with a provider outage or expired key; large execution contexts produced by long agent chains; upstream HTTP timeout cancelling summarization of a large context blob.
Related errors
- failed to get active task result: %w
- failed to set flow %d status: %w
- failed to renew flow %d status: %w
- failed to get flow %d status: %w
- flow %d is in unknown status: %s
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/1bb647b1abc9221e.
Report an issue: GitHub.