Spaces:
Sleeping
Sleeping
Fix agents SDK shadowing on Linux (cross-platform sys.path fix)
Browse filesWindows used .venv/Lib/site-packages (capital L); Linux needs
.venv/lib/python3.11/site-packages. Switch to sysconfig.get_path("purelib")
so the venv site-packages is correctly prioritised on both platforms.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- agents/rag_agent.py +7 -5
agents/rag_agent.py
CHANGED
|
@@ -1,13 +1,15 @@
|
|
| 1 |
import os
|
| 2 |
import sys
|
|
|
|
| 3 |
from pathlib import Path
|
| 4 |
|
| 5 |
-
# The local
|
| 6 |
-
# Fix:
|
| 7 |
-
_venv_site =
|
| 8 |
-
if _venv_site in sys.path:
|
| 9 |
sys.path.remove(_venv_site)
|
| 10 |
-
|
|
|
|
| 11 |
for _key in [k for k in sys.modules if k == "agents" or (k.startswith("agents.") and k != __name__)]:
|
| 12 |
del sys.modules[_key]
|
| 13 |
|
|
|
|
| 1 |
import os
|
| 2 |
import sys
|
| 3 |
+
import sysconfig
|
| 4 |
from pathlib import Path
|
| 5 |
|
| 6 |
+
# The local agents/ package shadows the openai-agents SDK which also installs as `agents`.
|
| 7 |
+
# Fix: move the venv site-packages to front of sys.path (works on Windows + Linux).
|
| 8 |
+
_venv_site = sysconfig.get_path("purelib")
|
| 9 |
+
if _venv_site and _venv_site in sys.path:
|
| 10 |
sys.path.remove(_venv_site)
|
| 11 |
+
if _venv_site:
|
| 12 |
+
sys.path.insert(0, _venv_site)
|
| 13 |
for _key in [k for k in sys.modules if k == "agents" or (k.startswith("agents.") and k != __name__)]:
|
| 14 |
del sys.modules[_key]
|
| 15 |
|