diff --git a/app/agent/tools/impl/ask_user_choice.py b/app/agent/tools/impl/ask_user_choice.py index 69dea084..5c2b3b05 100644 --- a/app/agent/tools/impl/ask_user_choice.py +++ b/app/agent/tools/impl/ask_user_choice.py @@ -66,8 +66,11 @@ class AskUserChoiceInput(BaseModel): class AskUserChoiceTool(MoviePilotTool): + """发送按钮选择并让当前 Agent 轮次等待用户回调消息。""" + name: str = "ask_user_choice" sends_message: bool = True + return_direct: bool = True description: str = ( "Ask the user to choose from button options on channels that support interactive buttons. " "After the user clicks a button, the selected value will come back as the user's next message." diff --git a/tests/test_agent_interaction.py b/tests/test_agent_interaction.py index 559edc27..d4e45b4a 100644 --- a/tests/test_agent_interaction.py +++ b/tests/test_agent_interaction.py @@ -54,6 +54,12 @@ class TestAgentInteraction(unittest.TestCase): self.assertIn("ask_user_choice", [tool.name for tool in telegram_tools]) self.assertNotIn("ask_user_choice", [tool.name for tool in wechat_tools]) + def test_choice_tool_returns_direct_after_sending_interaction(self): + """发送按钮后应结束当前 Agent 轮次,等待用户选择作为新消息进入。""" + tool = AskUserChoiceTool(session_id="session-1", user_id="10001") + + self.assertTrue(tool.return_direct) + def test_choice_tool_sends_buttons_and_registers_pending_request(self): tool = AskUserChoiceTool(session_id="session-1", user_id="10001") tool.set_message_attr(