Repository navigation
fix(enterprise): atomically migrate legacy empty tool settings - #12
Conversation
|
|
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
|
Repository-cutover replacement for OpenHands/OpenHands#15343; the validated commit is unchanged. All migration, lint, and Python/enterprise test checks pass. The only red check is the cutover-wide GHCR package authorization failure recorded at OpenHands/OpenHands#15396. |
|
Read-only pre-migration database baseline completed on 2026-07-27. Both connections reported
These are exact top-level |
9d28790 to
5c9020a
Compare
|
Concurrency fix pushed in 5c9020a. Revision 141 now performs one atomic, set-based JSON update per table instead of reading rows and writing stale full documents. Validated against PostgreSQL 16 with the production pg8000 driver: the migration blocked behind a concurrent org-row writer, then preserved the writer's new model/marker while changing only |
There was a problem hiding this comment.
I tested this out against a real postgres database containing about twice the amount of data in the tables that this migration would touch in production, and the transaction took about 1.5 seconds.
In prod, these tables are seeing about 3 writes/min each. With such a low rate, I'm not expecting write contention to be much of an issue.
5c9020a to
7534e1b
Compare
|
🚀 Released in 1.49.0. |
HUMAN:
Replace legacy empty tool arrays with the default-tool sentinel through a durable database migration, so cloud and self-hosted upgrades can safely restore Agent Profile tool selection.
AGENT:
Rebased onto current main, covers the legacy user-settings source used by lazy user migration, and replaces stale full-document writes with atomic database updates.
Why
Before openhands-sdk 1.31.2,
OpenHandsAgentSettings.toolsdefaulted to[]. Ordinary cloud settings saves serialized that default into persisted settings.SDK 1.31.2 changed the contract:
tools: nulluses the default toolset.tools: []creates an intentionally bare agent.The persisted rows had no schema marker or migration. When OpenHands/OpenHands#15228 honored stored tool values during cloud launches, affected users lost terminal, file editor, task tracker, and browser tools. OpenHands/OpenHands#15339 reverted that behavior as containment.
Self-hosted installations may skip releases, so the compatibility boundary belongs in Alembic. The deprecated
user_settingstable must also be migrated becauseUserStore.migrate_usercan still copy itsagent_settingsinto new org and member rows after this revision has run.Summary
tools: []values totools: nullin:user_settings.agent_settingsorg.agent_settingsorg_member.agent_settings_diffjsonb_setto the current row value so concurrent changes are preserved.org.agent_profilesuntouched, so profile-leveltools: []remains an intentional bare-agent configuration.UserStore.migrate_userpath.UPDATEstatements and no read-then-writeSELECTloop.This migration does not re-land OpenHands/OpenHands#15228. It establishes the data precondition needed to reintroduce those launch features in a separate follow-up.
Issue Number
Closes #68.
How to Test
Result:
24 passed.PYTHONPATH=".:${PYTHONPATH}" poetry run --project=enterprise pytest -q \ -p no:ddtrace -p no:ddtrace.pytest_bdd -p no:ddtrace.pytest_benchmark \ enterprise/tests/unit/test_user_store.pyResult:
70 passedwith pre-existing aiosqlite event-loop shutdown warnings.Result: all hooks passed, including Ruff, formatting, and mypy.
Result:
Enterprise migration integrity checks passed.The migration was run directly and twice against PostgreSQL 16 with the production pg8000 driver. In a blocked-writer reproduction, revision 141 waited behind a concurrent
orgupdate, then preserved the writer’s new model and marker while changing onlytoolsto JSON null. The second run made no further changes; all three target tables had zero legacy rows remaining, and an Agent Profile containingtools: []remained unchanged.For staging and production validation, record these counts before and after upgrading; all three should be zero afterward:
Then reapply the OpenHands/OpenHands#15228 behavior on a staging build and launch conversations from a default profile, an intentionally bare profile, and a profile with an explicit tool list.
Video/Screenshots
Not applicable; this is a backend data migration.
Type
Notes
The downgrade is intentionally a no-op: after upgrade, a migrated null cannot be distinguished from a null that was already legitimate. Converting null values back to empty lists would corrupt user intent.
Enterprise server image for this PR: