Skip to content

Commit 2849a41

Browse files
authored
Merge pull request #84 from Serverless-Devs/add-super-agent
feat(super_agent): Add new super agent module and related APIs
2 parents 2a9f33d + 52cf6d1 commit 2849a41

30 files changed

Lines changed: 6150 additions & 32 deletions

agentrun/__init__.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,21 @@
113113
SandboxClient,
114114
Template,
115115
)
116+
# Super Agent
117+
from agentrun.super_agent import (
118+
ConversationInfo,
119+
InvokeResponseData,
120+
InvokeStream,
121+
)
122+
from agentrun.super_agent import Message as SuperAgentMessage
123+
from agentrun.super_agent import (
124+
SSEEvent,
125+
SuperAgent,
126+
SuperAgentClient,
127+
SuperAgentCreateInput,
128+
SuperAgentListInput,
129+
SuperAgentUpdateInput,
130+
)
116131
# Tool
117132
from agentrun.tool import Tool as ToolResource
118133
from agentrun.tool import ToolClient as ToolResourceClient
@@ -248,6 +263,20 @@
248263
"ModelProxyCreateInput",
249264
"ModelProxyUpdateInput",
250265
"ModelProxyListInput",
266+
######## Super Agent ########
267+
# base
268+
"SuperAgent",
269+
"SuperAgentClient",
270+
# inner model
271+
"InvokeStream",
272+
"SSEEvent",
273+
"ConversationInfo",
274+
"SuperAgentMessage",
275+
# api model
276+
"SuperAgentCreateInput",
277+
"SuperAgentUpdateInput",
278+
"SuperAgentListInput",
279+
"InvokeResponseData",
251280
######## Sandbox ########
252281
"SandboxClient",
253282
"BrowserSandbox",

