Skip to content

Commit db60865

Browse files
committed
improve comments and log message
1 parent 918091e commit db60865

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
lines changed

docs/e2b.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ RUN python3 -m pip install --no-cache-dir \
149149

150150
RUN apt-get update && \
151151
apt-get install -y --no-install-recommends \
152-
# ── 基础构建 & Python ───────────────────────────────
152+
# ── Basic build & Python ───────────────────────────────
153153
build-essential gfortran cmake pkg-config git curl wget ca-certificates \
154154
# ── scientific computing ───────────────────────────────────────
155155
libopenblas-dev liblapack-dev libatlas-base-dev \

libs/miroflow-tool/src/miroflow/tool/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ Add your tool configuration to `mirage/apps/reorg-modular-structure/src/mirage_a
108108

109109
```python
110110
def create_mcp_server_parameters(cfg: DictConfig, agent_cfg: DictConfig):
111-
"""定义并返回 MCP 服务器配置列表"""
111+
"""Define and return MCP server configuration list"""
112112
configs = []
113113

114114
# ... existing code ...

libs/miroflow-tool/src/miroflow/tool/manager.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import functools
77
from typing import Any, Awaitable, Callable, Protocol, TypeVar
88

9-
from mcp import ClientSession, StdioServerParameters # (已在 config.py 导入)
9+
from mcp import ClientSession, StdioServerParameters # (already imported in config.py)
1010
from mcp.client.sse import sse_client
1111
from mcp.client.stdio import stdio_client
1212

