fix for clone repo (#6116)

This commit is contained in:
Robert Brennan 2025-01-07 11:42:41 -05:00 committed by GitHub
parent 9016b9c434
commit affbc49b08
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 6 deletions

View File

@ -210,9 +210,11 @@ class Runtime(FileEditRuntimeMixin):
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

View File

@ -30,9 +30,7 @@ UPDATED_AT_CALLBACK_ID = 'updated_at_callback_id'
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')
@ -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')

View File

@ -204,7 +204,10 @@ class AgentSession:
)
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