Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

LLM generates malformed XML closing tag causing extraction failure #2

@shepelt

Description

@shepelt

Issue

When generating code files, Claude Sonnet occasionally generates malformed XML closing tags that break file extraction.

Example

Project ID: 3jWgMMickCJqLWQCB (on macserver)
Model: anthropic/claude-haiku-4-5-20251001

The LLM generated:

<sg-file path="src/components/ui/button.tsx" summary="Created button UI component">
... code content ...
</sx-file>  ❌ WRONG - should be </sg-file>

Impact

  1. ❌ File extraction fails - content not written to workspace
  2. ❌ Raw XML tags left in message display, confusing users
  3. ✅ In this case, build still succeeded because button.tsx already existed in scaffold

Root Cause

Claude Sonnet made a typo in the closing tag: </sx-file> instead of </sg-file>

Sigrid's XML parser expects exact tag matching:

  • Opening: <sg-file>
  • Closing: </sg-file>

When tags don't match, the parser:

  1. Fails to extract file content
  2. Fails to clean up tags from message content
  3. Leaves raw XML visible to users

Suggested Fixes

Option 1: More lenient parsing

  • Accept common typos like </sx-file>, </sg-files>
  • Use fuzzy matching for closing tags

Option 2: Better error recovery

  • Strip malformed tags from message display even if extraction fails
  • Show user-friendly error message instead of raw XML

Option 3: Prompt engineering

  • Add explicit examples in system prompt emphasizing exact tag format
  • Add validation reminder before generating closing tags

Related Code

File extraction likely happens in:

  • filetooling.js
  • llm-static.js or llm-dynamic.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions