ContextLab / ContextLab/orchestrator
Remove module-scope langchain imports so the package imports without the langgraph extra
- Dominant language
- Python
- Stars
- 3
- Forks
- 2
- Avg merge
- 13m
- Merged PRs (30d)
- 1
Description
Verified on `main` today.
## Evidence
```
src/orchestrator/tools/auto_debugger.py:29:from langchain.tools import BaseTool
src/orchestrator/control_systems/research_control_system.py:516:from langchain.agents import create_react_agent
src/orchestrator/control_systems/research_control_system.py:517:from langchain.tools import Tool
src/orchestrator/control_systems/research_control_system.py:557:from langchain.agents import initialize_agent, AgentType
src/orchestrator/control_systems/research_control_system.py:558:from langchain.tools import DuckDuckGoSearchRun, WikipediaQueryRun
```
## Impact
`langchain` is behind the `[langgraph]` extra, not a core dependency. Any import path reaching these modules fails outright without that extra, which defeats the lazy-import work that got `import orchestrator` down to ~5 ms with zero heavy modules.
`auto_debugger.py` is the harder case: it **subclasses** `BaseTool`, so it cannot be made lazy by moving the import into a function — the class body needs the symbol at definition time.
## Proposed fix
- `research_control_system.py`: move the imports into the functions that use them. Mechanical.
- `auto_debugger.py`: needs restructuring — either invert the dependency (compose rather than subclass `BaseTool`, adapting at the boundary), or move the whole module behind the extra and register it conditionally.
Recommend composition: subclassing a third-party type to satisfy an optional integration is what created the coupling.
## Acceptance criteria
- `grep -rn "^from langchain\|^import langchain" src/orchestrator/` returns nothing
- In a venv **without** the `[langgraph]` extra, importing every module in `orchestrator.__all__` succeeds
Contributor guide
Assessment
This issue has not been assessed yet.