Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions agentrace/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ def cmd_check(args) -> int:
flagged += 1
total_findings += len(findings)
console.print(
f"\n[bold]{r.description or '(no description)'}[/] [dim]{r.tool_use_id[-8:]}[/]"
f"\n[bold]{escape(r.description or '(no description)')}[/] [dim]{r.tool_use_id[-8:]}[/]"
)
for f in findings:
colour = _SEV_COLOUR.get(f.severity, "white")
console.print(f" [{colour}]{f.severity:<6}[/] [bold]{f.check}[/] {f.message}")
console.print(f" [{colour}]{f.severity:<6}[/] [bold]{escape(f.check)}[/] {escape(f.message)}")
if f.evidence:
console.print(f" [dim]{f.evidence}[/]")
console.print(f" [dim]{escape(f.evidence)}[/]")

console.print(
f"\n[bold]{flagged}/{len(runs)}[/] runs flagged, {total_findings} findings. "
Expand All @@ -119,18 +119,18 @@ def cmd_show(args) -> int:
console.print(f"[red]No run matching {args.id!r}[/]")
return 1
r = match[0]
console.print(f"[bold]{r.description}[/] [dim]{r.tool_use_id}[/]")
console.print(f"[bold]{escape(r.description)}[/] [dim]{escape(r.tool_use_id)}[/]")
console.print(f"[dim]duration: {r.duration_s}s | background: {r.background}[/]\n")
console.print("[bold cyan]PROMPT[/]")
console.print(r.prompt[: args.max] or "[dim](empty)[/]")
console.print(escape(r.prompt[: args.max]) if r.prompt[: args.max] else "[dim](empty)[/]")
console.print("\n[bold cyan]RESULT[/]")
console.print(r.result[: args.max] or "[dim](empty)[/]")
console.print(escape(r.result[: args.max]) if r.result[: args.max] else "[dim](empty)[/]")
findings = analyse(r)
if findings:
console.print("\n[bold cyan]FINDINGS[/]")
for f in findings:
colour = _SEV_COLOUR.get(f.severity, "white")
console.print(f" [{colour}]{f.severity:<6}[/] {f.check}: {f.message}")
console.print(f" [{colour}]{f.severity:<6}[/] {escape(f.check)}: {escape(f.message)}")
return 0


Expand Down
16 changes: 16 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,19 @@ def test_version():
result = run_cli("--version")
assert result.returncode == 0
assert "0.1.0" in result.stdout


def test_check_prints_bracketed_description_literally(monkeypatch, capsys):
start = datetime(2026, 1, 1, tzinfo=UTC)
run = AgentRun(
tool_use_id="toolu_test123456",
description="run [bold]pwned[/bold] test",
prompt="x" * 500,
result="I could not complete the task because access was denied.",
started_at=start,
ended_at=start + timedelta(seconds=1),
)
monkeypatch.setattr(cli, "_load", lambda args: [run])

assert cli.cmd_check(Namespace(severity=None, strict=False)) == 0
assert "run [bold]pwned[/bold] test" in capsys.readouterr().out
Loading