Skip to content

Commit c8847e0

Browse files
committed
refactor(super_agent): Update tag constants and simplify creation process
This change updates the `SUPER_AGENT_TAG` constant from `"x-agentrun-super-agent"` to `"x-agentrun-super"`, removes the `EXTERNAL_TAG` from the default tags when creating a super agent runtime, and adds clarifying comments about the purpose of `external_agent_endpoint_url`. The corresponding unit tests have also been updated accordingly. Co-developed-by: Aone Copilot <noreply@alibaba-inc.com> Signed-off-by: Sodawyx <sodawyx@126.com>
1 parent 3609964 commit c8847e0

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

agentrun/super_agent/__client_async_template.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
内部持有一个 :class:`AgentRuntimeClient` 实例, 通过 ``api/control.py`` 的
55
转换函数把 ``SuperAgent`` 与 ``AgentRuntime`` 互相映射。
66
7-
list 固定按 tag ``x-agentrun-super-agent`` 过滤, 不接受用户自定义 tag。
7+
list 固定按 tag ``x-agentrun-super`` 过滤, 不接受用户自定义 tag。
88
"""
99

1010
import asyncio

agentrun/super_agent/api/control.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@
5050
API_VERSION = "2025-09-10"
5151
SUPER_AGENT_PROTOCOL_TYPE = "SUPER_AGENT"
5252
# ``SUPER_AGENT_TAG`` 标识下游 AgentRuntime 是超级 Agent, 用于 list 过滤。
53-
SUPER_AGENT_TAG = "x-agentrun-super-agent"
53+
SUPER_AGENT_TAG = "x-agentrun-super"
5454
# ``EXTERNAL_TAG`` 标识下游 AgentRuntime 由外部 (SuperAgent) 托管调用, 不由 AgentRun 直接托管。
55+
# 保留常量以便外部消费者引用; 创建超级 Agent 时不再写入此 tag。
5556
EXTERNAL_TAG = "x-agentrun-external"
56-
# 创建下游 AgentRuntime 时固定写入的 tag 列表: ``[EXTERNAL_TAG, SUPER_AGENT_TAG]``。
57-
SUPER_AGENT_CREATE_TAGS = [EXTERNAL_TAG, SUPER_AGENT_TAG]
57+
# 创建下游 AgentRuntime 时固定写入的 tag 列表: ``[SUPER_AGENT_TAG]`` (仅一个)
58+
SUPER_AGENT_CREATE_TAGS = [SUPER_AGENT_TAG]
5859
SUPER_AGENT_RESOURCE_PATH = "__SUPER_AGENT__"
5960
SUPER_AGENT_INVOKE_PATH = "/invoke"
6061
SUPER_AGENT_NAMESPACE = (
@@ -131,8 +132,8 @@ class _SuperAgentCreateInput(AgentRuntimeCreateInput):
131132
"""默认使用 ``serialize_as_any=True`` 的 create input, 保留子类 extras.
132133
133134
``external_agent_endpoint_url`` 是基类 ``AgentRuntimeMutableProps`` 没有覆盖
134-
的顶层字段, 但在 ``x-agentrun-external`` tag 下服务端强制要求填入, 这里显式
135-
补齐 (alias 由 BaseModel 的 ``to_camel_case`` 生成 → ``externalAgentEndpointUrl``)
135+
的顶层字段, 这里显式补齐 (alias 由 BaseModel 的 ``to_camel_case`` 生成 →
136+
``externalAgentEndpointUrl``), 用于承载超级 Agent 的数据面入口地址
136137
"""
137138

138139
external_agent_endpoint_url: Optional[str] = None
@@ -407,8 +408,7 @@ def to_create_input(
407408
description=description,
408409
protocol_configuration=pc,
409410
tags=list(SUPER_AGENT_CREATE_TAGS),
410-
# 带 ``x-agentrun-external`` tag 时服务端强制要求 externalAgentEndpointUrl 非空,
411-
# 对超级 Agent 而言即数据面入口 (与 protocolConfiguration.externalEndpoint 同值)。
411+
# 超级 Agent 的数据面入口 (与 protocolConfiguration.externalEndpoint 同值)。
412412
external_agent_endpoint_url=build_super_agent_endpoint(cfg),
413413
# 占位 artifact: SUPER_AGENT 不跑用户 container/code, 但服务端要求非空。
414414
artifact_type=AgentRuntimeArtifact.CONTAINER,
@@ -439,7 +439,7 @@ def to_update_input(
439439
description=merged.get("description"),
440440
protocol_configuration=pc,
441441
tags=list(SUPER_AGENT_CREATE_TAGS),
442-
# 带 ``x-agentrun-external`` tag 时服务端强制要求 externalAgentEndpointUrl 非空
442+
# 超级 Agent 的数据面入口 (与 protocolConfiguration.externalEndpoint 同值)
443443
external_agent_endpoint_url=build_super_agent_endpoint(cfg),
444444
# 占位 artifact: SUPER_AGENT 不跑用户 container/code, 但服务端要求非空。
445445
artifact_type=AgentRuntimeArtifact.CONTAINER,

agentrun/super_agent/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
内部持有一个 :class:`AgentRuntimeClient` 实例, 通过 ``api/control.py`` 的
1515
转换函数把 ``SuperAgent`` 与 ``AgentRuntime`` 互相映射。
1616
17-
list 固定按 tag ``x-agentrun-super-agent`` 过滤, 不接受用户自定义 tag。
17+
list 固定按 tag ``x-agentrun-super`` 过滤, 不接受用户自定义 tag。
1818
"""
1919

2020
import asyncio

tests/unittests/super_agent/test_control.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def test_to_create_input_minimal():
108108
cfg = Config(account_id="123", region_id="cn-hangzhou")
109109
inp = to_create_input("alpha", cfg=cfg)
110110
assert inp.agent_runtime_name == "alpha"
111-
assert inp.tags == [EXTERNAL_TAG, SUPER_AGENT_TAG]
111+
assert inp.tags == [SUPER_AGENT_TAG]
112112
pc = inp.protocol_configuration
113113
assert pc.type == SUPER_AGENT_PROTOCOL_TYPE
114114
assert pc.external_endpoint.endswith("/super-agents/__SUPER_AGENT__")
@@ -149,7 +149,7 @@ def test_to_create_input_full():
149149
def test_to_create_input_tags_fixed():
150150
cfg = Config(account_id="123", region_id="cn-hangzhou")
151151
inp = to_create_input("c", cfg=cfg)
152-
assert inp.tags == [EXTERNAL_TAG, SUPER_AGENT_TAG]
152+
assert inp.tags == [SUPER_AGENT_TAG]
153153

154154

155155
def test_to_create_input_metadata_only_agent_runtime_name():

0 commit comments

Comments
 (0)