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'll start by exploring the repository structure to understand the codebase. Let's first check what's in the root directory.
- Assistant
Let me look at the error traceback more carefully. The issue is in
src/openjarvis/cli/agent_cmd.pyat line 91. The error is aMarkupErrorfrom Rich library when trying to print an error message with markup tags. The issue is that the error message itself contains characters that Rich interprets as markup, causing the closing tag[/red]to not match any open tag.Let me look at the relevant file.
- Assistant
Now I understand the issue. The error is clear from the traceback:
coderich.errors.MarkupError: closing tag '[/red]' at position 65 doesn't match any open tagThis happens at line 91 in
list_agents:pythonconsole.print(f"[red]Error: {exc}[/red]")The problem is that the exception message (
exc) itself contains Rich markup characters (like[and]). When the error message from the database/manager contains bracket characters, Rich tries to interpret them as markup tags and gets confused.The fix is to escape the exception message before inserting it into the markup. Let me check all the places where this pattern is used in the file.
- Assistant
There are 11 occurrences. I need to fix all of them by using
rich.markup.escape(). Let me first write a reproduction script to confirm the issue. - Assistant
I need to run via uv.
- Assistant
Interesting! The first case actually succeeded because Rich interpreted
[bold]as a valid markup tag. But the issue in the real traceback is different - the error message contains something like[/red]which doesn't match any open tag.Let me reproduce the actual failure case:
- Assistant
Now I can reproduce the exact error. The fix is to use
rich.markup.escape()on the exception message. Let me fix all occurrences in the file.First, I need to add the import for
escape: - Assistant
Let me add the import and fix all the occurrences.
- Assistant
Now let me replace all occurrences of the error pattern:
- Assistant
Let me verify the change was applied correctly:
- Assistant
Now let me also check the status_style code that constructs Rich markup dynamically. The traceback shows that the issue happens when listing agents. Let me look at the status_style code more carefully:
- Assistant
Now let me also check if there's an issue with the status_style code. If
a['status']contains brackets, it could also cause a MarkupError: - Assistant
Let me also check the AgentManager to understand what exceptions might be thrown:
- Assistant
Now let me also check if there are other places in the file where exception messages might contain Rich markup characters. Let me look at the other files too, but the issue is specifically about this file.
Let me also check if the
status_stylemapping might have an issue. Ifa['status']has an unexpected value not in the mapping,status_stylewould be an empty string"", and the markup would be[][]]which is invalid Rich markup.Wait, looking more carefully:
pythonstatus_style = { "idle": "dim", "running": "green", "paused": "yellow", "error": "red", "archived": "dim strike", }.get(a["status"], "")If
a["status"]is not one of the known values,status_stylebecomes"", and then the f-string would produce[][]]which is invalid Rich markup. That could also cause a MarkupError!Let me fix that as well.
- Assistant
Now let me also check if there are other similar patterns in the codebase that might have the same issue:
- Assistant
There are many other files with the same pattern. Let me check all of them:
- Assistant
The primary issue is in
agent_cmd.pyas shown in the traceback. But the exception message itself contains Rich markup characters that need escaping. Let me also check if there might be a root cause - the status_style being empty for unknown status values: - Assistant
Now let me verify the complete fix by looking at the imports and key section:
- Assistant
Now let me also check if there are other similar patterns in the codebase that might have the same issue.
- Assistant
The issue is specifically about
agent_cmd.pyas shown in the traceback. My fix there is correct. However, there's also a potential root cause issue - if the agent status is a value not in thestatus_stylemapping (like "needs_attention"),status_stylewould be empty string"", which would produce invalid Rich markup[]status[//]. But the traceback shows the error is caught in the except block and then the error message itself contains markup characters.Let me now run any existing tests to make sure my changes don't break anything:
- Assistant
Let me check the existing tests for agent_cmd.py:
- Assistant
Let me run the existing tests to make sure nothing is broken:
- Assistant
All tests pass. Now let me also fix the other files that have the same vulnerability, since this is a systemic issue:
- Assistant
The issue description is specifically about
agent_cmd.py. Let me also check if there are other patterns in the same file that use{exc}directly in Rich markup: - Assistant
Those lines use
click.echowhich doesn't interpret Rich markup, so they're fine. Let me verify the full diff of my changes: - Assistant
The
uv.lockchanges are just noise from runninguv run. Let me revert those: - Assistant
Now let me verify only the relevant change remains:
- Assistant
The diff looks clean. Let me run the tests again to confirm everything passes:
- Assistant
All tests pass. Now let me create a quick verification script to confirm the fix handles the exact error scenario:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.