百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
返回工具页/返回 Issues 列表
#4336·camel

[BUG] 同步流式聊天代理在流式工具调用超出 tool_execution_timeout 时,会引发未捕获的 TimeoutError,而不是警告

作者: BlueX888创建于 2026年9月15日更新于 2026年9月15日

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

查看 GitHub 原文在 GitHub 查看讨论