feat(trace):Add run_name to the trace info for system agents. (#2492)

* feat(trace): Add `run_name` to the trace info for suggestions and memory.

before(in langsmith):
CodexChatModel
CodexChatModel
lead_agent
after:
suggest_agent
memory_agent
lead_agent

feat(trace): Add `run_name` to the trace info for suggestions and memory.

before(in langsmith):
CodexChatModel
CodexChatModel
lead_agent
after:
suggest_agent
memory_agent
lead_agent

* feat(trace): Add `run_name` to the trace info for system agents.

before(in langsmith):
CodexChatModel
CodexChatModel
CodexChatModel
CodexChatModel
lead_agent
after:
suggest_agent
title_agent
security_agent
memory_agent
lead_agent

* chore(code format):code format

---------

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
This commit is contained in:
Airene Fang
2026-04-24 17:06:55 +08:00
committed by GitHub
parent e8572b9d0c
commit 11f557a2c6
8 changed files with 34 additions and 4 deletions
@@ -409,7 +409,7 @@ class MemoryUpdater:
current_memory, prompt = prepared
model = self._get_model()
response = await model.ainvoke(prompt)
response = await model.ainvoke(prompt, config={"run_name": "memory_agent"})
return await asyncio.to_thread(
self._finalize_update,
current_memory=current_memory,
@@ -127,7 +127,7 @@ class TitleMiddleware(AgentMiddleware[TitleMiddlewareState]):
model = create_chat_model(name=config.model_name, thinking_enabled=False)
else:
model = create_chat_model(thinking_enabled=False)
response = await model.ainvoke(prompt)
response = await model.ainvoke(prompt, config={"run_name": "title_agent"})
title = self._parse_title(response.content)
if title:
return {"title": title}
@@ -54,7 +54,8 @@ async def scan_skill_content(content: str, *, executable: bool = False, location
[
{"role": "system", "content": rubric},
{"role": "user", "content": prompt},
]
],
config={"run_name": "security_agent"},
)
parsed = _extract_json_object(str(getattr(response, "content", "") or ""))
if parsed and parsed.get("decision") in {"allow", "warn", "block"}: