fix: unset CLAUDECODE in spawned sessions to prevent nested session errors
The spawn command was creating tmux sessions without calling agent.getEnvironment(), causing spawned sessions to inherit CLAUDECODE from the parent orchestrator session. This caused Claude to refuse to start with "cannot launch inside another Claude Code session" error. Now properly calls agent.getEnvironment() and merges those env vars (including CLAUDECODE="") into the tmux session creation. Fixes sessions ao-22 through ao-25 which were spawned but never had Claude running. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
79aac7cf1d
commit
a6866458ec
|
|
@ -133,9 +133,17 @@ async function spawnSession(
|
|||
|
||||
spinner.text = "Creating tmux session";
|
||||
|
||||
// Get agent-specific environment variables (e.g., unset CLAUDECODE)
|
||||
const agentEnv = agent.getEnvironment({
|
||||
sessionId: sessionName,
|
||||
projectConfig: project,
|
||||
issueId,
|
||||
permissions: project.agentConfig?.permissions,
|
||||
});
|
||||
|
||||
// Create tmux session
|
||||
const envVar = `${prefix.toUpperCase().replace(/[^A-Z0-9_]/g, "_")}_SESSION`;
|
||||
await exec("tmux", [
|
||||
const tmuxArgs = [
|
||||
"new-session",
|
||||
"-d",
|
||||
"-s",
|
||||
|
|
@ -152,7 +160,14 @@ async function spawnSession(
|
|||
`AO_DATA_DIR=${config.dataDir}`,
|
||||
"-e",
|
||||
"DIRENV_LOG_FORMAT=",
|
||||
]);
|
||||
];
|
||||
|
||||
// Add agent environment variables
|
||||
for (const [key, value] of Object.entries(agentEnv)) {
|
||||
tmuxArgs.push("-e", `${key}=${value}`);
|
||||
}
|
||||
|
||||
await exec("tmux", tmuxArgs);
|
||||
|
||||
// Run post-create hooks before agent launch (so environment is ready)
|
||||
if (project.postCreate) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue