From 73f46857294aa2f0a7cb2fa5baf4aa8b43d680f7 Mon Sep 17 00:00:00 2001 From: Chris Farhood Date: Tue, 12 May 2026 07:36:08 -0400 Subject: [PATCH] feat(plugin-sdk): also thread agentId into environmentResumeLease params Symmetric with the acquireLease change. Lets plugin-backed sandbox providers reject a reusable lease whose stored agentId doesn't match the current run's agent, forcing the host to acquire a fresh lease instead of stomping the previous agent's workspace state. Co-Authored-By: Claude Opus 4.7 (1M context) --- packages/plugins/sdk/src/protocol.ts | 8 ++++++++ server/src/services/environment-runtime.ts | 1 + 2 files changed, 9 insertions(+) diff --git a/packages/plugins/sdk/src/protocol.ts b/packages/plugins/sdk/src/protocol.ts index f3c05a5e..8cf74f68 100644 --- a/packages/plugins/sdk/src/protocol.ts +++ b/packages/plugins/sdk/src/protocol.ts @@ -393,6 +393,14 @@ export interface PluginEnvironmentAcquireLeaseParams extends PluginEnvironmentDr export interface PluginEnvironmentResumeLeaseParams extends PluginEnvironmentDriverBaseParams { providerLeaseId: string; leaseMetadata?: Record; + /** + * UUID of the agent the run is being resumed for. Symmetric with + * `PluginEnvironmentAcquireLeaseParams.agentId`. Plugins can compare this + * to the agentId they stored in `leaseMetadata` at acquire time; if it + * doesn't match, return `{ providerLeaseId: null, metadata: { expired: true } }` + * to force the host to create a fresh lease for the current agent. + */ + agentId?: string; } export interface PluginEnvironmentReleaseLeaseParams extends PluginEnvironmentDriverBaseParams { diff --git a/server/src/services/environment-runtime.ts b/server/src/services/environment-runtime.ts index 1cc6e7b4..82a16221 100644 --- a/server/src/services/environment-runtime.ts +++ b/server/src/services/environment-runtime.ts @@ -476,6 +476,7 @@ function createSandboxEnvironmentDriver( config: workerConfig, providerLeaseId: reusableLease.providerLeaseId, leaseMetadata: reusableLease.metadata ?? undefined, + ...(input.agentId ? { agentId: input.agentId } : {}), }, resolvePluginSandboxRpcTimeoutMs(workerConfig), ).then((resumed) =>