The 2026-04-30 staging incident traced back to workspaces booting with ANTHROPIC_BASE_URL pointing at a non-Anthropic shim (MiniMax / OpenAI gateway) but no explicit model configured. The adapter silently fell back to "sonnet" — an Anthropic-native alias the upstream didn't recognize — and the SDK --print probe hung 30s before timing out. Platform's phantom-busy sweep then nuked the workspace at 10min, producing "every workspace dead" with the root cause buried in a 30s subprocess hang. Pre-validate the combo at adapter boot: when ANTHROPIC_BASE_URL host is non-Anthropic AND no explicit model is set, raise ValueError with an actionable message pointing to MODEL_PROVIDER / runtime_config.model. Also log the resolved model + base_url_host every boot so future failures explain themselves in the workspace logs without digging into the SDK subprocess. Tests live under tests/ with their own pytest.ini that anchors rootdir there — keeps pytest from importing the package __init__.py (which does the runtime-discovery relative import that requires molecule_runtime installed). 7 tests cover: misconfig raises with the right message, Anthropic-native passes, no-base-url passes, custom-url + explicit model passes, dataclass + dict shapes, unparseable URL no-crash. CI runs them on every push/PR. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
12 lines
571 B
INI
12 lines
571 B
INI
[pytest]
|
|
# This pytest.ini anchors pytest's rootdir at tests/ (instead of the
|
|
# template directory itself). The template's __init__.py does
|
|
# `from .adapter import ClaudeCodeAdapter` for production runtime
|
|
# discovery; if pytest treats the template dir as the rootdir, it picks
|
|
# up __init__.py as a package node and the relative import fails because
|
|
# adapter.py's runtime deps (molecule_runtime, a2a) aren't installed in
|
|
# the test environment. Anchoring rootdir here keeps pytest from ever
|
|
# touching __init__.py.
|
|
addopts = --import-mode=importlib
|
|
asyncio_mode = auto
|