🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(in-app-agent): gate sandbox solely via provider env var (not NODE_ENV) (#15797)
Lysander Kiesela2b1e0ef5106
diff --git a/web/src/__tests__/server/in-app-agent-api-route-auth.servertest.ts b/web/src/__tests__/server/in-app-agent-api-route-auth.servertest.tsindex b067e3728c..086cea59b5 100644--- a/web/src/__tests__/server/in-app-agent-api-route-auth.servertest.ts+++ b/web/src/__tests__/server/in-app-agent-api-route-auth.servertest.ts@@ -50,6 +50,13 @@ const langfuseClientMocks = vi.hoisted(() => ({getLangfuseClient: vi.fn(() => ({})),}));+vi.hoisted(() => {+ // This suite mocks the agent stream and does not exercise a sandbox+ // provider. Keep its provider selection explicit rather than inheriting the+ // developer's root .env.+ delete process.env.LANGFUSE_IN_APP_AGENT_SANDBOX_PROVIDER;+});+vi.mock("@/src/server/auth", () => ({getServerAuthSessionForRequest: authMocks.getServerAuthSessionForRequest,}));diff --git a/web/src/features/in-app-agent/server/handler.ts b/web/src/features/in-app-agent/server/handler.tsindex 1545498dc9..3f7cb5944f 100644--- a/web/src/features/in-app-agent/server/handler.ts+++ b/web/src/features/in-app-agent/server/handler.ts@@ -617,7 +617,7 @@ export default async function handler(request: Request) {async function getInAppAgentSandboxProvider(providerType: ReturnType<typeof getDefaultInAppAgentSandboxProviderType>,) {- if (providerType === null || env.NODE_ENV === "test") {+ if (providerType === null) {return undefined;}diff --git a/worker/src/features/in-app-agent/executeInAppAgentRun.test.ts b/worker/src/features/in-app-agent/executeInAppAgentRun.test.tsindex 4550cfa4d5..77a1a93807 100644--- a/worker/src/features/in-app-agent/executeInAppAgentRun.test.ts+++ b/worker/src/features/in-app-agent/executeInAppAgentRun.test.ts@@ -9,6 +9,10 @@ import {} from "@langfuse/shared/in-app-agent";vi.hoisted(() => {+ // This suite uses mocked agent execution and does not exercise a sandbox+ // provider. Keep its provider selection explicit rather than inheriting the+ // developer's root .env.+ delete process.env.LANGFUSE_IN_APP_AGENT_SANDBOX_PROVIDER;process.env.NEXT_PUBLIC_LANGFUSE_CLOUD_REGION ??= "DEV";process.env.NEXTAUTH_URL ??= "http://localhost:3000";process.env.LANGFUSE_AWS_BEDROCK_REGION ??= "eu-central-1";diff --git a/worker/src/features/in-app-agent/executeInAppAgentRun.ts b/worker/src/features/in-app-agent/executeInAppAgentRun.tsindex fc21170d55..561877dac4 100644--- a/worker/src/features/in-app-agent/executeInAppAgentRun.ts+++ b/worker/src/features/in-app-agent/executeInAppAgentRun.ts@@ -288,7 +288,7 @@ export async function executeInAppAgentRun(params: {// ---- Sandbox (session created/resumed lazily per tool call). ----const sandboxProviderType = getDefaultInAppAgentSandboxProviderType();const sandboxProvider =- sandboxProviderType === null || env.NODE_ENV === "test"+ sandboxProviderType === null? undefined: await createInAppAgentSandboxProvider(sandboxProviderType);