2026-02-04 18:30:38 -08:00
|
|
|
"""Main entry point and CLI loop for Open SWE agent."""
|
|
|
|
|
# ruff: noqa: E402
|
|
|
|
|
|
|
|
|
|
# Suppress deprecation warnings from langchain_core (e.g., Pydantic V1 on Python 3.14+)
|
|
|
|
|
# ruff: noqa: E402
|
|
|
|
|
import logging
|
2026-03-25 11:32:44 -07:00
|
|
|
import os
|
2026-02-04 18:30:38 -08:00
|
|
|
import warnings
|
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
from langgraph.graph.state import RunnableConfig
|
|
|
|
|
from langgraph.pregel import Pregel
|
2026-02-06 13:23:09 -08:00
|
|
|
from langgraph_sdk import get_client
|
2026-02-04 18:30:38 -08:00
|
|
|
|
|
|
|
|
warnings.filterwarnings("ignore", module="langchain_core._api.deprecation")
|
|
|
|
|
|
|
|
|
|
import asyncio
|
|
|
|
|
|
|
|
|
|
# Suppress Pydantic v1 compatibility warnings from langchain on Python 3.14+
|
|
|
|
|
warnings.filterwarnings("ignore", message=".*Pydantic V1.*", category=UserWarning)
|
|
|
|
|
|
|
|
|
|
# Now safe to import agent (which imports LangChain modules)
|
|
|
|
|
from deepagents import create_deep_agent
|
2026-02-10 18:18:04 -08:00
|
|
|
from deepagents.backends.protocol import SandboxBackendProtocol
|
2026-05-01 14:24:25 -07:00
|
|
|
from langchain.agents.middleware import ModelCallLimitMiddleware
|
2026-02-25 18:27:22 -08:00
|
|
|
from langsmith.sandbox import SandboxClientError
|
|
|
|
|
|
fix: proxy config restored the branch yogesh/GitHub auth proxy (#1173)
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* removing logger.info
* formatting and linting
* fix: resolve lint errors in server.py (imports, unused vars, undefined names)
* feat: use opaque proxy headers for GitHub auth in sandbox
* linting formatting and test changes
* linting
* Delete .claude directory
* Delete tests/evals directory
* fix: address PR review — guard missing tokens, quote shell paths, add proxy auth tests
* fix: restore authorship, branch_name support, and installation token for PR creation
* linitng
* fix: move installation token fetch before commit, clean up dead proxy validation code
* fix: drop github_token arg from sandbox creation, use generic create_sandbox factory with langsmith-only proxy config
* fix: use _get_langsmith_api_key() for prod key fallback, warn when API key missing for proxy config
* linting
* linting
* fix: resolve merge conflicts with main, adopt deepagents v0.5.0a4 LangSmithSandbox
2026-04-08 15:02:52 -07:00
|
|
|
from .integrations.langsmith import _configure_github_proxy
|
2026-02-09 15:34:18 -08:00
|
|
|
from .middleware import (
|
|
|
|
|
ToolErrorMiddleware,
|
|
|
|
|
check_message_queue_before_model,
|
2026-03-04 17:59:52 -08:00
|
|
|
ensure_no_empty_msg,
|
2026-05-01 14:24:25 -07:00
|
|
|
notify_step_limit_reached,
|
2026-02-09 15:34:18 -08:00
|
|
|
open_pr_if_needed,
|
|
|
|
|
)
|
2026-02-06 13:23:09 -08:00
|
|
|
from .prompt import construct_system_prompt
|
2026-03-04 16:43:28 -08:00
|
|
|
from .tools import (
|
|
|
|
|
commit_and_open_pr,
|
2026-03-23 14:37:54 -07:00
|
|
|
create_pr_review,
|
|
|
|
|
dismiss_pr_review,
|
2026-03-04 16:43:28 -08:00
|
|
|
fetch_url,
|
feat: stop auto-cloning and let agent manage repo setup [closes OPE-21] (#1159)
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* removing logger.info
* formatting and linting
* fix: resolve lint errors in server.py (imports, unused vars, undefined names)
* feat: use opaque proxy headers for GitHub auth in sandbox
* linting formatting and test changes
* linting
* Delete .claude directory
* Delete tests/evals directory
* fix: address PR review — guard missing tokens, quote shell paths, add proxy auth tests
* fix: restore authorship, branch_name support, and installation token for PR creation
* linitng
* fix: move installation token fetch before commit, clean up dead proxy validation code
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* fix: address review feedback — restore agents_md, add git user config, lint fixes
* fix: drop github_token arg from sandbox creation, use generic create_sandbox factory with langsmith-only proxy config
* fix: use _get_langsmith_api_key() for prod key fallback, warn when API key missing for proxy config
* linting
* linting
* feat: add installation token auth to list_repos GitHub API call
* agents.md update
* linting
* fix: address PR review feedback — shell precedence bug in prompt, remove dead code
* linting
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* fix: address PR review feedback — restore {working_dir} in prompt, remove clone code block
* fix:Extract check_or_recreate_sandbox utility from inline sandbox health check
* fix: address PR review feedback — async list_repos, restore template name, fix prompt colon
* fix: resolve merge conflicts with main, adopt deepagents v0.5.0a4 LangSmithSandbox
* linting
* yogesh/ope-21-stop-auto-cloning
* Update agent/tools/list_repos.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Update agent/prompt.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* feat: address PR review — list_repos uses GitHub API only, PR trigger includes org/repo
* linting
* feat: address PR review feedback — list_repos pagination, simpler return, sandbox health check
* feat: support listing repos for personal user accounts via is_organization flag
---------
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
2026-04-10 17:04:55 -07:00
|
|
|
get_branch_name,
|
2026-05-01 12:19:04 -07:00
|
|
|
get_pr_check_runs,
|
2026-03-23 14:37:54 -07:00
|
|
|
get_pr_review,
|
2026-04-30 17:01:13 -07:00
|
|
|
get_pr_review_comments,
|
2026-03-09 17:14:13 -07:00
|
|
|
github_comment,
|
2026-03-04 16:43:28 -08:00
|
|
|
http_request,
|
|
|
|
|
linear_comment,
|
2026-03-23 14:32:44 -07:00
|
|
|
linear_create_issue,
|
|
|
|
|
linear_delete_issue,
|
|
|
|
|
linear_get_issue,
|
|
|
|
|
linear_get_issue_comments,
|
|
|
|
|
linear_list_teams,
|
|
|
|
|
linear_update_issue,
|
2026-03-23 14:37:54 -07:00
|
|
|
list_pr_review_comments,
|
|
|
|
|
list_pr_reviews,
|
feat: stop auto-cloning and let agent manage repo setup [closes OPE-21] (#1159)
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* removing logger.info
* formatting and linting
* fix: resolve lint errors in server.py (imports, unused vars, undefined names)
* feat: use opaque proxy headers for GitHub auth in sandbox
* linting formatting and test changes
* linting
* Delete .claude directory
* Delete tests/evals directory
* fix: address PR review — guard missing tokens, quote shell paths, add proxy auth tests
* fix: restore authorship, branch_name support, and installation token for PR creation
* linitng
* fix: move installation token fetch before commit, clean up dead proxy validation code
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* fix: address review feedback — restore agents_md, add git user config, lint fixes
* fix: drop github_token arg from sandbox creation, use generic create_sandbox factory with langsmith-only proxy config
* fix: use _get_langsmith_api_key() for prod key fallback, warn when API key missing for proxy config
* linting
* linting
* feat: add installation token auth to list_repos GitHub API call
* agents.md update
* linting
* fix: address PR review feedback — shell precedence bug in prompt, remove dead code
* linting
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* fix: address PR review feedback — restore {working_dir} in prompt, remove clone code block
* fix:Extract check_or_recreate_sandbox utility from inline sandbox health check
* fix: address PR review feedback — async list_repos, restore template name, fix prompt colon
* fix: resolve merge conflicts with main, adopt deepagents v0.5.0a4 LangSmithSandbox
* linting
* yogesh/ope-21-stop-auto-cloning
* Update agent/tools/list_repos.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Update agent/prompt.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* feat: address PR review — list_repos uses GitHub API only, PR trigger includes org/repo
* linting
* feat: address PR review feedback — list_repos pagination, simpler return, sandbox health check
* feat: support listing repos for personal user accounts via is_organization flag
---------
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
2026-04-10 17:04:55 -07:00
|
|
|
list_repos,
|
2026-05-01 12:19:04 -07:00
|
|
|
rerun_failed_workflow_runs,
|
2026-04-29 17:42:27 -07:00
|
|
|
slack_read_thread_messages,
|
2026-03-04 16:43:28 -08:00
|
|
|
slack_thread_reply,
|
2026-03-23 14:37:54 -07:00
|
|
|
submit_pr_review,
|
|
|
|
|
update_pr_review,
|
2026-03-25 16:24:31 -07:00
|
|
|
web_search,
|
2026-03-04 16:43:28 -08:00
|
|
|
)
|
2026-03-09 17:14:13 -07:00
|
|
|
from .utils.auth import resolve_github_token
|
fix: proxy config restored the branch yogesh/GitHub auth proxy (#1173)
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* removing logger.info
* formatting and linting
* fix: resolve lint errors in server.py (imports, unused vars, undefined names)
* feat: use opaque proxy headers for GitHub auth in sandbox
* linting formatting and test changes
* linting
* Delete .claude directory
* Delete tests/evals directory
* fix: address PR review — guard missing tokens, quote shell paths, add proxy auth tests
* fix: restore authorship, branch_name support, and installation token for PR creation
* linitng
* fix: move installation token fetch before commit, clean up dead proxy validation code
* fix: drop github_token arg from sandbox creation, use generic create_sandbox factory with langsmith-only proxy config
* fix: use _get_langsmith_api_key() for prod key fallback, warn when API key missing for proxy config
* linting
* linting
* fix: resolve merge conflicts with main, adopt deepagents v0.5.0a4 LangSmithSandbox
2026-04-08 15:02:52 -07:00
|
|
|
from .utils.github_app import get_github_app_installation_token
|
2026-04-28 15:03:21 -07:00
|
|
|
from .utils.model import ModelKwargs, OpenAIReasoning, make_model
|
2026-03-17 11:55:36 -07:00
|
|
|
from .utils.sandbox import create_sandbox
|
feat: stop auto-cloning and let agent manage repo setup [closes OPE-21] (#1159)
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* removing logger.info
* formatting and linting
* fix: resolve lint errors in server.py (imports, unused vars, undefined names)
* feat: use opaque proxy headers for GitHub auth in sandbox
* linting formatting and test changes
* linting
* Delete .claude directory
* Delete tests/evals directory
* fix: address PR review — guard missing tokens, quote shell paths, add proxy auth tests
* fix: restore authorship, branch_name support, and installation token for PR creation
* linitng
* fix: move installation token fetch before commit, clean up dead proxy validation code
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* fix: address review feedback — restore agents_md, add git user config, lint fixes
* fix: drop github_token arg from sandbox creation, use generic create_sandbox factory with langsmith-only proxy config
* fix: use _get_langsmith_api_key() for prod key fallback, warn when API key missing for proxy config
* linting
* linting
* feat: add installation token auth to list_repos GitHub API call
* agents.md update
* linting
* fix: address PR review feedback — shell precedence bug in prompt, remove dead code
* linting
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* fix: address PR review feedback — restore {working_dir} in prompt, remove clone code block
* fix:Extract check_or_recreate_sandbox utility from inline sandbox health check
* fix: address PR review feedback — async list_repos, restore template name, fix prompt colon
* fix: resolve merge conflicts with main, adopt deepagents v0.5.0a4 LangSmithSandbox
* linting
* yogesh/ope-21-stop-auto-cloning
* Update agent/tools/list_repos.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Update agent/prompt.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* feat: address PR review — list_repos uses GitHub API only, PR trigger includes org/repo
* linting
* feat: address PR review feedback — list_repos pagination, simpler return, sandbox health check
* feat: support listing repos for personal user accounts via is_organization flag
---------
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
2026-04-10 17:04:55 -07:00
|
|
|
from .utils.sandbox_paths import aresolve_sandbox_work_dir
|
2026-02-04 18:30:38 -08:00
|
|
|
|
|
|
|
|
client = get_client()
|
|
|
|
|
|
|
|
|
|
SANDBOX_CREATING = "__creating__"
|
|
|
|
|
SANDBOX_CREATION_TIMEOUT = 180
|
|
|
|
|
SANDBOX_POLL_INTERVAL = 1.0
|
|
|
|
|
|
2026-02-20 09:58:07 -08:00
|
|
|
from .utils.sandbox_state import SANDBOX_BACKENDS, get_sandbox_id_from_metadata
|
2026-02-04 18:30:38 -08:00
|
|
|
|
|
|
|
|
|
fix: proxy config restored the branch yogesh/GitHub auth proxy (#1173)
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* removing logger.info
* formatting and linting
* fix: resolve lint errors in server.py (imports, unused vars, undefined names)
* feat: use opaque proxy headers for GitHub auth in sandbox
* linting formatting and test changes
* linting
* Delete .claude directory
* Delete tests/evals directory
* fix: address PR review — guard missing tokens, quote shell paths, add proxy auth tests
* fix: restore authorship, branch_name support, and installation token for PR creation
* linitng
* fix: move installation token fetch before commit, clean up dead proxy validation code
* fix: drop github_token arg from sandbox creation, use generic create_sandbox factory with langsmith-only proxy config
* fix: use _get_langsmith_api_key() for prod key fallback, warn when API key missing for proxy config
* linting
* linting
* fix: resolve merge conflicts with main, adopt deepagents v0.5.0a4 LangSmithSandbox
2026-04-08 15:02:52 -07:00
|
|
|
async def _create_sandbox_with_proxy() -> SandboxBackendProtocol:
|
|
|
|
|
"""Create a new sandbox with GitHub proxy auth configured.
|
|
|
|
|
|
|
|
|
|
Uses create_sandbox (generic factory) so non-langsmith providers still work.
|
|
|
|
|
For langsmith sandboxes, configures the proxy with the installation token.
|
|
|
|
|
"""
|
|
|
|
|
sandbox_backend = await asyncio.to_thread(create_sandbox)
|
|
|
|
|
|
|
|
|
|
sandbox_type = os.getenv("SANDBOX_TYPE", "langsmith")
|
|
|
|
|
if sandbox_type == "langsmith":
|
|
|
|
|
installation_token = await get_github_app_installation_token()
|
|
|
|
|
if not installation_token:
|
|
|
|
|
msg = "Cannot configure proxy: GitHub App installation token is unavailable"
|
|
|
|
|
logger.error(msg)
|
|
|
|
|
raise ValueError(msg)
|
|
|
|
|
await asyncio.to_thread(_configure_github_proxy, sandbox_backend.id, installation_token)
|
|
|
|
|
|
|
|
|
|
return sandbox_backend
|
|
|
|
|
|
|
|
|
|
|
2026-04-09 14:59:49 -07:00
|
|
|
async def _refresh_github_proxy(
|
|
|
|
|
sandbox_backend: SandboxBackendProtocol,
|
|
|
|
|
) -> None:
|
|
|
|
|
"""Refresh GitHub proxy credentials for reused LangSmith sandboxes."""
|
|
|
|
|
if os.getenv("SANDBOX_TYPE", "langsmith") != "langsmith":
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
installation_token = await get_github_app_installation_token()
|
|
|
|
|
if not installation_token:
|
|
|
|
|
logger.warning(
|
|
|
|
|
"Skipping GitHub proxy refresh for sandbox %s: installation token unavailable",
|
|
|
|
|
sandbox_backend.id,
|
|
|
|
|
)
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
await asyncio.to_thread(_configure_github_proxy, sandbox_backend.id, installation_token)
|
|
|
|
|
|
|
|
|
|
|
feat: stop auto-cloning and let agent manage repo setup [closes OPE-21] (#1159)
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* removing logger.info
* formatting and linting
* fix: resolve lint errors in server.py (imports, unused vars, undefined names)
* feat: use opaque proxy headers for GitHub auth in sandbox
* linting formatting and test changes
* linting
* Delete .claude directory
* Delete tests/evals directory
* fix: address PR review — guard missing tokens, quote shell paths, add proxy auth tests
* fix: restore authorship, branch_name support, and installation token for PR creation
* linitng
* fix: move installation token fetch before commit, clean up dead proxy validation code
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* fix: address review feedback — restore agents_md, add git user config, lint fixes
* fix: drop github_token arg from sandbox creation, use generic create_sandbox factory with langsmith-only proxy config
* fix: use _get_langsmith_api_key() for prod key fallback, warn when API key missing for proxy config
* linting
* linting
* feat: add installation token auth to list_repos GitHub API call
* agents.md update
* linting
* fix: address PR review feedback — shell precedence bug in prompt, remove dead code
* linting
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* fix: address PR review feedback — restore {working_dir} in prompt, remove clone code block
* fix:Extract check_or_recreate_sandbox utility from inline sandbox health check
* fix: address PR review feedback — async list_repos, restore template name, fix prompt colon
* fix: resolve merge conflicts with main, adopt deepagents v0.5.0a4 LangSmithSandbox
* linting
* yogesh/ope-21-stop-auto-cloning
* Update agent/tools/list_repos.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Update agent/prompt.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* feat: address PR review — list_repos uses GitHub API only, PR trigger includes org/repo
* linting
* feat: address PR review feedback — list_repos pagination, simpler return, sandbox health check
* feat: support listing repos for personal user accounts via is_organization flag
---------
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
2026-04-10 17:04:55 -07:00
|
|
|
async def _recreate_sandbox(thread_id: str) -> SandboxBackendProtocol:
|
|
|
|
|
"""Recreate a sandbox after a connection failure.
|
2026-02-26 09:52:27 -08:00
|
|
|
|
|
|
|
|
Clears the stale cache entry, sets the SANDBOX_CREATING sentinel,
|
feat: stop auto-cloning and let agent manage repo setup [closes OPE-21] (#1159)
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* removing logger.info
* formatting and linting
* fix: resolve lint errors in server.py (imports, unused vars, undefined names)
* feat: use opaque proxy headers for GitHub auth in sandbox
* linting formatting and test changes
* linting
* Delete .claude directory
* Delete tests/evals directory
* fix: address PR review — guard missing tokens, quote shell paths, add proxy auth tests
* fix: restore authorship, branch_name support, and installation token for PR creation
* linitng
* fix: move installation token fetch before commit, clean up dead proxy validation code
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* fix: address review feedback — restore agents_md, add git user config, lint fixes
* fix: drop github_token arg from sandbox creation, use generic create_sandbox factory with langsmith-only proxy config
* fix: use _get_langsmith_api_key() for prod key fallback, warn when API key missing for proxy config
* linting
* linting
* feat: add installation token auth to list_repos GitHub API call
* agents.md update
* linting
* fix: address PR review feedback — shell precedence bug in prompt, remove dead code
* linting
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* fix: address PR review feedback — restore {working_dir} in prompt, remove clone code block
* fix:Extract check_or_recreate_sandbox utility from inline sandbox health check
* fix: address PR review feedback — async list_repos, restore template name, fix prompt colon
* fix: resolve merge conflicts with main, adopt deepagents v0.5.0a4 LangSmithSandbox
* linting
* yogesh/ope-21-stop-auto-cloning
* Update agent/tools/list_repos.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Update agent/prompt.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* feat: address PR review — list_repos uses GitHub API only, PR trigger includes org/repo
* linting
* feat: address PR review feedback — list_repos pagination, simpler return, sandbox health check
* feat: support listing repos for personal user accounts via is_organization flag
---------
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
2026-04-10 17:04:55 -07:00
|
|
|
and creates a fresh sandbox (with proxy auth configured).
|
|
|
|
|
The agent is responsible for cloning repos via tools.
|
2026-02-26 09:52:27 -08:00
|
|
|
"""
|
|
|
|
|
SANDBOX_BACKENDS.pop(thread_id, None)
|
|
|
|
|
await client.threads.update(
|
|
|
|
|
thread_id=thread_id,
|
|
|
|
|
metadata={"sandbox_id": SANDBOX_CREATING},
|
|
|
|
|
)
|
|
|
|
|
try:
|
fix: proxy config restored the branch yogesh/GitHub auth proxy (#1173)
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* removing logger.info
* formatting and linting
* fix: resolve lint errors in server.py (imports, unused vars, undefined names)
* feat: use opaque proxy headers for GitHub auth in sandbox
* linting formatting and test changes
* linting
* Delete .claude directory
* Delete tests/evals directory
* fix: address PR review — guard missing tokens, quote shell paths, add proxy auth tests
* fix: restore authorship, branch_name support, and installation token for PR creation
* linitng
* fix: move installation token fetch before commit, clean up dead proxy validation code
* fix: drop github_token arg from sandbox creation, use generic create_sandbox factory with langsmith-only proxy config
* fix: use _get_langsmith_api_key() for prod key fallback, warn when API key missing for proxy config
* linting
* linting
* fix: resolve merge conflicts with main, adopt deepagents v0.5.0a4 LangSmithSandbox
2026-04-08 15:02:52 -07:00
|
|
|
sandbox_backend = await _create_sandbox_with_proxy()
|
2026-02-26 09:52:27 -08:00
|
|
|
except Exception:
|
|
|
|
|
logger.exception("Failed to recreate sandbox after connection failure")
|
|
|
|
|
await client.threads.update(thread_id=thread_id, metadata={"sandbox_id": None})
|
|
|
|
|
raise
|
feat: stop auto-cloning and let agent manage repo setup [closes OPE-21] (#1159)
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* removing logger.info
* formatting and linting
* fix: resolve lint errors in server.py (imports, unused vars, undefined names)
* feat: use opaque proxy headers for GitHub auth in sandbox
* linting formatting and test changes
* linting
* Delete .claude directory
* Delete tests/evals directory
* fix: address PR review — guard missing tokens, quote shell paths, add proxy auth tests
* fix: restore authorship, branch_name support, and installation token for PR creation
* linitng
* fix: move installation token fetch before commit, clean up dead proxy validation code
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* fix: address review feedback — restore agents_md, add git user config, lint fixes
* fix: drop github_token arg from sandbox creation, use generic create_sandbox factory with langsmith-only proxy config
* fix: use _get_langsmith_api_key() for prod key fallback, warn when API key missing for proxy config
* linting
* linting
* feat: add installation token auth to list_repos GitHub API call
* agents.md update
* linting
* fix: address PR review feedback — shell precedence bug in prompt, remove dead code
* linting
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* fix: address PR review feedback — restore {working_dir} in prompt, remove clone code block
* fix:Extract check_or_recreate_sandbox utility from inline sandbox health check
* fix: address PR review feedback — async list_repos, restore template name, fix prompt colon
* fix: resolve merge conflicts with main, adopt deepagents v0.5.0a4 LangSmithSandbox
* linting
* yogesh/ope-21-stop-auto-cloning
* Update agent/tools/list_repos.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Update agent/prompt.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* feat: address PR review — list_repos uses GitHub API only, PR trigger includes org/repo
* linting
* feat: address PR review feedback — list_repos pagination, simpler return, sandbox health check
* feat: support listing repos for personal user accounts via is_organization flag
---------
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
2026-04-10 17:04:55 -07:00
|
|
|
return sandbox_backend
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def check_or_recreate_sandbox(
|
|
|
|
|
sandbox_backend: SandboxBackendProtocol, thread_id: str
|
|
|
|
|
) -> SandboxBackendProtocol:
|
|
|
|
|
"""Check if a cached sandbox is reachable; recreate it if not.
|
|
|
|
|
|
|
|
|
|
Pings the sandbox with a lightweight command. If the sandbox is
|
|
|
|
|
unreachable (SandboxClientError), it is torn down and a fresh one
|
|
|
|
|
is created via _recreate_sandbox.
|
|
|
|
|
|
|
|
|
|
Returns the original backend if healthy, or a new one if recreated.
|
|
|
|
|
"""
|
|
|
|
|
try:
|
|
|
|
|
await asyncio.to_thread(sandbox_backend.execute, "echo ok")
|
|
|
|
|
except SandboxClientError:
|
|
|
|
|
logger.warning(
|
|
|
|
|
"Cached sandbox is no longer reachable for thread %s, recreating",
|
|
|
|
|
thread_id,
|
|
|
|
|
)
|
|
|
|
|
sandbox_backend = await _recreate_sandbox(thread_id)
|
|
|
|
|
return sandbox_backend
|
2026-02-26 09:52:27 -08:00
|
|
|
|
|
|
|
|
|
2026-02-04 18:30:38 -08:00
|
|
|
async def _wait_for_sandbox_id(thread_id: str) -> str:
|
|
|
|
|
"""Wait for sandbox_id to be set in thread metadata.
|
|
|
|
|
|
|
|
|
|
Polls thread metadata until sandbox_id is set to a real value
|
|
|
|
|
(not the creating sentinel).
|
|
|
|
|
|
|
|
|
|
Raises:
|
|
|
|
|
TimeoutError: If sandbox creation takes too long
|
|
|
|
|
"""
|
|
|
|
|
elapsed = 0.0
|
|
|
|
|
while elapsed < SANDBOX_CREATION_TIMEOUT:
|
2026-02-17 16:50:08 -08:00
|
|
|
sandbox_id = await get_sandbox_id_from_metadata(thread_id)
|
2026-02-04 18:30:38 -08:00
|
|
|
if sandbox_id is not None and sandbox_id != SANDBOX_CREATING:
|
|
|
|
|
return sandbox_id
|
|
|
|
|
await asyncio.sleep(SANDBOX_POLL_INTERVAL)
|
|
|
|
|
elapsed += SANDBOX_POLL_INTERVAL
|
|
|
|
|
|
|
|
|
|
msg = f"Timeout waiting for sandbox creation for thread {thread_id}"
|
|
|
|
|
raise TimeoutError(msg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def graph_loaded_for_execution(config: RunnableConfig) -> bool:
|
|
|
|
|
"""Check if the graph is loaded for actual execution vs introspection."""
|
|
|
|
|
return (
|
|
|
|
|
config["configurable"].get("__is_for_execution__", False)
|
|
|
|
|
if "configurable" in config
|
|
|
|
|
else False
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
2026-04-28 15:03:21 -07:00
|
|
|
DEFAULT_LLM_MODEL_ID = "openai:gpt-5.5"
|
|
|
|
|
DEFAULT_LLM_REASONING: OpenAIReasoning = {"effort": "medium"}
|
|
|
|
|
DEFAULT_LLM_MAX_TOKENS = 64_000
|
|
|
|
|
DEFAULT_RECURSION_LIMIT = 9_999
|
2026-02-06 13:23:09 -08:00
|
|
|
|
|
|
|
|
|
feat: stop auto-cloning and let agent manage repo setup [closes OPE-21] (#1159)
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* removing logger.info
* formatting and linting
* fix: resolve lint errors in server.py (imports, unused vars, undefined names)
* feat: use opaque proxy headers for GitHub auth in sandbox
* linting formatting and test changes
* linting
* Delete .claude directory
* Delete tests/evals directory
* fix: address PR review — guard missing tokens, quote shell paths, add proxy auth tests
* fix: restore authorship, branch_name support, and installation token for PR creation
* linitng
* fix: move installation token fetch before commit, clean up dead proxy validation code
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* fix: address review feedback — restore agents_md, add git user config, lint fixes
* fix: drop github_token arg from sandbox creation, use generic create_sandbox factory with langsmith-only proxy config
* fix: use _get_langsmith_api_key() for prod key fallback, warn when API key missing for proxy config
* linting
* linting
* feat: add installation token auth to list_repos GitHub API call
* agents.md update
* linting
* fix: address PR review feedback — shell precedence bug in prompt, remove dead code
* linting
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* fix: address PR review feedback — restore {working_dir} in prompt, remove clone code block
* fix:Extract check_or_recreate_sandbox utility from inline sandbox health check
* fix: address PR review feedback — async list_repos, restore template name, fix prompt colon
* fix: resolve merge conflicts with main, adopt deepagents v0.5.0a4 LangSmithSandbox
* linting
* yogesh/ope-21-stop-auto-cloning
* Update agent/tools/list_repos.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Update agent/prompt.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* feat: address PR review — list_repos uses GitHub API only, PR trigger includes org/repo
* linting
* feat: address PR review feedback — list_repos pagination, simpler return, sandbox health check
* feat: support listing repos for personal user accounts via is_organization flag
---------
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
2026-04-10 17:04:55 -07:00
|
|
|
async def get_agent(config: RunnableConfig) -> Pregel:
|
2026-02-04 18:30:38 -08:00
|
|
|
"""Get or create an agent with a sandbox for the given thread."""
|
|
|
|
|
thread_id = config["configurable"].get("thread_id", None)
|
|
|
|
|
|
2026-02-06 13:23:09 -08:00
|
|
|
config["recursion_limit"] = DEFAULT_RECURSION_LIMIT
|
|
|
|
|
|
2026-02-04 18:30:38 -08:00
|
|
|
if thread_id is None or not graph_loaded_for_execution(config):
|
|
|
|
|
logger.info("No thread_id or not for execution, returning agent without sandbox")
|
2026-02-06 13:23:09 -08:00
|
|
|
return create_deep_agent(
|
|
|
|
|
system_prompt="",
|
|
|
|
|
tools=[],
|
|
|
|
|
).with_config(config)
|
2026-02-04 18:30:38 -08:00
|
|
|
|
2026-03-09 17:14:13 -07:00
|
|
|
github_token, new_encrypted = await resolve_github_token(config, thread_id)
|
2026-03-04 15:57:03 -08:00
|
|
|
config["metadata"]["github_token_encrypted"] = new_encrypted
|
|
|
|
|
|
2026-02-17 15:03:20 -08:00
|
|
|
sandbox_backend = SANDBOX_BACKENDS.get(thread_id)
|
2026-02-17 16:50:08 -08:00
|
|
|
sandbox_id = await get_sandbox_id_from_metadata(thread_id)
|
2026-02-04 18:30:38 -08:00
|
|
|
|
2026-02-17 15:03:20 -08:00
|
|
|
if sandbox_id == SANDBOX_CREATING and not sandbox_backend:
|
2026-02-04 18:30:38 -08:00
|
|
|
logger.info("Sandbox creation in progress, waiting...")
|
|
|
|
|
sandbox_id = await _wait_for_sandbox_id(thread_id)
|
|
|
|
|
|
2026-02-17 15:03:20 -08:00
|
|
|
if sandbox_backend:
|
|
|
|
|
logger.info("Using cached sandbox backend for thread %s", thread_id)
|
2026-04-09 14:59:49 -07:00
|
|
|
await _refresh_github_proxy(sandbox_backend)
|
feat: stop auto-cloning and let agent manage repo setup [closes OPE-21] (#1159)
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* removing logger.info
* formatting and linting
* fix: resolve lint errors in server.py (imports, unused vars, undefined names)
* feat: use opaque proxy headers for GitHub auth in sandbox
* linting formatting and test changes
* linting
* Delete .claude directory
* Delete tests/evals directory
* fix: address PR review — guard missing tokens, quote shell paths, add proxy auth tests
* fix: restore authorship, branch_name support, and installation token for PR creation
* linitng
* fix: move installation token fetch before commit, clean up dead proxy validation code
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* fix: address review feedback — restore agents_md, add git user config, lint fixes
* fix: drop github_token arg from sandbox creation, use generic create_sandbox factory with langsmith-only proxy config
* fix: use _get_langsmith_api_key() for prod key fallback, warn when API key missing for proxy config
* linting
* linting
* feat: add installation token auth to list_repos GitHub API call
* agents.md update
* linting
* fix: address PR review feedback — shell precedence bug in prompt, remove dead code
* linting
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* fix: address PR review feedback — restore {working_dir} in prompt, remove clone code block
* fix:Extract check_or_recreate_sandbox utility from inline sandbox health check
* fix: address PR review feedback — async list_repos, restore template name, fix prompt colon
* fix: resolve merge conflicts with main, adopt deepagents v0.5.0a4 LangSmithSandbox
* linting
* yogesh/ope-21-stop-auto-cloning
* Update agent/tools/list_repos.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Update agent/prompt.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* feat: address PR review — list_repos uses GitHub API only, PR trigger includes org/repo
* linting
* feat: address PR review feedback — list_repos pagination, simpler return, sandbox health check
* feat: support listing repos for personal user accounts via is_organization flag
---------
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
2026-04-10 17:04:55 -07:00
|
|
|
sandbox_backend = await check_or_recreate_sandbox(sandbox_backend, thread_id)
|
2026-02-17 15:03:20 -08:00
|
|
|
|
|
|
|
|
elif sandbox_id is None:
|
2026-02-04 18:30:38 -08:00
|
|
|
logger.info("Creating new sandbox for thread %s", thread_id)
|
|
|
|
|
await client.threads.update(thread_id=thread_id, metadata={"sandbox_id": SANDBOX_CREATING})
|
|
|
|
|
|
|
|
|
|
try:
|
fix: proxy config restored the branch yogesh/GitHub auth proxy (#1173)
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* removing logger.info
* formatting and linting
* fix: resolve lint errors in server.py (imports, unused vars, undefined names)
* feat: use opaque proxy headers for GitHub auth in sandbox
* linting formatting and test changes
* linting
* Delete .claude directory
* Delete tests/evals directory
* fix: address PR review — guard missing tokens, quote shell paths, add proxy auth tests
* fix: restore authorship, branch_name support, and installation token for PR creation
* linitng
* fix: move installation token fetch before commit, clean up dead proxy validation code
* fix: drop github_token arg from sandbox creation, use generic create_sandbox factory with langsmith-only proxy config
* fix: use _get_langsmith_api_key() for prod key fallback, warn when API key missing for proxy config
* linting
* linting
* fix: resolve merge conflicts with main, adopt deepagents v0.5.0a4 LangSmithSandbox
2026-04-08 15:02:52 -07:00
|
|
|
sandbox_backend = await _create_sandbox_with_proxy()
|
2026-02-04 18:30:38 -08:00
|
|
|
logger.info("Sandbox created: %s", sandbox_backend.id)
|
|
|
|
|
except Exception:
|
feat: stop auto-cloning and let agent manage repo setup [closes OPE-21] (#1159)
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* removing logger.info
* formatting and linting
* fix: resolve lint errors in server.py (imports, unused vars, undefined names)
* feat: use opaque proxy headers for GitHub auth in sandbox
* linting formatting and test changes
* linting
* Delete .claude directory
* Delete tests/evals directory
* fix: address PR review — guard missing tokens, quote shell paths, add proxy auth tests
* fix: restore authorship, branch_name support, and installation token for PR creation
* linitng
* fix: move installation token fetch before commit, clean up dead proxy validation code
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* fix: address review feedback — restore agents_md, add git user config, lint fixes
* fix: drop github_token arg from sandbox creation, use generic create_sandbox factory with langsmith-only proxy config
* fix: use _get_langsmith_api_key() for prod key fallback, warn when API key missing for proxy config
* linting
* linting
* feat: add installation token auth to list_repos GitHub API call
* agents.md update
* linting
* fix: address PR review feedback — shell precedence bug in prompt, remove dead code
* linting
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* fix: address PR review feedback — restore {working_dir} in prompt, remove clone code block
* fix:Extract check_or_recreate_sandbox utility from inline sandbox health check
* fix: address PR review feedback — async list_repos, restore template name, fix prompt colon
* fix: resolve merge conflicts with main, adopt deepagents v0.5.0a4 LangSmithSandbox
* linting
* yogesh/ope-21-stop-auto-cloning
* Update agent/tools/list_repos.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Update agent/prompt.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* feat: address PR review — list_repos uses GitHub API only, PR trigger includes org/repo
* linting
* feat: address PR review feedback — list_repos pagination, simpler return, sandbox health check
* feat: support listing repos for personal user accounts via is_organization flag
---------
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
2026-04-10 17:04:55 -07:00
|
|
|
logger.exception("Failed to create sandbox")
|
2026-02-04 18:30:38 -08:00
|
|
|
try:
|
|
|
|
|
await client.threads.update(thread_id=thread_id, metadata={"sandbox_id": None})
|
|
|
|
|
logger.info("Reset sandbox_id to None for thread %s", thread_id)
|
|
|
|
|
except Exception:
|
|
|
|
|
logger.exception("Failed to reset sandbox_id metadata")
|
|
|
|
|
raise
|
|
|
|
|
else:
|
|
|
|
|
logger.info("Connecting to existing sandbox %s", sandbox_id)
|
|
|
|
|
try:
|
2026-03-17 11:55:36 -07:00
|
|
|
sandbox_backend = await asyncio.to_thread(create_sandbox, sandbox_id)
|
2026-02-04 18:30:38 -08:00
|
|
|
logger.info("Connected to existing sandbox %s", sandbox_id)
|
|
|
|
|
except Exception:
|
2026-02-06 13:23:09 -08:00
|
|
|
logger.warning("Failed to connect to existing sandbox %s, creating new one", sandbox_id)
|
fix: proxy config restored the branch yogesh/GitHub auth proxy (#1173)
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* removing logger.info
* formatting and linting
* fix: resolve lint errors in server.py (imports, unused vars, undefined names)
* feat: use opaque proxy headers for GitHub auth in sandbox
* linting formatting and test changes
* linting
* Delete .claude directory
* Delete tests/evals directory
* fix: address PR review — guard missing tokens, quote shell paths, add proxy auth tests
* fix: restore authorship, branch_name support, and installation token for PR creation
* linitng
* fix: move installation token fetch before commit, clean up dead proxy validation code
* fix: drop github_token arg from sandbox creation, use generic create_sandbox factory with langsmith-only proxy config
* fix: use _get_langsmith_api_key() for prod key fallback, warn when API key missing for proxy config
* linting
* linting
* fix: resolve merge conflicts with main, adopt deepagents v0.5.0a4 LangSmithSandbox
2026-04-08 15:02:52 -07:00
|
|
|
# Reset sandbox_id and create a new sandbox with proxy auth configured
|
2026-02-06 10:37:28 -08:00
|
|
|
await client.threads.update(
|
|
|
|
|
thread_id=thread_id,
|
|
|
|
|
metadata={"sandbox_id": SANDBOX_CREATING},
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
try:
|
fix: proxy config restored the branch yogesh/GitHub auth proxy (#1173)
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* removing logger.info
* formatting and linting
* fix: resolve lint errors in server.py (imports, unused vars, undefined names)
* feat: use opaque proxy headers for GitHub auth in sandbox
* linting formatting and test changes
* linting
* Delete .claude directory
* Delete tests/evals directory
* fix: address PR review — guard missing tokens, quote shell paths, add proxy auth tests
* fix: restore authorship, branch_name support, and installation token for PR creation
* linitng
* fix: move installation token fetch before commit, clean up dead proxy validation code
* fix: drop github_token arg from sandbox creation, use generic create_sandbox factory with langsmith-only proxy config
* fix: use _get_langsmith_api_key() for prod key fallback, warn when API key missing for proxy config
* linting
* linting
* fix: resolve merge conflicts with main, adopt deepagents v0.5.0a4 LangSmithSandbox
2026-04-08 15:02:52 -07:00
|
|
|
sandbox_backend = await _create_sandbox_with_proxy()
|
2026-02-06 10:37:28 -08:00
|
|
|
logger.info("New sandbox created: %s", sandbox_backend.id)
|
|
|
|
|
except Exception:
|
|
|
|
|
logger.exception("Failed to create replacement sandbox")
|
2026-02-06 13:23:09 -08:00
|
|
|
await client.threads.update(thread_id=thread_id, metadata={"sandbox_id": None})
|
2026-02-06 10:37:28 -08:00
|
|
|
raise
|
2026-02-04 18:30:38 -08:00
|
|
|
|
2026-04-09 14:59:49 -07:00
|
|
|
await _refresh_github_proxy(sandbox_backend)
|
feat: stop auto-cloning and let agent manage repo setup [closes OPE-21] (#1159)
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* removing logger.info
* formatting and linting
* fix: resolve lint errors in server.py (imports, unused vars, undefined names)
* feat: use opaque proxy headers for GitHub auth in sandbox
* linting formatting and test changes
* linting
* Delete .claude directory
* Delete tests/evals directory
* fix: address PR review — guard missing tokens, quote shell paths, add proxy auth tests
* fix: restore authorship, branch_name support, and installation token for PR creation
* linitng
* fix: move installation token fetch before commit, clean up dead proxy validation code
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* fix: address review feedback — restore agents_md, add git user config, lint fixes
* fix: drop github_token arg from sandbox creation, use generic create_sandbox factory with langsmith-only proxy config
* fix: use _get_langsmith_api_key() for prod key fallback, warn when API key missing for proxy config
* linting
* linting
* feat: add installation token auth to list_repos GitHub API call
* agents.md update
* linting
* fix: address PR review feedback — shell precedence bug in prompt, remove dead code
* linting
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* fix: address PR review feedback — restore {working_dir} in prompt, remove clone code block
* fix:Extract check_or_recreate_sandbox utility from inline sandbox health check
* fix: address PR review feedback — async list_repos, restore template name, fix prompt colon
* fix: resolve merge conflicts with main, adopt deepagents v0.5.0a4 LangSmithSandbox
* linting
* yogesh/ope-21-stop-auto-cloning
* Update agent/tools/list_repos.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Update agent/prompt.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* feat: address PR review — list_repos uses GitHub API only, PR trigger includes org/repo
* linting
* feat: address PR review feedback — list_repos pagination, simpler return, sandbox health check
* feat: support listing repos for personal user accounts via is_organization flag
---------
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
2026-04-10 17:04:55 -07:00
|
|
|
sandbox_backend = await check_or_recreate_sandbox(sandbox_backend, thread_id)
|
2026-02-04 18:30:38 -08:00
|
|
|
|
2026-02-10 11:22:52 -08:00
|
|
|
SANDBOX_BACKENDS[thread_id] = sandbox_backend
|
2026-02-04 18:30:38 -08:00
|
|
|
|
feat: stop auto-cloning and let agent manage repo setup [closes OPE-21] (#1159)
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* removing logger.info
* formatting and linting
* fix: resolve lint errors in server.py (imports, unused vars, undefined names)
* feat: use opaque proxy headers for GitHub auth in sandbox
* linting formatting and test changes
* linting
* Delete .claude directory
* Delete tests/evals directory
* fix: address PR review — guard missing tokens, quote shell paths, add proxy auth tests
* fix: restore authorship, branch_name support, and installation token for PR creation
* linitng
* fix: move installation token fetch before commit, clean up dead proxy validation code
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* fix: address review feedback — restore agents_md, add git user config, lint fixes
* fix: drop github_token arg from sandbox creation, use generic create_sandbox factory with langsmith-only proxy config
* fix: use _get_langsmith_api_key() for prod key fallback, warn when API key missing for proxy config
* linting
* linting
* feat: add installation token auth to list_repos GitHub API call
* agents.md update
* linting
* fix: address PR review feedback — shell precedence bug in prompt, remove dead code
* linting
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* fix: address PR review feedback — restore {working_dir} in prompt, remove clone code block
* fix:Extract check_or_recreate_sandbox utility from inline sandbox health check
* fix: address PR review feedback — async list_repos, restore template name, fix prompt colon
* fix: resolve merge conflicts with main, adopt deepagents v0.5.0a4 LangSmithSandbox
* linting
* yogesh/ope-21-stop-auto-cloning
* Update agent/tools/list_repos.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Update agent/prompt.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* feat: address PR review — list_repos uses GitHub API only, PR trigger includes org/repo
* linting
* feat: address PR review feedback — list_repos pagination, simpler return, sandbox health check
* feat: support listing repos for personal user accounts via is_organization flag
---------
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
2026-04-10 17:04:55 -07:00
|
|
|
if sandbox_id != sandbox_backend.id:
|
|
|
|
|
await client.threads.update(
|
|
|
|
|
thread_id=thread_id,
|
|
|
|
|
metadata={"sandbox_id": sandbox_backend.id},
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
await asyncio.to_thread(
|
2026-03-20 10:53:33 -07:00
|
|
|
sandbox_backend.execute,
|
feat: stop auto-cloning and let agent manage repo setup [closes OPE-21] (#1159)
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* removing logger.info
* formatting and linting
* fix: resolve lint errors in server.py (imports, unused vars, undefined names)
* feat: use opaque proxy headers for GitHub auth in sandbox
* linting formatting and test changes
* linting
* Delete .claude directory
* Delete tests/evals directory
* fix: address PR review — guard missing tokens, quote shell paths, add proxy auth tests
* fix: restore authorship, branch_name support, and installation token for PR creation
* linitng
* fix: move installation token fetch before commit, clean up dead proxy validation code
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* fix: address review feedback — restore agents_md, add git user config, lint fixes
* fix: drop github_token arg from sandbox creation, use generic create_sandbox factory with langsmith-only proxy config
* fix: use _get_langsmith_api_key() for prod key fallback, warn when API key missing for proxy config
* linting
* linting
* feat: add installation token auth to list_repos GitHub API call
* agents.md update
* linting
* fix: address PR review feedback — shell precedence bug in prompt, remove dead code
* linting
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* fix: address PR review feedback — restore {working_dir} in prompt, remove clone code block
* fix:Extract check_or_recreate_sandbox utility from inline sandbox health check
* fix: address PR review feedback — async list_repos, restore template name, fix prompt colon
* fix: resolve merge conflicts with main, adopt deepagents v0.5.0a4 LangSmithSandbox
* linting
* yogesh/ope-21-stop-auto-cloning
* Update agent/tools/list_repos.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Update agent/prompt.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* feat: address PR review — list_repos uses GitHub API only, PR trigger includes org/repo
* linting
* feat: address PR review feedback — list_repos pagination, simpler return, sandbox health check
* feat: support listing repos for personal user accounts via is_organization flag
---------
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
2026-04-10 17:04:55 -07:00
|
|
|
"git config --global user.name 'open-swe[bot]' && git config --global user.email 'open-swe@users.noreply.github.com'",
|
2026-03-20 10:53:33 -07:00
|
|
|
)
|
|
|
|
|
|
2026-02-06 17:16:00 -08:00
|
|
|
linear_issue = config["configurable"].get("linear_issue", {})
|
|
|
|
|
linear_project_id = linear_issue.get("linear_project_id", "")
|
|
|
|
|
linear_issue_number = linear_issue.get("linear_issue_number", "")
|
feat: stop auto-cloning and let agent manage repo setup [closes OPE-21] (#1159)
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* removing logger.info
* formatting and linting
* fix: resolve lint errors in server.py (imports, unused vars, undefined names)
* feat: use opaque proxy headers for GitHub auth in sandbox
* linting formatting and test changes
* linting
* Delete .claude directory
* Delete tests/evals directory
* fix: address PR review — guard missing tokens, quote shell paths, add proxy auth tests
* fix: restore authorship, branch_name support, and installation token for PR creation
* linitng
* fix: move installation token fetch before commit, clean up dead proxy validation code
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* fix: address review feedback — restore agents_md, add git user config, lint fixes
* fix: drop github_token arg from sandbox creation, use generic create_sandbox factory with langsmith-only proxy config
* fix: use _get_langsmith_api_key() for prod key fallback, warn when API key missing for proxy config
* linting
* linting
* feat: add installation token auth to list_repos GitHub API call
* agents.md update
* linting
* fix: address PR review feedback — shell precedence bug in prompt, remove dead code
* linting
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* fix: address PR review feedback — restore {working_dir} in prompt, remove clone code block
* fix:Extract check_or_recreate_sandbox utility from inline sandbox health check
* fix: address PR review feedback — async list_repos, restore template name, fix prompt colon
* fix: resolve merge conflicts with main, adopt deepagents v0.5.0a4 LangSmithSandbox
* linting
* yogesh/ope-21-stop-auto-cloning
* Update agent/tools/list_repos.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Update agent/prompt.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* feat: address PR review — list_repos uses GitHub API only, PR trigger includes org/repo
* linting
* feat: address PR review feedback — list_repos pagination, simpler return, sandbox health check
* feat: support listing repos for personal user accounts via is_organization flag
---------
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
2026-04-10 17:04:55 -07:00
|
|
|
|
|
|
|
|
work_dir = await aresolve_sandbox_work_dir(sandbox_backend)
|
2026-02-06 17:16:00 -08:00
|
|
|
|
2026-04-28 15:03:21 -07:00
|
|
|
model_id = os.environ.get("LLM_MODEL_ID", DEFAULT_LLM_MODEL_ID)
|
|
|
|
|
model_kwargs: ModelKwargs = {"max_tokens": DEFAULT_LLM_MAX_TOKENS}
|
|
|
|
|
if model_id == DEFAULT_LLM_MODEL_ID:
|
|
|
|
|
model_kwargs["reasoning"] = DEFAULT_LLM_REASONING
|
|
|
|
|
|
2026-02-04 18:30:38 -08:00
|
|
|
logger.info("Returning agent with sandbox for thread %s", thread_id)
|
2026-02-06 13:23:09 -08:00
|
|
|
return create_deep_agent(
|
2026-04-28 15:03:21 -07:00
|
|
|
model=make_model(model_id, **model_kwargs),
|
2026-02-06 17:16:00 -08:00
|
|
|
system_prompt=construct_system_prompt(
|
feat: stop auto-cloning and let agent manage repo setup [closes OPE-21] (#1159)
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* removing logger.info
* formatting and linting
* fix: resolve lint errors in server.py (imports, unused vars, undefined names)
* feat: use opaque proxy headers for GitHub auth in sandbox
* linting formatting and test changes
* linting
* Delete .claude directory
* Delete tests/evals directory
* fix: address PR review — guard missing tokens, quote shell paths, add proxy auth tests
* fix: restore authorship, branch_name support, and installation token for PR creation
* linitng
* fix: move installation token fetch before commit, clean up dead proxy validation code
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* fix: address review feedback — restore agents_md, add git user config, lint fixes
* fix: drop github_token arg from sandbox creation, use generic create_sandbox factory with langsmith-only proxy config
* fix: use _get_langsmith_api_key() for prod key fallback, warn when API key missing for proxy config
* linting
* linting
* feat: add installation token auth to list_repos GitHub API call
* agents.md update
* linting
* fix: address PR review feedback — shell precedence bug in prompt, remove dead code
* linting
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* fix: address PR review feedback — restore {working_dir} in prompt, remove clone code block
* fix:Extract check_or_recreate_sandbox utility from inline sandbox health check
* fix: address PR review feedback — async list_repos, restore template name, fix prompt colon
* fix: resolve merge conflicts with main, adopt deepagents v0.5.0a4 LangSmithSandbox
* linting
* yogesh/ope-21-stop-auto-cloning
* Update agent/tools/list_repos.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Update agent/prompt.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* feat: address PR review — list_repos uses GitHub API only, PR trigger includes org/repo
* linting
* feat: address PR review feedback — list_repos pagination, simpler return, sandbox health check
* feat: support listing repos for personal user accounts via is_organization flag
---------
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
2026-04-10 17:04:55 -07:00
|
|
|
working_dir=work_dir,
|
2026-02-06 17:16:00 -08:00
|
|
|
linear_project_id=linear_project_id,
|
|
|
|
|
linear_issue_number=linear_issue_number,
|
|
|
|
|
),
|
2026-03-09 17:14:13 -07:00
|
|
|
tools=[
|
|
|
|
|
http_request,
|
|
|
|
|
fetch_url,
|
2026-03-25 16:24:31 -07:00
|
|
|
web_search,
|
feat: stop auto-cloning and let agent manage repo setup [closes OPE-21] (#1159)
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* feat: authenticate git operations via sandbox proxy instead of credential files
* removing logger.info
* formatting and linting
* fix: resolve lint errors in server.py (imports, unused vars, undefined names)
* feat: use opaque proxy headers for GitHub auth in sandbox
* linting formatting and test changes
* linting
* Delete .claude directory
* Delete tests/evals directory
* fix: address PR review — guard missing tokens, quote shell paths, add proxy auth tests
* fix: restore authorship, branch_name support, and installation token for PR creation
* linitng
* fix: move installation token fetch before commit, clean up dead proxy validation code
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* feat: stop auto-cloning and let agent manage repo setup [closes OPE-21]
* fix: address review feedback — restore agents_md, add git user config, lint fixes
* fix: drop github_token arg from sandbox creation, use generic create_sandbox factory with langsmith-only proxy config
* fix: use _get_langsmith_api_key() for prod key fallback, warn when API key missing for proxy config
* linting
* linting
* feat: add installation token auth to list_repos GitHub API call
* agents.md update
* linting
* fix: address PR review feedback — shell precedence bug in prompt, remove dead code
* linting
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Apply suggestion from @bracesproul
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* fix: address PR review feedback — restore {working_dir} in prompt, remove clone code block
* fix:Extract check_or_recreate_sandbox utility from inline sandbox health check
* fix: address PR review feedback — async list_repos, restore template name, fix prompt colon
* fix: resolve merge conflicts with main, adopt deepagents v0.5.0a4 LangSmithSandbox
* linting
* yogesh/ope-21-stop-auto-cloning
* Update agent/tools/list_repos.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* Update agent/prompt.py
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
* feat: address PR review — list_repos uses GitHub API only, PR trigger includes org/repo
* linting
* feat: address PR review feedback — list_repos pagination, simpler return, sandbox health check
* feat: support listing repos for personal user accounts via is_organization flag
---------
Co-authored-by: Brace Sproul <braceasproul@gmail.com>
2026-04-10 17:04:55 -07:00
|
|
|
list_repos,
|
|
|
|
|
get_branch_name,
|
2026-03-09 17:14:13 -07:00
|
|
|
commit_and_open_pr,
|
|
|
|
|
linear_comment,
|
2026-03-23 14:32:44 -07:00
|
|
|
linear_create_issue,
|
|
|
|
|
linear_delete_issue,
|
|
|
|
|
linear_get_issue,
|
|
|
|
|
linear_get_issue_comments,
|
|
|
|
|
linear_list_teams,
|
|
|
|
|
linear_update_issue,
|
2026-04-29 17:42:27 -07:00
|
|
|
slack_read_thread_messages,
|
2026-03-09 17:14:13 -07:00
|
|
|
slack_thread_reply,
|
|
|
|
|
github_comment,
|
2026-04-30 17:01:13 -07:00
|
|
|
get_pr_review_comments,
|
2026-03-23 14:37:54 -07:00
|
|
|
list_pr_reviews,
|
|
|
|
|
get_pr_review,
|
|
|
|
|
create_pr_review,
|
|
|
|
|
update_pr_review,
|
|
|
|
|
dismiss_pr_review,
|
|
|
|
|
submit_pr_review,
|
|
|
|
|
list_pr_review_comments,
|
2026-05-01 12:19:04 -07:00
|
|
|
get_pr_check_runs,
|
|
|
|
|
rerun_failed_workflow_runs,
|
2026-03-09 17:14:13 -07:00
|
|
|
],
|
2026-02-06 13:23:09 -08:00
|
|
|
backend=sandbox_backend,
|
2026-02-04 18:30:38 -08:00
|
|
|
middleware=[
|
2026-05-01 14:24:25 -07:00
|
|
|
ModelCallLimitMiddleware(run_limit=60, exit_behavior="end"),
|
2026-02-09 12:53:34 -08:00
|
|
|
ToolErrorMiddleware(),
|
2026-02-04 18:30:38 -08:00
|
|
|
check_message_queue_before_model,
|
2026-03-04 17:59:52 -08:00
|
|
|
ensure_no_empty_msg,
|
2026-05-01 14:24:25 -07:00
|
|
|
# after_agent hooks run in reverse list order; notify after the PR safety net.
|
|
|
|
|
notify_step_limit_reached,
|
2026-02-04 18:30:38 -08:00
|
|
|
open_pr_if_needed,
|
|
|
|
|
],
|
2026-02-06 13:23:09 -08:00
|
|
|
).with_config(config)
|