Repository navigation
fix(local): attribute local automation conversations per installation - #758
Conversation
…shared user Every local installation owns its rows as the same deterministic placeholder user, and that ID was forwarded as AUTOMATION_USER_ID, which the presets pass as the conversation user_id and the agent-server uses as the analytics distinct id. In local mode, forward the installation's persisted analytics identity instead, and omit the variable when it cannot be resolved. Cloud runs still forward the owner's user ID. Fixes #675 Co-authored-by: openhands <openhands@all-hands.dev>
|
📁 PR Artifacts Notice This PR adds or changes temporary PR-specific documents under |
|
Warning Your comment is too long (maximum is 65536 characters), so the coverage report was not added. See the job log for how to reduce it. |
|
@all-hands-bot Please review the latest head 18e718a. All CI checks are green and the branch merges cleanly with main. Before/after evidence is in the PR description. This comment/PR was created by an AI agent (OpenHands) on behalf of Graham Neubig. |
all-hands-bot
left a comment
There was a problem hiding this comment.
This review was posted by an AI agent (OpenHands).
Reviewed at head 18e718a7d93bfffe3e09808403c524881403d581 against the repository guidance (AGENTS.md, .agents/skills/custom-codereview-guide.md) and linked issue #675. No material findings — this is ready to merge.
Scope and ownership. Dispatch env-var forwarding and the automation service's telemetry identity belong to this repository; the change stays inside that boundary (local-mode attribution only, _get_local_user() DB ownership untouched, agent-server defense-in-depth correctly left to software-agent-sdk per the issue's triage). Issue #675 is labeled bug / ready-for-dev / priority:medium, and every acceptance criterion is met: the shared uuid5 placeholder can no longer be forwarded in local mode (overridden with the persisted automation-backend:<uuid4> identity, or omitted entirely when that cannot be read — never a fallback to the constant), cloud mode still forwards str(automation.user_id), distinct-per-installation and restart-stable identities are covered by a regression test, no migration is required, and all three preset runners' AUTOMATION_USER_ID docs now describe the local-mode value.
Correctness. The new dispatcher branch is defensive in the right direction: get_automation_backend_distinct_id (a pre-existing, unchanged helper already used for local-mode service events) fails safe to None, and None simply drops the env var — the preset runners then create the conversation without user_id rather than attributing it to a person-forming shared ID. The conversation-analytics identity now matches the distinct_id the service itself uses for local events, so run conversations and service events land on the same per-installation person, which is the intended outcome of #675. test_disable_automation's mock backend correctly becomes the cloud stand-in (is_local_mode=False); all other tests that patch get_backend already pin the mode explicitly, and the required unit-tests / backend / windows-tests checks are green on this head.
Tests and evidence. The new tests/test_local_attribution_identity.py drives the real _execute_run with the real local backend over two file-backed SQLite installations (distinct IDs, neither equals the placeholder, stable across restart, omitted when unavailable, cloud keeps the owner's user ID). I ran the focused suites locally: test_local_attribution_identity.py (3 passed), test_disable_automation.py + test_observability.py (23 passed, 8 skipped). The .pr/issue-675/ artifacts follow the repository's PR-specific-documents policy, and the PR description carries adequate design context (intent, before/after, compatibility, SHA-pinned evidence).
✅ APPROVED
|
🚀 Released in 1.33.0. |
Why
Fixes #675.
Every local installation owns its rows as the same deterministic placeholder user,
uuid5(NAMESPACE_DNS, "openhands-local-user")(auth._get_local_user). The dispatcher forwarded that ID asAUTOMATION_USER_IDon every run. The prompt, plugin and plugin-spec runners pass it as the conversationuser_id, and the agent-server uses a conversationuser_idverbatim as its analyticsdistinct_id. So every local installation reported its automation conversations as one analytics person.Summary
dispatcher._execute_run: in local mode,AUTOMATION_USER_IDis now this installation's persisted analytics identity, theautomation-backend:<uuid4>stored inautomation_service_metadata(telemetry.get_automation_backend_distinct_id). The service already uses that identity for its own local-mode events, so a run's conversation and the service's events land on the same per-installation person. If the identity cannot be read, the variable is omitted; the shared placeholder is never sent.str(automation.user_id)._get_local_user()and local DB ownership are unchanged, and no migration is needed. The identity row is created on first use withINSERT ... ON CONFLICT DO NOTHINGand stays the same across restarts.AUTOMATION_USER_IDdocs in the three preset runners now describe the local-mode value.tests/test_local_attribution_identity.py) run the real_execute_runwith the real local backend and two file-backed SQLite installations. They check that the two IDs differ and neither is the placeholder, that installation A keeps its ID after a restart, that the variable is omitted when the ID cannot be read, and that a cloud run keeps the owner's user ID. The first two tests fail onmain. The mock backend intest_disable_automation, which stands in for the cloud backend, now setsis_local_mode=False.How to Test
End to end (
.pr/issue-675/repro_675.sh): start two independent local installations, each an agent-server 1.62.0 plus the automation service in local mode with its own SQLite DB. Dispatch a custom-tarball run in each that recordsAUTOMATION_USER_ID, then restart installation A and dispatch again.Out of scope, per the issue triage: the agent-server defense-in-depth change in software-agent-sdk, and cleanup of the existing shared analytics person.
This comment/PR was created by an AI agent (OpenHands) on behalf of Graham Neubig.