{"record":{"id":"1bb647b1abc9221e","repo":"vxcontrol/pentagi","slug":"failed-to-get-subtask-context-w","errorCode":null,"errorMessage":"failed to get subtask context: %w","messagePattern":"failed to get subtask context: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/tools/flow_manager.go","lineNumber":328,"sourceCode":"\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)\n\t\t}\n\t\tif verbose && st.Context != \"\" {\n\t\t\texecContext, err := t.getDescriptionText(ctx, st.Context)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", fmt.Errorf(\"failed to get subtask context: %w\", err)\n\t\t\t}\n\t\t\tfmt.Fprintf(sb, \"\\nExecution context:\\n%s\\n\", execContext)\n\t\t}\n\t\tif st.Status == database.SubtaskStatusWaiting {\n\t\t\tfmt.Fprintf(sb, \"\\nNote: subtask is waiting for user input (ask state).\\n\")\n\t\t\tfmt.Fprintf(sb, \"Use %s to provide the answer and resume execution.\\n\", SubmitFlowInputToolName)\n\t\t}\n\n\t\tmsgLimit := msgLogLimitNormal\n\t\tif verbose {\n\t\t\tmsgLimit = msgLogLimitVerbose\n\t\t}\n\t\tmsgLogs, err := t.appendSubtaskMsgLogs(ctx, st.ID, msgLimit)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed to get subtask msg logs: %w\", err)\n\t\t}\n\t\tsb.WriteString(msgLogs)\n","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/flow_manager.go#L310-L346","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: verbose only, no fallback\nexecContext, err := t.getDescriptionText(ctx, st.Context)\nif err != nil {\n\treturn \"\", fmt.Errorf(\"failed to get subtask context: %w\", err)\n}\n\n// after: fall back to truncated raw context on summarizer failure\nexecContext, err := t.getDescriptionText(ctx, st.Context)\nif err != nil {\n\tlog.Warn(\"context summarization failed; using raw truncation\", \"err\", err)\n\texecContext = truncateText(st.Context, descriptionLimit)\n}","handlingStrategy":"fallback","validationCode":"// avoid the summarizer entirely in the common case\nif verbose && st.Context != \"\" && len(st.Context) <= 2*descriptionLimit {\n\texecContext := truncateText(st.Context, descriptionLimit) // no LLM call\n}","typeGuard":"func contextNeedsLLM(st database.Subtask, verbose bool, hasSummarizer bool) bool {\n\treturn verbose && st.Context != \"\" && hasSummarizer && len(st.Context) > 2*descriptionLimit\n}","tryCatchPattern":"execContext, err := getDescriptionText(ctx, st.Context)\nif err != nil {\n\t// degrade: show raw truncated context rather than failing verbose status\n\tlog.Warn(\"subtask context summarization failed\", \"err\", err)\n\texecContext = truncateText(st.Context, descriptionLimit)\n}","preventionTips":["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."],"tags":["go","llm-summarizer","flow-status","verbose"],"backgroundTag":"llm-summarization-failed","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}