I still need some asyncio functionality - so I add...
# proj-sdk
s
I still need some asyncio functionality - so I added this PR: https://github.com/All-Hands-AI/agent-sdk/pull/217 (From previous discussions) Recommendations for running in an async context: • Have a single thread to handle asyncio (The main runloop) • Run conversations one per thread in the background • Use an
AsyncCallbackWrapper
to pass events from the conversation thread back into the main runloop This gives a clear boundary and we shouldn't encounter any of that "Coroutine was executed in a different runloop" nonsense.
c
Hey Tim, could you share your code branch that implements this stuff? I've been thinking about how we ship the agent into the nested runtime a lot... Here are my current thoughts: https://github.com/All-Hands-AI/agent-sdk/issues/218 Would adopting this protocol make your life a lot easier? Since it may contain most of the stuff you need: https://a2a-protocol.org/latest/specification/#356-method-mapping-reference-table
w
Actually thinking more about this--I think the server needs to be able to run the SDK directly instead of always using a remote agent
unless server in local mode could rely on a local AgentServer?
s
I think there may be some crossed wires here
c
I think the problem that bugged me the most about using SDK directly in application is that, if the agent team want to ship something much fancier (eg coordinating multiple parallel agents / plan), we will need to modify the server code directly — which might operate under a different assumption (eg we have only ONE conversation), and this will create a tons of frictions for agent team (eg implementing the agent is easy, shipping it is super hard, you’d need to change a tons of code on server ends to make that happen). Another problem is that, if OpenHands application server is the only place we build the agent for production — it creates problem for how we may run evals in sandboxes. So I feel it becomes more and more important that we consider a middle layer there to sort of separate out our agent logic with our application logic, and evals and applications depends on that layer. That layer can either be pure python class with much fewer API (similar to A2A), just start pause stop, send message, maybe a way to pull events — or it can be a A2A compatible server that can be run in isolation.
s
When I say "RunLoop" - I mean asyncio.runloop
this is just a small utility intended to wrap a conversation so we can use it with asyncio
It is not intended to be aware of any clustering details or where in a cluster the agent is run
Strictly speaking, it is not server specific - in theory, anywhere that uses asyncio would find it useful
That's why I figured it belonged in agent sdk
👍 1
I have been working on a service layer to handle where an agent is run - I look forward to your thoughts on this
c
👍 I think this is reasonable— I was mainly worried about the separation here, could you share your current code there (ie the service layer)
I was wondering if we can do a good job abstract things out so it will be fairly easy for agent team to ship new fancy stuff in the future (application just need to handle a few more event type, update the service version, and that’s it)
s
The code for the service layer is in a rough state - it is the major thing I'm working on today
c
no worries! hit me up with links whenever you have it -- i just want to get a rough ideas of what you'd want/need there to think this abstraction layer through