mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-06 05:22:10 +00:00
refactor: make github_token keyword-only in _recreate_sandbox and drop redundant repo_dir metadata update
This commit is contained in:
parent
bec922b3b1
commit
9066b36063
1 changed files with 3 additions and 6 deletions
|
|
@ -174,12 +174,13 @@ async def _recreate_sandbox(
|
||||||
thread_id: str,
|
thread_id: str,
|
||||||
repo_owner: str,
|
repo_owner: str,
|
||||||
repo_name: str,
|
repo_name: str,
|
||||||
|
*,
|
||||||
github_token: str | None,
|
github_token: str | None,
|
||||||
) -> tuple[SandboxBackendProtocol, str]:
|
) -> tuple[SandboxBackendProtocol, str]:
|
||||||
"""Recreate a sandbox and clone the repo after a connection failure.
|
"""Recreate a sandbox and clone the repo after a connection failure.
|
||||||
|
|
||||||
Clears the stale cache entry, sets the SANDBOX_CREATING sentinel,
|
Clears the stale cache entry, sets the SANDBOX_CREATING sentinel,
|
||||||
creates a fresh sandbox, clones the repo, and updates repo_dir metadata.
|
creates a fresh sandbox, and clones the repo.
|
||||||
"""
|
"""
|
||||||
SANDBOX_BACKENDS.pop(thread_id, None)
|
SANDBOX_BACKENDS.pop(thread_id, None)
|
||||||
await client.threads.update(
|
await client.threads.update(
|
||||||
|
|
@ -191,10 +192,6 @@ async def _recreate_sandbox(
|
||||||
repo_dir = await _clone_or_pull_repo_in_sandbox(
|
repo_dir = await _clone_or_pull_repo_in_sandbox(
|
||||||
sandbox_backend, repo_owner, repo_name, github_token
|
sandbox_backend, repo_owner, repo_name, github_token
|
||||||
)
|
)
|
||||||
await client.threads.update(
|
|
||||||
thread_id=thread_id,
|
|
||||||
metadata={"repo_dir": repo_dir},
|
|
||||||
)
|
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("Failed to recreate sandbox after connection failure")
|
logger.exception("Failed to recreate sandbox after connection failure")
|
||||||
await client.threads.update(thread_id=thread_id, metadata={"sandbox_id": None})
|
await client.threads.update(thread_id=thread_id, metadata={"sandbox_id": None})
|
||||||
|
|
@ -281,7 +278,7 @@ async def get_agent(config: RunnableConfig) -> Pregel: # noqa: PLR0915
|
||||||
thread_id,
|
thread_id,
|
||||||
)
|
)
|
||||||
sandbox_backend, repo_dir = await _recreate_sandbox(
|
sandbox_backend, repo_dir = await _recreate_sandbox(
|
||||||
thread_id, repo_owner, repo_name, github_token
|
thread_id, repo_owner, repo_name, github_token=github_token
|
||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("Failed to pull repo in cached sandbox")
|
logger.exception("Failed to pull repo in cached sandbox")
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue