The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(gateway): remove residual intra-body blank lines in slash handlers
Teknium674a1232373d
diff --git a/gateway/slash_commands.py b/gateway/slash_commands.pyindex aeabe2d5d60..2e0797ff297 100644--- a/gateway/slash_commands.py+++ b/gateway/slash_commands.py@@ -277,7 +277,6 @@ class GatewaySlashCommandsMixin(user_config.setdefault(section, {})["write_approval"] = bool(enabled)atomic_config_write(config_path, user_config)self._evict_cached_agent(session_key)-return _set_approvalasync def _deliver_approval_confirmation(self, event: MessageEvent, confirmation_text: str, verb: str):@@ -375,7 +374,6 @@ class GatewaySlashCommandsMixin(text = (event.text or "").strip().lstrip("/")if text.startswith("kanban"):text = text[len("kanban"):].lstrip()-requested_board = action = Nonetokens = iter(shlex.split(text) if text else [])for tok in tokens: # leading --board/--board=<b> options, then the action verb@@ -588,7 +586,6 @@ class GatewaySlashCommandsMixin(# .restart_notify.json (unlinked once the new gateway sends its notification) this persists# so a delayed Telegram redelivery is still detectable. Overwritten on every /restart.await _write_marker(".restart_last_processed.json", lambda: _restart_dedup_payload(event), "dedup marker")-active_agents = self._running_agent_count()# Under a service manager (systemd/launchd) or Docker/Podman, exit 75 so the supervisor /# restart policy restarts us — detached setsid+bash fails there (systemd KillMode=mixed kills@@ -636,7 +633,6 @@ class GatewaySlashCommandsMixin():return t("gateway.set_home.save_failed",error="Relay does not authenticate this logical home target")-thread_id = _home_thread_from_source(source)home = HomeChannel(platform=source.platform, chat_id=str(chat_id), name=chat_name,@@ -729,7 +725,6 @@ class GatewaySlashCommandsMixin(tokens = event.get_command_args().strip().split()restore_all = any(tok.lower() in ("--all", "--force") for tok in tokens)arg = " ".join(tok for tok in tokens if tok.lower() not in ("--all", "--force"))-checkpoints = mgr.list_checkpoints(cwd)if not arg:return format_checkpoint_list(checkpoints, cwd)@@ -745,7 +740,6 @@ class GatewaySlashCommandsMixin(if not 0 <= idx < len(checkpoints):return t("gateway.rollback.invalid_number", max=len(checkpoints))target_hash = checkpoints[idx]["hash"]-result = mgr.restore(cwd, target_hash, safe=not restore_all)if not result["success"]:return t("gateway.rollback.restore_failed", error=result["error"])@@ -770,7 +764,6 @@ class GatewaySlashCommandsMixin(stat_only = Trueelse:mode = _DIFF_MODE_BY_ARG.get(low, mode)-cwd = self._terminal_cwd()if mode == "session":# Cumulative checkpoint-baseline diff.@@ -916,7 +909,6 @@ class GatewaySlashCommandsMixin(return ("Skill write approval is off (skills.write_approval). ""Enable it with /skills approval on, then review staged ""writes here with /skills pending.")-out = handle_pending_subcommand(wa.SKILLS, args, set_mode_fn=self._write_approval_setter("skills", event))@@ -1022,7 +1014,6 @@ class GatewaySlashCommandsMixin(adapter = self._adapter_for_source(event.source)if adapter is not None:adapter._busy_text_mode = self._effective_busy_text_mode(event.source)-return EphemeralReply(f"Busy input mode set to **`{arg}`** (saved)." + "\n" f"_{_BUSY_MODE_BEHAVIOR[arg][1]}_")@@ -1032,7 +1023,6 @@ class GatewaySlashCommandsMixin(from gateway.run import _load_gateway_config, _resolve_gateway_modelfrom gateway.runtime_footer import format_runtime_footer, resolve_footer_configconfig_path, platform_key = self._display_config_target(event)-arg = ""try:text = (getattr(event, "message", None) or "").strip()@@ -1124,7 +1114,6 @@ class GatewaySlashCommandsMixin(result = await self._run_in_executor_with_context(reload_skills)added, removed = result.get("added", []), result.get("removed", []) # [{"name", "description"}]total = result.get("total", 0)-# Let adapters refresh platform-side state that cached the skill list at startup (today:# Discord /skill autocomplete — otherwise new skills stay invisible and deleted ones# error). Adapters without refresh_skill_group are skipped; the in-process reload suffices.@@ -1164,7 +1153,6 @@ class GatewaySlashCommandsMixin(sections += ["", note_header] + formattedlines.append(t("gateway.reload_skills.total", count=total))sections += ["", "Use skills_list to see the updated catalog.]"]-session_key = self._session_key_for_source(event.source)if not hasattr(self, "_pending_skills_reload_notes"):self._pending_skills_reload_notes = {}@@ -1327,7 +1315,6 @@ class GatewaySlashCommandsMixin(_tmp_pending.write_text(json.dumps(pending), encoding="utf-8")_tmp_pending.replace(pending_path)exit_code_path.unlink(missing_ok=True)-try:_spawn_detached_update(hermes_cmd, output_path, exit_code_path)except Exception as e:diff --git a/gateway/slash_commands_goals.py b/gateway/slash_commands_goals.pyindex 83f999aef78..9936af96050 100644--- a/gateway/slash_commands_goals.py+++ b/gateway/slash_commands_goals.py@@ -42,7 +42,6 @@ class GatewayGoalCommandsMixin:"""args = (event.get_command_args() or "").strip()lower = args.lower()-mgr, _session_entry = await self._get_goal_manager_for_event(event)if mgr is None:return t("gateway.goal.unavailable")@@ -192,7 +191,6 @@ class GatewayGoalCommandsMixin:headline, parsed = parse_contract(args)args = headline or argscontract = parsed if not parsed.is_empty() else None-try:state = mgr.set(args, contract=contract)except ValueError as exc:@@ -217,7 +215,6 @@ class GatewayGoalCommandsMixin:from hermes_cli.heartbeat import parse_interval, format_interval, MIN_INTERVAL_SECONDSargs = (event.get_command_args() or "").strip()lower = args.lower()-mgr, _session_entry = await self._get_heartbeat_manager_for_event(event)if mgr is None:return "Heartbeats unavailable (no session)."@@ -353,7 +350,6 @@ class GatewayGoalCommandsMixin:tokens = args.split(None, 1)verb = tokens[0].lower()rest = tokens[1].strip() if len(tokens) > 1 else ""-if verb == "remove":if not rest:return "Usage: /subgoal remove <n>"@@ -409,7 +405,6 @@ class GatewayGoalCommandsMixin:route = {k: v for k, v in route.items() if v}except Exception:route = {}-result = dispatch_loop_command(mgr, (event.get_command_args() or "").strip(), route=route)output = result.get("output") or ""if result.get("created") and _quiet_bool(lambda: goal_blocks_loop_tick(mgr.session_id)):diff --git a/gateway/slash_commands_status.py b/gateway/slash_commands_status.pyindex b110e2beabe..64891154f03 100644--- a/gateway/slash_commands_status.py+++ b/gateway/slash_commands_status.py@@ -95,7 +95,6 @@ def _status_model_route(status_agent, persisted_route: dict, session_row: dict,# First fully-resolved (model AND provider) route wins; the SessionDB row is used even if partial.model_name, provider_name = next((r for r in routes if r[0] and r[1]), row_route)context_used = context_used or _int_value(getattr(session_entry, "last_prompt_tokens", 0))-user_config: dict[str, Any] = {}if not model_name or not provider_name or not context_total:user_config = _quiet_sync(_load_gateway_config, {})@@ -389,7 +388,6 @@ class GatewayStatusCommandsMixin:now = time.time()current_session_key = self._session_key_for_source(event.source)running_started: dict = getattr(self, "_running_agents_ts", {}) or {}-agent_rows: list[dict] = []for session_key, agent in (getattr(self, "_running_agents", {}) or {}).items():pending = agent is _AGENT_PENDING_SENTINEL@@ -401,10 +399,8 @@ class GatewayStatusCommandsMixin:"model": "" if pending else str(getattr(agent, "model", "") or ""),})agent_rows.sort(key=lambda row: row["elapsed"], reverse=True)-procs = _quiet_sync(process_registry.list_sessions, [])running_processes = [p for p in procs if p.get("status") == "running"]-background_tasks = [task for task in (getattr(self, "_background_tasks", set()) or set())if hasattr(task, "done") and not task.done()@@ -513,7 +509,6 @@ class GatewayStatusCommandsMixin:account/credit blocks; ``/usage reset [--force]`` redeems a banked Codex reset credit."""source = event.sourcesession_key = self._session_key_for_source(source)-raw_args = event.get_command_args().strip()args = [a.lower() for a in raw_args.split()] if raw_args else []wants_reset = bool(args) and args[0] == "reset"@@ -530,7 +525,6 @@ class GatewayStatusCommandsMixin:)if not provider and getattr(self, "_session_db", None) is not None:provider, base_url = await self._persisted_billing_route(source)-if wants_reset:if str(provider or "").strip().lower() != "openai-codex":return t("gateway.usage.reset_wrong_provider")