Skip to content
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

Fix up conversation initialization #6430

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open

Fix up conversation initialization #6430

wants to merge 24 commits into from

Conversation

rbren
Copy link
Collaborator

@rbren rbren commented Jan 23, 2025

End-user friendly description of the problem this fixes or functionality that this introduces

  • Include this change in the Release Notes. If checked, you must provide an end-user friendly description for your change below
    no changelog

Give a summary of what the PR does, explaining any non-trivial design decisions

The biggest issue this fixes is that currently, if you start a conversation, then navigate away, then navigate back, your first message is destroyed and never gets to the agent.

The fix here is that we now post the initial prompt, plus any files, to the new_conversation API endpoint, and the backend handles all the initialization.


Link of any specific issues this addresses


To run this PR locally, use the following command:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:2f96f68-nikolaik   --name openhands-app-2f96f68   docker.all-hands.dev/all-hands-ai/openhands:2f96f68

@rbren rbren marked this pull request as ready for review January 23, 2025 19:57
ChangeAgentStateAction(AgentState.AWAITING_USER_INPUT),
EventSource.ENVIRONMENT,
)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initial state is now AWAITING_USER_INPUT rather than INIT. I like this because I think there has been some general confusion on what the INIT state means - "INITIALIZED" vs "INITIALIZING".

Do you foresee any consequences of this in the frontend?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main consequence here is that, if you start with a repo/zip, instead of seeing a blue "Initialized" indicator, you now see a yellow "waiting for user input" indicator

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, I like it too. INIT was the only thing different in the stream between a UI session and a CLI session, I think - CLI streams never had anything with it.

Happy to see it go 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed this to a blue indicator now

@@ -28,10 +28,13 @@ export const useCreateConversation = () => {
throw new Error("No query provided");
}

if (variables.q) dispatch(setInitialQuery(variables.q));
if (variables.q) dispatch(setInitialPrompt(variables.q));

return OpenHands.createConversation(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that we marked this function async, shouldn't this now be:
return await OpenHands.createConversation(

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Otherwise the result will be a promise wrapped in a promise?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this works just fine--promises are pretty intelligent about nesting IIRC.

Copy link
Collaborator

@tofarr tofarr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With all the changes to init, I would like to test some of the workflows when you kill / restart the server and try to reconnect before merging.

@@ -6,10 +6,6 @@ class AgentState(str, Enum):
"""The agent is loading.
"""

INIT = 'init'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think INIT exists in the event stream, at least as value of an agent change observation. It might be worth to test restoring a session, to see if we can recreate the events.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh good point

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works!

@rbren
Copy link
Collaborator Author

rbren commented Jan 23, 2025

Confirmed that we can:

  • Start a session on main, and continue to load that conversation on this branch
  • Kill the server and restart it, and still see the conversation

Copy link
Collaborator

@enyst enyst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

@rbren rbren enabled auto-merge (squash) January 23, 2025 21:15
@rbren rbren disabled auto-merge January 23, 2025 21:16
Copy link
Collaborator

@tofarr tofarr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍰

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants