refactor: update internal helpers and improve slugify function usage

This commit is contained in:
Abhimanyu Saharan
2026-02-11 00:27:44 +05:30
parent b038d0df4c
commit f4161494d9
6 changed files with 83 additions and 198 deletions

View File

@@ -1,6 +1,7 @@
"""Internal typed helpers shared across OpenClaw service modules."""
"""Internal typed helpers shared across OpenClaw service modules.
from .agent_key import agent_key
from .retry import with_coordination_gateway_retry
Import submodules directly (for example: ``app.services.openclaw.internal.agent_key``)
to avoid shadowing submodule names with re-exported symbols.
"""
__all__ = ["agent_key", "with_coordination_gateway_retry"]
__all__: list[str] = []

View File

@@ -9,7 +9,7 @@ from app.models.agents import Agent
from app.services.openclaw.constants import _SESSION_KEY_PARTS_MIN
def _slugify(value: str) -> str:
def slugify(value: str) -> str:
slug = re.sub(r"[^a-z0-9]+", "-", value.lower()).strip("-")
return slug or uuid4().hex
@@ -21,4 +21,4 @@ def agent_key(agent: Agent) -> str:
parts = session_key.split(":")
if len(parts) >= _SESSION_KEY_PARTS_MIN and parts[1]:
return parts[1]
return _slugify(agent.name)
return slugify(agent.name)