-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Fix NoneType error in get_conversation and other typesafety #8915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
agent_state_changed = event | ||
else: | ||
await sio.emit('oh_event', event_to_dict(event), to=connection_id) | ||
if agent_loop_info.event_store: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will silently do nothing if agent_loop_info.event_store
is None
, is that the proper behavior? Or is the proper behavior to throw an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good question, I don't know enough about the scenario it could be None in. My thinking was "Well we're looking over all the events so if there's no store there are definitely no events to loop over".
But I can equally argue that AsyncEventStoreWrapper would have exploded before so we should preserve the behavior unless we know we want different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tofarr @malhotra5 Would you know more about the desired behavior here?
@@ -27,4 +27,5 @@ async def get_conversation( | |||
try: | |||
yield conversation | |||
finally: | |||
await conversation_manager.detach_from_conversation(conversation) | |||
if conversation: | |||
await conversation_manager.detach_from_conversation(conversation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the one from the prod error.
@@ -145,5 +145,5 @@ async def search_events( | |||
@app.post('/events') | |||
async def add_event(request: Request, conversation: ServerConversation = Depends(get_conversation)): | |||
data = request.json() | |||
conversation_manager.send_to_event_stream(conversation.sid, data) | |||
await conversation_manager.send_to_event_stream(conversation.sid, data) | |||
return JSONResponse({'success': True}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably this was a hidden performance bug.
7be24b4
to
d2c5c00
Compare
Looks like there are a few issues preventing this PR from being merged!
If you'd like me to help, just leave a comment, like
Feel free to include any additional details that might help me get this PR into a better state. You can manage your notification settings |
Partially done in #8927, going to do the rest later. |
End-user friendly description of the problem this fixes or functionality this introduces.
Summarize what the PR does, explaining any non-trivial design decisions.
Adding the type annotation to conversation_manager in shared.py makes it so mypy catches the missing None check behind this recent runtime exception:
It also appears to have flagged a missing async. It's possible that these constants have left a larger hole in our type-checking. I originally tried to solve this by forcing return type annotations in #8911 (maybe still a good idea), but this turned out to me enough.
Link of any specific issues this addresses:
To run this PR locally, use the following command: