mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-19 04:14:46 +08:00
Support custom channel assistant IDs via lead_agent (#1500)
* Support custom channel assistant IDs via lead agent * Normalize custom channel agent names
This commit is contained in:
@@ -498,10 +498,11 @@ class TestChannelManager:
|
||||
|
||||
mock_client.runs.wait.assert_called_once()
|
||||
call_args = mock_client.runs.wait.call_args
|
||||
assert call_args[0][1] == "mobile_agent"
|
||||
assert call_args[0][1] == "lead_agent"
|
||||
assert call_args[1]["config"]["recursion_limit"] == 55
|
||||
assert call_args[1]["context"]["thinking_enabled"] is False
|
||||
assert call_args[1]["context"]["subagent_enabled"] is True
|
||||
assert call_args[1]["context"]["agent_name"] == "mobile-agent"
|
||||
|
||||
_run(go())
|
||||
|
||||
@@ -525,7 +526,7 @@ class TestChannelManager:
|
||||
},
|
||||
"users": {
|
||||
"vip-user": {
|
||||
"assistant_id": "vip_agent",
|
||||
"assistant_id": " VIP_AGENT ",
|
||||
"config": {"recursion_limit": 77},
|
||||
"context": {
|
||||
"thinking_enabled": True,
|
||||
@@ -556,14 +557,56 @@ class TestChannelManager:
|
||||
|
||||
mock_client.runs.wait.assert_called_once()
|
||||
call_args = mock_client.runs.wait.call_args
|
||||
assert call_args[0][1] == "vip_agent"
|
||||
assert call_args[0][1] == "lead_agent"
|
||||
assert call_args[1]["config"]["recursion_limit"] == 77
|
||||
assert call_args[1]["context"]["thinking_enabled"] is True
|
||||
assert call_args[1]["context"]["subagent_enabled"] is True
|
||||
assert call_args[1]["context"]["agent_name"] == "vip-agent"
|
||||
assert call_args[1]["context"]["is_plan_mode"] is True
|
||||
|
||||
_run(go())
|
||||
|
||||
def test_handle_chat_rejects_invalid_custom_agent_name(self):
|
||||
from app.channels.manager import ChannelManager
|
||||
|
||||
async def go():
|
||||
bus = MessageBus()
|
||||
store = ChannelStore(path=Path(tempfile.mkdtemp()) / "store.json")
|
||||
manager = ChannelManager(
|
||||
bus=bus,
|
||||
store=store,
|
||||
channel_sessions={
|
||||
"telegram": {
|
||||
"assistant_id": "bad agent!",
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
outbound_received = []
|
||||
|
||||
async def capture_outbound(msg):
|
||||
outbound_received.append(msg)
|
||||
|
||||
bus.subscribe_outbound(capture_outbound)
|
||||
|
||||
mock_client = _make_mock_langgraph_client()
|
||||
manager._client = mock_client
|
||||
|
||||
await manager.start()
|
||||
|
||||
inbound = InboundMessage(channel_name="telegram", chat_id="chat1", user_id="user1", text="hi")
|
||||
await bus.publish_inbound(inbound)
|
||||
await _wait_for(lambda: len(outbound_received) >= 1)
|
||||
await manager.stop()
|
||||
|
||||
mock_client.runs.wait.assert_not_called()
|
||||
assert outbound_received[0].text == (
|
||||
"Invalid channel session assistant_id 'bad agent!'. "
|
||||
"Use 'lead_agent' or a custom agent name containing only letters, digits, and hyphens."
|
||||
)
|
||||
|
||||
_run(go())
|
||||
|
||||
def test_handle_feishu_chat_streams_multiple_outbound_updates(self, monkeypatch):
|
||||
from app.channels.manager import ChannelManager
|
||||
|
||||
|
||||
Reference in New Issue
Block a user