Skip to content

fix(desktop): make LocalAgentProviderDetector hermetic (#9033) - #9047

Merged
kodjima33 merged 1 commit into
mainfrom
watchdog/issue-9033-hermetic-agent-detector
Jul 9, 2026
Merged

kodjima33 merged 1 commit into
mainfrom
watchdog/issue-9033-hermetic-agent-detector

Conversation

@kodjima33

@kodjima33 kodjima33 commented Jul 5, 2026 •

Copy link
Copy Markdown
Collaborator

Bug

LocalAgentProviderDetector.availability is meant to detect whether a local agent runtime (Hermes / OpenClaw) is installed, using only the injected homeDirectory + environment so it is deterministic across machines and CI runners (issue #9033).

But adapterActivationSearchDirectories hard-coded two absolute system dirs:

"/opt/homebrew/bin",
"/usr/local/bin",

These are outside the injected environment, so on any machine where openclaw/hermes are installed in a system bin dir, testLocalAgentProviderDetectorMissingPromptIsUserFacing (injects a missing PATH + /tmp/missing-home, expects unavailable) reports isAvailable == true. Detection leaks the host's global installs.

Root cause

Filesystem search included absolute system paths that ignore the injected environment/home. The committed test contract already establishes the intended design: testLocalAgentProviderDetectorIgnoresArbitraryPathEntries deliberately does not trust arbitrary $PATH; only home-relative activation dirs and the explicit OMI_*_ADAPTER_COMMAND env are trusted.

Fix

Drop /opt/homebrew/bin and /usr/local/bin from adapterActivationSearchDirectories, so detection consults only home-relative activation directories plus the explicit command env. Detection is now hermetic w.r.t. the injected homeDirectory/environment.

availability is used only as an availability gate (RealtimeHubController line ~1496); the resolved command path is not used to spawn the agent, so the actual launch path is unchanged.

Verification

xcrun swift test --filter PiMonoWiringTests/testLocalAgentProviderDetector — all 4 detector tests pass (0 failures); clean debug compile.

🤖 automated by hourly watchdog; opened for review, not merged.

Review in cubic

adapterActivationSearchDirectories hard-coded /opt/homebrew/bin and
/usr/local/bin, so local-agent (Hermes/OpenClaw) availability depended on
the host machine's global installs instead of only the injected
homeDirectory/environment. On any machine where those agents are installed
in a system bin dir, testLocalAgentProviderDetectorMissingPromptIsUserFacing
(missing home + missing PATH) wrongly reported the agent as available.

Drop the two absolute system dirs so detection consults only home-relative
activation directories plus the explicit OMI_*_ADAPTER_COMMAND env — matching
the ratified test contract (arbitrary $PATH already intentionally ignored).
The resolved command path is used only as an availability gate, not to spawn,
so the actual launch path is unchanged.

🤖 automated by hourly watchdog; opened for review, not merged.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Re-trigger cubic

@Git-on-my-level

Copy link
Copy Markdown
Member

Static review of this small hermeticity fix (automated by Omi PR monitor, model: glm-5.2).

Verified correct: The change correctly removes /opt/homebrew/bin and /usr/local/bin from LocalAgentProviderDetector.adapterActivationSearchDirectories, so availability detection is now driven only by the injected homeDirectory/environment, consistent with issue #9033 and the existing test contract in PiMonoWiringTests.swift (4 detector tests).

Launch path unchanged — confirmed: I checked that the actual spawn path resolution in AgentRuntimeProcess.swift (lines ~598–625) has its own adapterSearchDirs that still includes the system bin dirs, and the detector's resolved path is never passed to the process spawner. The detector is consumed only as an availability gate (4 call sites: RealtimeHubController, FloatingControlBarWindow, ChatToolExecutor, RealtimeHubTools). So the PR's claim that the launch path is unchanged is accurate.

UX trade-off to flag for maintainer awareness: After this change the availability detector is narrower than the launcher. A user who installed hermes or openclaw only via Homebrew (/opt/homebrew/bin) will now see the "not installed" setup prompt even though the launcher would still find and run the binary. That may be the intended behavior for deterministic detection (it aligns with #9033), but it is a user-visible shift worth a conscious sign-off.

CI note: Lint & Format Check is failing only because check-desktop-changelog.py requires a changelog fragment under desktop/macos/changelog/unreleased/ for desktop changes. This can be resolved either by adding a one-line JSON fragment or by labeling the PR no-changelog-needed if the change is deemed internal-only (note it does affect user-visible prompts).

Flagging for human maintainer review on the detection-breadth trade-off. Not approving — the UX implication and failing CI warrant human judgment.

@Git-on-my-level Git-on-my-level added the needs-maintainer-review Needs a human maintainer to sign off before merge label Jul 5, 2026

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the focused fix. The code change looks directionally right to me: it removes the non-hermetic /opt/homebrew/bin and /usr/local/bin probes, while still preserving the explicit OMI_*_ADAPTER_COMMAND escape hatch and the home-relative activation locations. That matches the detector tests' existing contract of not trusting arbitrary host PATH state.

Blocking before merge: the required lint/format workflow is currently failing because this desktop change does not include an unreleased desktop changelog fragment:

FAIL: desktop changes require an unreleased changelog fragment.
Add a one-line user-facing JSON fragment under desktop/macos/changelog/unreleased/, or label the PR no-changelog-needed for internal-only changes.

Please either add the changelog fragment, or have a maintainer decide this is internal-only and apply no-changelog-needed. I did not formally approve because the PR is marked for maintainer review and the required check is failing.

Verification from my side:

  • Reviewed the one-file Swift diff and surrounding detector/tests.
  • Reproduced the changelog gate failure locally with python3 .github/scripts/check-desktop-changelog.py --base origin/main --head HEAD.
  • Could not rerun the macOS Swift test here because this Linux runner does not have xcrun installed.

@kodjima33
kodjima33 merged commit fab03f0 into main Jul 9, 2026
2 of 3 checks passed
@kodjima33
kodjima33 deleted the watchdog/issue-9033-hermetic-agent-detector branch July 9, 2026 04:06
@undivisible undivisible added the AI label Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI needs-maintainer-review Needs a human maintainer to sign off before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants