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

[Enhancement]: Handle GH token refresh inside runtime #6632

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

Conversation

malhotra5
Copy link
Contributor

@malhotra5 malhotra5 commented Feb 6, 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

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

The GH token can expire inside the runtime (either during the session or when returning to one after a long time). This PR does the following for remote runtimes only

  • Checks incoming CmdRunActions that are attempting to use $GITHUB_TOKEN
  • Before executing the incoming command, it will first perform export GITHUB_TOKEN={token} where the token is fetched from GitHubService (this diff explains this exact behavior)

This ensures that the latest Github token has been exported to the env BEFORE any Github API request is executed by the agent


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:639eb03-nikolaik   --name openhands-app-639eb03   docker.all-hands.dev/all-hands-ai/openhands:639eb03

@malhotra5 malhotra5 marked this pull request as draft February 6, 2025 01:42
@malhotra5 malhotra5 changed the title [Experimental]: Handle GH token refresh inside runtime [Enhancement]: Handle GH token refresh inside runtime Feb 6, 2025
@malhotra5 malhotra5 marked this pull request as ready for review February 6, 2025 03:54
Copy link
Collaborator

@xingyaoww xingyaoww left a comment

Choose a reason for hiding this comment

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

LGTM!

status_callback=self._status_callback,
headless_mode=False,
env_vars=env_vars,
user_id=self.user_id, # Pass user id
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: maybe we could just do:

kwargs = {}
if runtime_cls == RemoteRuntime:
    kwargs['user_id'] = self.user_id

And then pass **kwargs in runtime_cls constructor to reduce some code duplication

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.

2 participants