Description
When OpenAlice is started from within a Claude Code terminal session (e.g., running pnpm dev inside Claude Code), the Agent SDK provider silently fails. All user messages receive no response — the SSE stream either hangs or closes abruptly.
Root Cause
Claude Code sets a CLAUDECODE environment variable in its shell. When OpenAlice's Agent SDK spawns a new Claude Code subprocess via @anthropic-ai/claude-agent-sdk, this variable is inherited through process.env, causing the subprocess to detect a "nested session" and exit immediately with code 1:
Error: Claude Code cannot be launched inside another Claude Code session.
Nested sessions share runtime resources and will crash all active sessions.
Steps to Reproduce
- Open a terminal inside Claude Code
- Run
pnpm dev to start OpenAlice
- Send any message via the Web UI
- Observe: no response is returned;
logs/agent-sdk.log shows "Claude Code process exited with code 1"
Expected Behavior
OpenAlice should respond normally regardless of whether it was launched from a Claude Code terminal.
Environment
- Claude Code: v2.1.96
- Agent SDK: v0.2.72
- Node.js: v24.4.1
- macOS (Darwin 25.3.0)
Description
When OpenAlice is started from within a Claude Code terminal session (e.g., running
pnpm devinside Claude Code), the Agent SDK provider silently fails. All user messages receive no response — the SSE stream either hangs or closes abruptly.Root Cause
Claude Code sets a
CLAUDECODEenvironment variable in its shell. When OpenAlice's Agent SDK spawns a new Claude Code subprocess via@anthropic-ai/claude-agent-sdk, this variable is inherited throughprocess.env, causing the subprocess to detect a "nested session" and exit immediately with code 1:Steps to Reproduce
pnpm devto start OpenAlicelogs/agent-sdk.logshows"Claude Code process exited with code 1"Expected Behavior
OpenAlice should respond normally regardless of whether it was launched from a Claude Code terminal.
Environment