{"record":{"id":"116c1b77b801d1bd","repo":"vxcontrol/pentagi","slug":"failed-to-unmarshal-s-store-guide-action-argument","errorCode":null,"errorMessage":"failed to unmarshal %s store guide action arguments: %w","messagePattern":"failed to unmarshal (.+?) store guide action arguments: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/pkg/tools/guide.go","lineNumber":220,"sourceCode":"\t\t\t\tctx,\n\t\t\t\tagentCtx.ParentAgentType,\n\t\t\t\tagentCtx.CurrentAgentType,\n\t\t\t\tfiltersData,\n\t\t\t\tqueriesText,\n\t\t\t\tdatabase.VecstoreActionTypeRetrieve,\n\t\t\t\tbuffer.String(),\n\t\t\t\tg.taskID,\n\t\t\t\tg.subtaskID,\n\t\t\t)\n\t\t}\n\n\t\treturn buffer.String(), nil\n\n\tcase StoreGuideToolName:\n\t\tvar action StoreGuideAction\n\t\tif err := json.Unmarshal(args, &action); err != nil {\n\t\t\tlogger.WithError(err).Error(\"failed to unmarshal store guide action\")\n\t\t\treturn \"\", fmt.Errorf(\"failed to unmarshal %s store guide action arguments: %w\", name, err)\n\t\t}\n\n\t\tguide := fmt.Sprintf(\"Question:\\n%s\\n\\nGuide:\\n%s\", action.Question, action.Guide)\n\n\t\t// Anonymize before anything else so all downstream paths (including error\n\t\t// branches that emit langfuse events) only ever expose the anonymized form.\n\t\tvar (\n\t\t\tanonymizedGuide     = g.replacer.ReplaceString(guide)\n\t\t\tanonymizedQuestion  = g.replacer.ReplaceString(action.Question)\n\t\t\tanonymizedGuideOnly = g.replacer.ReplaceString(action.Guide) // used in slow-path embedding text\n\t\t)\n\n\t\teventMetadata := map[string]any{\n\t\t\t\"tool_name\":  name,\n\t\t\t\"message\":    action.Message,\n\t\t\t\"doc_type\":   guideVectorStoreDefaultType,\n\t\t\t\"guide_type\": action.Type,\n\t\t}","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/vxcontrol/pentagi/blob/ea665308baaff015b226f308438a68d929d0f29b/backend/pkg/tools/guide.go#L202-L238","documentation":"Returned by the guide tool dispatcher (backend/pkg/tools/guide.go) when the JSON arguments of the 'store' guide action cannot be unmarshaled into StoreGuideAction (expects 'question' and 'guide' string fields). Indicates malformed tool-call arguments from the LLM; the call is rejected before storing anything.","triggerScenarios":"Agent emits invalid JSON for store_guide: malformed question/guide strings with unescaped quotes/newlines, missing required fields, or completely non-JSON args.","commonSituations":"LLM writes the guide content containing raw quotes or control characters without proper JSON escaping; oversized or truncated tool-call output; strict-mode providers disabled so the model free-forms arguments.","solutions":["Check the logged 'args' field for the exact malformed payload.","Retry the agent turn; unescaped quotes from the model are usually transient.","Verify the tool schema for store_guide (question, guide fields) matches what the prompt instructs.","Pre-sanitize/strip markdown fences before Unmarshal.","Enable strict/JSON-mode function calling on the provider."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"func isValidStoreGuideArgs(args json.RawMessage) bool {\n    var probe struct {\n        Question string `json:\"question\"`\n        Guide    string `json:\"guide\"`\n    }\n    return json.Unmarshal(args, &probe) == nil && probe.Guide != \"\"\n}","typeGuard":"func asStoreGuideAction(args json.RawMessage) (*StoreGuideAction, bool) {\n    var a StoreGuideAction\n    if err := json.Unmarshal(args, &a); err != nil || a.Question == \"\" {\n        return nil, false\n    }\n    return &a, true\n}","tryCatchPattern":"out, err := tool.Handle(ctx, \"store_guide\", args)\nif err != nil {\n    if strings.Contains(err.Error(), \"failed to unmarshal\") {\n        return regenerateToolCallWithSchemaExample()\n    }\n    return err\n}","preventionTips":["Instruct the model to escape quotes/newlines inside guide content","Use provider-side strict JSON schema enforcement","Validate args against the schema before dispatching to the tool","Persist failing payloads for reproducible tests"],"tags":["json","unmarshal","tool-arguments","llm"],"backgroundTag":"json-unmarshal-tool-args","analyzedSha":"ea665308baaff015b226f308438a68d929d0f29b","analyzedAt":"2026-09-01T14:16:31.421Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}