Skip to content

Commit fa1698d

Browse files
Merge branch 'mcp'
2 parents 9b5ff8e + c273e9e commit fa1698d

19 files changed

+245
-318
lines changed

__init__.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,37 @@
99
# Copyright (C) 2025 AIDC-AI
1010
# Licensed under the MIT License.
1111

12-
import asyncio
12+
import sys
1313
import os
14+
15+
# Ensure 'agents' resolves to openai-agents (not legacy RL package)
16+
try:
17+
import importlib.metadata as _im
18+
from pathlib import Path as _Path
19+
20+
try:
21+
_dist = _im.distribution("openai-agents")
22+
except _im.PackageNotFoundError:
23+
_dist = None
24+
25+
if _dist and _dist.files:
26+
_init_rel = next((f for f in _dist.files if str(f).replace("\\", "/").endswith("agents/__init__.py")), None)
27+
if _init_rel:
28+
_init_path = _dist.locate_file(_init_rel)
29+
_agents_parent = _Path(_init_path).parent.parent
30+
_pp = str(_agents_parent)
31+
if _pp not in sys.path:
32+
sys.path.insert(0, _pp)
33+
34+
# If an incompatible 'agents' was already imported, drop it
35+
m = sys.modules.get("agents")
36+
if m is not None and not hasattr(m, "Agent"):
37+
sys.modules.pop("agents", None)
38+
except Exception:
39+
# Fail-open: never block plugin loading if aliasing fails
40+
pass
41+
42+
import asyncio
1443
import server
1544
from aiohttp import web
1645
import folder_paths
Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)