feat(agent): mark and propagate voice input metadata in agent messages; clarify terminal tool usage in prompts

- Add `has_audio_input` flag to agent message handling and propagate through processing pipeline
- Structure agent input payloads to include `input.mode` and `input.transcribed` for voice messages
- Update prompts and tool descriptions to clarify that `send_voice_message` and `ask_user_choice` are terminal tools and should not be followed by redundant text replies
- Enhance tests to cover voice input metadata propagation and prompt updates
This commit is contained in:
jxxghp
2026-05-31 18:04:02 +08:00
parent 13b2163788
commit 855681ff35
11 changed files with 139 additions and 10 deletions

View File

@@ -10,6 +10,7 @@ from app.agent import (
AgentManager,
ReplyMode,
UNSUPPORTED_IMAGE_INPUT_MESSAGE,
_MessageTask,
)
from app.agent.memory import memory_manager
from app.agent.tools.factory import MoviePilotToolFactory
@@ -288,6 +289,28 @@ class AgentBackgroundOutputTest(unittest.IsolatedAsyncioTestCase):
process_message.assert_not_awaited()
async def test_agent_manager_preserves_voice_input_flag(self):
"""会话队列执行时应把语音输入标记继续传给 Agent。"""
manager = AgentManager()
agent = MoviePilotAgent(session_id="session-1", user_id="user-1")
manager.active_agents["session-1"] = agent
agent.process = AsyncMock(return_value="ok")
task = _MessageTask(
session_id="session-1",
user_id="user-1",
message="帮我推荐一部电影",
has_audio_input=True,
)
await manager._process_message_internal(task)
agent.process.assert_awaited_once_with(
"帮我推荐一部电影",
images=None,
files=None,
has_audio_input=True,
)
async def test_create_agent_excludes_activity_log_for_heartbeat_session(self):
agent = MoviePilotAgent(
session_id=f"{HEARTBEAT_SESSION_PREFIX}test__",