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
Let me start by understanding the issue. The traceback shows an error in
agent_cmd.pyat line 91:File "/home/gru/projects/OpenJarvis/src/openjarvis/cli/agent_cmd.py", line 91, in list_agents console.print(f"[red]Error: {exc}[/red]")The error is:
rich.errors.MarkupError: closing tag '[/red]' at position 65 doesn't match any open tagThis suggests that the error message
{exc}contains text that includes square brackets[and]which Rich's markup parser is interpreting as markup tags. Specifically, ifexccontains something like[/something], it would break the Rich markup since[/red]would then not match the opening[red]tag.Let me look at the code to understand the issue better.
Assistant
Now I can see the issue clearly. The problem is in
agent_cmd.pyline 91 and many other places:console.print(f"[red]Error: {exc}[/red]")When
{exc}contains text with square brackets (like URLs, file paths, or JSON), Rich's markup parser interprets them as markup tags. For example, if the exception message contains[/some_tag], then the[/red]closing tag won't match the opening[red]tag.Let me first confirm this is the root cause and find all affected
Assistant
There are 11 occurrences in this file. Let me also check the rest of the codebase for similar patterns:
Assistant
Good, I can see the widespread pattern. Let me first create a simple script to reproduce the error and confirm my understanding:
Assistant
I need to use the venv. Let me use the project's virtual environment.
Assistant
I've confirmed the bug. Now let me fix all occurrences in
agent_cmd.py. Let me check the imports firstAssistant
Let me look at the exact lines:
Assistant
Now let me fix all occurrences. First, add the import, then replace all patterns
Assistant
Now let me replace the pattern. The pattern is
f"[red]Error: {exc}[/red]"and I want to change it tof"[red]Error: {escape(str(exc))}[/red]".Wait, but sed will have trouble with the special characters. Let me use
replacecommand orsedcarefully. Actually, since the entire string is identical on all 11 lines, I can use a sed command.Let me use:
sed -i 's/{exc}\[/red\]/{escape(str(exc))}[\/red]/g'Hmm, that's tricky with sed. Let me use a simpler approach.
Assistant
Let me verify the changes were applied correctly:
Assistant
All 11 occurrences fixed. Let me also verify no old patterns remain
Assistant
No old patterns remain. Let me verify the import section
Assistant
Now let me test with a reproduction script
Assistant
The fix works. Let me also check if there are any other embedded
excpatterns in agent_cmd.py that I might haveAssistant
Good - those two use
click.echo(not Rich markup), so they're safe. Let me check the full diffAssistant
The
uv.lockchanges are unrelated to my fix - they were likely pre-existing. Let me verify by checking what I actually changed:Assistant
The
uv.lockchanges are unrelated to the fix. Let me restore it to its originalAssistant
Now let me verify the final diff is clean with only my intended
Assistant
Now the diff is clean. Let me run a quick sanity check to make sure the file parses correctly
Assistant
Let me check if there are tests for the agent commands
Assistant
Let me see if there are general tests that exercise the CLI
Assistant
Let me do a final import test to make sure everything works
Assistant
My fix is complete. Let me go through the checklist:
-
✅ Reproduced the error: I confirmed that
console.print(f"[red]Error: {exc}[/red]")throwsMarkupErrorwhen the exception message contains square brackets like[/some_tag]. -
✅ Fix resolves the error: Using
rich.markup.escape(str(exc))properly escapes any Rich markup in the exception string before embedding it. -
✅ Edge cases considered:
- Exception messages with
[and]characters → properly escaped - Empty exception messages → safe
- All 11 occurrences in the file are fixed consistently
- Exception messages with
-
✅ Tests: The file parses and imports correctly. There are no dedicated tests for this CLI module in the repository.
The root cause was that
{exc}in f-strings likef"[red]Error: {exc}[/red]"could contain text that Rich interprets as markup tags (e.g., HTTP URLs likehttp://[::1]:11434or JSON-like content). When the error message contained something like[/foo], Rich would see it as closing a tag that was never opened, making invalid.-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.