Skip to content

fix: drop explicit OH_PERSISTENCE_DIR from dev-docker.mjs, use derived default#329

Closed
xingyaoww wants to merge 1 commit into
mainfrom
fix/drop-persistence-dir-env
Closed

fix: drop explicit OH_PERSISTENCE_DIR from dev-docker.mjs, use derived default#329
xingyaoww wants to merge 1 commit into
mainfrom
fix/drop-persistence-dir-env

Conversation

@xingyaoww
Copy link
Copy Markdown
Member

@xingyaoww xingyaoww commented May 11, 2026

Problem

dev-docker.mjs explicitly sets OH_PERSISTENCE_DIR=/home/openhands/.openhands in the container environment, but:

  1. The agent-server already derives a suitable default — when OH_PERSISTENCE_DIR is unset, _get_persistence_dir() in the SDK falls back to config.conversations_path.parent / ".openhands". Since OH_CONVERSATIONS_PATH is set to /home/openhands/.openhands/agent-canvas/conversations, the derived default resolves to /home/openhands/.openhands/agent-canvas/.openhands — still on the mounted ~/.openhands volume, so settings and secrets persist across container restarts.

  2. buildAgentServerEnv() in dev-safe.mjs never sets OH_PERSISTENCE_DIR — the Docker path was the only place this env var was explicitly set, creating an inconsistency between Docker and non-Docker dev workflows.

Fix

Remove OH_PERSISTENCE_DIR from the containerEnv object in dev-docker.mjs, letting the agent-server use its derived default. This follows the same pattern as the TMUX_TMPDIR removal in #325.

Remaining containerEnv vars (and why they stay)

Env var Why it's needed
OH_CONVERSATIONS_PATH Without it, conversations go to the ephemeral container path /agent-server/workspace/conversations
OH_BASH_EVENTS_DIR Same — bash events would be lost on restart
OH_SECRET_KEY Stable dev encryption key shared across Docker/non-Docker runs
OH_SESSION_API_KEYS_0 Must match the frontend's VITE_SESSION_API_KEY for auth

This PR was created by an AI agent (OpenHands) on behalf of the user.

…d default

OH_PERSISTENCE_DIR was set to /home/openhands/.openhands in the Docker
containerEnv, but the agent-server already derives a suitable persistence
directory from conversations_path.parent / '.openhands' when the env var
is absent. Since OH_CONVERSATIONS_PATH points at
/home/openhands/.openhands/agent-canvas/conversations, the derived
default resolves to /home/openhands/.openhands/agent-canvas/.openhands —
still on the mounted volume, so settings and secrets persist across
container restarts.

This also brings dev-docker.mjs in line with buildAgentServerEnv() in
dev-safe.mjs, which never set OH_PERSISTENCE_DIR.

Co-authored-by: openhands <openhands@all-hands.dev>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
agent-canvas Ready Ready Preview, Comment May 11, 2026 5:44pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants