XMLAgentOutputParser()| Name | Type | Description |
|---|---|---|
escape_format* | unknown | The escaping format to use when parsing XML content. Supports 'minimal' which uses custom delimiters like [[tool]] to replace XML tags within content, preventing parsing conflicts. Use 'minimal' if using a corresponding encoding format that uses the _escape function when formatting the output (e.g., with format_xml). |
Parses tool invocations and final answers from XML-formatted agent output.
This parser extracts structured information from XML tags to determine whether an agent should perform a tool action or provide a final answer. It includes built-in escaping support to safely handle tool names and inputs containing XML special characters.
Expected formats:
Tool invocation (returns AgentAction):
Final answer (returns AgentFinish): <final_answer>The answer is 4</final_answer>
Minimal escaping allows tool names containing XML tags to be safely represented.
For example, a tool named search<tool>nested</tool> would be escaped as
search[[tool]]nested[[/tool]] in the XML and automatically unescaped during
parsing.