[BUG] 同步流式聊天代理在流式工具调用超出 tool_execution_timeout 时,会引发未捕获的 TimeoutError,而不是警告
import time from unittest.mock import MagicMock from OpenAI.types.chat.chat_completion_chunk import ( ChatCompletionChunk, Choice as ChunkChoice, ChoiceDelta, ChoiceDeltaToolCall, ChoiceDeltaToolCallFunction, ) from camel.agents import ChatAgent from camel.models import StubModel from camel.types import ModelType from camel.toolkits import FunctionTool def slow_tool() -> str: """A tool that takes far longer than the configured timeout.""" time.sleep(2.0) return "done" model = StubModel(ModelType.STUB, model_config_dict={"stream": True}) chunks = [ ChatCompletionChunk( id="mock_stream_tool", choices=[ ChunkChoice( delta=ChoiceDelta( role="assistant", tool_calls=[ ChoiceDeltaToolCall( index=0, id="call_1", type="function", function=ChoiceDeltaToolCallFunction( name="slow_tool", arguments="{}" ), ) ], ), index=0, finish_reason=None, ) ], created=1234567890, model="GPT-5-mini", object="chat.completion.chunk", …
内容来源: camel-ai/camel