Skip to content

fix(sdk): expand ~ in OH_PERSISTENCE_DIR for the meta-profile store - #5884

Merged
enyst merged 1 commit into
mainfrom
claude/umbrella-bug-fixes-tgz9ai-persistence-dir
Oct 17, 2026
Merged

enyst merged 1 commit into
mainfrom
claude/umbrella-bug-fixes-tgz9ai-persistence-dir

Conversation

@enyst

@enyst enyst commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

HUMAN:
This PR proposes a fix for a bug uncovered during the first full agentic run of verify-agent-server.


AGENT:

I'm an AI agent (Claude Code) helping Engel Nyst (@enyst) with project maintenance.

Requested by Engel · project thread

Why

With OH_PERSISTENCE_DIR='~/x', the agent server writes settings.json (and the LLM profiles) to $HOME/x/, but meta-profiles go to <server cwd>/~/x/meta-profiles/, a directory literally named ~. The API keeps working because the router and the routing tool share the same helper, but the files sit outside the persistence directory.

Summary

  • default_meta_profile_dir() (openhands-sdk/openhands/sdk/llm/meta_profile_store.py) now returns get_user_persistence_dir() / "meta-profiles", so ~ is expanded and a relative value is anchored exactly as for every other store. It is still evaluated at call time, so the router, launch.py and bare MetaProfileStore() pick it up unchanged.
  • New unit test for OH_PERSISTENCE_DIR='~/state'.
  • The F22.persistence-dir map bullet drops its # bug marker and "known bug" label; prose and Gotchas now describe the expected behaviour.

Issue Number

Fixes #5878

How to Test

  • uv run pytest tests/sdk/llm/test_meta_profile_store.py -k persistence_dir: the new test fails on main (PosixPath('~/state/meta-profiles')) and passes here.
  • uv run pytest tests/sdk/llm/test_meta_profile_store.py tests/agent_server/test_meta_profiles_router.py tests/agent_server/test_active_meta_profile.py tests/sdk/tool/test_classify_and_switch_llm.py tests/sdk/test_settings.py tests/sdk/launch tests/agent_server/test_settings_router.py tests/sdk/tool/test_registry.py: 450 passed.
  • Map proof: control-agent-server map run --file F22 --only F22.persistence-dir --fresh --repeat 2 --checkout <main checkout> reports xfail twice on main (6e7a853); the same command from this branch without --checkout reports xpass twice. After removing the marker, control-agent-server map check reports no problems and map run --file F22 --only F22.persistence-dir --fresh reports pass.
  • pre-commit run --files <changed files>: all hooks pass.

Video/Screenshots

n/a

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change
  • Docs / chore

Notes

Related history: #3836 added OH_PERSISTENCE_DIR support to the meta-profile store with its own copy of the lookup; this PR replaces that copy with the shared helper. Tracked in umbrella #5653.

🤖 Generated with Claude Code

https://claude.ai/code/session_014MKndVj7XWvRQmvW9w2bDg


Generated by Claude Code


🐳 Agent Server images for this PR — GHCR package, pull/run commands, and all pushed tags (click to expand)

• GHCR package: https://github.com/OpenHands/agent-sdk/pkgs/container/agent-server

Variants & Base Images

Variant Architectures Base Image Docs / Tags
java amd64, arm64 eclipse-temurin:17-jdk Link
python-slim amd64, arm64 python-node-runtime Link
python-minimal amd64, arm64 python-node-runtime Link
python amd64, arm64 python-node-runtime Link
golang amd64, arm64 golang:1.21-bookworm Link

Pull (multi-arch manifest)

# Each variant is a multi-arch manifest supporting both amd64 and arm64
docker pull ghcr.io/openhands/agent-server:b1f62cd-python

Run

docker run -it --rm \
  -p 8000:8000 \
  --name agent-server-b1f62cd-python \
  ghcr.io/openhands/agent-server:b1f62cd-python

All tags pushed for this build

