The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(anthropic): probe every PATH hit before the install prefixes
kshitijk4poore58d7df33974
diff --git a/agent/anthropic_adapter.py b/agent/anthropic_adapter.pyindex 1297d740ba0..d94b176e5f2 100644--- a/agent/anthropic_adapter.py+++ b/agent/anthropic_adapter.py@@ -6,7 +6,9 @@ credentials}.py``; import them from there."""import loggingimport math+import osimport re+import shutilimport subprocessfrom collections.abc import Iterablefrom contextlib import suppress@@ -231,15 +233,25 @@ _CLAUDE_CODE_PREFIXES = ()+_CLAUDE_CODE_NAMES = ("claude", "claude-code")++def _claude_code_candidates() -> List[str]:- """Executable paths to try, PATH hit first, deduped and filtered to files that exist."""- import os.path- import shutil+ """Executable paths to try, deduped and filtered to files that exist.+ Two passes: every PATH hit first (what the user's shell would run), then the+ well-known install prefixes. A single nested loop would probe a stale prefix+ ``claude`` before a current PATH ``claude-code``.+ """seen: Dict[str, None] = {}- for name in ("claude", "claude-code"):- for cmd in (shutil.which(name), *(f"{p}/{name}" for p in _CLAUDE_CODE_PREFIXES)):- if cmd and os.path.isfile(path := os.path.expanduser(cmd)):+ for name in _CLAUDE_CODE_NAMES:+ hit = shutil.which(name)+ if hit and os.path.isfile(hit):+ seen.setdefault(hit)+ for prefix in _CLAUDE_CODE_PREFIXES:+ for name in _CLAUDE_CODE_NAMES:+ path = os.path.join(os.path.expanduser(prefix), name)+ if os.path.isfile(path):seen.setdefault(path)return list(seen)