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 "@" }
My config is terse # OpenJarvis configuration # Hardware: 13th Gen Intel(R) Core(TM) i9-13900K (32 cores, 62.6 GB RAM) # GPU: NVIDIA GeForce RTX 4090 (24.0 GB VRAM) # Full reference config: jarvis init --full
[engine] default = "ollama"
[engine.ollama] # host = "http://localhost:11434" # set to remote URL if engine runs elsewhere
[intelligence] default_model = "gemma4:31b"
[agent] default_agent = "simple"
[tools] enabled = ["code_interpreter", "web_search", "file_read", "shell_exec"]
Steps to Reproduce
- Start an initial WSL Ubuntu shell
- run "jarvis"
- this will list the --help command
- run "jarvis agents list"
- this will list a table with one agent b0e6dece007b │ My Assistant │ deep_research │ idle │ 0 │ 0
- run "jarvis agents ask b0e6dece007b "How are you""
- this will respond after it loads and starts the model, GPU memory is utilized
- run "ps -aux|grep ollama" in another shell window
- this will output two processes:
- ollama 196 0.0 0.3 3405152 220636 ? Ssl 11:29 0:01 /usr/local/bin/ollama serve
- ollama 1078 66.2 6.9 195616136 4544716 ? Sl 12:39 5:25 /usr/local/bin/ollama runner --ollama-engine --model usr/share/ollama/.ollama/models/blobs/sha256-280af6832eca23cb322c4dcc65edfea98a21b8f8ab07dc7553bd6f7e6e7a3313 --port 42291
- run "jarvis agents ask b0e6dece007b "How can I contribute to the OpenJarvis Project""
- This will respond
- Wait a bit, until GPU memory frees
- run the "ps -aux|grep ollama" in another shell window and see only the one ollam process for the "serve"
- run "jarvis agents list"
- see Traceback
Expected Behavior
Expected the table listing with one idle agent: b0e6dece007b │ My Assistant │ deep_research │ idle │ 0 │ 0
Actual Behavior
Traceback
Operating System
Linux
Python Version
3.12
Hardware
NVIDIA GPU
Engine
Ollama
Logs / Traceback
Traceback (most recent call last): File "/home/gru/projects/OpenJarvis/.venv/bin/jarvis", line 10, in <module> sys.exit(main()) ^^^^^^ File "/home/gru/projects/OpenJarvis/src/openjarvis/cli/__init__.py", line 122, in main cli() File "/home/gru/projects/OpenJarvis/.venv/lib/python3.12/site-packages/click/core.py", line 1485, in __call__ return self.main(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gru/projects/OpenJarvis/.venv/lib/python3.12/site-packages/click/core.py", line 1406, in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ File "/home/gru/projects/OpenJarvis/.venv/lib/python3.12/site-packages/click/core.py", line 1873, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gru/projects/OpenJarvis/.venv/lib/python3.12/site-packages/click/core.py", line 1873, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gru/projects/OpenJarvis/.venv/lib/python3.12/site-packages/click/core.py", line 1269, in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gru/projects/OpenJarvis/.venv/lib/python3.12/site-packages/click/core.py", line 824, in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gru/projects/OpenJarvis/src/openjarvis/cli/agent_cmd.py", line 91, in list_agents console.print(f"[red]Error: {exc}[/red]") File "/home/gru/projects/OpenJarvis/.venv/lib/python3.12/site-packages/rich/console.py", line 1698, in print renderables = self._collect_renderables( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/gru/projects/OpenJarvis/.venv/lib/python3.12/site-packages/rich/console.py", line 1558, in _collect_renderables self.render_str( File "/home/gru/projects/OpenJarvis/.venv/lib/python3.12/site-packages/rich/console.py", line 1448, in render_str rich_text = render_markup( ^^^^^^^^^^^^^^ File "/home/gru/projects/OpenJarvis/.venv/lib/python3.12/site-packages/rich/markup.py", line 167, in render raise MarkupError( rich.errors.MarkupError: closing tag '[/red]' at position 65 doesn't match any open tagADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /OpenJarvis, current file: none) bash-$
Assistant
Let me analyze the issue. The error is:
rich.errors.MarkupError: closing tag '[/red]' at position 65 doesn't match any open tagThis happens in
src/openjarvis/cli/agent_cmd.pyat line 91:console.print(f"[red]Error: {exc}[/red]")The problem is that when an exception message (
exc) contains Rich markup tags (like square brackets), Rich tries to interpret them as markup. If the exception message contains something like[/something], it could conflict with the closing[/red]tag.Actually, looking more carefully, the issue is that if
exccontains a[character that Rich interprets as the start of a tag, but the corresponding closing tag doesn't match properly, it causes this error.Let me first explore the repository structure and find the relevant file.
Assistant
Let me look at the agent_cmd.py file to understand the issue.
Assistant
Now I can see the issue. The error occurs at line 91 in the
list_agentsfunction:console.print(f"[red]Error: {exc}[/red]")The problem is that when an exception message contains square brackets (like
[or]), Rich interprets them as markup tags. If the exception message contains something that looks like a closing tag (e.g.,[/red]), it conflicts with the actual closing tag.Looking at the traceback again:
rich.errors.MarkupError: closing tag '[/red]' at position 65 doesn't match any open tagThe error message from the exception likely contains some text with brackets that Rich misinterprets. The fix is to escape the exception message so Rich treats it as literal text, not markup.
In Rich, you can escape user content by using
{exc!r}or by using thesoft_wrapor escaping brackets. The proper way is to escape the markup by replacing[with\\[or by using a different approach.Let me check all the occurrences of this pattern in the file:
Assistant
There are 11 occurrences of the same pattern. The fix is to escape the exception message so Rich treats it as literal text, not markup. Rich provides
rich.markup.escape()for this purpose, or we can escape the brackets manually.Let me first create a script to reproduce the issue:
Assistant
Interesting, it worked with a simple error. Let me try to find what kind of exception message would cause the specific issue mentioned in the traceback:
Assistant
Now I've reproduced the issue. The problem is that when an exception message contains
[/red]or any Rich markup tag, it confuses Rich's parser. The fix is to escape the exception message before passing it to Rich.Let me check what Rich provides for escaping:
Assistant
The
rich.markup.escape()function properly escapes the exception message. Now I need to fix all 11 occurrences in the file. Let me also check if there are similar patterns elsewhere:Assistant
There are many occurrences of this pattern across multiple files. I need to fix them all. The best approach would be to:
- Fix the issue in all affected files by escaping the exception message using
rich.markup.escape() - Alternatively, use a simpler approach that doesn't require importing
escape- just escape the brackets manually using string replacement
Since there are many files, let me think about the best approach. The simplest fix that works in all cases without changing imports would be to replace
{exc}with{str(exc).replace("[", "[[]")}or userich.markup.escape().Actually, looking at the imports in agent_cmd.py, it already imports from rich:
from rich.console import Console from rich.table import TableSo I could add
from rich.markup import escapeto the import. But this needs to be done for all files.Let me check if each file already imports from rich, and what the cleanest fix would be. Actually, the simplest and most robust approach is to use
str(exc).replace("[", "[[]")which escapes the brackets for Rich markup without requiring additional imports.Wait, let me think about this more carefully. The Rich escape syntax uses
[[]for literal[. Let me verify:<tool_call> <function=bash_terminal> <parameter=command> cd /OpenJarvis && uv run python3 -c " from rich.console import Console
exc = Exception('some error with [/red] tag') console = Console(stderr=True)
Test escaping brackets manually
console.print(f'[red]Error: {str(exc).replace("[", "[[]")}') " </tool_call>
- Fix the issue in all affected files by escaping the exception message using
Assistant
The issue is that I need to properly escape the shell command with the quotes. Let me try a different approach.
Assistant
The
[[]escape doesn't work correctly - it shows[[]literally. Let me check the correct escape sequence for Rich.Assistant
Now I need to fix all files. The fix requires:
- Adding
from rich.markup import escapeimport - Replacing
{exc}with{escape(str(exc))}in error print statements
Let me start with the file from the traceback (agent_cmd.py):
- Adding
Assistant
The file already imports from rich. I need to:
- Add
escapeto the imports from rich.markup - Replace all
console.print(f"[red]Error: {exc}[/red]")withconsole.print(f"[red]Error: {escape(str(exc))}[/red]")
Let me do this for agent_cmd.py first, then for all other files.
- Add
Assistant
The user seems to have sent an empty message or just whitespace. I should continue with my work on fixing the Rich markup error issue. I was in the process of fixing the files. Let me check the current state and continue.
Assistant
Good, the import was added. Now I need to replace all the error print statements in agent_cmd.py with the escaped version.
Assistant
The sed command failed because of the special characters. Let me use a different approach with Python to do the replacement.
Assistant
No matches found, which means all occurrences were replaced. Let me verify the replacement worked correctly:
Assistant
Now I need to fix all the other files that have the same pattern. Let me create a script to automate this:
Assistant
Now let me verify the changes were applied correctly:
Assistant
All 46 occurrences have been replaced. Now let me verify the fix works by testing with a simulated error:
Assistant
The fix works. Now let me check if there are any tests I should run to make sure nothing is broken:
Assistant
Let me check if there are any CLI-related tests I can run:
Assistant
There's a
test_agent_cmd.pywhich is directly related to the file I modified. Let me run it to verify my changes don't break existing tests.Assistant
There's an indentation error in optimize_cmd.py. My script must have corrupted the import section of some files. Let me check and fix it.
Assistant
The imports look fine at the top. Let me check around line 460 where the error is:
Assistant
I see the issue. The script added
from rich.markup import escapeafter the local importfrom rich.console import Consoleinside the function, but with wrong indentation. This happened because my script found afrom rich.console import Consoleline that was inside a function, not at module level.Let me fix this file:
Assistant
Now let me check if there are any other files that might have the same issue. My script might have inserted the import incorrectly in files that have
from rich.console import Consoleinside functions.Assistant
Let me check all files that have
from rich.console import Consoleinside a function (not at the module level) to see if my script may have caused issues:Assistant
These look correct - they're at the module level. Let me check for any indentation issues in all the files I modified:
Assistant
All files compile correctly now. Let me run the test again:
Assistant
All 17 tests pass. Let me also run some of the other CLI tests to make sure I haven't broken anything:
Assistant
Excellent! All 38 tests pass. Let me now also verify my fix handles the edge cases correctly by writing a quick test script:
Assistant
All edge cases pass. Now let me review the checklist and summarize what I've done:
Checklist Review:
-
If an error was reported in the issue description, I have successfully reproduced it.
- ✅ I reproduced the
rich.errors.MarkupError: closing tag '[/red]' at position 65 doesn't match any open tagerror by simulating an exception message containing Rich markup tags like[/red].
- ✅ I reproduced the
-
If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- ✅ I confirmed the fix by:
- Testing that the error occurs without the fix
- Testing that the fix using
rich.markup.escape()prevents the error - Testing multiple edge cases with various problematic exception messages
- ✅ I confirmed the fix by:
-
I have thought about edge cases and made sure my fix handles them as well.
- ✅ I tested edge cases including:
- Normal error messages
- Messages with square brackets like
[brackets] - Messages with Rich tags like
[/red],[bold],[link=...] - Messages that look like connection errors
[Errno 111] - Messages with multiple closing tags
- ✅ I tested edge cases including:
-
I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass.
- ✅ I ran tests in:
tests/cli/test_agent_cmd.py- 17 tests passedtests/cli/test_tool_cmd.py- 18 tests passedtests/cli/test_workflow_cmd.py- 4 tests passedtests/cli/test_config_cmd.py- 16 tests passed
- All 55 tests passed successfully.
- ✅ I ran tests in:
Let me do a final verification by checking the diff of my changes:
-
Assistant
The uv.lock file changed during the build process but that's not part of my fix. Let me restore that file:
Assistant
I have successfully resolved the issue. Here's a summary of the fix:
Problem
The
jarvis agents listcommand was throwing arich.errors.MarkupErrorwhen an exception occurred and the exception message contained square brackets (like[/red]). Rich interprets square brackets as markup tags, causing a parsing error when the exception message contains tags that conflict with the surrounding markup.Root Cause
In
src/openjarvis/cli/agent_cmd.pyline 91 (and similar patterns in other CLI files):console.print(f"[red]Error: {exc}[/red]")When
exccontains Rich markup-like strings (e.g., connection errors with[Errno 111]), Rich's parser fails.Fix
Added
from rich.markup import escapeimport and changed all occurrences to:console.print(f"[red]Error: {escape(str(exc))}[/red]")The
escape()function properly escapes square brackets in the exception message so Rich treats them as literal text.Files Modified
src/openjarvis/cli/agent_cmd.py(11 occurrences fixed)src/openjarvis/cli/compose_cmd.py(7 occurrences fixed)src/openjarvis/cli/config_cmd.py(5 occurrences fixed)src/openjarvis/cli/eval_cmd.py(1 occurrence fixed)src/openjarvis/cli/feedback_cmd.py(4 occurrences fixed)src/openjarvis/cli/operators_cmd.py(9 occurrences fixed)src/openjarvis/cli/optimize_cmd.py(3 occurrences fixed)src/openjarvis/cli/registry_cmd.py(1 occurrence fixed)src/openjarvis/cli/scheduler_cmd.py(1 occurrence fixed)src/openjarvis/cli/tool_cmd.py(2 occurrences fixed)src/openjarvis/cli/workflow_cmd.py(2 occurrences fixed)
Checklist
- ✅ Reproduced the error: Confirmed the
MarkupErroroccurs with exception messages containing Rich markup tags - ✅ Confirmed fix works: Tested that
escape(str(exc))prevents the error for various problematic exception messages - ✅ Edge cases handled: Tested normal messages, brackets, Rich tags, connection errors, and multiple closing tags
- ✅ Existing tests pass: Ran 55 related CLI tests, all passed
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- xiaomi/mimo-v2.5-proCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →