AstrBot icon indicating copy to clipboard operation
AstrBot copied to clipboard

[Bug]Python报错

Open zanglikun opened this issue 10 months ago • 1 comments

What happened / 发生了什么

[17:54:34] [Core] [INFO] [runners.tool_loop_agent_runner:331]: Agent 使用工具: ['web_search_tavily'] [17:54:34] [Core] [INFO] [runners.tool_loop_agent_runner:356]: 使用工具:web_search_tavily,参数:{'query': '日报 2026年1月7日 日常汇报 工作日志', 'max_results': 6, 'search_depth': 'basic'} [17:54:34] [Plug] [INFO] [web_searcher.main:297]: web_searcher - search_from_tavily: 日报 2026年1月7日 日常汇报 工作日志 [17:54:34] [Core] [WARN] [runners.tool_loop_agent_runner:509]: Traceback (most recent call last): File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 413, in _handle_function_tools async for resp in executor: # type: ignore File "/AstrBot/astrbot/core/astr_agent_tool_exec.py", line 47, in execute async for r in cls._execute_local(tool, run_context, **tool_args): File "/AstrBot/astrbot/core/astr_agent_tool_exec.py", line 134, in _execute_local resp = await asyncio.wait_for( ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/asyncio/tasks.py", line 489, in wait_for return fut.result() ^^^^^^^^^^^^ File "/AstrBot/astrbot/core/astr_agent_tool_exec.py", line 275, in call_local_llm_tool ret = await ready_to_call ^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/builtin_stars/web_searcher/main.py", line 326, in search_from_tavily results = await self._web_search_tavily(cfg, payload) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/builtin_stars/web_searcher/main.py", line 129, in _web_search_tavily tavily_key = await self._get_tavily_key(cfg) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/builtin_stars/web_searcher/main.py", line 119, in _get_tavily_key key = tavily_keys[self.tavily_key_index] ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^ IndexError: list index out of range

Reproduce / 如何复现?

看日志 Mac Docker部署的

AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器

Mac Docker部署的

OS

macOS

Logs / 报错日志

[17:54:34] [Core] [INFO] [runners.tool_loop_agent_runner:331]: Agent 使用工具: ['web_search_tavily'] [17:54:34] [Core] [INFO] [runners.tool_loop_agent_runner:356]: 使用工具:web_search_tavily,参数:{'query': '日报 2026年1月7日 日常汇报 工作日志', 'max_results': 6, 'search_depth': 'basic'} [17:54:34] [Plug] [INFO] [web_searcher.main:297]: web_searcher - search_from_tavily: 日报 2026年1月7日 日常汇报 工作日志 [17:54:34] [Core] [WARN] [runners.tool_loop_agent_runner:509]: Traceback (most recent call last): File "/AstrBot/astrbot/core/agent/runners/tool_loop_agent_runner.py", line 413, in _handle_function_tools async for resp in executor: # type: ignore File "/AstrBot/astrbot/core/astr_agent_tool_exec.py", line 47, in execute async for r in cls._execute_local(tool, run_context, **tool_args): File "/AstrBot/astrbot/core/astr_agent_tool_exec.py", line 134, in _execute_local resp = await asyncio.wait_for( ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/asyncio/tasks.py", line 489, in wait_for return fut.result() ^^^^^^^^^^^^ File "/AstrBot/astrbot/core/astr_agent_tool_exec.py", line 275, in call_local_llm_tool ret = await ready_to_call ^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/builtin_stars/web_searcher/main.py", line 326, in search_from_tavily results = await self._web_search_tavily(cfg, payload) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/builtin_stars/web_searcher/main.py", line 129, in _web_search_tavily tavily_key = await self._get_tavily_key(cfg) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/AstrBot/astrbot/builtin_stars/web_searcher/main.py", line 119, in _get_tavily_key key = tavily_keys[self.tavily_key_index] ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^ IndexError: list index out of range

Are you willing to submit a PR? / 你愿意提交 PR 吗?

  • [ ] Yes!

Code of Conduct

zanglikun avatar Jan 07 '26 09:01 zanglikun

Hi @zanglikun! I'm Dosu and I’m helping the AstrBot team.

你的报错是因为 Tavily API key 配置为空或未正确设置。AstrBot 近期已将 websearch_tavily_key 从单个字符串改为字符串列表(支持多个 key 轮询),现在配置必须是非空的字符串数组,否则会出现 IndexError 或 ValueError(新版会提示“错误:Tavily API密钥未在AstrBot中配置。”)详情见此 PR。

请检查你的配置文件(通常在 provider_settings 下),确保 websearch_tavily_key 是一个包含至少一个有效 Tavily key 的列表,例如:

"provider_settings": {
  "websearch_tavily_key": ["你的 Tavily API key"]
}

如果你之前用的是字符串,AstrBot 会自动迁移为列表格式并保存,但如果原本就是空字符串,迁移后还是空列表,需要你手动补充 key。修改后重启服务即可恢复正常。

To reply, just mention @dosu.


Docs are dead. Just use Dosu.

Leave Feedback Ask Dosu about AstrBot Share Dosu with your team

dosubot[bot] avatar Jan 07 '26 09:01 dosubot[bot]