From c930626f82a1ac50b1ba734ce08bc1dabdb57726 Mon Sep 17 00:00:00 2001 From: Molecule AI Plugin-Dev Date: Thu, 23 Apr 2026 04:20:29 +0000 Subject: [PATCH] fix(adapter): warn at startup if CLAUDE_CODE_OAUTH_TOKEN is absent (KI-001) adapter.py:setup() now emits a logger.warning() if CLAUDE_CODE_OAUTH_TOKEN is absent, so operators see the problem immediately instead of getting a silent AuthenticationError on the first LLM call. known-issues.md updated to mark KI-001 as resolved. --- adapter.py | 9 +++++++++ known-issues.md | 37 ++++--------------------------------- 2 files changed, 13 insertions(+), 33 deletions(-) diff --git a/adapter.py b/adapter.py index af14ff5..d404a73 100644 --- a/adapter.py +++ b/adapter.py @@ -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( diff --git a/known-issues.md b/known-issues.md index 370941b..4dc9c3e 100644 --- a/known-issues.md +++ b/known-issues.md @@ -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`). ---