

Who this is for
- Agent Application Developer
- Multi-Tools AI Assistant Designer
What problem does this article solve?
After there are many tools, the model is easy to choose wrong, repeat calls or omit the necessary steps.
Key concepts
- tool routing
- Tool description
- parameter verification
- Call limit
- Fallback response
Walkthrough
- Define multiple tools
- Write tool boundaries
- Implement a local executor that routes tool calls
- Log each tool call log
Python code example
The companion demo is generated in:
cd examples/llm-guides/015_tool_calling_router
python demo.py
The example follows two principles:
- From
OPENAI_API_KEY, load the key at runtime to avoid hard-coding it. - Without an API key, the example runs in mock mode so you can follow the workflow.
The essential call looks like this:
import os
api_key = os.getenv("OPENAI_API_KEY")
if not api_key:
print("未配置 OPENAI_API_KEY,进入 mock 模式。")
else:
# 真实项目中在这里初始化 SDK 客户端并发起请求。
print("已读取 OPENAI_API_KEY,可以调用模型。")
Common pitfalls
- Publishing after a single successful demo run leaves out error handling, logging and human review.
- Including API keys, real file paths, account details or business data in published articles or code.
- Readers can struggle to reproduce an example if it is unclear which parts are mocked and which run in production.
- Citing an API or framework feature without checking its documentation can mislead readers when versions change.
Summary
- LLM Guide 15 covers routing when several tools are available. As the tool list grows, a model can pick the wrong one, repeat a call, or skip a necessary step.
- Make the workflow reproducible, reversible and easy to review. One good generation tells you little about how it will hold up in use.
- Before publishing, check current documentation for model capabilities, API parameters and third-party frameworks.
CSDN tags
Agent, Tool Calling, large model, Python, Tool routing
WeChat article summary
When several tools work together, their descriptions tell the model what each does, their boundaries clarify when to use them, and call logs show what actually ran.
Alternative title for Zhihu
- Why are multi-tool agents easy to call randomly?
- How to make the model choose the right tool?
- What problems will the tool description fail to write well?
References and further reading
- Check the OpenAI documentation for your model, SDK and account permissions.
- Python documentation on environment variables, virtual environments and exception handling.
- Consult the documentation for the tools used in the example, such as LangChain, LlamaIndex, Haystack or the vector database.