HKUDS/DeepTutor · error · RuntimeError
CodeBuddy CLI is required to sync account models.
Error message
CodeBuddy CLI is required to sync account models.
What it means
fetch_codebuddy_models() needs the CodeBuddy CLI executable (codebuddy or cbc) on PATH to query the account's model catalog via a subprocess; shutil.which() found neither, so it raises RuntimeError. The SDK alone isn't enough — model sync shells out to the CLI.
Source
Thrown at deeptutor/services/llm/provider_core/codebuddy_provider.py:788
return
async with _API_KEY_ENV_LOCK:
previous = os.environ.get(_CODEBUDDY_API_KEY_ENV)
os.environ[_CODEBUDDY_API_KEY_ENV] = api_key
try:
yield
finally:
if previous is None:
os.environ.pop(_CODEBUDDY_API_KEY_ENV, None)
else:
os.environ[_CODEBUDDY_API_KEY_ENV] = previous
async def fetch_codebuddy_models(api_key: str | None = None) -> list[str]:
"""Return the model catalog currently available to the logged-in account."""
_load_sdk()
cli_path = shutil.which("codebuddy") or shutil.which("cbc")
if not cli_path:
raise RuntimeError("CodeBuddy CLI is required to sync account models.")
cli_args = [
cli_path,
"--print",
".",
"--model",
"__deeptutor_list_models__",
"--output-format",
"json",
"--max-turns",
"1",
]
process_kwargs: dict[str, Any] = {}
if os.name == "nt":
command = ["cmd.exe", "/d", "/s", "/c", subprocess.list2cmdline(cli_args)]
# Windows-only constants; the stubs omit them off-Windows, and mypy
# cannot narrow on os.name the way it narrows on sys.platform.
process_kwargs["creationflags"] = (View on GitHub (pinned to 3e82f13042)
Solutions
- Install the CodeBuddy CLI and ensure `codebuddy` (or `cbc`) is on PATH (verify with `which codebuddy`).
- In containers/CI, add the CLI install step to the image.
- If PATH is the issue, launch the process with an environment that includes the CLI's install dir.
Example fix
# before # CLI not installed models = await fetch_codebuddy_models() # after # Dockerfile / CI RUN npm install -g @codebuddy/cli models = await fetch_codebuddy_models()
Defensive patterns
Strategy: validation
Validate before calling
import shutil
if not (shutil.which("codebuddy") or shutil.which("cbc")):
print("CodeBuddy CLI missing — install it and ensure it is on PATH") Type guard
def codebuddy_cli_on_path() -> bool:
import shutil
return shutil.which("codebuddy") is not None or shutil.which("cbc") is not None Try / catch
try:
models = await fetch_codebuddy_models()
except RuntimeError as e:
if "CLI is required" in str(e):
# skip model sync, use a static fallback list
models = ["fallback-model"]
else:
raise Prevention
- Install the CLI in the same image/environment as the SDK.
- Add a which-codebuddy check to container healthchecks.
- Fall back to a cached/static model list when the CLI is absent.
When it happens
Trigger: Calling fetch_codebuddy_models() on a machine without the CodeBuddy CLI installed, or where the binary isn't on PATH (installed via nvm-style isolated location, GUI session PATH, container image).
Common situations: Docker/CI images that pip-install the SDK but never install the CLI; SSH non-login shells with trimmed PATH; macOS app-launched processes missing /usr/local/bin.
Related errors
- codebuddy-agent-sdk is not installed. Install it with `pytho
- Installed codebuddy-agent-sdk does not expose query().
- The installed codebuddy-agent-sdk does not accept the turn l
- {output.strip() or "CodeBuddy did not return an account mode
- {_SIGN_IN_HINT}
AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27).
Data as JSON: /api/errors/eac9f6d1aacd29cf.
Report an issue: GitHub.