Skip to content

"Vibe-Trading: Your Personal Trading Agent"

fix(render): drop markdown HR separators and bump valid_sources

Haozhe Wud542038d36c3
diff --git a/agent/cli/ui/transcript.py b/agent/cli/ui/transcript.py
index dc9c137ac..a768155f3 100644
--- a/agent/cli/ui/transcript.py
+++ b/agent/cli/ui/transcript.py
@@ -15,6 +15,9 @@ from rich.text import Text
from cli.theme import Theme
_PIPE_SEPARATOR = re.compile(r"^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)+\|?\s*$")
+# Standalone markdown horizontal rule (---, ***, ___). Stripped from
+# assistant answers so they don't render as full-width terminal lines.
+_HR_LINE = re.compile(r"^\s*(?:-{3,}|\*{3,}|_{3,})\s*$")
_PROMPT_BORDER = "#4b5563"
_MUTED = "#6b7280"
@@ -91,6 +94,11 @@ def render_answer(content: str) -> Group:
else:
pending.extend(table_lines)
continue
+ if _HR_LINE.match(lines[index]):
+ # Drop standalone horizontal rules — Rich renders them as a
+ # full-width terminal line that looks like a separator border.
+ index += 1
+ continue
pending.append(lines[index])
index += 1
diff --git a/agent/src/agent/context.py b/agent/src/agent/context.py
index 042d288a6..9811e352d 100644
--- a/agent/src/agent/context.py
+++ b/agent/src/agent/context.py
@@ -16,7 +16,7 @@ if TYPE_CHECKING:
logger = logging.getLogger(__name__)
-_SYSTEM_PROMPT = """You are a finance research agent with {skill_count} specialist skills, {tool_count} tools, 5 data sources (with auto-fallback), and 29 multi-agent swarm teams.
+_SYSTEM_PROMPT = """You are a finance research agent with {skill_count} specialist skills, {tool_count} tools, 7 data sources (with auto-fallback), and 29 multi-agent swarm teams.
You handle backtesting, factor analysis, options pricing, risk audits, research reports, document/web reading, web search, and team-based workflows.
## Tools
@@ -71,7 +71,8 @@ Decide which workflow to use based on the request:
- Load the relevant skill BEFORE starting any task. Skills contain the exact API contracts and examples.
- Ask the user if critical info is missing (assets, dates, strategy type). Never guess.
-- Output results as markdown tables. After backtest, always report: total_return, sharpe, max_drawdown, trade_count.
+- Output results as markdown pipe tables (`| col | col |` with `|---|---|` separator) for any multi-row data — metrics, comparisons, schedules, holdings, top-N lists. Renderers upgrade these to native tables. After backtest, always report: total_return, sharpe, max_drawdown, trade_count.
+- Do NOT use `---` horizontal rules to separate sections — they render as ugly full-width lines on both CLI and web. Use `##` / `###` markdown headings instead.
- All file paths are relative to run_dir (auto-injected).
- Respond in the same language the user used.
- You have persistent cross-session memory (`remember` tool). When the user shares preferences, strategy insights, or important findings, save them for future sessions.
diff --git a/agent/src/tools/backtest_tool.py b/agent/src/tools/backtest_tool.py
index 30ed764c9..c224e9745 100644
--- a/agent/src/tools/backtest_tool.py
+++ b/agent/src/tools/backtest_tool.py
@@ -38,7 +38,7 @@ def run_backtest(run_dir: str) -> str:
if "source" not in config:
return json.dumps({"status": "error", "error": "config.json missing 'source' field (tushare/okx/yfinance)"}, ensure_ascii=False)
- valid_sources = {"tushare", "okx", "yfinance", "akshare", "ccxt", "auto"}
+ valid_sources = {"tushare", "okx", "yfinance", "akshare", "mootdx", "ccxt", "futu", "auto"}
if config["source"] not in valid_sources:
return json.dumps({"status": "error", "error": f"source must be one of {valid_sources}, got: {config['source']}"}, ensure_ascii=False)
diff --git a/agent/tests/test_cli_ui_redesign.py b/agent/tests/test_cli_ui_redesign.py
index 8cb31136e..7f9d634b6 100644
--- a/agent/tests/test_cli_ui_redesign.py
+++ b/agent/tests/test_cli_ui_redesign.py
@@ -143,3 +143,34 @@ def test_answer_renderer_upgrades_markdown_pipe_tables() -> None:
assert "$217.61" in out
assert "Metric" in out
assert "| **Last** | **$217.61** |" not in out
+
+
+def test_answer_renderer_strips_standalone_horizontal_rules() -> None:
+ """`---` HR lines render as ugly full-width terminal lines — drop them."""
+ content = """## Section A
+
+收益指标
+- total_return: 15%
+
+---
+
+## Section B
+
+风险指标
+- max_drawdown: -8%
+
+***
+
+## Section C
+
+更多内容
+"""
+ out = _render(render_answer(content))
+
+ assert "Section A" in out
+ assert "Section B" in out
+ assert "Section C" in out
+ # Rich's HR is rendered with U+2500. After stripping `---` / `***`
+ # standalone lines, no run of three or more box-drawing chars should
+ # appear in the rendered output (table borders are short and bracketed).
+ assert "─" * 10 not in out
diff --git a/frontend/src/components/chat/MessageBubble.tsx b/frontend/src/components/chat/MessageBubble.tsx
index 467b07e8f..adcb1691a 100644
--- a/frontend/src/components/chat/MessageBubble.tsx
+++ b/frontend/src/components/chat/MessageBubble.tsx
@@ -69,7 +69,7 @@ export const MessageBubble = memo(function MessageBubble({ msg, onRetry }: Props
<AgentAvatar />
<div className="flex-1 min-w-0 relative">
<CopyButton text={msg.content} />
- <div className="prose prose-sm dark:prose-invert max-w-none leading-relaxed prose-table:border prose-table:border-border/50 prose-th:bg-muted/30 prose-th:px-3 prose-th:py-1.5 prose-td:px-3 prose-td:py-1.5 prose-th:text-left prose-th:text-xs prose-th:font-medium prose-td:text-xs">
+ <div className="prose prose-sm dark:prose-invert max-w-none leading-relaxed prose-table:border prose-table:border-border/50 prose-th:bg-muted/30 prose-th:px-3 prose-th:py-1.5 prose-td:px-3 prose-td:py-1.5 prose-th:text-left prose-th:text-xs prose-th:font-medium prose-td:text-xs prose-hr:hidden">
<ReactMarkdown remarkPlugins={remarkPlugins} rehypePlugins={rehypePlugins}>{msg.content}</ReactMarkdown>
</div>
{ts && <span className="text-[9px] text-muted-foreground/30 mt-1 opacity-0 group-hover:opacity-100 transition-opacity">{ts}</span>}