feat(agent-registry): prefer globally installed agent binaries over npx#230
Open
ApolloS-Hub wants to merge 1 commit intoopenclaw:mainfrom
Open
feat(agent-registry): prefer globally installed agent binaries over npx#230ApolloS-Hub wants to merge 1 commit intoopenclaw:mainfrom
ApolloS-Hub wants to merge 1 commit intoopenclaw:mainfrom
Conversation
When a built-in agent adapter (e.g. claude-agent-acp, codex-acp) is globally installed and available on PATH, use it directly instead of falling back to npx package-exec. This eliminates the network dependency during agent spawn, which is critical for: - Slow-network environments (high latency to npm registry) - Corporate proxies / restricted networks - Regions with unreliable npm mirror access - Faster startup in all environments (no npx cache check overhead) Resolution order is now: 1. Local node_modules install (existing behavior) 2. Global PATH binary (NEW - via which/where) 3. npx package-exec bridge (existing fallback) The new resolveGlobalPathAgentLaunch() function uses 'which' (Unix) or 'where' (Windows) with a 5-second timeout to detect globally installed binaries. Fixes openclaw/openclaw#51345
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When a built-in agent adapter (e.g.
claude-agent-acp,codex-acp) is globally installed and available onPATH, use it directly instead of falling back tonpxpackage-exec.Problem
The current agent resolution only checks:
node_modulesinstallnpxpackage-exec bridgeIn slow-network environments (high latency to npm registry, corporate proxies, China mainland, restricted networks), the
npxdownload/cache-check during probe can time out, causing the acpx backend to stay atregisteredand never reachready. This manifests assessions_spawn(runtime="acp")hanging indefinitely.Related: openclaw/openclaw#51345 —
sessions_spawn(runtime="acp") hangs immediatelySolution
Add a new resolution step between local install and npx fallback:
New
resolveGlobalPathAgentLaunch()function useswhich(Unix) orwhere(Windows) with a 5-second timeout to detect globally installed binaries.Changes
src/agent-registry.ts: AddedresolveGlobalPathAgentLaunch()and integrated it intoresolveBuiltInAgentLaunch()resolution chainsrc/acp/client.ts: Added spawn log message forglobal-pathsourcetest/agent-registry.test.ts: Added 4 new tests covering the global PATH resolutionBenefits
which) and Windows (where)Test Results
All 16 tests pass, including 4 new tests:
resolveGlobalPathAgentLaunch uses a globally installed binary from PATHresolveGlobalPathAgentLaunch returns undefined when binary is not on PATHresolveGlobalPathAgentLaunch ignores non-built-in commandsresolveBuiltInAgentLaunch prefers global PATH over package-exec when local install unavailable