dry-autumn-33122
09/13/2025, 1:16 AMnutritious-balloon-65098
09/13/2025, 1:16 AMnutritious-balloon-65098
09/13/2025, 1:25 AMRecallObservation working_dir bug in local runtime headless mode.
Problem: When using local runtime with SANDBOX_VOLUMES={real_dir}:/workspace:rw, the `RecallObservation`'s working_dir was incorrectly set to /workspace instead of the actual host directory.
Root Cause: Both headless mode (openhands/core/main.py) and server mode (openhands/server/session/agent_session.py) were using config.workspace_mount_path_in_sandbox (always /workspace) instead of the actual working directory.
Solution: Changed both files to use config.workspace_mount_path or config.workspace_mount_path_in_sandbox, which:
• Uses the actual host directory when SANDBOX_VOLUMES is set
• Falls back to /workspace when no custom mount is configured
Changes Made:
1. Fixed headless mode in openhands/core/main.py
2. Fixed server mode in openhands/server/session/agent_session.py
3. Added comprehensive unit tests in tests/unit/test_recall_observation_working_dir.py
Verification: All tests pass, including new unit tests that reproduce the bug and verify the fix works correctly with various SANDBOX_VOLUMES configurations.
Alternative Solutions: I analyzed 6 alternative approaches, with the current solution providing the best balance of simplicity, correctness, and maintainability.
The fix ensures that workspace context in LLM instructions now correctly shows the real working directory path instead of the hardcoded /workspace when using local runtime with custom volume mounts.
Would you like me to push these changes to a new branch and create a pull request?
<sub>View full conversation</sub>