fix(ssh): don't leak session-scoped metadata across sibling sessions
reuseExistingEnvironment copies persistent metadata from the previous ExecutorRunning row into the new launch request so executors can pick up worktree/container/sandbox IDs. For SSH that swept in session-scoped keys too — agentctl PID/port, session dir, local forward port — which made the second session's ResumeRemoteInstance reattach to the first session's agentctl process. Mark those keys as session-scoped and skip them in applyExecutorRunningMetadata; the same-session resume path (applyRunningRecordToResumeRequest) still copies them because it works off the session's own ExecutorRunning record.
This commit is contained in:
@@ -133,9 +133,21 @@ func applyExecutorRunningMetadata(req *LaunchAgentRequest, running *models.Execu
|
||||
if metadata == nil {
|
||||
metadata = ensureLaunchMetadata(req)
|
||||
}
|
||||
if _, exists := metadata[k]; !exists && lifecycle.ShouldPersistMetadataKey(k) {
|
||||
metadata[k] = v
|
||||
if _, exists := metadata[k]; exists {
|
||||
continue
|
||||
}
|
||||
if !lifecycle.ShouldPersistMetadataKey(k) {
|
||||
continue
|
||||
}
|
||||
// Skip session-scoped runtime resources (PIDs, ports, session dirs).
|
||||
// Carrying these across sibling sessions on the same task makes a
|
||||
// fresh launch look like a same-session resume — see SSH executor's
|
||||
// ResumeRemoteInstance — and the new session ends up sharing the
|
||||
// previous session's agentctl process.
|
||||
if lifecycle.IsSessionScopedMetadataKey(k) {
|
||||
continue
|
||||
}
|
||||
metadata[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user