{"record":{"id":"d862bd5ae72d6e58","repo":"vxcontrol/pentagi","slug":"failed-to-parse-get-flow-status-args-w","errorCode":null,"errorMessage":"failed to parse get_flow_status args: %w","messagePattern":"failed to parse get_flow_status args: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/tools/flow_manager.go","lineNumber":70,"sourceCode":"\ttaskReadyPollTimeout   = 2 * time.Minute\n\twaitFlowDefaultTimeout = 1 * time.Minute\n\twaitFlowMaxTimeout     = 1 * time.Hour\n\tmsgLogsLimit           = 16 * 1024  // 16 KB\n\tsummaryLimit           = 32 * 1024  // 32 KB\n\ttaskListLimit          = 32 * 1024  // 32 KB\n\tsubtasksListLimit      = 48 * 1024  // 48 KB\n\tplannedListLimit       = 32 * 1024  // 32 KB\n\trunningInfoLimit       = 48 * 1024  // 48 KB\n\tinputLimit             = 8 * 1024   // 8 KB\n\tdescriptionLimit       = 4 * 1024   // 4 KB\n\tresultLimit            = 8 * 1024   // 8 KB\n\tsummarizationLimit     = 128 * 1024 // 128 KB hard limit\n)\n\nfunc (t *flowStatusTool) Handle(ctx context.Context, name string, args json.RawMessage) (string, error) {\n\tvar action GetFlowStatusAction\n\tif err := json.Unmarshal(args, &action); err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to parse get_flow_status args: %w\", err)\n\t}\n\n\tverbose := action.Verbose.Bool()\n\n\tswitch action.Detail {\n\tcase FlowStatusDetailSummary:\n\t\treturn t.buildSummary(ctx, verbose)\n\tcase FlowStatusDetailTasks:\n\t\treturn t.buildTasksList(ctx, verbose)\n\tcase FlowStatusDetailSubtasks:\n\t\treturn t.buildSubtasksList(ctx, action.TaskID.PtrInt64(), verbose)\n\tcase FlowStatusDetailRunning:\n\t\treturn t.buildRunningInfo(ctx, verbose)\n\tcase FlowStatusDetailPlanned:\n\t\treturn t.buildPlannedList(ctx, action.TaskID.PtrInt64(), verbose)\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"unknown detail level %q; use one of: summary, tasks, subtasks, running, planned\", action.Detail)\n\t}","sourceCodeStart":52,"sourceCodeEnd":88,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/flow_manager.go#L52-L88","documentation":"The get_flow_status tool unmarshals its JSON arguments into GetFlowStatusAction before dispatching. If args is not valid JSON or does not match the expected struct (wrong types, malformed syntax), the tool returns this wrapped parse error. It is a tool-input contract failure, not a flow-state problem.","triggerScenarios":"Tool called with args like '{detail:}' (invalid JSON), '{\"detail\": 123}' (type mismatch — Detail is a string enum), or a JSON array/string where an object was expected.","commonSituations":"LLM tool-caller emits single-quoted or unquoted JSON; caller passes the detail value as a number; argument serialization bug upstream producing empty or truncated JSON; nested quotes not escaped properly.","solutions":["Validate the args JSON with a parser (jq) and fix the syntax error indicated by the wrapped message.","Ensure 'detail' is a string: one of summary, tasks, subtasks, running, planned.","Omit optional fields rather than sending them with wrong types (e.g. verbose must be boolean).","If an LLM generates the args, tighten the tool's JSON schema / prompt examples for get_flow_status."],"exampleFix":"// before\n{\"detail\": summary, \"verbose\": \"true\"}\n\n// after\n{\"detail\": \"summary\", \"verbose\": true}","handlingStrategy":"validation","validationCode":"func validGetFlowStatusArgs(raw json.RawMessage) error {\n\tif !json.Valid(raw) { return errors.New(\"args is not valid JSON\") }\n\tvar probe struct {\n\t\tDetail  *string `json:\"detail\"`\n\t\tVerbose *bool   `json:\"verbose\"`\n\t}\n\tif err := json.Unmarshal(raw, &probe); err != nil { return err }\n\treturn nil\n}","typeGuard":"func isValidFlowStatusArgs(raw json.RawMessage) bool {\n\tvar action GetFlowStatusAction\n\treturn json.Unmarshal(raw, &action) == nil\n}","tryCatchPattern":"out, err := tool.Handle(ctx, \"get_flow_status\", args)\nif err != nil {\n\tvar parseErr *json.SyntaxTypeError\n\tif errors.As(err, &parseErr) {\n\t\t// re-serialize args strictly with encoding/json before retrying\n\t}\n\treturn err\n}","preventionTips":["Generate tool args with encoding/json.Marshal, never string concatenation","Keep the tool's JSON schema strict so LLM callers get constrained to correct types","Validate args with json.Valid before invoking the tool","Ensure booleans are JSON true/false, not \"true\" strings"],"tags":["json","tool-args","parsing","llm-tools"],"backgroundTag":"tool-args-json-parse-failed","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}