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 and locate the relevant files mentioned in the traceback. Let's first get an overview.
- Assistant
Let me look at the specific file mentioned in the traceback:
src/openjarvis/cli/agent_cmd.pyaround line 91. - Assistant
Let me look at the traceback more carefully. The error is:
coderich.errors.MarkupError: closing tag '[/red]' at position 65 doesn't match any open tagThis is happening at line 91:
pythonconsole.print(f"[red]Error: {exc}[/red]")The issue is that
{exc}contains some text that has Rich markup-like syntax, and when it's interpolated into the string with[red]tags, it's causing a parsing error. This is a common issue with Rich - if the error message contains characters like[and], Rich will try to interpret them as markup tags.The fix is to escape the error message before inserting it into the Rich markup string, or use Rich's escape function. Rich provides
rich.markup.escape()for this purpose.Let me look at the specific line and see what the fix should be.
- Assistant
Now let me look at the full file to see all instances of this pattern:
- Assistant
Now I understand the issue. The error is:
coderich.errors.MarkupError: closing tag '[/red]' at position 65 doesn't match any open tagThis happens because the exception message (
{exc}) contains characters that Rich interprets as markup. For example, if the exception message contains something like[/red]or[, Rich's markup parser gets confused.The fix is to use
rich.markup.escape()to escape the exception message before inserting it into the Rich markup string.Let me check if
rich.markupis already imported: - Assistant
Now I understand the issue. The problem is that the error message
{exc}may contain Rich markup special characters like[and], and when it's interpolated directly into the Rich markup stringf"[red]Error: {exc}[/red]", Rich tries to parse those characters as markup tags, which causes theMarkupError.The fix is to escape the
{exc}portion so Rich doesn't try to interpret it as markup. I'll usefrom rich.markup import escapeand wrap the exception inescape().Let me first look at the Manager's
list_agentsmethod to understand what kind of exception might be raised: - Assistant
Let me look at the list_agents method to understand what exception could produce a message with brackets.
- Assistant
Let me look at the
list_agentsmethod to see what exceptions might be thrown: - Assistant
Now I understand the issue. The problem is on line 91 in
agent_cmd.py:pythonconsole.print(f"[red]Error: {exc}[/red]")When the exception message contains characters that look like Rich markup (square brackets
[and]), Rich tries to parse them as markup tags and fails with aMarkupError. This is a common issue when interpolating arbitrary strings into Rich markup.The fix is to escape the exception message so that square brackets are not interpreted as markup. We can use
rich.markup.escape()for this purpose.Let me look at all the places where this pattern is used:
- Assistant
Let me also check if there are similar patterns in other CLI files:
- Assistant
Now I understand the issue clearly. The problem is that when
exccontains Rich markup characters like[or](which is common in error messages, especially database errors that include table names in brackets), it breaks Rich's markup parser.The traceback shows:
coderich.errors.MarkupError: closing tag '[/red]' at position 65 doesn't match any open tagThe fix is to escape the
excvalue before embedding it in Rich markup. I need to importfrom rich.markup import escapeand use it on all the error formatting lines.Let me fix the
agent_cmd.pyfile: - Assistant
Now I need to replace all occurrences of the error pattern. Let me replace them:
- Assistant
Good. Now let me also check if there are other places in the file where user/DB data is embedded directly in Rich markup that could also cause issues:
- Assistant
Let me check for other problematic patterns:
- Assistant
Now let me verify the fix is complete by checking the current state of the key line:
- Assistant
Good. Now let me also fix the other files that have the same pattern to prevent similar issues elsewhere. Let me do it for all files:
- Assistant
Let me focus on fixing
agent_cmd.pyas that's the file in the traceback. Now let me also fix thedeep_research_setup_cmd.pywhich has a slightly different pattern: - Assistant
Let me now fix all the other files with the same pattern. I'll do them all at once to be thorough:
- Assistant
Let me verify the changes in a few files:
- Assistant
Let me verify the actual replacement happened in the other files too:
- Assistant
Good, all the unescaped patterns are now gone (0 counts). Let me verify the escaped patterns are present:
- Assistant
Now let me verify the other files also got properly fixed:
- Assistant
Good - no more instances of the unescaped pattern remain. Let me now check if the sed command properly fixed the other files:
- Assistant
All instances have been updated. Now let me verify that all the imports are in place:
- Assistant
I see
optimize_cmd.pyhas 2 imports - let me fix that duplicate: - Assistant
There's a duplicate import at line 459 in optimize_cmd.py. Let me fix that:
- Assistant
I see the issue - the duplicate import was inserted inside the function with wrong indentation. Let me fix that:
- Assistant
There's a duplicate
from rich.table import Tableon lines 459-460. Let me fix that: - Assistant
Now let me verify the optimize_cmd.py no longer has duplicate imports:
- Assistant
Now let me also check
config_cmd.pywhich had a different pattern: - Assistant
Line 331 in config_cmd.py has a slightly different pattern where
{exc}is outside the red tags. Let me also fix that for consistency: - Assistant
Line 331 also needs fixing since
excis still in a Rich console.print which interprets markup: - Assistant
Now let me also fix the other error message on line 338-341 where
{exc}is used without escaping: - Assistant
Good. Now let me also verify the import is properly placed in config_cmd.py:
- Assistant
Now let me create a test script to verify the fix works:
- Assistant
Let me use the project's venv.
- Assistant
The test confirms the fix works:
[managed_agents]in the error message gets silently swallowed by Rich (it's an unknown tag)[/red]in the error message causes the exact MarkupError from the issue- Using
escape()fixes both cases
Now let me check if there are existing tests for the CLI commands:
- Assistant
Let me check if there are existing tests for the agent_cmd.py that I can run:
- Assistant
Let me run the tests to make sure my changes don't break anything:
- Assistant
All tests pass. Let me also run the broader CLI tests:
- Assistant
The 14 failures are all pre-existing and unrelated to my changes (memory module issues, telemetry export issues, doctor labels issues, etc.). The key tests (test_agent_cmd.py) all pass. Let me clean up and do a final review of all changes:
- Assistant
Now let me do a final review of all changes:
- Assistant
The
uv.lockchanges are unrelated. Let me restore that file and check just the source changes: - Assistant
Let me do a final review of the changes:
- Assistant
Let me do a final review of the primary file:
- Assistant
Let me run the agent_cmd tests one final time to confirm everything is working:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.