Shurem Claude Sonnet 4.6 commited on
Commit
543dff7
Β·
1 Parent(s): 1fee1c2

Fix agents SDK shadowing on Linux (cross-platform sys.path fix)

Browse files

Windows 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>

Files changed (1) hide show
  1. 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 backend/agents/ package shadows the openai-agents SDK `agents` package.
6
- # Fix: force .venv/Lib/site-packages to index 0, then clear the cached local entry.
7
- _venv_site = str((Path(__file__).parent.parent / ".venv" / "Lib" / "site-packages").resolve())
8
- if _venv_site in sys.path:
9
  sys.path.remove(_venv_site)
10
- sys.path.insert(0, _venv_site)
 
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