Skip to content

Commit 4e6625d

Browse files
committed
fix: handle missing input_json in tool call parsing
When a provider (e.g. MiniMax) sends a tool_use block without incremental input_json_delta events, the accumulated input_json key may not exist. Add an explicit else branch to fall back to the input dict initialized at tool_use start instead of skipping the else branch and having input remain as the raw {} init value with a JSONDecodeError silently yielding empty tool args.
1 parent 2e16281 commit 4e6625d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

astrbot/core/provider/sources/anthropic_source.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,8 @@ async def _query_stream(
421421
try:
422422
if "input_json" in tool_info:
423423
tool_info["input"] = json.loads(tool_info["input_json"])
424+
else:
425+
tool_info["input"] = tool_info.get("input", {})
424426

425427
# 添加到最终结果
426428
final_tool_calls.append(
@@ -442,7 +444,7 @@ async def _query_stream(
442444
id=id,
443445
)
444446
except json.JSONDecodeError:
445-
# JSON 解析失败,跳过这个工具调用
447+
# JSON 解析失败,跳过这个工具调用,不 yield
446448
logger.warning(f"工具调用参数 JSON 解析失败: {tool_info}")
447449

448450
# 清理缓冲区

0 commit comments

Comments
 (0)