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 and then look at the specific file mentioned in the traceback.
Assistant
Let me look at the agent_cmd.py file first.
Assistant
Now I can see the issue clearly. The traceback shows that the error handling itself fails:
codeFile "/home/gru/projects/OpenJarvis/src/openjarvis/cli/agent_cmd.py", line 91, in list_agents console.print(f"[red]Error: {exc}[/red]") rich.errors.MarkupError: closing tag '[/red]' at position 65 doesn't match any open tagThe exception message
exccontains text with square brackets (rich markup-like characters), which breaks the rich markup parser. Let me explore the codebase to understand the root cause and the underlying exception.Assistant
I need to make one call at a time. Let me search for the error pattern across the CLI files.
Assistant
This is a widespread pattern. The issue is that when
exccontains text with square brackets (e.g., a connection error message with a URL likehttp://[::1]:11434), the rich markup parser treats them as tags and crashes. Let me first understand the underlying exception by looking at the manager.Assistant
The
list_agentsmethod just queries SQLite, so the underlying exception likely comes from elsewhere (DB lock, connection, etc.). But the reported bug is theMarkupErrorin the error handler itself. Let me reproduce that specific error first.Assistant
That didn't reproduce it. The error says
position 65, which means the exception text contains something that closes the[red]tag early (like a[/red]or an unbalanced[). Let me figure out the actual underlying exception. Let me look at the manager init and what could fail.Assistant
Let me look at
list_tasks,list_channel_bindings, and_row_to_agentwhich are all called in thelist_agentsloop.Assistant
These are all plain SQLite queries. The exact underlying exception is hard to determine, but the reported bug is the
MarkupErrorin the error handler. Let me reproduce it precisely — the error is at position 65, suggesting the exception text closes the[red]tag early. Let me test various exception messages.Assistant
I reproduced the
MarkupError. The exception message contains markup-like text (e.g.[/red]) that closes the[red]tag early. Now let me verify the fix usingrich.markup.escape().Assistant
The fix works. The same vulnerable pattern exists across ~50 locations in many CLI files. Let me check the CLI structure to find the best approach — whether there's a shared utility module.
Assistant
Let me look at all the distinct patterns of error printing to understand the variations.
Assistant
Let me look at the
config_cmd.pyspecial cases (lines 330 and 338) which have a different structure.Assistant
Now I have a complete picture. Let me check which files already import from
rich.markup.Assistant
Let me check the import structure in a couple of files to know where to add the
escapeimport.Assistant
Let me see ALL lines containing
{exc}in console.print/add_row context across the CLI to make sure my replacement is precise.Assistant
This is much more widespread than the initial grep showed — there are 80+ occurrences across ~25 files, with various patterns (
[red]{exc}[/red],{exc}outside tags,[yellow]...{exc}, etc.). All are vulnerable to the sameMarkupErrorwhen exception text contains brackets.The root cause is that dynamic exception text is interpolated into rich markup strings without escaping. The correct, comprehensive fix is to escape
{exc}withrich.markup.escape()everywhere it's interpolated into a rich markup string (console.print / add_row), while leavingclick.echocalls alone (those don't parse markup).Let me write a careful script to do this consistently.
Assistant
80 occurrences escaped. Now let me handle the special case in
config_cmd.pywhere{value!r}is interpolated into a markup string (line 338).Assistant
Let me verify whether line 338's
{exc}(on the continuation line) was escaped — it may have been missed since it lacksconsole.printon that exact line.Assistant
Right, line 340's
{exc}and line 339's{value!r}were missed because they're on continuation lines of a multi-lineconsole.print(...). Let me fix this one manually.Assistant
Now let me verify the changes look correct in
agent_cmd.py(the file from the traceback) and confirm the import was added.Assistant
Let me verify there are no remaining unescaped
{exc}interpolations inconsole.print/add_rowmarkup strings (including multi-line cases the script might have missed).Assistant
These are in
CheckResultobjects and a helper that returns a string. Let me check howCheckResultmessages are rendered — if they're printed as rich markup, they'd have the same bug.Assistant
Rich
Tablecells render content as markup too. TheCheckResult.message(containing{exc}) is added viatable.add_row(...)at line 344, so it has the same vulnerability. Let me look at theCheckResultdataclass and thedetailsfield.Assistant
The
CheckResult.message(with{exc}) is rendered as a rich table cell, which parses markup. Let me look at the rendering code to fix it centrally.Assistant
Let me check the
quickstart_cmd.py:80usage and the_STATUS_ICONSto understand the full rendering path.Assistant
I found more cases. In
quickstart_cmd.py:155,response(which can be"(query failed: {exc})") is interpolated into markup. And indoctor_cmd.py,check.message/check.details(with{exc}) are added to a rich table. Let me fix both. First, doctor_cmd.py:Assistant
I also see line 365 interpolates
bg.rust_errorinto markup. Let me check doctor_cmd's imports and then fix the rendering loop and the rust_error line.Assistant
Let me add the import via sed and then fix the rendering loop.
Assistant
Now let me fix the rendering loop in doctor_cmd.py to escape the dynamic message and details, plus the rust_error line.
Assistant
Now let me escape
bg.rust_erroron line 369 and fix thequickstart_cmd.pyresponse line.Assistant
Now let me fix the
quickstart_cmd.pyresponse line.Assistant
Now let me verify all modified files have the import and that they compile. Let me do a comprehensive check.
Assistant
All modules import successfully. Now let me write a reproduction script that simulates the exact issue scenario — the
list_agentserror handler printing an exception containing brackets.Assistant
The reproduction confirms the fix. Now let me test the actual CLI command end-to-end by monkeypatching
_get_managerto raise an exception with brackets (simulating the real failure).Assistant
Excellent! The end-to-end test passes —
jarvis agents listnow prints the error cleanly instead of crashing.But let me investigate the real underlying exception more deeply. The error says position 65 and the exception text must contain
[/red]-like markup. Looking at thelist_agentstable rendering, I seestatus_stylecan be"dim strike"for archived, producingf"[{status_style}]{a['status']}[/{status_style}]". Let me test whether rich accepts[/dim strike]as a closing tag.Assistant
[dim strike]archived[/dim strike]works, but an unknown status with empty style produces[]{status}[/]which crashes. Let me test the cascade theory — maybe an inner MarkupError (whose message contains[/red]) is being caught and re-printed, causing the outer MarkupError at position 65.Assistant
This confirms the cascade theory: an inner
MarkupError(whose message literally contains[/red]) gets caught and re-printed with[red]...{exc}...[/red], causing the outerMarkupError. My escaping fix prevents this cascade entirely.Now let me check existing tests for the agent command to make sure I don't break anything, and to understand expected behavior.
Assistant
The existing tests only check
--help, so my changes are safe. Now let me make thelist_agentstable rendering itself robust so it doesn't raise aMarkupErrorin the first place (which would cascade). The status cell crashes when the style is empty (unknown status), and user-providednamecould contain brackets. Let me view and fix the table rendering.Assistant
I found a likely root cause! Line 81:
status_styledict only hasidle, running, paused, error, archived. But theerrorscommand (line ~later) checks for("error", "needs_attention")— so"needs_attention"is a valid status NOT in the dict! That would makestatus_style="", producing[]{status}[/]which crashes. Let me verify all valid statuses in the codebase.Assistant
Found the exact root cause! The valid agent statuses include
needs_attention,stalled,budget_exceeded(set by the executor at line 709), but thelist_agentsstatus_styledict only hasidle, running, paused, error, archived. So an agent with statusneeds_attentionrenders[]needs_attention[/](empty style) → innerMarkupError→ cascades to the outerMarkupErrorat position 65!Let me verify this exact cascade matches the issue's "position 65":
Assistant
This is the exact root cause! The output
OUTER: MarkupError | closing tag '[/red]' at position 65 doesn't match any open tagmatches the issue traceback exactly (position 65).The cascade: agent status
needs_attention(valid, set byexecutor.py:709) is missing from thestatus_styledict → empty style → cell[]needs_attention[/]→ innerMarkupErrorcontaining[/]→ the[/]closes the[red]tag early in the error handler → outerMarkupErrorat position 65.So I need TWO fixes:
- ✅ Error handler escaping (defensive, already done).
- The
list_agentsstatus rendering: missing valid statuses + crashes on empty/unknown style. This is the actual root cause.
Let me search for other places with the same status_style pattern, then fix.
Assistant
There's the same pattern in
scheduler_cmd.py. Let me look at both and fix them.Assistant
scheduler_cmd.pyuses.get(t.status, "white")— a non-empty default, so it won't crash on unknown statuses. Theagent_cmd.pyone uses""(empty) default, which is the bug. Let me fix thelist_agentsrendering to add the missing valid statuses and handle empty/unknown style safely, plus escape dynamic cell content.Assistant
Now I notice the
infocommand has the same class of latent bugs — especially line 140 (summary_memory, which is agent research output very likely to contain brackets/markdown) and line 146 ([{t['status']}]which rich misinterprets as a style tag). Let me fix these dynamic interpolations ininfotoo, since they'd cause the same crash class.Assistant
Let me see all the remaining dynamic interpolations in agent_cmd.py (agent_id, names, etc.) to fix them comprehensively.
Assistant
Let me fix the
infocommand block (lines 135-151) which renders agent data includingsummary_memory.Assistant
Now let me fix the
taskstable row and theagent_idinterpolations in create/pause/resume/delete/bind commands.Assistant
Now let me fix the remaining
agent_idinterpolations (pause/resume/delete/not-found) and the create/bind output lines.Assistant
Line 44 is
click.echo(no markup parsing), correctly left alone. Now let me fix thecreateandbindoutput lines that interpolate dict values.Assistant
Now the
bindcommand output line:Assistant
Let me check the
channelscommand and other table renderings further down in agent_cmd.py.Assistant
Let me fix the
channelsandsearchtable renderings (config, query, result data likely contain brackets), plus the search title.Assistant
Now the
searchcommand — title with user query and table rows with query/result data:Assistant
Let me check the rest of agent_cmd.py for more table renderings and dynamic interpolations (templates, learning, trace, logs commands).
Assistant
Let me look at the live trace rendering (lines 400-415) and the
askcommand's final response output (line 879), which renders agent response content that could contain brackets/markdown.Assistant
Line 879 renders the agent's response content directly into markup — high risk since agent responses (especially deep_research) contain brackets/markdown. And lines 403-404 render tool args. Let me fix both.
Assistant
Now the
askcommand's response output (line ~881) which renders agent response content:Assistant
Let me fix the
templatestable rendering for consistency (descriptions could contain brackets).Assistant
Now let me verify agent_cmd.py compiles and run the existing agent command tests.
Assistant
All agent_cmd tests pass. Now let me write an end-to-end reproduction that uses a real
AgentManagerwith an agent in theneeds_attentionstatus (the exact root cause) and invokes the actuallistcommand.Assistant
All statuses now list without a traceback. Let me also verify the table actually renders correctly (showing the status text) by capturing the output.
Assistant
Hmm, exit 1 and no output. The
mix_stderr=Falsewithcolor=Truemight be causing issues. Let me debug. The CliRunner with stderr Console might not capture stderr properly. Let me check the exception.Actually, exit_code 1 with no output and color=True... Let me check if there's an exception. Let me re-run with exception printing.
Assistant
The table renders perfectly — name "My [bracketed] Assistant" (brackets escaped, shown literally) and status "needs_attention" both render with no crash.
Now let me run the broader CLI test suite to ensure I didn't break anything across all modified files.
Assistant
Let me check whether these failures are pre-existing (not caused by my changes) by stashing my changes and re-running the same tests.
Assistant
All 14 failures are pre-existing (they fail identically without my changes). My changes broke nothing. The stash pop failed due to a
uv.lockchange from the rebuild. Let me restore my changes properly.Assistant
My changes are restored. The
uv.lockgot modified again from the rebuild — let me restore it so I don't submit it.Assistant
Let me run the tests for the specific modules I modified to confirm no new failures (the 14 pre-existing failures are unrelated to my changes).
Assistant
All 130 tests pass for the modules I touched. Let me do a final review of the complete diff to ensure correctness.
Assistant
The agent_cmd.py diff looks clean and correct. Let me spot-check a couple of the other modified files to confirm the scripted changes are correct.
Assistant
All changes look correct and consistent. Let me do a final comprehensive check: every file that uses
escape(must have the import, and verify no syntax errors exist across all modified files.Assistant
All files have the import and compile cleanly. Let me do a final check for any remaining unescaped
{exc}in markup strings, and confirm the issue's exact scenario is resolved one more time.Assistant
Everything is verified. Let me clean up the temporary repro scripts and do a final review of the complete change set.
Assistant
The
uv.lockgot heavily modified by theuv runrebuilds — I must restore it to avoid submitting unrelated changes.Assistant
Now the diff is clean — only the 23 CLI source files. Let me do one final verification run of the agent command tests to confirm everything is good.
Assistant
All 17 agent_cmd tests pass. Let me do a final git status check to ensure only the intended source files are in the diff (no stray
uv.lockchanges).
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.