fix(scripts): agents discover
This commit is contained in:
parent
fa5a18bccd
commit
c440f98381
|
|
@ -350,11 +350,6 @@ class GatewayAdminLifecycleService(OpenClawDBService):
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
runtime_agents_raw = await openclaw_call("agents.list", config=config)
|
runtime_agents_raw = await openclaw_call("agents.list", config=config)
|
||||||
runtime_sessions_raw = await openclaw_call(
|
|
||||||
"sessions.list",
|
|
||||||
{"limit": 500},
|
|
||||||
config=config,
|
|
||||||
)
|
|
||||||
except OpenClawGatewayError as exc:
|
except OpenClawGatewayError as exc:
|
||||||
detail = normalize_gateway_error_message(str(exc))
|
detail = normalize_gateway_error_message(str(exc))
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
@ -362,18 +357,12 @@ class GatewayAdminLifecycleService(OpenClawDBService):
|
||||||
detail=f"Gateway runtime query failed: {detail}",
|
detail=f"Gateway runtime query failed: {detail}",
|
||||||
) from exc
|
) from exc
|
||||||
|
|
||||||
|
# sessions.list with any non-trivial limit blocks the gateway's Node.js event
|
||||||
|
# loop on large session stores, making the gateway unresponsive. The fallback
|
||||||
|
# key "agent:{id}:main" is the standard format used for every agent, so omitting
|
||||||
|
# the sessions lookup has no practical effect on matching accuracy.
|
||||||
runtime_agents = _as_dict_list(runtime_agents_raw)
|
runtime_agents = _as_dict_list(runtime_agents_raw)
|
||||||
runtime_sessions = _as_dict_list(runtime_sessions_raw)
|
|
||||||
|
|
||||||
session_by_agent_key: dict[str, str] = {}
|
session_by_agent_key: dict[str, str] = {}
|
||||||
for runtime_session in runtime_sessions:
|
|
||||||
key = runtime_session.get("key")
|
|
||||||
if not isinstance(key, str):
|
|
||||||
continue
|
|
||||||
parts = key.split(":")
|
|
||||||
if len(parts) < 2 or parts[0] != "agent":
|
|
||||||
continue
|
|
||||||
session_by_agent_key[parts[1]] = key
|
|
||||||
|
|
||||||
existing_agents = await Agent.objects.filter_by(gateway_id=gateway.id).all(self.session)
|
existing_agents = await Agent.objects.filter_by(gateway_id=gateway.id).all(self.session)
|
||||||
existing_by_session_key = {
|
existing_by_session_key = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue