Format tool descriptions with file URL usage guide. Jinja2 templates have ~10 lines of "文件链接使用指南" text that must be included here for semantic equivalence. Note: Managed agents use different presigned_url guidance than manager agents.
(
tools: Dict[str, Any],
language: str = "zh",
is_manager: bool = True,
)
| 264 | |
| 265 | |
| 266 | def _format_tools_description( |
| 267 | tools: Dict[str, Any], |
| 268 | language: str = "zh", |
| 269 | is_manager: bool = True, |
| 270 | ) -> str: |
| 271 | """Format tool descriptions with file URL usage guide. |
| 272 | |
| 273 | Jinja2 templates have ~10 lines of "文件链接使用指南" text that must be |
| 274 | included here for semantic equivalence. |
| 275 | |
| 276 | Note: Managed agents use different presigned_url guidance than manager agents. |
| 277 | """ |
| 278 | if not tools: |
| 279 | no_tools_msg = "- 当前没有可用的工具" if language == "zh" else "- No tools are currently available" |
| 280 | prefix = "1. 工具\n" if language == "zh" else "1. Tools\n" |
| 281 | return prefix + no_tools_msg |
| 282 | |
| 283 | lines = [] |
| 284 | |
| 285 | if language == "zh": |
| 286 | lines.append("1. 工具") |
| 287 | else: |
| 288 | lines.append("1. Tools") |
| 289 | |
| 290 | if language == "zh": |
| 291 | lines.append("- 你只能使用以下工具,不得使用任何其他工具:") |
| 292 | else: |
| 293 | lines.append("- You can only use the following tools and may not use any other tools:") |
| 294 | |
| 295 | for name, tool in tools.items(): |
| 296 | if hasattr(tool, 'description'): |
| 297 | desc = tool.description |
| 298 | inputs = tool.inputs |
| 299 | output_type = tool.output_type |
| 300 | source = getattr(tool, 'source', 'local') |
| 301 | else: |
| 302 | desc = tool.get('description', '') |
| 303 | inputs = tool.get('inputs', '') |
| 304 | output_type = tool.get('output_type', '') |
| 305 | source = tool.get('source', 'local') |
| 306 | |
| 307 | # MCP tools have [MCP] prefix |
| 308 | if source == 'mcp': |
| 309 | if language == "zh": |
| 310 | lines.append(f"- [MCP] {name}: {desc}") |
| 311 | lines.append(f" 接受输入: {inputs}") |
| 312 | lines.append(f" 返回输出类型: {output_type}") |
| 313 | else: |
| 314 | lines.append(f"- [MCP] {name}: {desc}") |
| 315 | lines.append(f" Accepts input: {inputs}") |
| 316 | lines.append(f" Returns output type: {output_type}") |
| 317 | else: |
| 318 | if language == "zh": |
| 319 | lines.append(f"- {name}: {desc}") |
| 320 | lines.append(f" 接受输入: {inputs}") |
| 321 | lines.append(f" 返回输出类型: {output_type}") |
| 322 | else: |
| 323 | lines.append(f"- {name}: {desc}") |