Fix nested Claude Code session detection and centralize provider availability checks
Strip parent Claude Code session env vars (CLAUDECODE, CLAUDE_CODE_ENTRYPOINT, etc.) from child agent environments so spawned agents don't fail with "cannot be launched inside another Claude Code session". Centralize isProviderAvailable to check both binary and credential availability. Add red e2e test for send-during-tool-call bug and force-cancel stale foreground turns in cancelAgentRun.
This commit is contained in:
@@ -111,6 +111,26 @@ describe("applyProviderEnv", () => {
|
||||
|
||||
expect(env.PATH).toBe("/custom/path");
|
||||
});
|
||||
|
||||
test("strips parent Claude Code session env vars", () => {
|
||||
const base = {
|
||||
PATH: "/usr/bin",
|
||||
CLAUDECODE: "1",
|
||||
CLAUDE_CODE_ENTRYPOINT: "sdk-ts",
|
||||
CLAUDE_CODE_SSE_PORT: "11803",
|
||||
CLAUDE_AGENT_SDK_VERSION: "0.2.71",
|
||||
CLAUDE_CODE_ENABLE_SDK_FILE_CHECKPOINTING: "true",
|
||||
};
|
||||
|
||||
const env = applyProviderEnv(base, undefined, {});
|
||||
|
||||
expect(env.PATH).toBe("/usr/bin");
|
||||
expect(env.CLAUDECODE).toBeUndefined();
|
||||
expect(env.CLAUDE_CODE_ENTRYPOINT).toBeUndefined();
|
||||
expect(env.CLAUDE_CODE_SSE_PORT).toBeUndefined();
|
||||
expect(env.CLAUDE_AGENT_SDK_VERSION).toBeUndefined();
|
||||
expect(env.CLAUDE_CODE_ENABLE_SDK_FILE_CHECKPOINTING).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("findExecutable", () => {
|
||||
|
||||
Reference in New Issue
Block a user