agentrun/agent_runtime/__client_async_template.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,12 @@ async def delete_async(
118118
result = await self.__control_api.delete_agent_runtime_async(
119119
id, config=config
120120
)
121-
return AgentRuntime.from_inner_object(result)
121+
# Delete 响应只有 agentRuntimeId 有效,其他字段为空字符串/零值,
122+
# 走 from_inner_object 会在 status/artifactType 等 Enum 字段上触发
123+
# 伪校验错误。这里直接构造一个只带 id 的极简对象。
124+
return AgentRuntime.model_construct(
125+
agent_runtime_id=result.agent_runtime_id
126+
)
122127
except HTTPError as e:
123128
raise e.to_resource_error("AgentRuntime", id) from e
124129

agentrun/agent_runtime/api/control.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
CreateAgentRuntimeEndpointRequest,
2222
CreateAgentRuntimeInput,
2323
CreateAgentRuntimeRequest,
24+
DeleteAgentRuntimeEndpointRequest,
25+
DeleteAgentRuntimeRequest,
26+
GetAgentRuntimeEndpointRequest,
2427
GetAgentRuntimeRequest,
2528
ListAgentRuntimeEndpointsOutput,
2629
ListAgentRuntimeEndpointsRequest,
@@ -193,6 +196,7 @@ def delete_agent_runtime(
193196
client = self._get_client(config)
194197
response = client.delete_agent_runtime_with_options(
195198
agent_id,
199+
DeleteAgentRuntimeRequest(),
196200
headers=headers or {},
197201
runtime=RuntimeOptions(),
198202
)
@@ -248,6 +252,7 @@ async def delete_agent_runtime_async(
248252
client = self._get_client(config)
249253
response = await client.delete_agent_runtime_with_options_async(
250254
agent_id,
255+
DeleteAgentRuntimeRequest(),
251256
headers=headers or {},
252257
runtime=RuntimeOptions(),
253258
)
@@ -778,6 +783,7 @@ def delete_agent_runtime_endpoint(
778783
response = client.delete_agent_runtime_endpoint_with_options(
779784
agent_id,
780785
endpoint_id,
786+
DeleteAgentRuntimeEndpointRequest(),
781787
headers=headers or {},
782788
runtime=RuntimeOptions(),
783789
)
@@ -838,6 +844,7 @@ async def delete_agent_runtime_endpoint_async(
838844
await client.delete_agent_runtime_endpoint_with_options_async(
839845
agent_id,
840846
endpoint_id,
847+
DeleteAgentRuntimeEndpointRequest(),
841848
headers=headers or {},
842849
runtime=RuntimeOptions(),
843850
)
@@ -1028,6 +1035,7 @@ def get_agent_runtime_endpoint(
10281035
response = client.get_agent_runtime_endpoint_with_options(
10291036
agent_id,
10301037
endpoint_id,
1038+
GetAgentRuntimeEndpointRequest(),
10311039
headers=headers or {},
10321040
runtime=RuntimeOptions(),
10331041
)
@@ -1088,6 +1096,7 @@ async def get_agent_runtime_endpoint_async(
10881096
await client.get_agent_runtime_endpoint_with_options_async(
10891097
agent_id,
10901098
endpoint_id,
1099+
GetAgentRuntimeEndpointRequest(),
10911100
headers=headers or {},
10921101
runtime=RuntimeOptions(),
10931102
)

agentrun/agent_runtime/client.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,12 @@ async def delete_async(
171171
result = await self.__control_api.delete_agent_runtime_async(
172172
id, config=config
173173
)
174-
return AgentRuntime.from_inner_object(result)
174+
# Delete 响应只有 agentRuntimeId 有效,其他字段为空字符串/零值,
175+
# 走 from_inner_object 会在 status/artifactType 等 Enum 字段上触发
176+
# 伪校验错误。这里直接构造一个只带 id 的极简对象。
177+
return AgentRuntime.model_construct(
178+
agent_runtime_id=result.agent_runtime_id
179+
)
175180
except HTTPError as e:
176181
raise e.to_resource_error("AgentRuntime", id) from e
177182

@@ -191,7 +196,12 @@ def delete(self, id: str, config: Optional[Config] = None) -> AgentRuntime:
191196
"""
192197
try:
193198
result = self.__control_api.delete_agent_runtime(id, config=config)
194-
return AgentRuntime.from_inner_object(result)
199+
# Delete 响应只有 agentRuntimeId 有效,其他字段为空字符串/零值,
200+
# 走 from_inner_object 会在 status/artifactType 等 Enum 字段上触发
201+
# 伪校验错误。这里直接构造一个只带 id 的极简对象。
202+
return AgentRuntime.model_construct(
203+
agent_runtime_id=result.agent_runtime_id
204+
)
195205
except HTTPError as e:
196206
raise e.to_resource_error("AgentRuntime", id) from e
197207

agentrun/agent_runtime/model.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ class AgentRuntimeProtocolType(str, Enum):
185185

186186
HTTP = "HTTP"
187187
MCP = "MCP"
188+
SUPER_AGENT = "SUPER_AGENT"
188189

189190

190191
class AgentRuntimeProtocolConfig(BaseModel):
@@ -251,6 +252,8 @@ class AgentRuntimeMutableProps(BaseModel):
251252
"""会话空闲超时时间,单位:秒"""
252253
tags: Optional[List[str]] = None
253254
"""标签列表"""
255+
system_tags: Optional[List[str]] = None
256+
"""系统标签列表 (由平台内部使用, 例如 SuperAgent 用来标识下游 AgentRuntime)"""
254257

255258

256259
class AgentRuntimeImmutableProps(BaseModel):
@@ -322,6 +325,8 @@ class AgentRuntimeListInput(PageableInput):
322325
"""Agent Runtime 名称"""
323326
tags: Optional[str] = None
324327
"""标签过滤,多个标签用逗号分隔"""
328+
system_tags: Optional[str] = None
329+
"""系统标签过滤, 多个标签用逗号分隔"""
325330
search_mode: Optional[str] = None
326331
"""搜索模式"""
327332

agentrun/integration/utils/tool.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,8 +1614,8 @@ def _build_openapi_schema(
16141614
if isinstance(schema, dict):
16151615
properties[name] = {
16161616
**schema,
1617-
"description": (
1618-
param.get("description") or schema.get("description", "")
1617+
"description": param.get("description") or schema.get(
1618+
"description", ""
16191619
),
16201620
}
16211621
if param.get("required"):

0 commit comments

Comments
 (0)