ripperdoc 0.2.6__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. ripperdoc/__init__.py +3 -0
  2. ripperdoc/__main__.py +20 -0
  3. ripperdoc/cli/__init__.py +1 -0
  4. ripperdoc/cli/cli.py +405 -0
  5. ripperdoc/cli/commands/__init__.py +82 -0
  6. ripperdoc/cli/commands/agents_cmd.py +263 -0
  7. ripperdoc/cli/commands/base.py +19 -0
  8. ripperdoc/cli/commands/clear_cmd.py +18 -0
  9. ripperdoc/cli/commands/compact_cmd.py +23 -0
  10. ripperdoc/cli/commands/config_cmd.py +31 -0
  11. ripperdoc/cli/commands/context_cmd.py +144 -0
  12. ripperdoc/cli/commands/cost_cmd.py +82 -0
  13. ripperdoc/cli/commands/doctor_cmd.py +221 -0
  14. ripperdoc/cli/commands/exit_cmd.py +19 -0
  15. ripperdoc/cli/commands/help_cmd.py +20 -0
  16. ripperdoc/cli/commands/mcp_cmd.py +70 -0
  17. ripperdoc/cli/commands/memory_cmd.py +202 -0
  18. ripperdoc/cli/commands/models_cmd.py +413 -0
  19. ripperdoc/cli/commands/permissions_cmd.py +302 -0
  20. ripperdoc/cli/commands/resume_cmd.py +98 -0
  21. ripperdoc/cli/commands/status_cmd.py +167 -0
  22. ripperdoc/cli/commands/tasks_cmd.py +278 -0
  23. ripperdoc/cli/commands/todos_cmd.py +69 -0
  24. ripperdoc/cli/commands/tools_cmd.py +19 -0
  25. ripperdoc/cli/ui/__init__.py +1 -0
  26. ripperdoc/cli/ui/context_display.py +298 -0
  27. ripperdoc/cli/ui/helpers.py +22 -0
  28. ripperdoc/cli/ui/rich_ui.py +1557 -0
  29. ripperdoc/cli/ui/spinner.py +49 -0
  30. ripperdoc/cli/ui/thinking_spinner.py +128 -0
  31. ripperdoc/cli/ui/tool_renderers.py +298 -0
  32. ripperdoc/core/__init__.py +1 -0
  33. ripperdoc/core/agents.py +486 -0
  34. ripperdoc/core/commands.py +33 -0
  35. ripperdoc/core/config.py +559 -0
  36. ripperdoc/core/default_tools.py +88 -0
  37. ripperdoc/core/permissions.py +252 -0
  38. ripperdoc/core/providers/__init__.py +47 -0
  39. ripperdoc/core/providers/anthropic.py +250 -0
  40. ripperdoc/core/providers/base.py +265 -0
  41. ripperdoc/core/providers/gemini.py +615 -0
  42. ripperdoc/core/providers/openai.py +487 -0
  43. ripperdoc/core/query.py +1058 -0
  44. ripperdoc/core/query_utils.py +622 -0
  45. ripperdoc/core/skills.py +295 -0
  46. ripperdoc/core/system_prompt.py +431 -0
  47. ripperdoc/core/tool.py +240 -0
  48. ripperdoc/sdk/__init__.py +9 -0
  49. ripperdoc/sdk/client.py +333 -0
  50. ripperdoc/tools/__init__.py +1 -0
  51. ripperdoc/tools/ask_user_question_tool.py +431 -0
  52. ripperdoc/tools/background_shell.py +389 -0
  53. ripperdoc/tools/bash_output_tool.py +98 -0
  54. ripperdoc/tools/bash_tool.py +1016 -0
  55. ripperdoc/tools/dynamic_mcp_tool.py +428 -0
  56. ripperdoc/tools/enter_plan_mode_tool.py +226 -0
  57. ripperdoc/tools/exit_plan_mode_tool.py +153 -0
  58. ripperdoc/tools/file_edit_tool.py +346 -0
  59. ripperdoc/tools/file_read_tool.py +203 -0
  60. ripperdoc/tools/file_write_tool.py +205 -0
  61. ripperdoc/tools/glob_tool.py +179 -0
  62. ripperdoc/tools/grep_tool.py +370 -0
  63. ripperdoc/tools/kill_bash_tool.py +136 -0
  64. ripperdoc/tools/ls_tool.py +471 -0
  65. ripperdoc/tools/mcp_tools.py +591 -0
  66. ripperdoc/tools/multi_edit_tool.py +456 -0
  67. ripperdoc/tools/notebook_edit_tool.py +386 -0
  68. ripperdoc/tools/skill_tool.py +205 -0
  69. ripperdoc/tools/task_tool.py +379 -0
  70. ripperdoc/tools/todo_tool.py +494 -0
  71. ripperdoc/tools/tool_search_tool.py +380 -0
  72. ripperdoc/utils/__init__.py +1 -0
  73. ripperdoc/utils/bash_constants.py +51 -0
  74. ripperdoc/utils/bash_output_utils.py +43 -0
  75. ripperdoc/utils/coerce.py +34 -0
  76. ripperdoc/utils/context_length_errors.py +252 -0
  77. ripperdoc/utils/exit_code_handlers.py +241 -0
  78. ripperdoc/utils/file_watch.py +135 -0
  79. ripperdoc/utils/git_utils.py +274 -0
  80. ripperdoc/utils/json_utils.py +27 -0
  81. ripperdoc/utils/log.py +176 -0
  82. ripperdoc/utils/mcp.py +560 -0
  83. ripperdoc/utils/memory.py +253 -0
  84. ripperdoc/utils/message_compaction.py +676 -0
  85. ripperdoc/utils/messages.py +519 -0
  86. ripperdoc/utils/output_utils.py +258 -0
  87. ripperdoc/utils/path_ignore.py +677 -0
  88. ripperdoc/utils/path_utils.py +46 -0
  89. ripperdoc/utils/permissions/__init__.py +27 -0
  90. ripperdoc/utils/permissions/path_validation_utils.py +174 -0
  91. ripperdoc/utils/permissions/shell_command_validation.py +552 -0
  92. ripperdoc/utils/permissions/tool_permission_utils.py +279 -0
  93. ripperdoc/utils/prompt.py +17 -0
  94. ripperdoc/utils/safe_get_cwd.py +31 -0
  95. ripperdoc/utils/sandbox_utils.py +38 -0
  96. ripperdoc/utils/session_history.py +260 -0
  97. ripperdoc/utils/session_usage.py +117 -0
  98. ripperdoc/utils/shell_token_utils.py +95 -0
  99. ripperdoc/utils/shell_utils.py +159 -0
  100. ripperdoc/utils/todo.py +203 -0
  101. ripperdoc/utils/token_estimation.py +34 -0
  102. ripperdoc-0.2.6.dist-info/METADATA +193 -0
  103. ripperdoc-0.2.6.dist-info/RECORD +107 -0
  104. ripperdoc-0.2.6.dist-info/WHEEL +5 -0
  105. ripperdoc-0.2.6.dist-info/entry_points.txt +3 -0
  106. ripperdoc-0.2.6.dist-info/licenses/LICENSE +53 -0
  107. ripperdoc-0.2.6.dist-info/top_level.txt +1 -0
@@ -0,0 +1,379 @@
1
+ """Task tool that delegates work to configured subagents."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import time
6
+ from typing import Any, AsyncGenerator, Callable, Dict, Iterable, List, Optional
7
+
8
+ from pydantic import BaseModel, Field
9
+
10
+ from ripperdoc.core.agents import (
11
+ AgentDefinition,
12
+ AgentLoadResult,
13
+ FILE_EDIT_TOOL_NAME,
14
+ GREP_TOOL_NAME,
15
+ VIEW_TOOL_NAME,
16
+ clear_agent_cache,
17
+ load_agent_definitions,
18
+ resolve_agent_tools,
19
+ summarize_agent,
20
+ )
21
+ from ripperdoc.core.query import QueryContext, query
22
+ from ripperdoc.core.system_prompt import build_environment_prompt
23
+ from ripperdoc.core.tool import Tool, ToolOutput, ToolProgress, ToolResult, ToolUseContext
24
+ from ripperdoc.utils.messages import AssistantMessage, create_user_message
25
+ from ripperdoc.utils.log import get_logger
26
+
27
+ logger = get_logger()
28
+
29
+
30
+ class TaskToolInput(BaseModel):
31
+ """Input schema for delegating to a subagent."""
32
+
33
+ prompt: str = Field(description="Detailed task description for the subagent to perform")
34
+ subagent_type: str = Field(description="Agent type to run (matches agent frontmatter name)")
35
+
36
+
37
+ class TaskToolOutput(BaseModel):
38
+ """Summary of a completed subagent run."""
39
+
40
+ agent_type: str
41
+ result_text: str
42
+ duration_ms: float
43
+ tool_use_count: int
44
+ missing_tools: List[str] = Field(default_factory=list)
45
+ model_used: Optional[str] = None
46
+
47
+
48
+ class TaskTool(Tool[TaskToolInput, TaskToolOutput]):
49
+ """Launches a configured agent in a fresh context."""
50
+
51
+ def __init__(self, available_tools_provider: Callable[[], Iterable[Tool[Any, Any]]]) -> None:
52
+ super().__init__()
53
+ self._available_tools_provider = available_tools_provider
54
+
55
+ @property
56
+ def name(self) -> str:
57
+ return "Task"
58
+
59
+ async def description(self) -> str:
60
+ clear_agent_cache()
61
+ agents = load_agent_definitions()
62
+ agent_lines = "\n".join(summarize_agent(agent) for agent in agents.active_agents)
63
+ return (
64
+ "Launch a specialized subagent in its own context window to handle a task.\n"
65
+ f"Available agents:\n{agent_lines or '- general-purpose (built-in)'}"
66
+ )
67
+
68
+ @property
69
+ def input_schema(self) -> type[TaskToolInput]:
70
+ return TaskToolInput
71
+
72
+ async def prompt(self, safe_mode: bool = False) -> str:
73
+ del safe_mode
74
+ clear_agent_cache()
75
+ agents: AgentLoadResult = load_agent_definitions()
76
+
77
+ agent_lines: List[str] = []
78
+ for agent in agents.active_agents:
79
+ properties = (
80
+ "Properties: access to current context; "
81
+ if getattr(agent, "fork_context", False)
82
+ else ""
83
+ )
84
+ tools_label = "All tools"
85
+ if getattr(agent, "tools", None):
86
+ tools_label = "All tools" if "*" in agent.tools else ", ".join(agent.tools)
87
+ agent_lines.append(
88
+ f"- {agent.agent_type}: {agent.when_to_use} ({properties}Tools: {tools_label})"
89
+ )
90
+
91
+ agent_block = "\n".join(agent_lines) or "- general-purpose (built-in)"
92
+
93
+ task_tool_name = self.name
94
+ file_read_tool_name = VIEW_TOOL_NAME
95
+ search_tool_name = GREP_TOOL_NAME
96
+ code_tool_name = FILE_EDIT_TOOL_NAME
97
+ background_fetch_tool_name = task_tool_name
98
+
99
+ return (
100
+ f"Launch a new agent to handle complex, multi-step tasks autonomously. \n\n"
101
+ f"The {task_tool_name} tool launches specialized agents (subprocesses) that autonomously handle complex tasks. Each agent type has specific capabilities and tools available to it.\n\n"
102
+ f"Available agent types and the tools they have access to:\n"
103
+ f"{agent_block}\n\n"
104
+ f"When using the {task_tool_name} tool, you must specify a subagent_type parameter to select which agent type to use.\n\n"
105
+ f"When NOT to use the {task_tool_name} tool:\n"
106
+ f"- If you want to read a specific file path, use the {file_read_tool_name} or {search_tool_name} tool instead of the {task_tool_name} tool, to find the match more quickly\n"
107
+ f'- If you are searching for a specific class definition like "class Foo", use the {search_tool_name} tool instead, to find the match more quickly\n'
108
+ f"- If you are searching for code within a specific file or set of 2-3 files, use the {file_read_tool_name} tool instead of the {task_tool_name} tool, to find the match more quickly\n"
109
+ "- Other tasks that are not related to the agent descriptions above\n"
110
+ "\n"
111
+ "\n"
112
+ "Usage notes:\n"
113
+ "- Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses\n"
114
+ "- When the agent is done, it will return a single message back to you. The result returned by the agent is not visible to the user. To show the user the result, you should send a text message back to the user with a concise summary of the result.\n"
115
+ f"- You can optionally run agents in the background using the run_in_background parameter. When an agent runs in the background, you will need to use {background_fetch_tool_name} to retrieve its results once it's done. You can continue to work while background agents run - When you need their results to continue you can use {background_fetch_tool_name} in blocking mode to pause and wait for their results.\n"
116
+ "- Agents can be resumed using the `resume` parameter by passing the agent ID from a previous invocation. When resumed, the agent continues with its full previous context preserved. When NOT resuming, each invocation starts fresh and you should provide a detailed task description with all necessary context.\n"
117
+ "- When the agent is done, it will return a single message back to you along with its agent ID. You can use this ID to resume the agent later if needed for follow-up work.\n"
118
+ "- Provide clear, detailed prompts so the agent can work autonomously and return exactly the information you need.\n"
119
+ '- Agents with "access to current context" can see the full conversation history before the tool call. When using these agents, you can write concise prompts that reference earlier context (e.g., "investigate the error discussed above") instead of repeating information. The agent will receive all prior messages and understand the context.\n'
120
+ "- The agent's outputs should generally be trusted\n"
121
+ "- Clearly tell the agent whether you expect it to write code or just to do research (search, file reads, web fetches, etc.), since it is not aware of the user's intent\n"
122
+ "- If the agent description mentions that it should be used proactively, then you should try your best to use it without the user having to ask for it first. Use your judgement.\n"
123
+ f'- If the user specifies that they want you to run agents "in parallel", you MUST send a single message with multiple {task_tool_name} tool use content blocks. For example, if you need to launch both a code-reviewer agent and a test-runner agent in parallel, send a single message with both tool calls.\n'
124
+ "\n"
125
+ "Example usage:\n"
126
+ "\n"
127
+ "<example_agent_descriptions>\n"
128
+ '"code-reviewer": use this agent after you are done writing a signficant piece of code\n'
129
+ '"greeting-responder": use this agent when to respond to user greetings with a friendly joke\n'
130
+ "</example_agent_description>\n"
131
+ "\n"
132
+ "<example>\n"
133
+ 'user: "Please write a function that checks if a number is prime"\n'
134
+ "assistant: Sure let me write a function that checks if a number is prime\n"
135
+ f"assistant: First let me use the {code_tool_name} tool to write a function that checks if a number is prime\n"
136
+ f"assistant: I'm going to use the {code_tool_name} tool to write the following code:\n"
137
+ "<code>\n"
138
+ "function isPrime(n) {\n"
139
+ " if (n <= 1) return false\n"
140
+ " for (let i = 2; i * i <= n; i++) {\n"
141
+ " if (n % i === 0) return false\n"
142
+ " }\n"
143
+ " return true\n"
144
+ "}\n"
145
+ "</code>\n"
146
+ "<commentary>\n"
147
+ "Since a signficant piece of code was written and the task was completed, now use the code-reviewer agent to review the code\n"
148
+ "</commentary>\n"
149
+ "assistant: Now let me use the code-reviewer agent to review the code\n"
150
+ f"assistant: Uses the {task_tool_name} tool to launch the code-reviewer agent \n"
151
+ "</example>\n"
152
+ "\n"
153
+ "<example>\n"
154
+ 'user: "Hello"\n'
155
+ "<commentary>\n"
156
+ "Since the user is greeting, use the greeting-responder agent to respond with a friendly joke\n"
157
+ "</commentary>\n"
158
+ f'assistant: "I\'m going to use the {task_tool_name} tool to launch the greeting-responder agent"\n'
159
+ "</example>"
160
+ )
161
+
162
+ def is_read_only(self) -> bool:
163
+ return True
164
+
165
+ def is_concurrency_safe(self) -> bool:
166
+ return True
167
+
168
+ def render_result_for_assistant(self, output: TaskToolOutput) -> str:
169
+ details: List[str] = []
170
+ if output.tool_use_count:
171
+ details.append(f"{output.tool_use_count} tool uses")
172
+ details.append(f"{output.duration_ms / 1000:.1f}s")
173
+ if output.missing_tools:
174
+ details.append(f"missing tools: {', '.join(output.missing_tools)}")
175
+
176
+ suffix = f" ({'; '.join(details)})" if details else ""
177
+ return f"[subagent:{output.agent_type}] {output.result_text}{suffix}"
178
+
179
+ def render_tool_use_message(self, input_data: TaskToolInput, verbose: bool = False) -> str:
180
+ del verbose
181
+ return f"Task via {input_data.subagent_type}: {input_data.prompt}"
182
+
183
+ async def call(
184
+ self,
185
+ input_data: TaskToolInput,
186
+ context: ToolUseContext,
187
+ ) -> AsyncGenerator[ToolOutput, None]:
188
+ clear_agent_cache()
189
+ agents = load_agent_definitions()
190
+ target_agent = next(
191
+ (
192
+ agent
193
+ for agent in agents.active_agents
194
+ if agent.agent_type == input_data.subagent_type
195
+ ),
196
+ None,
197
+ )
198
+ if not target_agent:
199
+ raise ValueError(
200
+ f"Agent type '{input_data.subagent_type}' not found. "
201
+ f"Available agents: {', '.join(agent.agent_type for agent in agents.active_agents)}"
202
+ )
203
+
204
+ available_tools = list(self._available_tools_provider())
205
+ agent_tools, missing_tools = resolve_agent_tools(target_agent, available_tools, self.name)
206
+ if not agent_tools:
207
+ raise ValueError(
208
+ f"Agent '{target_agent.agent_type}' has no usable tools. "
209
+ f"Missing or unknown tools: {', '.join(missing_tools) if missing_tools else 'none'}"
210
+ )
211
+
212
+ # Type conversion: List[object] -> List[Tool[Any, Any]]
213
+ from ripperdoc.core.tool import Tool
214
+
215
+ typed_agent_tools: List[Tool[Any, Any]] = [
216
+ tool for tool in agent_tools if isinstance(tool, Tool)
217
+ ]
218
+
219
+ agent_system_prompt = self._build_agent_prompt(target_agent, typed_agent_tools)
220
+ subagent_messages = [create_user_message(input_data.prompt)]
221
+
222
+ subagent_context = QueryContext(
223
+ tools=typed_agent_tools,
224
+ safe_mode=context.safe_mode,
225
+ verbose=context.verbose,
226
+ model=target_agent.model or "task",
227
+ )
228
+
229
+ start = time.time()
230
+ assistant_messages: List[AssistantMessage] = []
231
+ tool_use_count = 0
232
+
233
+ yield ToolProgress(content=f"Launching subagent '{target_agent.agent_type}'")
234
+
235
+ async for message in query(
236
+ subagent_messages, # type: ignore[arg-type]
237
+ agent_system_prompt,
238
+ {},
239
+ subagent_context,
240
+ context.permission_checker,
241
+ ):
242
+ if getattr(message, "type", "") == "assistant":
243
+ # Surface subagent tool requests as progress so the user sees activity.
244
+ msg_content = getattr(message, "message", None)
245
+ blocks = getattr(msg_content, "content", []) if msg_content else []
246
+ if isinstance(blocks, list):
247
+ for block in blocks:
248
+ block_type = getattr(block, "type", None) or (
249
+ block.get("type") if isinstance(block, Dict) else None
250
+ )
251
+ if block_type == "tool_use":
252
+ tool_name = getattr(block, "name", None) or (
253
+ block.get("name") if isinstance(block, Dict) else "unknown tool"
254
+ )
255
+ block_input = (
256
+ getattr(block, "input", None)
257
+ if hasattr(block, "input")
258
+ else (block.get("input") if isinstance(block, Dict) else None)
259
+ )
260
+ summary = self._summarize_tool_input(block_input)
261
+ label = f"Subagent requesting {tool_name}"
262
+ if summary:
263
+ label += f" — {summary}"
264
+ yield ToolProgress(content=label)
265
+ if block_type == "text":
266
+ text_val = getattr(block, "text", None) or (
267
+ block.get("text") if isinstance(block, Dict) else ""
268
+ )
269
+ if text_val:
270
+ snippet = str(text_val).strip()
271
+ if snippet:
272
+ short = (
273
+ snippet if len(snippet) <= 200 else snippet[:197] + "..."
274
+ )
275
+ yield ToolProgress(content=f"Subagent: {short}")
276
+ assistant_messages.append(message) # type: ignore[arg-type]
277
+ if isinstance(message, AssistantMessage):
278
+ tool_use_count += self._count_tool_uses(message)
279
+
280
+ duration_ms = (time.time() - start) * 1000
281
+ result_text = (
282
+ self._extract_text(assistant_messages[-1])
283
+ if assistant_messages
284
+ else "Agent returned no response."
285
+ )
286
+
287
+ output = TaskToolOutput(
288
+ agent_type=target_agent.agent_type,
289
+ result_text=result_text.strip(),
290
+ duration_ms=duration_ms,
291
+ tool_use_count=tool_use_count,
292
+ missing_tools=missing_tools,
293
+ model_used=target_agent.model or "task",
294
+ )
295
+
296
+ yield ToolResult(data=output, result_for_assistant=self.render_result_for_assistant(output))
297
+
298
+ def _build_agent_prompt(self, agent: AgentDefinition, tools: List[Tool[Any, Any]]) -> str:
299
+ tool_names = ", ".join(tool.name for tool in tools if getattr(tool, "name", None))
300
+ guidance = (
301
+ "You are a specialized Ripperdoc subagent working autonomously. "
302
+ "Execute the task completely using the allowed tools. "
303
+ "Return a single, concise summary for the parent agent that includes what you did, "
304
+ "important findings, and any follow-ups. Do not ask the user questions."
305
+ )
306
+ sections = [
307
+ guidance,
308
+ f"Agent type: {agent.agent_type}",
309
+ f"When to use: {agent.when_to_use}",
310
+ f"Allowed tools: {tool_names}",
311
+ "Agent system prompt:",
312
+ agent.system_prompt or "(no additional prompt)",
313
+ build_environment_prompt(),
314
+ ]
315
+ return "\n\n".join(sections)
316
+
317
+ def _extract_text(self, message: AssistantMessage) -> str:
318
+ content = message.message.content
319
+ if isinstance(content, str):
320
+ return content
321
+ if isinstance(content, list):
322
+ parts: List[str] = []
323
+ for block in content:
324
+ text = getattr(block, "text", None) or (
325
+ block.get("text") if isinstance(block, Dict) else None
326
+ )
327
+ if text:
328
+ parts.append(str(text))
329
+ return "\n".join(parts)
330
+ return ""
331
+
332
+ def _count_tool_uses(self, message: AssistantMessage) -> int:
333
+ content = message.message.content
334
+ if not isinstance(content, list):
335
+ return 0
336
+ count = 0
337
+ for block in content:
338
+ block_type = getattr(block, "type", None) or (
339
+ block.get("type") if isinstance(block, Dict) else None
340
+ )
341
+ if block_type == "tool_use":
342
+ count += 1
343
+ return count
344
+
345
+ def _summarize_tool_input(self, inp: Any) -> str:
346
+ """Generate a short human-readable summary of a tool_use input."""
347
+ if not inp or not isinstance(inp, (dict, Dict)):
348
+ return ""
349
+
350
+ pieces: List[str] = []
351
+ # Prioritize common keys
352
+ for key in ("command", "file_path", "path", "glob", "pattern", "description", "prompt"):
353
+ if key in inp and inp[key]:
354
+ val = str(inp[key])
355
+ short = val if len(val) <= 80 else val[:77] + "..."
356
+ pieces.append(f"{key}={short}")
357
+
358
+ # Include range info if present
359
+ start = inp.get("start_line") or inp.get("offset")
360
+ end = inp.get("end_line") or inp.get("limit")
361
+ if start is not None or end is not None:
362
+ pieces.append(f"range={start or 0}-{end or '…'}")
363
+
364
+ if not pieces:
365
+ # Fallback to truncated dict representation
366
+ import json
367
+
368
+ try:
369
+ serialized = json.dumps(inp, ensure_ascii=False)
370
+ except (TypeError, ValueError) as exc:
371
+ logger.warning(
372
+ "[task_tool] Failed to serialize tool_use input: %s: %s",
373
+ type(exc).__name__, exc,
374
+ extra={"tool_use_input": str(inp)[:200]},
375
+ )
376
+ serialized = str(inp)
377
+ return serialized if len(serialized) <= 120 else serialized[:117] + "..."
378
+
379
+ return ", ".join(pieces)