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

@@ -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)