using sandbox api instead of failing

This commit is contained in:
aran-yogesh 2026-02-12 15:10:26 -08:00
parent 8ebc71266f
commit 8755933364

View file

@ -3,8 +3,10 @@ import logging
from typing import Any
from langgraph.config import get_config
from langgraph_sdk import get_client
from ..encryption import decrypt_token
from ..server import _create_langsmith_sandbox
from ..utils.github import (
create_github_pr,
get_github_default_branch,
@ -21,6 +23,7 @@ from ..utils.github import (
from ..utils.sandbox_state import SANDBOX_BACKENDS
logger = logging.getLogger(__name__)
client = get_client()
def commit_and_open_pr(
@ -128,7 +131,18 @@ def commit_and_open_pr(
sandbox_backend = SANDBOX_BACKENDS.get(thread_id)
if not sandbox_backend:
return {"success": False, "error": "Missing sandbox backend", "pr_url": None}
loop = asyncio.get_event_loop()
thread = loop.run_until_complete(client.threads.get(thread_id=thread_id))
sandbox_id = thread.get("metadata", {}).get("sandbox_id")
if not sandbox_id:
return {"success": False, "error": "No sandbox found for thread", "pr_url": None}
# Connect to existing sandbox
sandbox_backend = _create_langsmith_sandbox(sandbox_id)
SANDBOX_BACKENDS[thread_id] = sandbox_backend
logger.info("Fetched sandbox %s for thread %s", sandbox_id, thread_id)
repo_dir = f"/workspace/{repo_name}"