Claude Code Claude Opus 4.6 commited on
Commit
575f47c
·
1 Parent(s): bf46867

Claude Code: Simplify brain import in error_handlers.py

Browse files

Remove redundant sys.path manipulation - openclaw/__init__.py already
sets up the path correctly. Match the import pattern used in app.py.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Files changed (1) hide show
  1. error_handlers.py +2 -7
error_handlers.py CHANGED
@@ -148,14 +148,9 @@ def handle_brain_response(message: str) -> str:
148
  AttributeError: If required brain methods are missing.
149
  """
150
  try:
151
- # Import openclaw first to set up sys.path, then import agents
 
152
  import openclaw
153
- # Ensure .openclaw path is added for agents import
154
- import sys
155
- from pathlib import Path
156
- _openclaw_internal = Path(__file__).parent / "openclaw" / ".openclaw"
157
- if str(_openclaw_internal) not in sys.path:
158
- sys.path.insert(0, str(_openclaw_internal))
159
  from agents import brain_minimal
160
 
161
  brain = brain_minimal.get_brain(agent_name="cain", legacy_mode=True)
 
148
  AttributeError: If required brain methods are missing.
149
  """
150
  try:
151
+ # Import openclaw first - it sets up sys.path to include .openclaw
152
+ # Then we can import agents directly (same pattern as app.py)
153
  import openclaw
 
 
 
 
 
 
154
  from agents import brain_minimal
155
 
156
  brain = brain_minimal.get_brain(agent_name="cain", legacy_mode=True)