update
This commit is contained in:
@@ -62,7 +62,7 @@ def _format_single_todo(item: dict) -> Text:
|
|||||||
line.append(" ", style="dim")
|
line.append(" ", style="dim")
|
||||||
# Truncate long content
|
# Truncate long content
|
||||||
if len(content_text) > 60:
|
if len(content_text) > 60:
|
||||||
content_text = content_text[:57] + "..."
|
content_text = content_text[:57] + "\u2026"
|
||||||
line.append(content_text, style=style)
|
line.append(content_text, style=style)
|
||||||
return line
|
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):
|
for i, line in enumerate(display_lines):
|
||||||
prefix = "\u2514" if i == 0 else " "
|
prefix = "\u2514" if i == 0 else " "
|
||||||
if len(line) > 80:
|
if len(line) > 80:
|
||||||
line = line[:77] + "..."
|
line = line[:77] + "\u2026"
|
||||||
style = "dim" if is_success(content) else "red dim"
|
style = "dim" if is_success(content) else "red dim"
|
||||||
elements.append(Text(f" {prefix} {line}", style=style))
|
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
|
# Build display name
|
||||||
display_name = f"Cooking with {sa.name}"
|
display_name = f"Cooking with {sa.name}"
|
||||||
if sa.description:
|
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}"
|
display_name += f" \u2014 {desc}"
|
||||||
|
|
||||||
# --- Compact mode: 1-line summary for completed sub-agents ---
|
# --- Compact mode: 1-line summary for completed sub-agents ---
|
||||||
@@ -415,8 +416,8 @@ def create_streaming_display(
|
|||||||
if preview:
|
if preview:
|
||||||
last_line = preview.split("\n")[-1].strip()
|
last_line = preview.split("\n")[-1].strip()
|
||||||
if last_line:
|
if last_line:
|
||||||
if len(last_line) > 80:
|
if len(last_line) > 60:
|
||||||
last_line = last_line[:77] + "..."
|
last_line = last_line[:57] + "\u2026"
|
||||||
elements.append(Text(f" {last_line}", style="dim italic"))
|
elements.append(Text(f" {last_line}", style="dim italic"))
|
||||||
|
|
||||||
# Task List panel (persistent, updates on write_todos / read_todos)
|
# Task List panel (persistent, updates on write_todos / read_todos)
|
||||||
@@ -521,8 +522,12 @@ def display_final_results(
|
|||||||
console.print()
|
console.print()
|
||||||
|
|
||||||
if state.response_text:
|
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()
|
||||||
console.print(Markdown(state.response_text))
|
console.print(Markdown(clean_response or state.response_text))
|
||||||
console.print()
|
console.print()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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()
|
sa_name = str(args.get("subagent_type", "")).strip()
|
||||||
if not sa_name:
|
if not sa_name:
|
||||||
# Fallback to description snippet (may be empty during streaming)
|
# 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:
|
if not sa_name:
|
||||||
sa_name = "sub-agent"
|
sa_name = "sub-agent"
|
||||||
|
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ def format_tool_compact(name: str, args: dict | None) -> str:
|
|||||||
if name_lower == "execute":
|
if name_lower == "execute":
|
||||||
cmd = args.get("command", "")
|
cmd = args.get("command", "")
|
||||||
if len(cmd) > 50:
|
if len(cmd) > 50:
|
||||||
cmd = cmd[:47] + "..."
|
cmd = cmd[:47] + "\u2026"
|
||||||
return f"execute({cmd})"
|
return f"execute({cmd})"
|
||||||
|
|
||||||
# File operations
|
# File operations
|
||||||
@@ -134,14 +134,14 @@ def format_tool_compact(name: str, args: dict | None) -> str:
|
|||||||
if name_lower == "glob":
|
if name_lower == "glob":
|
||||||
pattern = args.get("pattern", "")
|
pattern = args.get("pattern", "")
|
||||||
if len(pattern) > 40:
|
if len(pattern) > 40:
|
||||||
pattern = pattern[:37] + "..."
|
pattern = pattern[:37] + "\u2026"
|
||||||
return f"glob({pattern})"
|
return f"glob({pattern})"
|
||||||
|
|
||||||
if name_lower == "grep":
|
if name_lower == "grep":
|
||||||
pattern = args.get("pattern", "")
|
pattern = args.get("pattern", "")
|
||||||
path = args.get("path", ".")
|
path = args.get("path", ".")
|
||||||
if len(pattern) > 30:
|
if len(pattern) > 30:
|
||||||
pattern = pattern[:27] + "..."
|
pattern = pattern[:27] + "\u2026"
|
||||||
return f"grep({pattern}, {path})"
|
return f"grep({pattern}, {path})"
|
||||||
|
|
||||||
# Directory listing
|
# Directory listing
|
||||||
@@ -163,16 +163,17 @@ def format_tool_compact(name: str, args: dict | None) -> str:
|
|||||||
if name_lower == "task":
|
if name_lower == "task":
|
||||||
sa_type = args.get("subagent_type", "").strip()
|
sa_type = args.get("subagent_type", "").strip()
|
||||||
task_desc = args.get("description", args.get("task", "")).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 sa_type:
|
||||||
if task_desc:
|
if task_desc:
|
||||||
if len(task_desc) > 50:
|
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} — {task_desc}"
|
||||||
return f"Cooking with {sa_type}"
|
return f"Cooking with {sa_type}"
|
||||||
# Fallback if no subagent_type
|
# Fallback if no subagent_type
|
||||||
if task_desc:
|
if task_desc:
|
||||||
if len(task_desc) > 50:
|
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 f"Cooking with sub-agent — {task_desc}"
|
||||||
return "Cooking with sub-agent"
|
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"):
|
if name_lower in ("tavily_search", "internet_search"):
|
||||||
query = args.get("query", "")
|
query = args.get("query", "")
|
||||||
if len(query) > 40:
|
if len(query) > 40:
|
||||||
query = query[:37] + "..."
|
query = query[:37] + "\u2026"
|
||||||
return f"{name}({query})"
|
return f"{name}({query})"
|
||||||
|
|
||||||
# Think/reflection
|
# Think/reflection
|
||||||
if name_lower == "think_tool":
|
if name_lower == "think_tool":
|
||||||
reflection = args.get("reflection", "")
|
reflection = args.get("reflection", "")
|
||||||
if len(reflection) > 40:
|
if len(reflection) > 40:
|
||||||
reflection = reflection[:37] + "..."
|
reflection = reflection[:37] + "\u2026"
|
||||||
return f"think_tool({reflection})"
|
return f"think_tool({reflection})"
|
||||||
|
|
||||||
# Default: show first few params
|
# 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]:
|
for k, v in list(args.items())[:2]:
|
||||||
v_str = str(v)
|
v_str = str(v)
|
||||||
if len(v_str) > 20:
|
if len(v_str) > 20:
|
||||||
v_str = v_str[:17] + "..."
|
v_str = v_str[:17] + "\u2026"
|
||||||
params.append(f"{k}={v_str}")
|
params.append(f"{k}={v_str}")
|
||||||
|
|
||||||
params_str = ", ".join(params)
|
params_str = ", ".join(params)
|
||||||
if len(params_str) > 50:
|
if len(params_str) > 50:
|
||||||
params_str = params_str[:47] + "..."
|
params_str = params_str[:47] + "\u2026"
|
||||||
|
|
||||||
return f"{name}({params_str})"
|
return f"{name}({params_str})"
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class TestFormatToolCompact:
|
|||||||
long_cmd = "x" * 60
|
long_cmd = "x" * 60
|
||||||
result = format_tool_compact("execute", {"command": long_cmd})
|
result = format_tool_compact("execute", {"command": long_cmd})
|
||||||
assert len(result) < 70
|
assert len(result) < 70
|
||||||
assert result.endswith("...)")
|
assert result.endswith("\u2026)")
|
||||||
|
|
||||||
def test_read_file(self):
|
def test_read_file(self):
|
||||||
result = format_tool_compact("read_file", {"path": "src/main.py"})
|
result = format_tool_compact("read_file", {"path": "src/main.py"})
|
||||||
@@ -128,7 +128,7 @@ class TestFormatToolCompact:
|
|||||||
|
|
||||||
def test_unknown_tool_long_value(self):
|
def test_unknown_tool_long_value(self):
|
||||||
result = format_tool_compact("custom_tool", {"key": "a" * 30})
|
result = format_tool_compact("custom_tool", {"key": "a" * 30})
|
||||||
assert "..." in result
|
assert "\u2026" in result
|
||||||
|
|
||||||
|
|
||||||
# === truncate ===
|
# === truncate ===
|
||||||
|
|||||||
Reference in New Issue
Block a user