@@ -138,7 +138,7 @@ async def _find_servers_with_tool(self, tool_name):
138138
break
139139
else:
140140
logger.error(
141-
f"错误: 服务器 '{server_name}' 的参数类型未知: {type(server_params)}"
141+
f"Error: Unknown parameter type for server '{server_name}': {type(server_params)}"
142142
)
143143
# For unknown types, we skip rather than throw an exception, because this is a search function
144144
continue
@@ -208,7 +208,7 @@ async def get_all_tool_definitions(self):
208208
)
209209
else:
210210
logger.error(
211-
f"错误: 服务器 '{server_name}' 的参数类型未知: {type(server_params)}"
211+
f"Error: Unknown parameter type for server '{server_name}': {type(server_params)}"
212212
)
213213
raise TypeError(
214214
f"Unknown server params type for {server_name}: {type(server_params)}"
@@ -239,18 +239,18 @@ async def execute_tool_call(self, server_name, tool_name, arguments) -> Any:
239239
:return: Dictionary containing result or error
240240
"""
241241

242-
# 原远程服务器调用逻辑
242+
# Original remote server call logic
243243
server_params = self.get_server_params(server_name)
244244
if not server_params:
245-
logger.error(f"错误: 尝试调用未找到的服务器 '{server_name}'")
245+
logger.error(f"Error: Attempting to call server '{server_name}' that was not found")
246246
return {
247247
"server_name": server_name,
248248
"tool_name": tool_name,
249249
"error": f"Server '{server_name}' not found.",
250250
}
251251

252252
logger.info(
253-
f"正在连接到服务器 '{server_name}' 以调用工具 '{tool_name}'...调用参数为'{arguments}'..."
253+
f"Connecting to server '{server_name}' to call tool '{tool_name}'...call arguments: '{arguments}'..."
254254
)
255255

256256
if server_name == "playwright":
@@ -262,10 +262,10 @@ async def execute_tool_call(self, server_name, tool_name, arguments) -> Any:
262262
tool_name, arguments=arguments
263263
)
264264

265-
# 检查结果是否为空并提供更好的反馈
265+
# Check if result is empty and provide better feedback
266266
if tool_result is None or tool_result == "":
267267
logger.error(
268-
f"工具 '{tool_name}' 返回了空结果,可能是正常的(如删除操作)或工具执行有问题"
268+
f"Tool '{tool_name}' returned empty result, this may be normal (such as delete operations) or the tool execution may have issues"
269269
)
270270
return {
271271
"server_name": server_name,
@@ -297,23 +297,23 @@ async def execute_tool_call(self, server_name, tool_name, arguments) -> Any:
297297
tool_result = await session.call_tool(
298298
tool_name, arguments=arguments
299299
)
300-
# 安全地提取结果内容,不改变原始格式
300+
# Safely extract result content without changing original format
301301
if tool_result.content and len(tool_result.content) > 0:
302302
text_content = tool_result.content[-1].text
303303
if (
304304
text_content is not None
305305
and text_content.strip()
306306
):
307-
result_content = text_content # 保留原始格式!
307+
result_content = text_content # Preserve original format!
308308
else:
309309
result_content = f"Tool '{tool_name}' completed but returned empty text - this may be expected or indicate an issue"
310310
else:
311311
result_content = f"Tool '{tool_name}' completed but returned no content - this may be expected or indicate an issue"
312312

313-
# 如果结果为空,记录警告
313+
# If result is empty, log warning
314314
if not tool_result.content:
315315
logger.error(
316-
f"工具 '{tool_name}' 返回了空内容,tool_result.content: {tool_result.content}"
316+
f"Tool '{tool_name}' returned empty content, tool_result.content: {tool_result.content}"
317317
)
318318

319319
# post hoc check for browsing agent reading answers from hf datsets
@@ -338,23 +338,23 @@ async def execute_tool_call(self, server_name, tool_name, arguments) -> Any:
338338
tool_result = await session.call_tool(
339339
tool_name, arguments=arguments
340340
)
341-
# 安全地提取结果内容,不改变原始格式
341+
# Safely extract result content without changing original format
342342
if tool_result.content and len(tool_result.content) > 0:
343343
text_content = tool_result.content[-1].text
344344
if (
345345
text_content is not None
346346
and text_content.strip()
347347
):
348-
result_content = text_content # 保留原始格式!
348+
result_content = text_content # Preserve original format!
349349
else:
350350
result_content = f"Tool '{tool_name}' completed but returned empty text - this may be expected or indicate an issue"
351351
else:
352352
result_content = f"Tool '{tool_name}' completed but returned no content - this may be expected or indicate an issue"
353353

354-
# 如果结果为空,记录警告
354+
# If result is empty, log warning
355355
if not tool_result.content:
356356
logger.error(
357-
f"工具 '{tool_name}' 返回了空内容,tool_result.content: {tool_result.content}"
357+
f"Tool '{tool_name}' returned empty content, tool_result.content: {tool_result.content}"
358358
)
359359

360360
# post hoc check for browsing agent reading answers from hf datsets
@@ -372,20 +372,20 @@ async def execute_tool_call(self, server_name, tool_name, arguments) -> Any:
372372
f"Unknown server params type for {server_name}: {type(server_params)}"
373373
)
374374

375-
logger.info(f"工具 '{tool_name}' (服务器: '{server_name}') 调用成功。")
375+
logger.info(f"Tool '{tool_name}' (server: '{server_name}') called successfully.")
376376

377377
return {
378378
"server_name": server_name,
379379
"tool_name": tool_name,
380-
"result": result_content, # 返回提取的文本内容
380+
"result": result_content, # Return extracted text content
381381
}
382382

383383
except Exception as outer_e: # Rename this to outer_e to avoid shadowing
384384
logger.error(
385-
f"错误: 调用工具 '{tool_name}' (服务器: '{server_name}') 失败: {outer_e}"
385+
f"Error: Failed to call tool '{tool_name}' (server: '{server_name}'): {outer_e}"
386386
)
387387
# import traceback
388-
# traceback.print_exc() # 打印详细堆栈跟踪以进行调试
388+
# traceback.print_exc() # Print detailed stack trace for debugging
389389

390390
# Store the original error message for later use
391391
error_message = str(outer_e)
@@ -397,18 +397,18 @@ async def execute_tool_call(self, server_name, tool_name, arguments) -> Any:
397397
and arguments["url"] is not None
398398
):
399399
try:
400-
logger.info("尝试使用 MarkItDown 进行回退...")
400+
logger.info("Attempting to use MarkItDown for fallback...")
401401
from markitdown import MarkItDown
402402

403403
md = MarkItDown(
404404
docintel_endpoint="<document_intelligence_endpoint>"
405405
)
406406
result = md.convert(arguments["url"])
407-
logger.info("使用 MarkItDown 成功")
407+
logger.info("Successfully used MarkItDown")
408408
return {
409409
"server_name": server_name,
410410
"tool_name": tool_name,
411-
"result": result.text_content, # 返回提取的文本内容
411+
"result": result.text_content, # Return extracted text content
412412
}
413413
except (
414414
Exception

libs/miroflow/src/miroflow/llm/providers/claude_openrouter_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ async def _create_message(
226226
raise ContextLimitError(f"Context limit exceeded: {error_str}")
227227

228228
logger.error(
229-
f"OpenRouter LLM 调用失败: {str(e)}, input = {json.dumps(params)}",
229+
f"OpenRouter LLM call failed: {str(e)}, input = {json.dumps(params)}",
230230
exc_info=True,
231231
)
232232
raise e

libs/miroflow/src/miroflow/prebuilt/orchestrator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ async def run_sub_agent(
547547
# Generate summary_prompt to check token limit
548548
temp_summary_prompt = generate_agent_summarize_prompt(
549549
task_description,
550-
task_failed=True, # 这里设为True,模拟可能的任务失败情况进行context检查
550+
task_failed=True, # Set to True here to simulate potential task failure for context checking
551551
agent_type=sub_agent_name,
552552
)
553553

@@ -556,7 +556,7 @@ async def run_sub_agent(
556556
message_history, temp_summary_prompt
557557
):
558558
# Context estimated to exceed limit, jump to summary stage
559-
task_failed = True # 标记任务失败
559+
task_failed = True # Mark task as failed
560560
self.task_log.log_step(
561561
f"{sub_agent_name}_context_limit_reached",
562562
"Context limit reached, triggering summary",

0 commit comments

Comments
 (0)