Summary
IM channel session sidecars do not inherit Provider API keys during initialization. While the main (direct) session correctly receives apiKeySource: "ANTHROPIC_API_KEY", IM sessions (WeChat, Telegram) receive apiKeySource: "none", causing the Claude Code SDK to generate a synthetic authentication_failed error before any model API call is attempted.
Impact: All IM channels are completely non-functional — every inbound message returns "Not logged in · Please run /login" regardless of channel type or plugin login status.
Reproduction Environment
- MyAgents version: 0.4.0
- OS: Windows 11 Home China 10.0.26200
- SDK version: Claude Code 2.1.201
- Runtime: builtin
- Model: deepseek-v4-pro (DeepSeek provider, protocol: anthropic)
- Affected channels: openclaw-weixin (WeChat), telegram
- Permission mode: fullAgency
Steps to Reproduce
- Configure an agent with a non-Anthropic Provider (e.g. DeepSeek) that has a valid API key
- Add an IM channel (WeChat or Telegram)
- Send a message to the bot
- Observe: "Not logged in · Please run /login"
Evidence
Main session (working)
"apiKeySource": "ANTHROPIC_API_KEY"
IM session (broken)
Both sessions: same workspace, same model (deepseek-v4-pro[1m]), same SDK version (2.1.201), same permission mode. Only apiKeySource differs.
SDK synthetic error (0 API calls)
{
"type": "result",
"is_error": true,
"duration_ms": 25,
"duration_api_ms": 0,
"result": "Not logged in · Please run /login",
"usage": { "input_tokens": 0, "output_tokens": 0 }
}
{
"message": {
"model": "<synthetic>"
},
"error": "authentication_failed"
}
model: "<synthetic>" and duration_api_ms: 0 confirm the model was never called.
WeChat plugin login is successful (not the cause)
From openclaw log: login confirmed, monitor started, messages received and dispatched correctly. The plugin forwards messages to the SDK, and the SDK returns the error synthetically.
Root Cause
- Direct sessions: MyAgents injects the Provider API key into the sidecar → SDK sees
apiKeySource: "ANTHROPIC_API_KEY"
- IM sessions: The sidecar spawns via a different code path that does NOT inject the Provider API key → SDK sees
apiKeySource: "none" → immediate rejection
Workaround
Set ANTHROPIC_API_KEY as a Windows system-level environment variable:
setx ANTHROPIC_API_KEY "any-non-empty-value"
Then restart MyAgents. The SDK only checks for variable presence; MyAgents proxy handles real auth.
Suggested Fix
In the IM session sidecar initialization path, ensure Provider API key credentials are passed to the sidecar process, mirroring the direct session path.
Summary
IM channel session sidecars do not inherit Provider API keys during initialization. While the main (direct) session correctly receives
apiKeySource: "ANTHROPIC_API_KEY", IM sessions (WeChat, Telegram) receiveapiKeySource: "none", causing the Claude Code SDK to generate a syntheticauthentication_failederror before any model API call is attempted.Impact: All IM channels are completely non-functional — every inbound message returns "Not logged in · Please run /login" regardless of channel type or plugin login status.
Reproduction Environment
Steps to Reproduce
Evidence
Main session (working)
IM session (broken)
Both sessions: same workspace, same model (
deepseek-v4-pro[1m]), same SDK version (2.1.201), same permission mode. OnlyapiKeySourcediffers.SDK synthetic error (0 API calls)
{ "type": "result", "is_error": true, "duration_ms": 25, "duration_api_ms": 0, "result": "Not logged in · Please run /login", "usage": { "input_tokens": 0, "output_tokens": 0 } }{ "message": { "model": "<synthetic>" }, "error": "authentication_failed" }model: "<synthetic>"andduration_api_ms: 0confirm the model was never called.WeChat plugin login is successful (not the cause)
From openclaw log: login confirmed, monitor started, messages received and dispatched correctly. The plugin forwards messages to the SDK, and the SDK returns the error synthetically.
Root Cause
apiKeySource: "ANTHROPIC_API_KEY"apiKeySource: "none"→ immediate rejectionWorkaround
Set
ANTHROPIC_API_KEYas a Windows system-level environment variable:Then restart MyAgents. The SDK only checks for variable presence; MyAgents proxy handles real auth.
Suggested Fix
In the IM session sidecar initialization path, ensure Provider API key credentials are passed to the sidecar process, mirroring the direct session path.