mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-06-12 03:01:45 +08:00
feat(agent): add ToolTag-based tags to all agent tools; implement tags.py for unified tool capability tagging
This commit is contained in:
@@ -9,6 +9,7 @@ if not hasattr(langchain_agents, "create_agent"):
|
||||
langchain_agents.create_agent = lambda *args, **kwargs: None
|
||||
|
||||
from app.agent.callback import StreamingHandler
|
||||
from app.agent.middleware.subagents import is_subagent_stream_metadata
|
||||
from app.agent.tools.base import MoviePilotTool
|
||||
from app.agent.tools.impl.send_voice_message import SendVoiceMessageTool
|
||||
from app.api.endpoints.openai import _OpenAIStreamingHandler
|
||||
@@ -114,6 +115,36 @@ class TestAgentToolStreaming(unittest.TestCase):
|
||||
"处理中:\n\n(执行了 2 次搜索,读取了 2 个文件)\n\n继续分析",
|
||||
)
|
||||
|
||||
def test_non_verbose_tool_summary_counts_subagents(self):
|
||||
async def _run():
|
||||
handler = StreamingHandler()
|
||||
await handler.start_streaming()
|
||||
handler.emit("处理中:")
|
||||
handler.record_tool_call(
|
||||
tool_name="task",
|
||||
tool_message="Subagent invoked",
|
||||
tool_kwargs={"subagent_type": "media-researcher"},
|
||||
)
|
||||
handler.record_tool_call(
|
||||
tool_name="task",
|
||||
tool_message="Subagent invoked",
|
||||
tool_kwargs={"subagent_type": "resource-searcher"},
|
||||
)
|
||||
return await handler.take()
|
||||
|
||||
buffered_message = asyncio.run(_run())
|
||||
|
||||
self.assertEqual(buffered_message, "处理中:\n\n(已调用 2 个子代理)\n\n")
|
||||
|
||||
def test_subagent_stream_metadata_is_suppressed(self):
|
||||
self.assertTrue(
|
||||
is_subagent_stream_metadata(
|
||||
{"metadata": {"ls_agent_type": "subagent"}}
|
||||
)
|
||||
)
|
||||
self.assertTrue(is_subagent_stream_metadata({"lc_agent_name": "media-researcher"}))
|
||||
self.assertFalse(is_subagent_stream_metadata({"lc_agent_name": "main"}))
|
||||
|
||||
def test_openai_streaming_handler_flushes_pending_summary_to_queue(self):
|
||||
async def _run():
|
||||
handler = _OpenAIStreamingHandler()
|
||||
|
||||
Reference in New Issue
Block a user