What is the point of the protocol `ListLike`? Do y...
# proj-sdk
s
What is the point of the protocol
ListLike
? Do you we really need it or could we replace all typing hints
ListLike[Event]
->
List[Event]
? In
agent-sdk
openhands/sdk/utils/protocol.py
@straight-sundown-84319
c
cc @wide-doctor-37830 who actually has more context
w
We had trouble serializing lists of events in the conversation state. There was a strategy from v0 where events were written out to files independently but for some reason we had to give up assignment to get it.
s
So the code breaks if
ListLike
is replaced by
List
?
w
Only if someone does an assignment? Maybe? Not sure how relevant the stricter type hint is tbh
s
I'm not sure but I thought Protocols were strictly for type checking and didn't have any impact otherwise. But maybe when serializing an instance that inherits from the protocol you can get weird behaviors?
w
Yeah, it has no runtime impact. But the event log is how the conversation state actually stores a list of events and we'd crash at runtime if someone tried to do an assignment into it. The
ListLike
protocol at least lets us detect that statically.
s
Oh OK got it. Question: could we also use the class EventLog for typing? You think it's cleaner to have a Protocol instead?
w
There's also this implementation of the protocol. We could very likely have a base class that both inherit from and use that instead.
👍 1