diff --git a/astrbot/core/provider/sources/openai_source.py b/astrbot/core/provider/sources/openai_source.py index d64feb5a07..68fad067b0 100644 --- a/astrbot/core/provider/sources/openai_source.py +++ b/astrbot/core/provider/sources/openai_source.py @@ -334,11 +334,15 @@ async def _query_stream( choice = chunk.choices[0] delta = choice.delta - # siliconflow workaround if dtcs := delta.tool_calls: - for tc in dtcs: + for idx, tc in enumerate(dtcs): + # siliconflow workaround if tc.function and tc.function.arguments: tc.type = "function" + # Fix for #6661: Add missing 'index' field to tool_call deltas + # Gemini and some OpenAI-compatible proxies omit this field + if not hasattr(tc, "index") or tc.index is None: + tc.index = idx try: state.handle_chunk(chunk) except Exception as e: