Skip to content

fix(xml-formatter): recover from malformed XML in tool call parsing#6

Open
francisjervis wants to merge 1 commit into
SALT-NLP:mainfrom
francisjervis:fix/xml-parsing-hardening
Open

fix(xml-formatter): recover from malformed XML in tool call parsing#6
francisjervis wants to merge 1 commit into
SALT-NLP:mainfrom
francisjervis:fix/xml-parsing-hardening

Conversation

@francisjervis

Copy link
Copy Markdown

Summary

Add a recovery pass using clean_malformed_xml before failing, and return an empty list instead of raising on parse error.

Problem

When the LLM returns structurally malformed XML (mismatched tags, stray angle brackets inside field values, etc.), ET.fromstring raises ET.ParseError. This caused background AgendaManager._process_qa_pair tasks to die silently, leaving memory/subtopic-coverage state partially un-updated.

Changes (src/utils/llm/xml_formatter.py)

  • Attempt 1: parse XML as-is (existing behaviour).
  • Attempt 2: on ParseError, run clean_malformed_xml on the string and retry.
  • Fallback: if both attempts fail, log the error and return [] so the calling interview continues unimpeded.

Add a recovery pass using clean_malformed_xml before failing, and
return an empty list instead of raising on parse error. Prevents
AgendaManager._process_qa_pair tasks from dying silently and leaving
memory/subtopic-coverage state partially un-updated.
@francisjervis francisjervis force-pushed the fix/xml-parsing-hardening branch from 350fd00 to 9a7a2b5 Compare June 2, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant