[Bug]: CLI crashes with Rich MarkupError when error text contains bracket-like output
Author: T90REALCreated Jun 25, 2026Updated Jun 25, 2026
Labelstype/bug
What happened?
This appears to be related to #281 and the fix in #341, but the issue is not fully fixed on the latest main branch.
The CLI still crashes with rich.errors.MarkupError when an exception message contains text that looks like a Rich markup closing tag, for example:
[/'A', 1, /'B']
[/\-\\+.$%*@?|]In my case this happened while running trae-cli with --console-type simple. The agent explored parser/grammar code and tool output contained strings like the examples above. Then Trae Agent attempted to print the exception and crashed inside Rich, masking the original error.
What did you expect to happen?
The CLI should not crash while reporting an exception. It should display the original exception and traceback.
Traceback
Traceback (most recent call last):
File "/home/agent/.local/bin/trae-cli", line 10, in <module>
sys.exit(main())
^^^^^^
File "/home/agent/.local/share/uv/tools/trae-agent/lib/python3.12/site-packages/trae_agent/cli.py", line 727, in main
cli()
File "/home/agent/.local/share/uv/tools/trae-agent/lib/python3.12/site-packages/click/core.py", line 1524, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/agent/.local/share/uv/tools/trae-agent/lib/python3.12/site-packages/click/core.py", line 1445, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/home/agent/.local/share/uv/tools/trae-agent/lib/python3.12/site-packages/click/core.py", line 1912, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/agent/.local/share/uv/tools/trae-agent/lib/python3.12/site-packages/click/core.py", line 1308, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/agent/.local/share/uv/tools/trae-agent/lib/python3.12/site-packages/click/core.py", line 877, in invoke
return callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/agent/.local/share/uv/tools/trae-agent/lib/python3.12/site-packages/trae_agent/cli.py", line 408, in run
console.print(f"\n{error_text}")
File "/home/agent/.local/share/uv/tools/trae-agent/lib/python3.12/site-packages/rich/console.py", line 1705, in print
renderables = self._collect_renderables(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/agent/.local/share/uv/tools/trae-agent/lib/python3.12/site-packages/rich/console.py", line 1560, in _collect_renderables
self.render_str(
File "/home/agent/.local/share/uv/tools/trae-agent/lib/python3.12/site-packages/rich/console.py", line 1442, in render_str
rich_text = render_markup(
^^^^^^^^^^^^^^
File "/home/agent/.local/share/uv/tools/trae-agent/lib/python3.12/site-packages/rich/markup.py", line 167, in render
raise MarkupError(
rich.errors.MarkupError: closing tag '[/'A', 1, /'B']' at position 32 doesn't match any open tagWhat is your system, Python, dependency version?
- Runtime: Docker / Linux container
- Python: 3.12
Additional information that you believe is relevant to this bug
No response
Source: bytedance/trae-agent