mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-03 19:03:21 +00:00
feat: add LANGSMITH_API_KEY_PROD fallback for LangGraph Cloud
Add helper function to check LANGSMITH_API_KEY first, then fall back to LANGSMITH_API_KEY_PROD for LangGraph Cloud deployments where LANGSMITH_API_KEY is reserved by the platform. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
9c29e3c9e0
commit
db2a755463
1 changed files with 12 additions and 0 deletions
|
|
@ -42,9 +42,21 @@ from deepagents_cli.tools import fetch_url, http_request, web_search
|
||||||
from .encryption import decrypt_token
|
from .encryption import decrypt_token
|
||||||
|
|
||||||
|
|
||||||
|
def _get_langsmith_api_key() -> str | None:
|
||||||
|
"""Get LangSmith API key from environment.
|
||||||
|
|
||||||
|
Checks LANGSMITH_API_KEY first, then falls back to LANGSMITH_API_KEY_PROD
|
||||||
|
for LangGraph Cloud deployments where LANGSMITH_API_KEY is reserved.
|
||||||
|
"""
|
||||||
|
return os.environ.get("LANGSMITH_API_KEY") or os.environ.get("LANGSMITH_API_KEY_PROD")
|
||||||
|
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
async def create_sandbox_async(provider: str, **kwargs):
|
async def create_sandbox_async(provider: str, **kwargs):
|
||||||
"""Async wrapper around create_sandbox for compatibility."""
|
"""Async wrapper around create_sandbox for compatibility."""
|
||||||
|
# For langsmith provider, pass the API key explicitly
|
||||||
|
if provider == "langsmith" and "api_key" not in kwargs:
|
||||||
|
kwargs["api_key"] = _get_langsmith_api_key()
|
||||||
with create_sandbox(provider, **kwargs) as sandbox:
|
with create_sandbox(provider, **kwargs) as sandbox:
|
||||||
yield sandbox
|
yield sandbox
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue