wangliang
15a4bdeb75
fix: 为 search_spu_products 工具注入 user_token 参数
## 问题
即使更新了 Product Agent prompt,LLM 仍然调用 search_products 而非 search_spu_products
## 根本原因
search_spu_products 工具需要 user_token 参数(Mall API 认证必需),
但 product_agent 函数中没有注入此参数,导致工具调用失败或被忽略
## 修改内容
### agent/agents/product.py:169-173
在工具调用前注入 user_token、user_id、account_id 参数:
```python
# Inject context for SPU product search (Mall API)
if result["tool_name"] == "search_spu_products":
arguments["user_token"] = state.get("user_token")
arguments["user_id"] = state["user_id"]
arguments["account_id"] = state["account_id"]
```
## 参数来源
- user_token: 从 Chatwoot webhook 提取(contact.custom_attributes.jwt_token)
- user_id: 从 AgentState 获取
- account_id: 从 AgentState 获取
## 预期效果
LLM 现在可以成功调用 search_spu_products 工具,
返回 Mall API 商品数据并以 Chatwoot cards 格式展示
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-26 18:10:36 +08:00
..
2026-01-14 19:25:22 +08:00
2026-01-16 16:28:47 +08:00
2026-01-23 18:49:40 +08:00
2026-01-26 13:15:47 +08:00
2026-01-26 18:10:36 +08:00
2026-01-20 14:51:30 +08:00