ISSUE DESCRIPTION jarvis agents list Traceback Description Learning OpenJarvis on a…
- User
ISSUE DESCRIPTION
jarvis agents list Traceback
Description
Learning OpenJarvis on a Windows machine with WSL2. I was wondering what would happen on a clean reboot and listed the agents. This worked the first two times and listed the "... My Assistant │ deep_research ...". I even used the ID to ask it questions which worked (jarvis agents ask b0e6dece007b "How can I contribute to the OpenJarvis Project"). I had not loaded the model (Gemma 4 31b) into Ollama (this was direct from an open WSL Ubuntu window). My alias for jarvis is jarvis() { cd "@" }
Assistant
I need to understand this issue. The traceback shows a
rich.errors.MarkupErrorwhen trying to print an error message in thelist_agentsfunction. This happens when the error message contains characters that interfere with rich's markup tags (like[or]).Let me first explore the repository structure and find the relevant code.
Assistant
Let me find the specific file with the
list_agentsfunction that's causing the issue.Assistant
I found the issue! The problem is in the error handling code. When an exception is caught, it prints the error message using rich markup:
pythonconsole.print(f"[red]Error: {exc}[/red]")The issue is that if the exception message
exccontains brackets (like[or]) or other special rich markup characters, it breaks the markup parser. This can happen when an exception message contains JSON-like content or other structured data with brackets.Let me see the full traceback to understand what error is being thrown. Let me first check the full content of the file around line 91:
Assistant
Now I can see the issue clearly. The problem is on line 91:
pythonconsole.print(f"[red]Error: {exc}[/red]")When
exc(the exception message) contains special characters like[or], it breaks the rich markup parser.The same issue might exist in other places in the file (create, info, tasks, etc.). I need to:
- Use
console.print()with a proper way to escape rich markup, or useconsole.print()without f-string interpolation for the exception message - Or use
markdownortextfrom rich to properly escape markup
Let me check what rich provides for escaping:
<tool_call> <function=bash_terminal> <parameter=command> cd /OpenJarvis && python3 -c "from rich.console import Console; from rich.markup import escape; help(escape)" </tool_call>
- Use
Assistant
Let me run the python command to check for escape functionality in rich.
Assistant
Let me use the virtual environment to check the rich module:
Assistant
Good! I found that
rich.markup.escapecan be used to escape the exception message. Let me check all the places in the file where similar issues could occur:Assistant
Now I understand the issue. The problem is in the error handling code where exception messages containing rich markup special characters (like
[or]) break the markup parser. There are multiple places withconsole.print(f"[red]Error: {exc}[/red]")that need to be fixed.Let me create a reproduction script first to confirm the issue:
Assistant
Interesting - the simple test didn't fail. Let me check what exact error message causes the issue. The traceback mentioned "closing tag '[/red]' at position 65 doesn't match any open tag" which suggests the exception message contains a malformed markup tag like
[/something].Let me test more edge cases:
Assistant
Perfect! I've confirmed the issue. When an exception message contains markup-like characters like
[/something]or[/red], it causes aMarkupError. The solution is to userich.markup.escape()to escape the exception message before inserting it into the rich markup string.Now I need to fix the
agent_cmd.pyfile. The fix should:- Import
escapefromrich.markup - Replace all
console.print(f"[red]Error: {exc}[/red]")withconsole.print(f"[red]Error: {escape(str(exc))}[/red]")
Let me fix all the affected lines in the file. I can see the following lines need fixing:
- Line 91 (list_agents)
- Line 111 (create_agent)
- Line 141 (info)
- Line 163 (tasks)
- Line 176 (pause)
- Line 189 (resume)
- Line 202 (delete)
- Line 233 (bind)
Let me make the changes:
<tool_call> <function=bash_terminal> <parameter=command> cd /OpenJarvis && sed -i 's/from rich.console import Console/from rich.console import Console\nfrom rich.markup import escape/' src/openjarvis/cli/agent_cmd.py </tool_call>
- Import
Assistant
Let me use the edit command to properly modify the file. First, I'll add the import, then replace all the error messages.
Assistant
Now let me verify the import was added correctly:
Assistant
The import was added. Now I need to replace all the
console.print(f"[red]Error: {exc}[/red]")statements with escaped versions. Let me use sed to replace all occurrences:Assistant
Let me verify the changes were applied correctly:
Assistant
The sed replacement didn't work. Let me try a different approach using a Python script:
Assistant
Excellent! All 11 occurrences have been replaced. Let me verify the changes:
Assistant
I see there's an extra
"at the end. Let me fix that:Assistant
Let me fix the Python script syntax:
Assistant
Let me check what the file currently looks like:
Assistant
I see the issue - the escape character is being escaped. Let me fix this directly using edit:
Assistant
Let me use a Python script to fix this properly:
Assistant
All 11 replacements are now correct. Let me verify the changes look good:
Assistant
Now let me verify the syntax is correct by importing the module:
<tool_call> <function=bash_terminal> <parameter=command> cd /OpenJarvis && source .venv/bin/activate && python3 -c "from openjarvis.cli.agent_cmd import *; print('Import successful!')" </tool_call>
Assistant
Let me run the Python command properly.
Assistant
Good! The module imports successfully. Now let me create a test to verify that the fix resolves the MarkupError issue:
<tool_call> <function=bash_terminal> <parameter=command> cd /OpenJarvis && source .venv/bin/activate && python3 << 'PYEOF' """Test that the fix resolves the MarkupError""" from rich.console import Console from rich.markup import escape
console = Console(stderr=True)
Simulate the problematic exception that would have caused the error
class MockException(Exception): pass
This is the kind of exception that would cause the MarkupError
exc = MockException("Error: Connection closed [/red]")
print("Testing the fixed error handling:") try: # This is what the fixed code does console.print(f"[red]Error: {escape(str(exc))}[/red]") print("SUCCESS: No MarkupError occurred!") except Exception as e: print(f"FAILED: {type(e).name}: {e}") PYEOF
Assistant
The command didn't work due to the syntax of the tool call. Let me try a different approach - create a test file and run it.
Assistant
The fix works! Now let me verify the complete file to make sure all changes are correct:
<tool_call> <function=bash_terminal> <parameter=command> head -95 /OpenJarvis/src/openjarvis/cli/agent_cmd.py </tool_call>
Assistant
The tool call didn't work because I need to use the proper command syntax. Let me try without the command field:
Assistant
Good! The import statement is there on line 10, and line 92 shows the fixed error handling code. Now let me check if there are any existing tests in the repository that I should run to make sure my changes don't break anything:
<tool_call> <function=bash_terminal> <parameter=command> find /OpenJarvis -type f -name "test.py" | grep -i agent | head -10 </tool_call>
Assistant
The tool call didn't work properly. Let me try without quoting.
Assistant
There's a test file specifically for the agent_cmd CLI! Let me look at it:
Assistant
Let me run these tests to make sure my changes don't break anything:
Assistant
All tests pass! Let me also check if there are similar patterns in other CLI files that might need the same fix:
Assistant
The tool call isn't working as expected. Let me try a simpler approach to test the fix.
Assistant
The fix is working! The error message with markup characters is now properly displayed without causing a
MarkupError.Now let me check if there are other CLI files that might have the same issue:
Assistant
There are many other files with the same issue! However, since the issue description specifically mentions the
agents listcommand, I should focus on fixing just that file for now. The user specifically reported the error inagents list, so let me make sure that fix is complete.Let me verify my fix is complete by checking all error handling lines in agent_cmd.py:
<tool_call> <function=bash_terminal> <parameter=command> grep -n "console.print.*Error" /OpenJarvis/src/openjarvis/cli/agent_cmd.py </tool_call>
Assistant
The command tool call didn't work properly. Let me try running the command differently.
Assistant
Great! All 11 error handling lines in the file now use
escape(str(exc))instead of just{exc}. The fix is complete for theagent_cmd.pyfile.Now let me create a summary of what I did and verify the fix by checking the git diff:
<tool_call> <function=bash_terminal> <parameter=command> cd /OpenJarvis && git diff src/openjarvis/cli/agent_cmd.py </tool_call>
Assistant
Let me try again without quotes around the command.
Assistant
The git diff shows exactly what I changed:
- Added the import
from rich.markup import escapeat line 10 - Changed all 11 instances of
console.print(f"[red]Error: {exc}[/red]")toconsole.print(f"[red]Error: {escape(str(exc))}[/red]")
This fix ensures that any exception message containing rich markup characters (like
[,],[/tag]) will be properly escaped and won't cause a MarkupError.Now let me run the tests again to make sure everything still passes:
<tool_call> <function=bash_terminal> <parameter=command> cd /OpenJarvis && source .venv/bin/activate && python -m pytest tests/cli/test_agent_cmd.py -v </tool_call>
- Added the import
Assistant
The tool call isn't working properly. Let me try running the command directly without quoting issues.
Assistant
All tests pass! Let me now create a final comprehensive test that simulates the exact error from the issue description:
Assistant
Excellent! The fix is working perfectly. Let me provide a summary of what I did:
Summary
Issue
When running
jarvis agents list, arich.errors.MarkupErrorwas being raised with the message "closing tag '[/red]' at position 65 doesn't match any open tag". This happened because the exception message contained rich markup special characters (like[/red]) that weren't properly escaped.Root Cause
In
src/openjarvis/cli/agent_cmd.py, all error handling code used:pythonconsole.print(f"[red]Error: {exc}[/red]")When the exception message
exccontained rich markup characters (like[,],[/tag]), the rich library's markup parser would fail because it tried to interpret those characters as markup tags.Fix
- Added the import:
Assistant
Let me check the uv.lock changes to make sure I'm only submitting the relevant fix:
Assistant
The uv.lock file was automatically modified by the environment, likely due to running Python in a different version. Let me restore the uv.lock file since it's not part of my fix:
<tool_call> <function=bash_terminal> <parameter=command> cd /OpenJarvis && git checkout uv.lock </tool_call>
Assistant
The command tool call didn't work properly. Let me try again without quoting.
Assistant
Good! The uv.lock file has been restored. Now let me verify the final state of the changes:
<tool_call> <function=bash_terminal> <parameter=command> cd /OpenJarvis && git status </tool_call>
Assistant
The tool call didn't work properly. Let me try again.
Assistant
Perfect! Now only the
agent_cmd.pyfile is modified, which is exactly what I intended. Let me verify the diff one more time to make sure my fix is correct:<tool_call> <function=bash_terminal> <parameter=command> cd /OpenJarvis && git diff src/openjarvis/cli/agent_cmd.py </tool_call>
Assistant
The tool call didn't work properly again. Let me try running it without the quoted format.
Assistant
The fix is complete. Let me now submit the solution:
Assistant
Let me try the submit command in the right format.
<tool_call> <function=bash_terminal> <parameter=command> submit </tool_call>
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.