Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions packages/junior/src/chat/sandbox/session.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { randomUUID } from "node:crypto";
import { Sandbox, type NetworkPolicy } from "@vercel/sandbox";
import { createBashTool } from "bash-tool";
import { setSpanAttributes, withSpan, type LogContext } from "@/chat/logging";
import { logInfo, logWarn, setSpanAttributes, withSpan, type LogContext } from "@/chat/logging";
import { getVercelSandboxCredentials } from "@/chat/sandbox/credentials";
import {
isAlreadyExistsError,
Expand Down Expand Up @@ -308,6 +308,12 @@ export function createSandboxSessionManager(options?: {
"app.sandbox.recovery.attempted": true,
"app.sandbox.recovery.source": source,
});
logWarn(
"sandbox_unavailable_recreating",
traceContext,
{ "app.sandbox.recovery.source": source },
"Sandbox unavailable; recreating",
);
Comment thread
cursor[bot] marked this conversation as resolved.
clearSession();
const replacement = await createFreshSandbox();
setSpanAttributes({
Expand Down Expand Up @@ -491,6 +497,19 @@ export function createSandboxSessionManager(options?: {
? { "app.sandbox.current_profile_hash": dependencyProfileHash }
: {}),
});
logInfo(
"sandbox_hint_discarded_profile_mismatch",
traceContext,
{
...(options?.sandboxDependencyProfileHash
? { "app.sandbox.previous_profile_hash": options.sandboxDependencyProfileHash }
: {}),
...(dependencyProfileHash
? { "app.sandbox.current_profile_hash": dependencyProfileHash }
: {}),
},
"Dependency profile changed; discarding sandbox hint and creating fresh session",
);
sandboxIdHint = undefined;
};

Expand Down Expand Up @@ -537,7 +556,16 @@ export function createSandboxSessionManager(options?: {
} as Parameters<typeof Sandbox.get>[0]),
),
);
} catch {
} catch (error) {
logWarn(
"sandbox_restore_hint_failed",
traceContext,
{
"app.sandbox.hint_id": sandboxIdHint,
"app.sandbox.error": error instanceof Error ? error.message : String(error),
},
"Failed to restore sandbox from hint; will create fresh session",
);
return null;
}

Expand Down
Loading