mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-10-03 10:23:26 +00:00
feat: inject LANGSMITH_AGENT_VERSION metadata into all run creation calls (#1066)
Reads LANGCHAIN_REVISION_ID env var (set by LSD from LANGSMITH_LANGGRAPH_GIT_REF_SHA) and injects it as LANGSMITH_AGENT_VERSION metadata on every runs.create() call. This enables the agent_deployments sync job to track which agent version produced each trace. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
633d80bf0e
commit
3e64399d13
1 changed files with 11 additions and 4 deletions
|
|
@ -66,6 +66,12 @@ LANGGRAPH_URL = os.environ.get("LANGGRAPH_URL") or os.environ.get(
|
||||||
"LANGGRAPH_URL_PROD", "http://localhost:2024"
|
"LANGGRAPH_URL_PROD", "http://localhost:2024"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
_AGENT_VERSION_METADATA: dict[str, str] = (
|
||||||
|
{"LANGSMITH_AGENT_VERSION": os.environ["LANGCHAIN_REVISION_ID"]}
|
||||||
|
if os.environ.get("LANGCHAIN_REVISION_ID")
|
||||||
|
else {}
|
||||||
|
)
|
||||||
|
|
||||||
ALLOWED_GITHUB_ORGS: frozenset[str] = frozenset(
|
ALLOWED_GITHUB_ORGS: frozenset[str] = frozenset(
|
||||||
org.strip().lower()
|
org.strip().lower()
|
||||||
for org in os.environ.get("ALLOWED_GITHUB_ORGS", "").split(",")
|
for org in os.environ.get("ALLOWED_GITHUB_ORGS", "").split(",")
|
||||||
|
|
@ -683,7 +689,7 @@ async def process_linear_issue( # noqa: PLR0912, PLR0915
|
||||||
thread_id,
|
thread_id,
|
||||||
"agent",
|
"agent",
|
||||||
input={"messages": [{"role": "user", "content": content_blocks}]},
|
input={"messages": [{"role": "user", "content": content_blocks}]},
|
||||||
config={"configurable": configurable},
|
config={"configurable": configurable, "metadata": _AGENT_VERSION_METADATA},
|
||||||
if_not_exists="create",
|
if_not_exists="create",
|
||||||
)
|
)
|
||||||
logger.info("LangGraph run created successfully for thread %s", thread_id)
|
logger.info("LangGraph run created successfully for thread %s", thread_id)
|
||||||
|
|
@ -798,7 +804,7 @@ async def process_slack_mention(event_data: dict[str, Any], repo_config: dict[st
|
||||||
thread_id,
|
thread_id,
|
||||||
"agent",
|
"agent",
|
||||||
input={"messages": [{"role": "user", "content": content_blocks}]},
|
input={"messages": [{"role": "user", "content": content_blocks}]},
|
||||||
config={"configurable": configurable},
|
config={"configurable": configurable, "metadata": _AGENT_VERSION_METADATA},
|
||||||
if_not_exists="create",
|
if_not_exists="create",
|
||||||
multitask_strategy="interrupt",
|
multitask_strategy="interrupt",
|
||||||
)
|
)
|
||||||
|
|
@ -1150,7 +1156,8 @@ async def _trigger_or_queue_run(
|
||||||
"github_login": github_login,
|
"github_login": github_login,
|
||||||
"repo": repo_config,
|
"repo": repo_config,
|
||||||
"pr_number": pr_number,
|
"pr_number": pr_number,
|
||||||
}
|
},
|
||||||
|
"metadata": _AGENT_VERSION_METADATA,
|
||||||
},
|
},
|
||||||
if_not_exists="create",
|
if_not_exists="create",
|
||||||
)
|
)
|
||||||
|
|
@ -1373,7 +1380,7 @@ async def process_github_issue(payload: dict[str, Any], event_type: str) -> None
|
||||||
thread_id,
|
thread_id,
|
||||||
"agent",
|
"agent",
|
||||||
input={"messages": [{"role": "user", "content": prompt}]},
|
input={"messages": [{"role": "user", "content": prompt}]},
|
||||||
config={"configurable": configurable},
|
config={"configurable": configurable, "metadata": _AGENT_VERSION_METADATA},
|
||||||
if_not_exists="create",
|
if_not_exists="create",
|
||||||
)
|
)
|
||||||
logger.info("LangGraph run created for thread %s from GitHub issue", thread_id)
|
logger.info("LangGraph run created for thread %s from GitHub issue", thread_id)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue