Bug 描述
使用 spawn 创建子 agent 时,子 agent 调用 litellm → OpenRouter 时报 401 User not found,无法正常执行任务。
根因分析
- Raven 主进程从
config.json 的 providers.openrouter.apiKey 读取 API key,主会话正常
spawn 出的子 agent 通过 litellm 调用 LLM
litellm 从环境变量 OPENROUTER_API_KEY 读取 API key
- 当前环境没有设置
OPENROUTER_API_KEY 环境变量
- litellm 带着空 key 发请求 → OpenRouter 返回
401 User not found
复现步骤
raven config 中 provider 设置为 openrouter
执行任意 spawn 操作
→ 子 agent 立即报错: 401 User not found
日志
~/.raven/workspace/sessions/sub/2064bdc3.jsonl:
{"role": "assistant", "content": "Error calling LLM: litellm.AuthenticationError: AuthenticationError: OpenrouterException - {\"error\":{\"message\":\"User not found.\",\"code\":401}}"}
建议修复
spawn 子进程时,应该将 providers.<provider>.apiKey 注入为对应 provider 的环境变量:
- OpenRouter →
OPENROUTER_API_KEY
- Anthropic →
ANTHROPIC_API_KEY
- OpenAI →
OPENAI_API_KEY
临时 workaround
export OPENROUTER_API_KEY=$(raven config show | python3 -c "import json,sys; print(json.load(sys.stdin)['providers']['openrouter']['apiKey'])")
环境
- Raven v0.1.10 / macOS arm64 / Python 3.12.13
- Provider: OpenRouter (deepseek-v4-pro)
Bug 描述
使用
spawn创建子 agent 时,子 agent 调用 litellm → OpenRouter 时报401 User not found,无法正常执行任务。根因分析
config.json的providers.openrouter.apiKey读取 API key,主会话正常spawn出的子 agent 通过litellm调用 LLMlitellm从环境变量OPENROUTER_API_KEY读取 API keyOPENROUTER_API_KEY环境变量401 User not found复现步骤
日志
~/.raven/workspace/sessions/sub/2064bdc3.jsonl:{"role": "assistant", "content": "Error calling LLM: litellm.AuthenticationError: AuthenticationError: OpenrouterException - {\"error\":{\"message\":\"User not found.\",\"code\":401}}"}建议修复
spawn子进程时,应该将providers.<provider>.apiKey注入为对应 provider 的环境变量:OPENROUTER_API_KEYANTHROPIC_API_KEYOPENAI_API_KEY临时 workaround
环境