ghcr.io/openhands/agent-server:b1f62cd-golang-amd64
ghcr.io/openhands/agent-server:b1f62cde2e77227c2b28083a12fb3202ce9565b9-golang-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-persistence-dir-golang-amd64
ghcr.io/openhands/agent-server:b1f62cd-golang_tag_1.21-bookworm-amd64
ghcr.io/openhands/agent-server:b1f62cd-golang-arm64
ghcr.io/openhands/agent-server:b1f62cde2e77227c2b28083a12fb3202ce9565b9-golang-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-persistence-dir-golang-arm64
ghcr.io/openhands/agent-server:b1f62cd-golang_tag_1.21-bookworm-arm64
ghcr.io/openhands/agent-server:b1f62cd-java-amd64
ghcr.io/openhands/agent-server:b1f62cde2e77227c2b28083a12fb3202ce9565b9-java-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-persistence-dir-java-amd64
ghcr.io/openhands/agent-server:b1f62cd-eclipse-temurin_tag_17-jdk-amd64
ghcr.io/openhands/agent-server:b1f62cd-java-arm64
ghcr.io/openhands/agent-server:b1f62cde2e77227c2b28083a12fb3202ce9565b9-java-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-persistence-dir-java-arm64
ghcr.io/openhands/agent-server:b1f62cd-eclipse-temurin_tag_17-jdk-arm64
ghcr.io/openhands/agent-server:b1f62cd-python-amd64
ghcr.io/openhands/agent-server:b1f62cde2e77227c2b28083a12fb3202ce9565b9-python-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-persistence-dir-python-amd64
ghcr.io/openhands/agent-server:b1f62cd-python-node-runtime-amd64
ghcr.io/openhands/agent-server:b1f62cd-python-arm64
ghcr.io/openhands/agent-server:b1f62cde2e77227c2b28083a12fb3202ce9565b9-python-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-persistence-dir-python-arm64
ghcr.io/openhands/agent-server:b1f62cd-python-node-runtime-arm64
ghcr.io/openhands/agent-server:b1f62cd-python-minimal-amd64
ghcr.io/openhands/agent-server:b1f62cde2e77227c2b28083a12fb3202ce9565b9-python-minimal-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-persistence-dir-python-minimal-amd64
ghcr.io/openhands/agent-server:b1f62cd-python-node-runtime-minimal-amd64
ghcr.io/openhands/agent-server:b1f62cd-python-minimal-arm64
ghcr.io/openhands/agent-server:b1f62cde2e77227c2b28083a12fb3202ce9565b9-python-minimal-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-persistence-dir-python-minimal-arm64
ghcr.io/openhands/agent-server:b1f62cd-python-node-runtime-minimal-arm64
ghcr.io/openhands/agent-server:b1f62cd-python-slim-amd64
ghcr.io/openhands/agent-server:b1f62cde2e77227c2b28083a12fb3202ce9565b9-python-slim-amd64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-persistence-dir-python-slim-amd64
ghcr.io/openhands/agent-server:b1f62cd-python-node-runtime-slim-amd64
ghcr.io/openhands/agent-server:b1f62cd-python-slim-arm64
ghcr.io/openhands/agent-server:b1f62cde2e77227c2b28083a12fb3202ce9565b9-python-slim-arm64
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-persistence-dir-python-slim-arm64
ghcr.io/openhands/agent-server:b1f62cd-python-node-runtime-slim-arm64
ghcr.io/openhands/agent-server:b1f62cd-golang
ghcr.io/openhands/agent-server:b1f62cde2e77227c2b28083a12fb3202ce9565b9-golang
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-persistence-dir-golang
ghcr.io/openhands/agent-server:b1f62cd-golang_tag_1.21-bookworm
ghcr.io/openhands/agent-server:b1f62cd-java
ghcr.io/openhands/agent-server:b1f62cde2e77227c2b28083a12fb3202ce9565b9-java
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-persistence-dir-java
ghcr.io/openhands/agent-server:b1f62cd-eclipse-temurin_tag_17-jdk
ghcr.io/openhands/agent-server:b1f62cd-python-minimal
ghcr.io/openhands/agent-server:b1f62cde2e77227c2b28083a12fb3202ce9565b9-python-minimal
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-persistence-dir-python-minimal
ghcr.io/openhands/agent-server:b1f62cd-python-node-runtime-minimal
ghcr.io/openhands/agent-server:b1f62cd-python-slim
ghcr.io/openhands/agent-server:b1f62cde2e77227c2b28083a12fb3202ce9565b9-python-slim
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-persistence-dir-python-slim
ghcr.io/openhands/agent-server:b1f62cd-python-node-runtime-slim
ghcr.io/openhands/agent-server:b1f62cd-python
ghcr.io/openhands/agent-server:b1f62cde2e77227c2b28083a12fb3202ce9565b9-python
ghcr.io/openhands/agent-server:claude-umbrella-bug-fixes-tgz9ai-persistence-dir-python
ghcr.io/openhands/agent-server:b1f62cd-python-node-runtime

About Multi-Architecture Support

  • Each variant tag (e.g., b1f62cd-python) is a multi-arch manifest supporting both amd64 and arm64
  • Docker automatically pulls the correct architecture for your platform
  • Individual architecture tags (e.g., b1f62cd-python-amd64) are also available if needed

default_meta_profile_dir() built the path from the raw OH_PERSISTENCE_DIR
value, so '~/x' wrote meta-profiles to '<cwd>/~/x/meta-profiles' while
settings.json landed in the expanded directory. Resolve it through
get_user_persistence_dir() like every other store, which expands '~' and
anchors relative values. Drop the F22.persistence-dir known-bug marker.

Fixes #5878

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014MKndVj7XWvRQmvW9w2bDg
@enyst enyst self-assigned this Oct 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

REST API breakage checks (OpenAPI) — ✅ PASSED

Result: ✅ PASSED

Action log

@github-actions

Copy link
Copy Markdown
Contributor

Coverage

Coverage Report •
FileStmtsMissCoverMissing
openhands-sdk/openhands/sdk/llm
   meta_profile_store.py103793%135, 138, 230–232, 263–264
TOTAL484441306273% 

@enyst
enyst marked this pull request as ready for review October 14, 2026 01:18
@enyst
enyst requested a review from all-hands-bot October 14, 2026 01:19

@all-hands-bot all-hands-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review was posted by an AI agent (OpenHands).

Review — PR #5884

Scope: In scope. default_meta_profile_dir() lives in the SDK, and its only consumers (the agent-server meta-profiles router, launch.py, and bare MetaProfileStore()) are in this repository. No cross-repo ownership question.

Change: default_meta_profile_dir() now returns get_user_persistence_dir() / "meta-profiles" instead of carrying its own Path(os.environ["OH_PERSISTENCE_DIR"]) copy. Call-time evaluation is preserved, so the router, launch.py, and bare MetaProfileStore() all pick up the same resolution as settings.json, LLM profiles, agent profiles, and the skills caches.

Verification I ran on b1f62cd:

  • Live, through the real agent-server entry point (python -m openhands.agent_server with HOME=<tmp>/home, OH_PERSISTENCE_DIR=~/qa-f22-tilde, empty server cwd): POST /api/meta-profiles/qa-tilde to 201 and POST .../activate to 200 wrote home/qa-f22-tilde/settings.json and home/qa-f22-tilde/meta-profiles/qa-tilde.json together, and no directory literally named ~ existed anywhere under the run tree.
  • Same probe against base origin/main (6e7a853): default_meta_profile_dir() returns the literal ~/x/meta-profiles, confirming the reported symptom.
  • uv run pytest tests/sdk/llm/test_meta_profile_store.py tests/sdk/utils/test_path.py -> 34 passed.
  • uv run pytest tests/cross/test_persistence_dir_call_sites.py tests/agent_server/test_meta_profiles_router.py tests/agent_server/test_active_meta_profile.py tests/sdk/tool/test_classify_and_switch_llm.py tests/sdk/test_settings.py tests/agent_server/test_settings_router.py -> 391 passed.
  • ruff check, ruff format --check, pyright, and scripts/check_import_rules.py on the changed file: clean.
  • control_agent_server.py map check --file F22: ok: true, no problems, so the removed known-bug marker is consistent with the map's own contract.
  • Head CI: all 53 check runs on b1f62cd pass; none failing.

Behavior note (non-blocking): the fallback path and absolute values are unchanged; a relative OH_PERSISTENCE_DIR now anchors to _INITIAL_CWD (import-time cwd) with a warning instead of the cwd at file access, which is exactly what every other store does. That is the intended unification, not a regression.

Acceptance: Linked issue #5878 (bug, priority:low, ready-for-dev) asks for meta-profiles at $HOME/x/meta-profiles/ using the same resolution as every other store. The head delivers that, with a regression test and a live-verified fix.

No material correctness, security, compatibility, or acceptance-criterion defects found.

✅ APPROVED

@enyst
enyst merged commit 3adf42f into main Oct 17, 2026
57 checks passed
@enyst
enyst deleted the claude/umbrella-bug-fixes-tgz9ai-persistence-dir branch October 17, 2026 00:10
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.

[Bug]: With OH_PERSISTENCE_DIR='~/x', meta-profiles are written to '<server cwd>/~/x/meta-profiles' instead of the expanded directory

3 participants