magnificent-hairdresser-38202
09/12/2025, 7:24 AMworking_dir attribute comes from. In local runtime, if the working directory is set to some other folder using SANDBOX_VOLUMES={other_folder}:/workspace:rw, the working_dir would reflect the config, except for the workspace_context recall case (where it still have working_dir = /workspace). Please find the problem and fix it.nutritious-balloon-65098
09/12/2025, 7:25 AMnutritious-balloon-65098
09/12/2025, 7:40 AMworking_dir issue in workspace context recall for local runtime. Here's what I accomplished:
Problem Analysis ✅
• Found that "Added workspace context" appears in RecallObservation.message for WORKSPACE_CONTEXT recall type
• Identified the root cause: inconsistency between runtime.workspace_root (correct path) and config.workspace_mount_path_in_sandbox (hardcoded /workspace)
• The issue occurred when using SANDBOX_VOLUMES={other_folder}:/workspace:rw - the workspace context would show /workspace instead of the actual folder path
Files Fixed ✅
1. openhands/cli/main.py (line 332): Changed working_dir=os.getcwd() to working_dir=str(runtime.workspace_root)
2. openhands/server/session/agent_session.py (lines 157-159): Added logic to use runtime.workspace_root when available, with fallback to config value
Testing ✅
• Created comprehensive unit tests in tests/unit/memory/test_working_dir_fix.py
• Tests reproduce the bug and verify the fix works correctly
• All existing tests continue to pass (110 memory tests, 243 CLI tests)
• Pre-commit hooks pass successfully
Key Technical Details ✅
• CLI runtime correctly overrides workspace_root property to return actual path: Path(os.path.abspath(self._workspace_path))
• Base runtime uses hardcoded config value: Path(self.config.workspace_mount_path_in_sandbox)
• The fix ensures proper fallback handling and maintains backward compatibility
Pull Request Created ✅
Pull Request: https://github.com/All-Hands-AI/OpenHands/pull/10951
The fix is minimal, targeted, and ensures that when using SANDBOX_VOLUMES={other_folder}:/workspace:rw, the working_dir in workspace context recall will correctly show the actual folder path instead of the hardcoded /workspace.
Would you like me to:
• Mark the pull request as ready for review?
• Make any additional changes to the implementation?
• Add any other documentation or tests?
<sub>View full conversation</sub>