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

Bugfix: Add config to disable plugin initialization for Persistent sandbox #2179

Merged
merged 7 commits into from
Jun 4, 2024

Conversation

SmartManoj
Copy link
Contributor

@SmartManoj SmartManoj commented Jun 1, 2024

Set initialize_plugins=0


This PR brings back the old behavior (always initialize). To disable the plugin initialization, one can set init_sandbox_plugins config to 0.


For persistent sandboxes, need to run source bashrc.
As source ~/.bashrc was removed in #2172, refactored the logic to execute source ~/.bashrc.
Solves current bug due to the removal, -bash: execute_cli: command not found error.
And with #2177, it won't cause the #2178 problem for persistent sandboxes.

@tobitege
Copy link
Collaborator

tobitege commented Jun 1, 2024

@SmartManoj
Isn't it possible that the .bashrc contains a (yet unidentified) command that could cause a user interaction and "cause" the hanging still, regardless of where the "source" is called?
I'm not a Linux guy, so had to ask my buddy WizardLM2 and got this as a reply, if that makes sense:

def start_ssh_session(self):
    self.__ssh_login()

    # Instead of sourcing .bashrc directly, you can selectively execute non-interactive parts of it.
    # This is a workaround to prevent hanging due to interactive commands in .bashrc.
    try:
        self.ssh.sendline("source /etc/profile.d/*.sh")  # Source system-wide profiles
        self.ssh.prompt()
        self.ssh.sendline("if [ -z \"$PS1\" ]; then . ~/.bashrc; fi")  # Condition to avoid interactive parts
        self.ssh.prompt()
    except pxssh.ExceptionPxssh as e:
        logger.exception('Failed to source .bashrc: %s', e)
        raise e

    # Fix: https://github.com/pexpect/pexpect/issues/669
    self.ssh.sendline("bind 'set enable-bracketed-paste off'")
    self.ssh.prompt()
    # cd to workspace
    self.ssh.sendline(f'cd {self.sandbox_workspace_dir}')
    self.ssh.prompt()

Further annotation was:
"This modification attempts to source only the parts of .bashrc that are safe for non-interactive sessions. It checks for the presence of the PS1 variable, which is typically set in interactive shells, to decide whether to source .bashrc."

@SmartManoj
Copy link
Contributor Author

This may be a solution for #2178


The current change concerns calling source ~/.bashrc when initializing the plugin.

@tobitege
Copy link
Collaborator

tobitege commented Jun 1, 2024

The current change concerns calling source ~/.bashrc when initializing the plugin.

Right, it's hard to keep track with the issues. :)

@SmartManoj SmartManoj requested a review from li-boxuan June 3, 2024 08:01
@SmartManoj SmartManoj changed the title Refactored source bashrc logic Fix execute_cli command not found for Persistent sandboxes Jun 3, 2024
Copy link
Collaborator

@rbren rbren left a comment

Choose a reason for hiding this comment

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

I'm not sure we want to add an option to disable the plugins. That could affect other behavior.

Can you describe the end goal here in more detail? Why does adding this flag help?

@SmartManoj
Copy link
Contributor Author

#2162

@ryanhoangt
Copy link
Contributor

Just tried it locally and I didn't get execute_cli command not found anymore. Looks good!

Copy link
Collaborator

@li-boxuan li-boxuan left a comment

Choose a reason for hiding this comment

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

I am a bit lost in this feature so I'll leave the review burden to Robert or anyone else 😄 . I just have one request:

once all issues with persistent sandbox are resolved, could you please add it to run-integration-tests.yml? You could add a new line to matrix. We now have three different kinds of sandboxes, and you could add a new dimension - persistent type.

@SmartManoj SmartManoj changed the title Fix execute_cli command not found for Persistent sandboxes Added config to disable plugin initialization for Persistent sandoxes Jun 4, 2024
@SmartManoj SmartManoj changed the title Added config to disable plugin initialization for Persistent sandoxes Bugfix by added config to disable plugin initialization for Persistent sandbox Jun 4, 2024
@rbren
Copy link
Collaborator

rbren commented Jun 4, 2024

@SmartManoj I still don't understand how/why this works. Does the user need to change the value of init_sandbox_plugins every time they start the app, depending on whether there's an existing sandbox?

Why is init_sandbox_plugins in the top-level configuration, instead of being handled internally like it was before?

@SmartManoj
Copy link
Contributor Author

SmartManoj commented Jun 4, 2024

It does not need to change every time.
Scenarios:

  1. for the manual trigger when a user switches from plugins not needed agents to another agent (happens in tests)
  2. when new plugins are added
  3. for quick debugging when the Jupyter plugin crashed

@rbren
Copy link
Collaborator

rbren commented Jun 4, 2024

Alright. I don't love the top-level config here--it puts too much burden on the user to know when to turn this flag on and off. But let's get this in since it's causing issues.

Long term, better solutions might be:

  • Always reboot the sandbox on version change
  • Always reboot the sandbox on agent change

@rbren rbren merged commit 4e47903 into All-Hands-AI:main Jun 4, 2024
2 checks passed
@SmartManoj
Copy link
Contributor Author

SmartManoj commented Jun 4, 2024

This PR brings back the old behavior (always initialize). To disable the plugin initialization, one can set init_sandbox_plugins config to 0.

@SmartManoj SmartManoj mentioned this pull request Jun 20, 2024
@SmartManoj SmartManoj changed the title Bugfix by added config to disable plugin initialization for Persistent sandbox Bugfix: Add config to disable plugin initialization for Persistent sandbox Jun 20, 2024
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.

6 participants