Failing to Save Trajectory from CLI Mode Run
I am running OpenHands using the CLI mode through docker.
docker run -it \
--pull=always \
-e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:0.40-nikolaik \
-e SANDBOX_USER_ID=$(id -u) \
-e SANDBOX_VOLUMES=$SANDBOX_VOLUMES \
-e LLM_MODEL=$LLM_MODEL \
-e LLM_NUM_RETRIES=$LLM_NUM_RETRIES \
-e LLM_RETRY_MIN_WAIT=$LLM_RETRY_MIN_WAIT \
-e LLM_RETRY_MAX_WAIT=$LLM_RETRY_MAX_WAIT \
-e LOG_ALL_EVENTS=$LOG_ALL_EVENTS \
-e DEBUG_RUNTIME=$DEBUG_RUNTIME \
-e LOG_TO_FILE=$LOG_TO_FILE \
-e LOG_JSON=$LOG_JSON \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ~/.openhands-state:/.openhands-state \
--add-host host.docker.internal:host-gateway \
--name openhands-app-$(date +%Y%m%d%H%M%S) \
docker.all-hands.dev/all-hands-ai/openhands:0.40 \
python -m openhands.cli.main --override-cli-mode true
I am able to prompt and run the agent perfectly. However, no trajectory file is getting saved anywhere.
Here's the config.toml file:
[core]
workspace_base="./workspace"
save_trajectory_path="./trajectories"
run_as_openhands = true
cache_dir = "./tmp/cache"
debug = true
[llm]
model="bedrock/us.anthropic.claude-3-7-sonnet-20250219-v1:0"
temperature = 0.0
aws_access_key_id = "xxx"
aws_region_name = "xxx"
aws_secret_access_key = "xxx"
num_retries = 5
retry_max_wait = 120
retry_min_wait = 30
[agent]
enable_browsing = true
enable_editor = true
enable_cmd = true
[security]
confirmation_mode = false
Am I missing something? Any direction would be helpful.
@ShoumikSaha on your local machine, inside the ~/.openhands-state folder, there should be a sessions folder. Is that not the case?
I am also experiencing this. I have checked the provided save_trajectory_path and the openhands-state folders but sessions are not saved. I am using -n sessionName and it is saving sessions correctly in headless mode but not in CLI mode.
saves session correctly at save_trajectory_path:
python -m openhands.core.main -t "write a bash script that prints hi" --config config.toml -n S1
Doesn't save session:
python -m openhands.cli.main --override-cli-mode True --config config.toml -n S1
@rbren did something change on the CLI side here?
@mamoodi No, there is no sessions folder under the ~/.openhands-state folder.
Hmm can you try adding -e FILE_STORE_PATH=/.openhands-state?
I think might be a permission error between the userid and the folder ownership. Setting FILE_STORE_PATH i get a permission error. An error occurred: [Errno 13] Permission denied: '/.openhands-state'
In my config file I have:
#user_id = 1000
run_as_openhands = false
and from the runtime container /.openhands-state is owned by root. In my case I have a volume mount to this path which is also owned by root on the host. Maybe the writting of trajectories uses a userid despite the above configs?
I think this might be related to this issue also: https://github.com/All-Hands-AI/OpenHands/issues/7906
I think I found where it gets saved in CLI. It's in ~/.openhands/sessions. Looks like the CLI looks in a different directory :/
CC @rbren
I have a PR to update the docs: https://github.com/All-Hands-AI/OpenHands/pull/9074
Thx @mamoodi, I found my prior sessions at /tmp/openhands_file_store/sessions
That was the default setting up to 0.40 when there was still an app_config.py and switched in 0.41 to '~/.openhands/file_store'
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for over 30 days with no activity.