Files
Airene Fang 923f516deb feat(trace):LangGraph -> lead_agent and set custom agent_name to run_name (#3101)
* feat(trace):LangGraph -> lead_agent and set user custom agent name to run_name

* feat(trace):follow github copilot suggest

* feat(trace):Refactor run_name resolution and improve test coverage
2026-05-21 14:48:28 +08:00

17 lines
582 B
Python

"""Run naming helpers for LangChain/LangSmith tracing."""
from __future__ import annotations
from collections.abc import Mapping
from typing import Any
def resolve_root_run_name(config: Mapping[str, Any], assistant_id: str | None) -> str:
for container_name in ("context", "configurable"):
container = config.get(container_name)
if isinstance(container, Mapping):
agent_name = container.get("agent_name")
if isinstance(agent_name, str) and agent_name.strip():
return agent_name
return assistant_id or "lead_agent"