From 80f9934f8fb347b1955cd1852f12047616fdd5a2 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Thu, 7 May 2026 11:19:46 +0800 Subject: [PATCH] =?UTF-8?q?loop:=20=E7=94=A8=20rich.Markdown=20=E6=B8=B2?= =?UTF-8?q?=E6=9F=93=20assistant=20=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前 console.print(f"...{content}") 只解析 [tag] 标签,不识别 **bold**、表格、列表 等 markdown 语法,LLM 回复会以原文显示。改成单独打印前缀后再 console.print(Markdown(content))。 Co-Authored-By: Claude Opus 4.7 (1M context) --- core/loop.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/loop.py b/core/loop.py index 95db636..4ca796d 100644 --- a/core/loop.py +++ b/core/loop.py @@ -5,6 +5,7 @@ import json from typing import Any, Dict, Optional from rich.console import Console +from rich.markdown import Markdown from .capabilities import ModelCapabilities from .llm import LLM @@ -44,7 +45,8 @@ class AgentLoop: tool_calls = getattr(msg, "tool_calls", None) or [] content = getattr(msg, "content", None) if content: - self.console.print(f"[cyan]assistant>[/cyan] {content}") + self.console.print("[cyan]assistant>[/cyan]") + self.console.print(Markdown(content)) if not tool_calls: return content or ""