Further to what Engel raised: We actually do have ...
# proj-sdk
s
Further to what Engel raised: We actually do have quite a bit of config in agent-sdk: For logging! It is currently all done via environment variables: https://github.com/All-Hands-AI/agent-sdk/blob/f8e800a93a3726555a30d1c42a692f4c556187c5/openhands/sdk/logger.py#L29
w
@calm-artist-7206, sorry if I missed it but is there a tl;dr on your preferred configuration strategy for the agent server? I think the agent server should mostly be a thin implementation detail for most end users--they won't even know it exists.
most of the configuration will be at the app level, and get passed into the Agent Server via request bodies
q
I'm not totally sure that the standard way of passing config as objects would work for logging. However I'm not sure the SDK even should be making any decisions about how to log, maybe the app using it should do all that. Related, if we put OpenTelemetry into SDK, the standard way to configure that is also ENV vars.
c
I’m really not sure that works, because as we’ve seen, configuration is actually necessary and real, so the agent server is an app, not a library. The way I see this is like: • configuration is necessary for UI apps, so CLI and server access the same source of truth on local • that implies
UserContext
is a thing in the server; is a dependency that the saas will override; we build local version from configuration • configuration objects are sent via requests; but there have to be classes in there to receive them • no MU/HA concerns (directly)
w
That makes sense to me, I think we're aligned there
c
Are we? I’m referring to the agent-server, not the MU/HA-intended app server. Once we accept it has configuration, with local behavior, it means users can run it, doesn’t it?
w
Oh wait
UserContext
is a thing in the server
do you mean agent server? or app server?
IMO it's app server
c
I meant agent server. 🤔 Why does the user need an app server?
w
The app server is where we aggregate conversations, store secrets, do authentication, etc
you'd need the app server if you want to use the full web interface
(though the conversation UI really just needs an agent server)
c
The agent-server that Tim made has/had multiple conversations
Well, "store secrets" is currently a configuration thing. So while we could try to think about taking configuration out of the agent server, I'd argue that it's not the case (we already have some config functionality in agent-server), so... I'm not sure this part answers the question why does the user need an app server, sorry
w
The goal here is to offload the compute/complexity of managing the agent loop into the runtime/sandbox environment. That way we can have one server that is a straight REST API, and another that does the complicated work of managing websockets and agent loops. The idea is to treat the agent-server as completely ephemeral. E.g. in an OSS env it'd getting started/stopped just like our current nikolaik runtimes. This makes the agent server very easy to manage and reason about Then the app-server can do all the complicated stuff around configuration and long-term state--normal behavior for an application server. So not just secrets management, but suggested tasks, brokering handshakes with GitHub/GitLab/Bitbucket, and especially runtime/sandbox management
👍 1
Hypothetically we could package the OSS as frontend+agent-server. But there'd be no docker sandboxes, and it would mean almost all our integrations and other features end up in a separate app server, and would create a ton of drift between what OSS users get vs what Cloud users get
Another way to think about the problem: We want agents to run inside of containerized runtimes. We need some kind of HTTP interface to drive those agents. Currently we have a pretty bananas setup we call "nested runtimes", where we run an entire OpenHands server inside the runtime environment. The idea is to instead have an extremely lightweight "agent server" to drive agents forward
c
Please don't get me wrong; I can see some things to like about this idea. But I do also see things that really don't look right.
w
nod it's a moving target, I'm definitely open to criticism
but we also need to move quickly, even if it means we have to throw some decisions away in a few weeks and do something else
❤️ 1
c
We want agents to run inside of containerized runtimes. We need some kind of HTTP interface to drive those agents.
I see that, but why? This was a Saas need, it didn’t seem like an OH need, right? A possibility… 🤔 OK, it was always a possibility, to want to run the agent fully in a container. But it’s not clear to me why we’d do that this way - stripping down the server, fully, to the point it cannot really run without another server - when we have runtimes. And something else seems a bit strange when I look from a different perspective: • so the Saas is a MU/HA application built on top of OH • it wants to run OH • it becomes clear that running it directly as if it was OH itself doesn’t scale • so it needs, instead of a dozen lines of code to start OH, to do more, to become an app • which packages/runs OH servers, overrides configuration[1] So… I’m dense, sorry, but is that app OH? I admit, I kinda thought about this before, such app makes sense. But, to my mind, this is a MU/HA app, and it’s a more complex and heavy setup and all. I’m not sure we need to burden OH users with it What if this app is separate, a separate repo, it packages OH by maybe removing some stuff, it hooks into stuff, when it starts OH it overrides configuration, etc; it’s very interesting that it’s sorta what you’ve done, but it also isn’t: one big deal really seems to be that the “user settings” need to be a different class (two, at least, or several); it’s a big deal because it drives the rest [1] This is a sticky point where I don’t get the “no configuration” desire. It… doesn’t really work IMO. To my mind, it needs to override, rather than say it had no configuration
w
I see that, but why? This was a Saas need, it didn’t seem like an OH need, right?
It's an OSS need if you want docker sandboxes
(and to not have a giant server doing both agent loops and normal REST)
c
Do you mean a sandbox for the runtime, or what will the runtimes become in this new perspective?
w
Yes exactly (we're starting to say "sandbox" instead of "runtime" but same thing) In the new world, instead of spinning up runtimes with an ActionExecutionServer, we'll spin up runtimes with an AgentServer
That's another good way to think about it: the AgentServer is a replacement for ActionExecutionServer, but also does a bit more work (full agent loops instead of just /execute_action)
c
Yes, but that means everything, unless we strip stuff out of it lolsob
w
what do you mean "everything"?
c
Everything that the OH server is doing today?
w
it definitely does a lot--everything around agent behavior But this is also how we're doing things today with NestedRuntimes (which IIRC was actually made the default architecture for OSS recently)--we run an entire nested OH server inside the runtime, instead of just an ActionExecutionServer
but AgentServer would not include: • runtime management • endpoints for listing repos, listing suggested tasks, etc • user/app settings • long-term storage
Another goal here is to make sure runtime download/startup time is as fast as possible. This setup lets us keep AgentServer (and therefore the runtime) super minimal, and whenever we want to add a new feature to the app it goes in the bigger AppServer
q
@calm-artist-7206 I’m trying to understand your core motivation on this. Am I understanding right that what seems off is that there are two servers, rather than the specific division of responsibility between them? And is the goal being threatened usability (it might be hard to start two servers), maintainability, or something else?
❤️ 1
c
Quick answer, Ray, please excuse the quick part and ask whatever you like • I still see it as a SaaS need, which implemented this way, seems to make life harder for OH users (usability, yes) • the theory sounds good, actually, but starts wrong: with env globals on import path • b/c we say there's no configuration, while the server needs configuration to start • the env stuff flashes red to me b/c I associate it with why we have a proprietary license on the repo • in topics on the new app server, I get that it's for users, billing and potential authz; which are all MU functionality that makes no sense in OH • so I'm concerned that means much more, not less, more meaningless code intently not working in V1 than in V0
w
If env globals on import path is the thing that's really underneath all this, we can definitely fix that
q
Thanks @calm-artist-7206 that helps. On the 1st: My understanding is it's a SaaS need in the sense that it's a scalability need (or reliability at scale). So I see some difference between some quirk of our enterprise implementation and this being generally tractable to deploy. That latter is more defensibly an OSS need. OSS doesn't implement MU but it does disable it. The idea that it's less usable is an assumption that we won't package it usably, that's reasonable to assume because we have a history of clumsy setup process, but it's addressable. It's not intrinsic to something having servers. I start text editors which run copious language servers and whatever else I never notice or think of. The env/config points I'm probably don't have the context on yet to understand.
👍 1
I associate it with why we have a proprietary license on the repo
Seems like a separate question. But I'll comment FWIW. What I'm hearing is that there being a non-MIT folder in the repo creates a problem, or maybe just feels distasteful, not sure which. IMO the repo merge was in the best interest of OSS under the current architecture because it addresses very common reasons the development flow breaks OSS code. An alternative would have been that Enterprise and OSS decouple and have a clearer boundary and interface between them. That would have been my choice, but not tractable when they share the whole GUI. I would have forked the GUI. That would have made OSS more independent but also likely to miss out on more improvements and features.
> I'm concerned that means much more, not less, more meaningless code intently not working in V1 than in V0 I don't have the info to confirm that or deny, but it's a very testable idea. We could get a clear idea of what does it mean for there to be "meaningless code" and where should it not be. An example we've talked about is Redis references, we don't have to list them all right now but that's something there can be a goal around if it's important.
c
>> the env stuff flashes red to me b/c I associate it with why we have a proprietary license on the repo > If env globals on import path is the thing that's really underneath all this, we can definitely fix that Robert, it's true this sounds dumb. I think maybe it's not dumb. 🤔 This is super-tight coupling between server configuration and both OH server code, and the Saas. And it's invisible, aka unexpected side effects. Three details • the last two big rounds of CI failing in the SaaS were due, IIRC, to
SESSION_API_KEY
and python path; it's the nested runtime key (and it's in agent-server) • just skimming through the bullet points of this comment, will be enough, you'll see; it's written by the agent, but it's accurate • there are many other entanglements in the SaaS that are vying for relevance; but most are localized, while this one affects a lot - a lot - of server code. It's like, a lot of the server code in v0, both on OH and SaaS works by side effects from ambient runtime environment, which... yes it does. (specially tests because of also order / import time / env), Very sensitive to any change/refactoring/sneeze. 🫠 In v1, Tim has done a lot of containment, it's not like in v0! I think the simple thing here, that we still should clearly deal with, is that the SaaS needs to override server configuration, when it runs OH server. OK, then maybe it should do it, but explicitly, typed, by using the appropriate configuration classes and load/save methods, so we can see it and contain it. Maybe we could • accept that the agent-server has configuration • decide a single source of truth for configuration defaults/local • send it configuration override values from the SaaS • regular, typed, getters/setters • there's e.g. conversation path, that should be overriddable on local; for the SaaS it's a constant, then in a single place on the SaaS, e.g. when it initializes servers, it should always set it to the constant, and send it over Where should configuration live in V1?
Ray, sorry, for context, latest discussion was around these vars. But mostly, I meant the way it works in V0 and how many affected are there (it's definitely much better atm in V1)
🙌 1
w
Thanks Engel for the detailed explanation! > I think the simple thing here, that we still should clearly deal with, is that the SaaS needs to override server configuration, when it runs OH server. Do you mean the AppServer needs to override the AgentServer? The AgentServer is where those globals are
I think we'll need to set configuration at startup time on that server, so I don't think getters/setters will work
I feel like there's some confusion here between AgentServer, AppServer, and EnterpriseAppServer
(I just invented that last one--but that's SaaS or self-hosted)
c
Right. Will come back on the import path thing, but: > I feel like there's some confusion here between AgentServer, AppServer, and EnterpriseAppServer Yes! Yes, it most definitely is confusing! Are you thinking of this actually like, repo level: • openhands/app-server ◦ configuration, microagents, secrets ◦ integrations (git) ◦ ? • openhands/agent-server ◦ conversations, one or more idk ◦ agent loop ◦ sandbox-able • enterprise/enterprise-app-server ◦ users, billing ◦ keycloak / auth ◦ (planned) authz Package level: • openhands ◦ only agent-server or maybe also app-server • enterprise ◦ idk, enterprise-app-server?
w
OK yes let's dig in further here 😄 here's what I'm thinking • Repo: OpenHands/Agent-SDK ◦ packages: ▪︎ sdk (core classes like Agent, Conversation, LLM) ▪︎ tools (bash, browser, file edits) ▪︎ server (AgentServer) • basic HTTP endpoints for interacting w/ SDK • contains a Dockerfile • Repo: OpenHands/OpenHands ◦ directories: ▪︎ ./cli ▪︎ ./web • ./server (AppServer) • ./frontend • ./enterprise (EnterpriseAppServer) Right now, I'm WAY more concerned about the handshake between AgentServer and (Enterprise)AppServer. I want to nail that down. I think there are still big unanswered questions about the handshake between AppServer and EnterpriseAppServer. The current implementation, where we end up with two separate docker images, is pretty clean. But I'm not sure if it's been causing any pain so far since we created the ./enterprise dir
I do want to avoid having EnterpriseAppServer and AppServer in separate repos, at least for now. If we can create a more stable interface between them, great, let's get them pulled apart. But right now the interface is way too porous
➕ 1
I do think getting them into separate repos is a good long-term goal, but I think we're ~months away from that, not ~days
c
Thank you, Robert, that helps, and it's funny. Please let me take a step back, and admit it's a bit embarrassing to me, because I should have known, but I fell into a trap these days: For more than an year, you AH folks must be speaking to yourselves like, "I am deploying OpenHands on our infrastructure". But you don't. Practically never did. You are deploying a fork of OpenHands. That matters! Simple ground lines: - OpenHands is single user; the AH enterprise fork is multi user - OH has multiple runtimes; the fork has HA As you know, Robert, I completely agree that MU doesn't really belong in OH. And I really really want to take out every shred of it, implicit or explicit; it is, from my perspective, baggage polluting the code, making it harder for OSS contributors, making it fragile for everyone, and making the two, OH and the fork, way way too coupled. Up to the point you can't even normally run one or the other without a high risk of something breaking. Now. These days, I heard things like - "OH server will have users, billing" <- me: umm what confused dog - "we may implement an authorization mechanism in OH" <- me: umm what confused dog - "yes, OH's MU is disabled" <- me: umm why are we talking about an OH MU confused dog This sounded contradictory, to me. I fell into the trap of thinking you might be talking about OH. OH, the open source project. I'm sorry, I should have realized folks use the name "OH" for the fork. Like my new friend, GPT-5, I might have been too sensitive to contradictions in messaging, so... it may resolve the contradictions in the weirdest ways. 🫠 (so my brain was like, what is happening, MU in OH app server?! "what, what part, how messy does it become, why are we going the wrooooong direction. Because the direction, afaik, was towards MU being out of OH, not in.") In my defense, we're just picking apart OH and the fork, and putting them back together, so things were in flux, otherwise I would have understood from context. 😊 And, hey, you are using the same name for different things.
w
aha! Yes I think we should be more explicit when we're talking about Enterprise
c
Is there any chance you could be convinced to give it a name? Obviously 'enterprise' doesn't always help, though it's fine for its public-facing purpose. Or a codename! - Blueberry App Server (because 'strawberry' is taken 😅) Blueberry! For any dependencies.
😂 1
s
Or... SingleHanded - for the Agent Server ManyHands - for the Enterprise Server 😜
w
Yeah a fun codename might help!
c
How about • Repo: OpenHands/OpenHands ◦ directories: ▪︎ ./cli ▪︎ ./server (AppServer) ▪︎ ./frontend ▪︎ ./enterprise (EnterpriseAppServer)
Maybe (unimportant atm, just for thought) somehow integrate cli in agent-sdk, it's application level, yes, but idk, it's fairly normal to have a cli to drop to
w
Yeah I had something like that originally. But I think it kinda makes sense for all the web-related stuff to live together?
c
Well, it's the proprietary licensing. It's normal to be top level if any, and I feel it shouldn't hide among the rest
w
ah yeah that's fair
what about • Repo: OpenHands/OpenHands ◦ directories: ▪︎ ./cli ▪︎ ./web • ./server (AppServer) • ./frontend ▪︎ ./enterprise (EnterpriseAppServer)
c
Sure
🙌 1
I do think getting them into separate repos is a good long-term goal, but I think we're ~months away from that, not ~days
How does ~weeks sound? Hey, two months is 8 weeks, two months and a half is 10 weeks, one could always use the word "weeks", it's a... reasonable expression of time Nooo ulterior motive! (OK with ulterior motives)
😂 1
w
I think we're going to need to sit back and assess the situation once v1 is stable
Most likely this would come from our next tech debt sprint, which would be end of December
😓 1
q
Sounds like it was more a matter of the conditions that must be created than being able to specify a timeline. But Engel I'd like to loop you in to the quality goals I'm trying to set, and that would help me factor this kind of thing in from the perspective of "what outcomes do we want" and not "what folder structure I saw mentioned"
c
Sorry, Ray, could you elaborate?
q
Sure. I am making measurable targets for quality / reliability, repo structure is one thing that impacts that, if there is another goal that requires changing that I need to understand it, is what I'm saying
And separately you have other insights on quality needs I'd want to factor in
w
(as an example target, percentage of commits in main that have broken tests)
c
I'm still a bit unclear, sorry, what measurable targets do you see, and how you'd measure a structure we don't currently have? I mean, CI shouldn't allow now tests to break, right, so how would you assess "if we have a blueberry repo, how many/often would break" 😊
q
@calm-artist-7206 Don't take that example too literally, it's not one of them. I'll start a new thread for that. But when you say things like "harder for OSS contributors", "fragile for everyone" I agree these are problems we have and that's the sort of thing I want to make sure is captured
c
Oh, of course. Maybe these are good examples? You mentioned redis before, and you were correct, but redis is just in one or two places in the code. The OH codebase is much more cluttered with other things. My pet peeve (sorry) is
if user_id
, which means code that never works in OH. • it takes a cognitive toll on potential OSS contributors ("I should test this, wait I can't"); • it looks bad ("not intended for you buzz off"), • and it's a very fragile interface between OH and Saas, e.g. it needs remembered and passed around everywhere (by the time it made it into the event stream in OH my brain was super-snappy, couldn't stand it anymore). More details in the second link below. Two references if you'd like - this is written by the agent, but it's good enough to get a grasp on numbers of occurrences/bloat https://github.com/All-Hands-AI/OpenHands/issues/10751 - this issue has technically two parts, please ignore the "auth system" part, the most of it is my playing around with how to fix these occurrences; it also includes another widespread thing that makes the code fragile: passing tokens around everywhere https://github.com/All-Hands-AI/OpenHands/issues/10850
An easy tiny thing IMHO: • code in the Saas calling directly private methods in OH classes. Funnily enough, one of the first things I did when I decided to send the agent scouring /enterprise, was to find me these. Because hey, I was sure the Saas code is doing this. Technically, either it was doing it, or it was fully duplicating code. But it was doing it. lolsob Seems obvious to me that no one will expect this, so I wouldn't be surprised if things just break. Though the same could be said about all inheritance in this case, because generally it's not known that the Saas subclasses what stuff, we don't even think of it as an API, so yeah. Maybe we could consider freezing/versioning the API for the core classes sometime too. 🤷‍♂️
q
^ private invocation is a great one. Meaningful signal and probably very measurable