From 8755933364b474c9b8ee408c19b53999e1082310 Mon Sep 17 00:00:00 2001 From: aran-yogesh Date: Thu, 12 Feb 2026 15:10:26 -0800 Subject: [PATCH] using sandbox api instead of failing --- apps/agent/agent/tools/commit_and_open_pr.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/agent/agent/tools/commit_and_open_pr.py b/apps/agent/agent/tools/commit_and_open_pr.py index 517f0051..6979deed 100644 --- a/apps/agent/agent/tools/commit_and_open_pr.py +++ b/apps/agent/agent/tools/commit_and_open_pr.py @@ -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}"