Skip to content

CLI crashes with XML parsing error when using Mistral models in confirmation modeΒ #11377

@jpshackelford

Description

@jpshackelford

Summary

The OpenHands CLI crashes with an XML parsing error when using Mistral models due to improper handling of function call syntax in the action confirmation dialog.

Problem

When using Mistral models, the CLI displays a confirmation dialog showing pending actions. However, the CLI attempts to display the raw function call syntax (e.g., <function=execute_bash>) in an HTML context, which causes an XML parsing error because the syntax is not valid XML/HTML.

Root Cause

The CLI's agent_action.py has not been properly adapted to work with the new agent-sdk ActionEvent structure. Specifically:

  1. The CLI tries to stringify action.action which can contain raw function call syntax
  2. Even with html.escape(), the escaped content like &lt;function=execute_bash&gt; is still problematic for XML parsing
  3. The CLI should use proper ActionEvent fields like action.tool_call.name and handle the display more robustly

Impact

  • CLI is completely unusable with Mistral models
  • Users cannot interact with the agent when confirmation mode is enabled
  • The error occurs before any actual work can be done

Error Details

xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 75

The error occurs in openhands_cli/user_actions/agent_action.py line 40-42 when trying to create an HTML object with the action content.

Steps to Reproduce

  1. Set up OpenHands CLI with Mistral model:

    # Install OpenHands CLI
    # Configure with Mistral model (e.g., mistral-small-24b-instruct-2501)
  2. Start a conversation with confirmation mode enabled (default behavior):

    openhands
  3. Send any request that would trigger a function call:

    > what files do you see in pwd?
    
  4. Observe the crash:

    • The agent generates a function call
    • CLI attempts to show confirmation dialog
    • XML parsing error occurs and CLI crashes

Expected Behavior

  • CLI should display the confirmation dialog properly
  • User should be able to confirm/reject the action
  • No XML parsing errors should occur

Actual Behavior

  • CLI crashes with XML parsing error
  • User cannot proceed with the conversation
  • Error traceback is displayed

Environment

  • OpenHands CLI version: Latest (main branch)
  • Model: Mistral (mistral-small-24b-instruct-2501)
  • Platform: Any
  • Agent-SDK integration: Using new agent-sdk structure

Additional Context

Error Log

Error: not well-formed (invalid token): line 1, column 75
Traceback (most recent call last):
  File "openhands_cli/user_actions/agent_action.py", line 40, in ask_user_confirmation
  File "prompt_toolkit/formatted_text/html.py", line 35, in __init__
  File "xml/dom/minidom.py", line 2000, in parseString
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 1, column 75

Related

Suggested Solution

  1. Update CLI to use proper ActionEvent fields:

    • Use action.tool_call.name for tool name
    • Use action.action.__class__.__name__ or similar for action display
    • Handle action.action being None properly
  2. Improve HTML content sanitization:

    • Don't try to display raw function call syntax in HTML
    • Use plain text or better formatting for action content
  3. Add error handling:

    • Wrap HTML creation in try-catch
    • Fall back to plain text display if HTML parsing fails

Files to modify

  • openhands-cli/openhands_cli/user_actions/agent_action.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIRelated to the command line interfacebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions