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 "OPENJARVISH@"
}
Assistant
This confirms the file list. Now let's run the fix script on these files.
Assistant
Now let's verify the changes look correct, check for syntax validity, and inspect a few diffs.
Assistant
Now let's inspect the diff for agent_cmd.py (the specific file in the issue) to confirm correctness.
Assistant
This looks correct. Let's check import ordering/isort conventions and also check other files' diffs for correctness (e.g. operators_cmd.py, compose_cmd.py with more edits).
Assistant
Looks good. Let's check the import placement is stylistically fine (import order) - not critical for functionality. Now let's check a couple more diffs, then run a reproduction test.
Assistant
These look good. Now let's check import placement fixes with isort/ruff if configured, and run linter to check for issues (unused imports, import order).
Assistant
Let's auto-fix import sorting with ruff for the affected files.
Assistant
Good, imports are now properly sorted. Now let's re-run ruff to make sure no remaining unsorted import issues, and run full lint check on modified files for other issues.
Assistant
Unused import now. Let's remove it since model.py has no other exception-message interpolation needing escaping.
Assistant
Now let's run ruff on all modified files to catch other lint issues (line length, unused imports, etc.)
Assistant
These two are still slightly over due to deep indentation. Let's shorten wording or restructure with implicit string concatenation.
Assistant
All lint checks pass now. Let's revert uv.lock if touched again, and write a reproduction test.
Assistant
The fix works correctly for the exact failure mode that matches the issue's traceback. Now let's directly test the actual agent_cmd.py list_agents function by monkeypatching to raise such an exception.
Assistant
No exception raised — the fix works end-to-end for jarvis agents list. Let's also confirm this would have failed before the fix by testing with git stash.
Assistant
We reproduced the exact traceback from the issue before the fix. Now let's restore our fix (git stash pop got blocked due to uv.lock).
Assistant
uv.lock got re-modified by the uv run invocation. Let's revert it again and confirm the fix works.
Assistant
Confirmed fixed (exit_code 0, error printed correctly) and uv.lock reverted (no output from final grep). Now let's run the existing test suite related to CLI to make sure nothing is broken.
Assistant
Same 14 failures pre-exist without my changes — confirming these are pre-existing/environmental issues unrelated to my fix. Let's restore my changes.
Assistant
uv.lock reverted properly this time (checked out before pop, popped clean stash without conflicts). Let's run the tests for the specifically modified files' test suites now (agent_cmd, tool_cmd, config_cmd, etc.) to double check.
Assistant
All relevant tests pass. Let's also check tests/cli/test_optimize_skills_command.py, tests/cli/test_model_cmd.py, tests/cli/test_model_pull.py, and check for the serve.py and evals/cli.py related tests too.
Assistant
Missing dependency unrelated to our change (pre-existing environment gap). Let's confirm it fails the same without our changes too, then move on.
Assistant
All good. Now let's do a final review of the full diff and clean up temp files.
Assistant
Let's do a final full diff review to double-check everything is sensible.
Assistant
All changes look correct and consistent. Let's check the remaining diffs for deep_research_setup_cmd.py, serve.py, and optimize_cmd.py for completeness.
Assistant
Everything is consistent and correct. Let's run the full test suite once more (broader) to check for regressions, then finalize.
Assistant
Same 14 pre-existing failures as the baseline (already confirmed identical earlier), no new failures introduced. Let's finalize and review the checklist.
Assistant
Everything looks clean. Let me also double check no leftover pip-installed ruff causes issues (not part of repo, doesn't matter for submission) and do a final sanity compile check.
Assistant
The fix resolves the issue end-to-end. Let's do the final status check to make sure uv.lock is not left modified before submission.
Assistant
Clean. Now going through the checklist:
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
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 tag
Interface
No new interfaces are introduced.
ADDITIONAL 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 using git reset --hard command.
Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later.
Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands.
However you don't need to use git add or git commit before submitting your changes. In fact,
submit only submits currently unstaged changes because it uses git diff to 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-$
Summary
Root cause: Throughout the CLI, exception messages were interpolated directly into f-strings passed to rich.console.Console.print(...), e.g. console.print(f"[red]Error: {exc}[/red]"). Since Console.print parses Rich markup by default, if the exception's string representation happened to contain bracket sequences that look like Rich markup tags (e.g. a stray [/], [/something], or similar), the markup parser's tag stack would get corrupted, causing a rich.errors.MarkupError: closing tag '[/red]' ... doesn't match any open tag — exactly the traceback reported for jarvis agents list when the underlying Ollama connection error text tripped this up.
Fix: Escape all exception-derived text before interpolating it into Rich markup-enabled console.print(...) calls, using rich.markup.escape(). I used an AST-based script to find every X.print(f"...") call across the codebase whose interpolated expression referenced an exception variable (exc, e, etc.), and wrapped those expressions with escape(str(...)), adding the necessary from rich.markup import escape import where missing. This covers agent_cmd.py (the file from the issue) plus 21 other CLI/evals modules with the identical pattern, since the bug is systemic, not isolated to one command. I also fixed line-length/import-order issues so ruff check passes cleanly, and reverted an unrelated uv.lock change accidentally produced by running uv run locally.
Verification:
Reproduced the exact original traceback via a script that mocks list_agents to raise an exception whose str() contains a bare [/] sequence — confirmed it fails with the same MarkupError on the pre-fix code.
Confirmed the fix eliminates the crash and prints the escaped, safe error text with exit_code == 0.
Ran the full tests/cli and tests/evals suites before and after the fix — the same 14 pre-existing failures (all unrelated environment/dependency issues like missing polars, version-check banner noise, etc.) occur in both cases; no new failures introduced.
Ran ruff check and python -m py_compile on every modified file — all pass.
Checklist
Reproduced the reported error exactly (same MarkupError traceback) using a script that simulates an agent-manager exception with markup-breaking content.
Confirmed the fix resolves the error — jarvis agents list (and all similarly patched commands) now print exceptions safely instead of crashing.
Considered edge cases: escaped not just {exc} but also {exc.message}, {exc.cmd[:3]}, etc. wherever they flow into markup-enabled prints; avoided escaping purely-numeric fields (like HTTP status codes) where it added unnecessary line length without safety benefit, but that's harmless either way; used AST-based detection instead of naive regex to avoid missing multi-line f-strings or corrupting unrelated code.
Ran existing test suites (tests/cli, tests/evals) before and after the change — identical pass/fail counts, confirming no regressions from this change.