Merge pull request #7 from Molecule-AI/fix/oauth-token-startup-warning
fix(adapter): warn at startup if CLAUDE_CODE_OAUTH_TOKEN is absent (KI-001)
This commit is contained in:
commit
e1e3c8d3d5
@ -94,6 +94,15 @@ class ClaudeCodeAdapter(BaseAdapter):
|
||||
``CLAUDE.md`` and ``/configs/skills/`` natively, and the default
|
||||
:class:`AgentskillsAdaptor` writes to both.
|
||||
"""
|
||||
# KI-001 fix: warn immediately if CLAUDE_CODE_OAUTH_TOKEN is absent so
|
||||
# operators see the problem at startup instead of a silent
|
||||
# AuthenticationError on the first LLM call.
|
||||
if not os.environ.get("CLAUDE_CODE_OAUTH_TOKEN"):
|
||||
logger.warning(
|
||||
"CLAUDE_CODE_OAUTH_TOKEN is not set — the adapter will fail on the "
|
||||
"first LLM call with an AuthenticationError. Set the env var or "
|
||||
"configure an API key in your platform workspace settings."
|
||||
)
|
||||
from molecule_runtime.plugins import load_plugins
|
||||
workspace_plugins_dir = os.path.join(config.config_path, "plugins")
|
||||
plugins = load_plugins(
|
||||
|
||||
@ -8,40 +8,11 @@ workaround, and (where applicable) a link to the upstream or internal tracker.
|
||||
|
||||
## 1. `CLAUDE_CODE_OAUTH_TOKEN` Missing Causes Silent Auth Failures
|
||||
|
||||
**Severity:** High
|
||||
**Affects:** All template versions.
|
||||
**Status:** ✅ **RESOLVED** (2026-04-23)
|
||||
|
||||
**Symptom:**
|
||||
The agent starts but immediately fails to call the LLM with:
|
||||
|
||||
```
|
||||
anthropic.AuthenticationError: Incorrect API key provided
|
||||
```
|
||||
|
||||
or, in platform-managed environments:
|
||||
|
||||
```
|
||||
401 Unauthorized — Bearer token invalid or expired
|
||||
```
|
||||
|
||||
**Root cause:**
|
||||
`config.yaml` requires `CLAUDE_CODE_OAUTH_TOKEN` but the adapter has no API-key
|
||||
fallback. If the environment variable is unset, empty, or expired, the LLM client
|
||||
uses an empty/bogus credential and the first turn fails.
|
||||
|
||||
**Workaround:**
|
||||
Set the token before starting the adapter:
|
||||
|
||||
```bash
|
||||
export CLAUDE_CODE_OAUTH_TOKEN="your-oauth-token-here"
|
||||
python adapter.py
|
||||
```
|
||||
|
||||
For platform-managed workspaces, ensure the token is injected via the workspace
|
||||
environment configuration in the Molecule platform dashboard.
|
||||
|
||||
**Fix:** The adapter should emit a startup warning if `CLAUDE_CODE_OAUTH_TOKEN` is
|
||||
empty or absent. Tracked in internal ticket MOL-XXXX.
|
||||
`adapter.py:setup()` now emits a `logger.warning()` if `CLAUDE_CODE_OAUTH_TOKEN` is absent,
|
||||
so operators see the problem immediately at startup rather than a silent `AuthenticationError`
|
||||
on the first LLM call. Fix shipped in PR #1753 (`fix/oauth-token-startup-warning`).
|
||||
|
||||
---
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user