Skip to content

[问题/Issue] 章节7.4:习题代码 test_react_agent.py 中注册calculate实参顺序错误 #354

@Nikolas-Cao

Description

@Nikolas-Cao

1. 遇到问题的章节 / Affected Chapter

Chapter7.4.2

2. 问题类型 / Issue Type

代码错误 / Code Error

3. 具体问题描述 / Problem Description

# test_react_agent.py
def test_custom_prompt():
    try:
        from hello_agents import calculate
        tool_registry.register_function("calculate", calculate, "数学计算工具")   # 顺序错了
    except ImportError:
        pass

tool_registry.register_function 调用实参顺序错误,应该是 name, description, function

4. 问题重现材料 / Reproduction Materials

现象
按照原本的代码执行,则tool_registry.get_tools_description()返回

calculate: <function calculate at 0x0000021879853E20>

建议修改

 tool_registry.register_function("calculate", "数学计算工具", calculate)

改后效果

calculate: 数学计算工具

5. 补充信息 / Additional Information

No response

确认事项 / Verification

  • 我已阅读过相关章节的文档 / I have read the relevant chapter documentation
  • 我已搜索过现有的Issues,确认此问题未被报告 / I have searched existing Issues and confirmed this hasn't been reported
  • 我已尝试过基本的故障排除(如重启、重新安装依赖等) / I have tried basic troubleshooting (restart, reinstall dependencies, etc.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions