Skip to content

Commit

Permalink
fix for clone repo (#6116)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbren authored Jan 7, 2025
1 parent 9016b9c commit affbc49
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 4 additions & 2 deletions openhands/runtime/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,11 @@ async def _handle_action(self, event: Action) -> None:
source = event.source if event.source else EventSource.AGENT
self.event_stream.add_event(observation, source) # type: ignore[arg-type]

def clone_repo(self, github_token: str | None, selected_repository: str | None):
def clone_repo(self, github_token: str, selected_repository: str):
if not github_token or not selected_repository:
return
raise ValueError(
'github_token and selected_repository must be provided to clone a repository'
)
url = f'https://{github_token}@github.com/{selected_repository}.git'
dir_name = selected_repository.split('/')[1]
# add random branch name to avoid conflicts
Expand Down
4 changes: 1 addition & 3 deletions openhands/server/routes/manage_conversations.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@

class InitSessionRequest(BaseModel):
github_token: str | None = None
latest_event_id: int = -1
selected_repository: str | None = None
args: dict | None = None


@app.post('/conversations')
Expand All @@ -53,7 +51,7 @@ async def new_conversation(request: Request, data: InitSessionRequest):
session_init_args = {**settings.__dict__, **session_init_args}

github_token = getattr(request.state, 'github_token', '')
session_init_args['github_token'] = github_token
session_init_args['github_token'] = github_token or data.github_token or ''
session_init_args['selected_repository'] = data.selected_repository
conversation_init_data = ConversationInitData(**session_init_args)
logger.info('Loading conversation store')
Expand Down
5 changes: 4 additions & 1 deletion openhands/server/session/agent_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@ async def _create_runtime(
)
return

self.runtime.clone_repo(github_token, selected_repository)
if selected_repository:
await call_sync_from_async(
self.runtime.clone_repo, github_token, selected_repository
)
if agent.prompt_manager:
microagents: list[BaseMicroAgent] = await call_sync_from_async(
self.runtime.get_microagents_from_selected_repo, selected_repository
Expand Down

0 comments on commit affbc49

Please sign in to comment.