Hey <@U06PYTVAES1> <@U08DZAR5JR3> could we sync re...
# dev-help
q
Hey @calm-artist-7206 @flaky-jordan-67349 could we sync regarding the org changes in 🧵 Seems like there's missing context that would be helpful to have consensus on
nod 1
šŸ‘ 2
Chuck will be posting the org requirements shortly There was prior discussion wrt the the database schemas https://openhands-ai.slack.com/archives/C09FJAZSP9N/p1761331470863679 If I understand correctly, Engel wants schema like the following which limit the foreign key dependencies and avoids introducing org tables locally Is this correct from a high level overview before we dig into the technical details?
^ i may be jumping the gun, please feel free to post additional context wrt how you're thinking about orgs (both product + tech constraints)
f
Here is the initial requirements/design doc that we were working off. This was created prior to V1 existing:
So I think we should look at 2 options. 1. Figure out the best way to remove all of the org stuff from the OSS schema without sacrificing any of the needed functionality 2. Make the OSS schema the same wrt orgs. It would be overkill in that it would not be used to its fullest and would be somewhat confusing in that context, but would be consistent for both OSS and SAAS.
c
@flaky-jordan-67349 on those options, please see the link that Rohit posted, I think we saw 3 options actually
f
I will look, but I think splitting the schemas would be more work.
c
So it's like • add org_id to openhands • remove user_id from openhands (conversation metadata table), and keep both user_id and org_id as Saas only • keep user_id, which is the status quo, but don't add org_id, and instead just join org table as necessary in the Saas
Let me take a step back. We have multiple issues here: • multiple orgs issue - which may actually be a user login issue? • org_id issue (OH/SaaS) • db model to account for org settings defaults/overrides
Chuck, I'd love to pick your brain about the first a bit, sorry to be dense, because I just realized maybe I didn't understand it: If we imagine we'd like this behavior: • we have user accounts, unrelated to an org • to be part of an org, a user would make a new account tied to that org Please bear with me for a bit, it's just an hypothesis. So my question is: if that was the behavior we want, is it even possible to do that, since user logins are... tied to github accounts?
f
I'm trying to get a full understanding of how this fits in with the V1 changes myself. These changes were originally in the "deploy" (i.e. SAAS) repo only.
nod 1
In SAAS, we are going to create a "personal" org for every user when it gets created. So the settings for a user will always be a combination of org and user settings.
c
Was it actually working, or was it a prototype, or WIP ?
f
It was about 80% complete before it go shelved for higher priority work.
šŸ‘ 1
So I'm suggesting we could do the same in OSS, just create an org when you "create" your user by linking to github. It would only impact how things are stored, not used in the python code.
But I'm open to not doing anything with orgs in the OSS code if we can make it work cleanly.
I just need to think about it (I'm just getting back from vacation today and this is the first I'm hearing about this issue).
c
We can make it work cleanly šŸ‘
šŸ‘ 1
f
The main issue is that we need to have users be able to switch between orgs (in SAAS/on-prem installs). So they will get different settings based on which org they are currently using. It's a way initially for companies to track spending and add funds for a group of users (more org specific stuff will follow).
One of those follow on things had to do with conversations and potentially allowing sharing with other users in an org.
So that was why the org_id showed up in that table.
q
If I'm understanding correctly, Engel is suggesting that we have a separate table where each row has an entry tying
conversation_id
<>
org_id
(something to that effect) But the conversation metadata table itself should not contain any
user_id
,
org_id
etc That way locally we can avoid any org related tables/logic. And the conversation metadata table will look identical between OSS and SAAS
f
Yes, we would need some reference in the conversation metadata table. That could point to just the user in OSS, and potentially the org_member table in SAAS.
Could be something like "owner_id"?
So instead of "github_user_id", "user_id", and "org_id", you could have "owner_id". In the OSS python models that "owner_id" would map to the "github_user_id" most likely. In SAAS, it would map to an "org_member_id" which would give us the user and org that the conversation belongs to.
I supposed it could be null in OSS if we deem it completely unnecessary.
But I assume the "github_user_id" is there for a reason.
c
org_id, user_id and conversation_id are indexed. šŸ¤” How bad would it be if we have: ConversationMetadata • conversation_id Some table • conversation_id • user_id • org_id
f
Probably not terrible.
So the separate table only exists in SAAS DB and models?
nod 2
c
But I assume the "github_user_id" is there for a reason.
I don't think so... šŸ¤” To the best of my knowledge there was an attempt to make the same migrations, so the initial ConversationMetadata table may have been designed with that assumption or hope. But I understand from Rohit that it didn't work? and it seems it won't work with orgs anyway
f
I can make these changes tonight. Shouldn't take too long.
q
"github_user_id" was there when we first rolled out saas and can be dropped completely we use "keycloak_id" now (used interchangeably with "user_id")
the "org_id" requirement in "StoredConversationMetadata" storage model was causing conflict with the local migrations The solution engel proposed above should solve this
aha 1
f
OK. I will attempt to pull it all together after dinner tonight and update the PR. Maybe we can even get it merged in the next day or 2. šŸ™‚
gratitude thank you 2
I made significant progress, but have some more to do. Still have some issues with local dev env with the move to V1 and being out last week. Things change pretty fast. šŸ™‚ I want to make sure some of the errors I'm getting aren't due to my changes, so I will try to get some of Tim's time tomorrow. Should be able to finish once I get past that. The OSS code works fine as I've removed all the user_id and org_id references. Just need to find everywhere on the SAAS side that uses StoredConversationMetadata and make sure it used the new class as well.
p
Interesting discussion have you guys considered user === org? (a db field could designate a user as an org; many packaging systems have this "upgrade own account to org protocol") also, I see an opportunity for multiple users working on the same conversational session, real-time, like a multiplayer chatroom the UX of which would go leaps and bounds above the solitary me+agent workflow of today would love to invite friends, in the same trajectory, to co-guide the swe-agent(s)
f
I've pushed up a commit with the fixes discussed. It seems to work as much as I could test it. I seem to be running into V1/repo rename issues.
Looks like I've got to update the tests. Working on that now.
All but one test works now. Looking at this test (test_user_isolation) to see if it is still valid in the OSS context. I don't think it is, but would need to be replaced by something similar in the enterprise tests.
thanks on a stick 1