From 3eec63a4479d679deb41339ed10434da586cc901 Mon Sep 17 00:00:00 2001 From: X-iZhang Date: Tue, 3 Feb 2026 00:20:45 +0000 Subject: [PATCH] update --- EvoScientist/stream/display.py | 17 +++++++++++------ EvoScientist/stream/events.py | 3 ++- EvoScientist/stream/utils.py | 19 ++++++++++--------- tests/test_stream_utils.py | 4 ++-- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/EvoScientist/stream/display.py b/EvoScientist/stream/display.py index a123d58..850eadb 100644 --- a/EvoScientist/stream/display.py +++ b/EvoScientist/stream/display.py @@ -62,7 +62,7 @@ def _format_single_todo(item: dict) -> Text: line.append(" ", style="dim") # Truncate long content if len(content_text) > 60: - content_text = content_text[:57] + "..." + content_text = content_text[:57] + "\u2026" line.append(content_text, style=style) return line @@ -110,7 +110,7 @@ def format_tool_result_compact(_name: str, content: str, max_lines: int = 5) -> for i, line in enumerate(display_lines): prefix = "\u2514" if i == 0 else " " if len(line) > 80: - line = line[:77] + "..." + line = line[:77] + "\u2026" style = "dim" if is_success(content) else "red dim" elements.append(Text(f" {prefix} {line}", style=style)) @@ -184,7 +184,8 @@ def _render_subagent_section(sa: 'SubAgentState', compact: bool = False) -> list # Build display name display_name = f"Cooking with {sa.name}" if sa.description: - desc = sa.description[:50] + "..." if len(sa.description) > 50 else sa.description + desc = sa.description.split("\n")[0].strip() + desc = desc[:50] + "\u2026" if len(desc) > 50 else desc display_name += f" \u2014 {desc}" # --- Compact mode: 1-line summary for completed sub-agents --- @@ -415,8 +416,8 @@ def create_streaming_display( if preview: last_line = preview.split("\n")[-1].strip() if last_line: - if len(last_line) > 80: - last_line = last_line[:77] + "..." + if len(last_line) > 60: + last_line = last_line[:57] + "\u2026" elements.append(Text(f" {last_line}", style="dim italic")) # Task List panel (persistent, updates on write_todos / read_todos) @@ -521,8 +522,12 @@ def display_final_results( console.print() if state.response_text: + # Strip trailing standalone "..." lines + clean_response = state.response_text.rstrip() + while clean_response.endswith("\n...") or clean_response.rstrip() == "...": + clean_response = clean_response.rstrip().removesuffix("...").rstrip() console.print() - console.print(Markdown(state.response_text)) + console.print(Markdown(clean_response or state.response_text)) console.print() diff --git a/EvoScientist/stream/events.py b/EvoScientist/stream/events.py index 1bb2a5b..9679c1b 100644 --- a/EvoScientist/stream/events.py +++ b/EvoScientist/stream/events.py @@ -51,7 +51,8 @@ async def stream_agent_events(agent: Any, message: str, thread_id: str) -> Async sa_name = str(args.get("subagent_type", "")).strip() if not sa_name: # Fallback to description snippet (may be empty during streaming) - sa_name = desc[:30] + "..." if len(desc) > 30 else desc + sa_name = desc.split("\n")[0].strip() + sa_name = sa_name[:30] + "\u2026" if len(sa_name) > 30 else sa_name if not sa_name: sa_name = "sub-agent" diff --git a/EvoScientist/stream/utils.py b/EvoScientist/stream/utils.py index f1bbc84..1bcf24f 100644 --- a/EvoScientist/stream/utils.py +++ b/EvoScientist/stream/utils.py @@ -114,7 +114,7 @@ def format_tool_compact(name: str, args: dict | None) -> str: if name_lower == "execute": cmd = args.get("command", "") if len(cmd) > 50: - cmd = cmd[:47] + "..." + cmd = cmd[:47] + "\u2026" return f"execute({cmd})" # File operations @@ -134,14 +134,14 @@ def format_tool_compact(name: str, args: dict | None) -> str: if name_lower == "glob": pattern = args.get("pattern", "") if len(pattern) > 40: - pattern = pattern[:37] + "..." + pattern = pattern[:37] + "\u2026" return f"glob({pattern})" if name_lower == "grep": pattern = args.get("pattern", "") path = args.get("path", ".") if len(pattern) > 30: - pattern = pattern[:27] + "..." + pattern = pattern[:27] + "\u2026" return f"grep({pattern}, {path})" # Directory listing @@ -163,16 +163,17 @@ def format_tool_compact(name: str, args: dict | None) -> str: if name_lower == "task": sa_type = args.get("subagent_type", "").strip() task_desc = args.get("description", args.get("task", "")).strip() + task_desc = task_desc.split("\n")[0].strip() if task_desc else "" if sa_type: if task_desc: if len(task_desc) > 50: - task_desc = task_desc[:47] + "..." + task_desc = task_desc[:47] + "\u2026" return f"Cooking with {sa_type} — {task_desc}" return f"Cooking with {sa_type}" # Fallback if no subagent_type if task_desc: if len(task_desc) > 50: - task_desc = task_desc[:47] + "..." + task_desc = task_desc[:47] + "\u2026" return f"Cooking with sub-agent — {task_desc}" return "Cooking with sub-agent" @@ -185,14 +186,14 @@ def format_tool_compact(name: str, args: dict | None) -> str: if name_lower in ("tavily_search", "internet_search"): query = args.get("query", "") if len(query) > 40: - query = query[:37] + "..." + query = query[:37] + "\u2026" return f"{name}({query})" # Think/reflection if name_lower == "think_tool": reflection = args.get("reflection", "") if len(reflection) > 40: - reflection = reflection[:37] + "..." + reflection = reflection[:37] + "\u2026" return f"think_tool({reflection})" # Default: show first few params @@ -200,12 +201,12 @@ def format_tool_compact(name: str, args: dict | None) -> str: for k, v in list(args.items())[:2]: v_str = str(v) if len(v_str) > 20: - v_str = v_str[:17] + "..." + v_str = v_str[:17] + "\u2026" params.append(f"{k}={v_str}") params_str = ", ".join(params) if len(params_str) > 50: - params_str = params_str[:47] + "..." + params_str = params_str[:47] + "\u2026" return f"{name}({params_str})" diff --git a/tests/test_stream_utils.py b/tests/test_stream_utils.py index 829ddd1..f698fff 100644 --- a/tests/test_stream_utils.py +++ b/tests/test_stream_utils.py @@ -51,7 +51,7 @@ class TestFormatToolCompact: long_cmd = "x" * 60 result = format_tool_compact("execute", {"command": long_cmd}) assert len(result) < 70 - assert result.endswith("...)") + assert result.endswith("\u2026)") def test_read_file(self): result = format_tool_compact("read_file", {"path": "src/main.py"}) @@ -128,7 +128,7 @@ class TestFormatToolCompact: def test_unknown_tool_long_value(self): result = format_tool_compact("custom_tool", {"key": "a" * 30}) - assert "..." in result + assert "\u2026" in result # === truncate ===