{"record":{"id":"418c49f9ab24e54c","repo":"HKUDS/DeepTutor","slug":"installed-codebuddy-agent-sdk-does-not-expose-quer","errorCode":null,"errorMessage":"Installed codebuddy-agent-sdk does not expose query().","messagePattern":"Installed codebuddy-agent-sdk does not expose query\\(\\)\\.","errorType":"error_code","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"deeptutor/services/llm/provider_core/codebuddy_provider.py","lineNumber":379,"sourceCode":"                if task is not None:\n                    task.uncancel()\n            except Exception:\n                pass\n\n    def get_default_model(self) -> str:\n        return self.default_model\n\n\ndef _load_sdk() -> ModuleType:\n    try:\n        import codebuddy_agent_sdk\n    except ImportError as exc:  # pragma: no cover - optional dependency\n        raise RuntimeError(\n            \"codebuddy-agent-sdk is not installed. Install it with \"\n            \"`python -m pip install codebuddy-agent-sdk` or `pip install -e .[codebuddy]`.\"\n        ) from exc\n    if not hasattr(codebuddy_agent_sdk, \"query\"):\n        raise RuntimeError(\"Installed codebuddy-agent-sdk does not expose query().\")\n    return codebuddy_agent_sdk\n\n\ndef _strip_model_prefix(model: str | None) -> str | None:\n    if not model:\n        return None\n    if \"/\" not in model:\n        return model\n    prefix, value = model.split(\"/\", 1)\n    if prefix.lower().replace(\"-\", \"_\") in {\"codebuddy\", \"codebuddy_code\", \"workbuddy\"}:\n        return value\n    return model\n\n\ndef _build_options(\n    sdk: ModuleType,\n    model: str | None,\n    max_tokens: int,","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/services/llm/provider_core/codebuddy_provider.py#L361-L397","documentation":"The codebuddy-agent-sdk package IS installed, but it doesn't expose the `query()` function this provider's integration contract requires — meaning an incompatible or outdated SDK version was installed. _load_sdk() validates the API surface after import and raises RuntimeError.","triggerScenarios":"An older/newer fork of codebuddy-agent-sdk where query() was renamed or removed; installing the SDK from PyPI while the provider expects the deeptutor-pinned version.","commonSituations":"Version drift after `pip install -U codebuddy-agent-sdk`, a lockfile pinning an old version, or a renamed API in a major SDK release.","solutions":["Install the version the provider pins: pip install \"deeptutor[codebuddy]\" which resolves a compatible SDK.","Check the installed version (pip show codebuddy-agent-sdk) and compare with deeptutor's requirement.","Downgrade/upgrade to the version whose module exposes query()."],"exampleFix":"# before\npip install codebuddy-agent-sdk  # latest, API changed\n\n# after\npip install \"deeptutor[codebuddy]\"  # resolves compatible SDK version","handlingStrategy":"validation","validationCode":"import codebuddy_agent_sdk\nif not hasattr(codebuddy_agent_sdk, \"query\"):\n    print(\"Incompatible codebuddy-agent-sdk version; reinstall via pip install 'deeptutor[codebuddy]'\")","typeGuard":"def sdk_has_query() -> bool:\n    try:\n        import codebuddy_agent_sdk as sdk\n    except ImportError:\n        return False\n    return hasattr(sdk, \"query\")","tryCatchPattern":"try:\n    ...\nexcept RuntimeError as e:\n    if \"does not expose query\" in str(e):\n        subprocess.run([sys.executable, \"-m\", \"pip\", \"install\", \"deeptutor[codebuddy]\"])\n    raise","preventionTips":["Install the codebuddy extra rather than the bare SDK so versions stay coupled.","Add a startup capability check (sdk_has_query()) before enabling the provider.","Lock dependency versions in CI to catch SDK drift."],"tags":["codebuddy","version-mismatch","sdk","breaking-change"],"backgroundTag":"sdk-version-incompatible","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}