{"record":{"id":"6b813b3d6f733379","repo":"plandex-ai/plandex","slug":"no-planname-tag-found-in-xml-response","errorCode":null,"errorMessage":"No planName tag found in XML response","messagePattern":"No planName tag found in XML response","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/model/name.go","lineNumber":95,"sourceCode":"\t\tMessages:      messages,\n\t\tTools:         tools,\n\t\tToolChoice:    toolChoice,\n\t\tSessionId:     sessionId,\n\t\tSettings:      settings,\n\t})\n\n\tif err != nil {\n\t\tfmt.Printf(\"Error during plan name model call: %v\\n\", err)\n\t\treturn \"\", err\n\t}\n\n\tvar planName string\n\tcontent := modelRes.Content\n\n\tif baseModelConfig.PreferredOutputFormat == shared.ModelOutputFormatXml {\n\t\tplanName = utils.GetXMLContent(content, \"planName\")\n\t\tif planName == \"\" {\n\t\t\treturn \"\", fmt.Errorf(\"No planName tag found in XML response\")\n\t\t}\n\t} else {\n\t\tif content == \"\" {\n\t\t\tfmt.Println(\"no namePlan function call found in response\")\n\t\t\treturn \"\", fmt.Errorf(\"No namePlan function call found in response. The model failed to generate a valid response.\")\n\t\t}\n\n\t\tvar nameRes prompts.PlanNameRes\n\t\terr = json.Unmarshal([]byte(content), &nameRes)\n\t\tif err != nil {\n\t\t\tfmt.Printf(\"Error unmarshalling plan description response: %v\\n\", err)\n\t\t\treturn \"\", err\n\t\t}\n\t\tplanName = nameRes.PlanName\n\t}\n\n\treturn planName, nil\n}","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/model/name.go#L77-L113","documentation":"GenPlanName requested XML output (PreferredOutputFormat == xml) but the model's returned content did not contain a parseable <planName> element, so utils.GetXMLContent returned an empty string. The library fails fast rather than returning an empty plan name. The model responded, but not in the expected structured shape.","triggerScenarios":"Model output format is XML and GetXMLContent(content, \"planName\") yields \"\": model omitted the tag, used different tag casing/nesting, wrapped XML in markdown fences, or produced prose instead of XML.","commonSituations":"Weak models ignoring the XML schema instruction; prompt changes dropping the schema example; providers adding code fences around XML; truncation cutting off the closing tag; switching to a model that follows structured output poorly.","solutions":["Retry the request; nondeterministic models often emit valid XML on retry","Strengthen the prompt with an explicit XML schema example for planName","Use a model known to follow structured output / the provider's native JSON mode","Preprocess content to strip markdown fences before GetXMLContent","Fall back to the non-XML branch (function-call content) or a default name if parsing fails"],"exampleFix":"// before\nplanName := utils.GetXMLContent(content, \"planName\")\nif planName == \"\" { return \"\", fmt.Errorf(\"No planName tag found in XML response\") }\n// after: strip fences then retry once\ncleaned := strings.TrimSpace(strings.Trim(content, \"` \\n\"))\nplanName := utils.GetXMLContent(cleaned, \"planName\")\nif planName == \"\" { planName = fallbackPlanName() }","handlingStrategy":"fallback","validationCode":"// request structured output explicitly and verify shape before parsing\nif baseModelConfig.PreferredOutputFormat == shared.ModelOutputFormatXml &&\n    !strings.Contains(modelRes.Content, \"<planName>\") {\n    // retry or switch to non-XML extraction path before failing\n}","typeGuard":"func hasPlanNameTag(content string) bool {\n    return strings.Contains(content, \"<planName>\") && strings.Contains(content, \"</planName>\")\n}","tryCatchPattern":"name, err := GenPlanName(ctx, ...)\nif err != nil && strings.Contains(err.Error(), \"No planName tag found\") {\n    name = retryOrExtractFallback(modelRes.Content) // e.g. regex or default name\n}","preventionTips":["Include a concrete XML schema example in the prompt","Prefer providers' native structured/JSON output modes for weak models","Strip markdown code fences before XML parsing","Retry once on parse failure; LLM structured output is nondeterministic"],"tags":["xml","parsing","llm-output","structured-output"],"backgroundTag":"missing-xml-tag-in-response","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}