diff --git a/cli.py b/cli.py index 038c83f06f..da401e5c18 100644 --- a/cli.py +++ b/cli.py @@ -6129,8 +6129,6 @@ class HermesCLI: self._handle_agents_command() elif canonical == "background": self._handle_background_command(cmd_original) - elif canonical == "btw": - self._handle_btw_command(cmd_original) elif canonical == "queue": # Extract prompt after "/queue " or "/q " parts = cmd_original.split(None, 1) @@ -6417,122 +6415,6 @@ class HermesCLI: self._background_tasks[task_id] = thread thread.start() - def _handle_btw_command(self, cmd: str): - """Handle /btw β€” ephemeral side question using session context. - - Snapshots the current conversation history, spawns a no-tools agent in - a background thread, and prints the answer without persisting anything - to the main session. - """ - parts = cmd.strip().split(maxsplit=1) - if len(parts) < 2 or not parts[1].strip(): - _cprint(" Usage: /btw ") - _cprint(" Example: /btw what module owns session title sanitization?") - _cprint(" Answers using session context. No tools, not persisted.") - return - - question = parts[1].strip() - task_id = f"btw_{datetime.now().strftime('%H%M%S')}_{uuid.uuid4().hex[:6]}" - - if not self._ensure_runtime_credentials(): - _cprint(" (>_<) Cannot start /btw: no valid credentials.") - return - - turn_route = self._resolve_turn_agent_config(question) - history_snapshot = list(self.conversation_history) - - preview = question[:60] + ("..." if len(question) > 60 else "") - _cprint(f' πŸ’¬ /btw: "{preview}"') - - def run_btw(): - try: - btw_agent = AIAgent( - model=turn_route["model"], - api_key=turn_route["runtime"].get("api_key"), - base_url=turn_route["runtime"].get("base_url"), - provider=turn_route["runtime"].get("provider"), - api_mode=turn_route["runtime"].get("api_mode"), - acp_command=turn_route["runtime"].get("command"), - acp_args=turn_route["runtime"].get("args"), - max_iterations=8, - enabled_toolsets=[], - quiet_mode=True, - verbose_logging=False, - session_id=task_id, - platform="cli", - reasoning_config=self.reasoning_config, - service_tier=self.service_tier, - request_overrides=turn_route.get("request_overrides"), - providers_allowed=self._providers_only, - providers_ignored=self._providers_ignore, - providers_order=self._providers_order, - provider_sort=self._provider_sort, - provider_require_parameters=self._provider_require_params, - provider_data_collection=self._provider_data_collection, - fallback_model=self._fallback_model, - session_db=None, - skip_memory=True, - skip_context_files=True, - persist_session=False, - ) - - btw_prompt = ( - "[Ephemeral /btw side question. Answer using the conversation " - "context. No tools available. Be direct and concise.]\n\n" - + question - ) - result = btw_agent.run_conversation( - user_message=btw_prompt, - conversation_history=history_snapshot, - task_id=task_id, - ) - - response = (result.get("final_response") or "") if result else "" - if not response and result and result.get("error"): - response = f"Error: {result['error']}" - - # TUI refresh before printing - if self._app: - self._app.invalidate() - time.sleep(0.05) - print() - - if response: - try: - from hermes_cli.skin_engine import get_active_skin - _skin = get_active_skin() - _resp_color = _skin.get_color("response_border", "#4F6D4A") - except Exception: - _resp_color = "#4F6D4A" - - ChatConsole().print(Panel( - _render_final_assistant_content(response, mode=self.final_response_markdown), - title=f"[{_resp_color} bold]βš• /btw[/]", - title_align="left", - border_style=_resp_color, - box=rich_box.HORIZONTALS, - padding=(1, 4), - )) - else: - _cprint(" πŸ’¬ /btw: (no response)") - - if self.bell_on_complete: - sys.stdout.write("\a") - sys.stdout.flush() - - except Exception as e: - if self._app: - self._app.invalidate() - time.sleep(0.05) - print() - _cprint(f" ❌ /btw failed: {e}") - finally: - if self._app: - self._invalidate(min_interval=0) - - thread = threading.Thread(target=run_btw, daemon=True, name=f"btw-{task_id}") - thread.start() - @staticmethod def _try_launch_chrome_debug(port: int, system: str) -> bool: """Try to launch Chrome/Chromium with remote debugging enabled. diff --git a/gateway/platforms/discord.py b/gateway/platforms/discord.py index 5d30f244e8..b4018c6df6 100644 --- a/gateway/platforms/discord.py +++ b/gateway/platforms/discord.py @@ -2315,11 +2315,6 @@ class DiscordAdapter(BasePlatformAdapter): async def slash_background(interaction: discord.Interaction, prompt: str): await self._run_simple_slash(interaction, f"/background {prompt}", "Background task started~") - @tree.command(name="btw", description="Ephemeral side question using session context") - @discord.app_commands.describe(question="Your side question (no tools, not persisted)") - async def slash_btw(interaction: discord.Interaction, question: str): - await self._run_simple_slash(interaction, f"/btw {question}") - # ── Auto-register any gateway-available commands not yet on the tree ── # This ensures new commands added to COMMAND_REGISTRY in # hermes_cli/commands.py automatically appear as Discord slash diff --git a/gateway/run.py b/gateway/run.py index d7331bdc75..6cd1083ba7 100644 --- a/gateway/run.py +++ b/gateway/run.py @@ -3773,9 +3773,6 @@ class GatewayRunner: if canonical == "background": return await self._handle_background_command(event) - if canonical == "btw": - return await self._handle_btw_command(event) - if canonical == "steer": # No active agent β€” /steer has no tool call to inject into. # Strip the prefix so downstream treats it as a normal user @@ -6673,177 +6670,6 @@ class GatewayRunner: except Exception: pass - async def _handle_btw_command(self, event: MessageEvent) -> str: - """Handle /btw β€” ephemeral side question in the same chat.""" - question = event.get_command_args().strip() - if not question: - return ( - "Usage: /btw \n" - "Example: /btw what module owns session title sanitization?\n\n" - "Answers using session context. No tools, not persisted." - ) - - source = event.source - session_key = self._session_key_for_source(source) - - # Guard: one /btw at a time per session - existing = getattr(self, "_active_btw_tasks", {}).get(session_key) - if existing and not existing.done(): - return "A /btw is already running for this chat. Wait for it to finish." - - if not hasattr(self, "_active_btw_tasks"): - self._active_btw_tasks: dict = {} - - import uuid as _uuid - task_id = f"btw_{datetime.now().strftime('%H%M%S')}_{_uuid.uuid4().hex[:6]}" - _task = asyncio.create_task(self._run_btw_task(question, source, session_key, task_id)) - self._background_tasks.add(_task) - self._active_btw_tasks[session_key] = _task - - def _cleanup(task): - self._background_tasks.discard(task) - if self._active_btw_tasks.get(session_key) is task: - self._active_btw_tasks.pop(session_key, None) - - _task.add_done_callback(_cleanup) - - preview = question[:60] + ("..." if len(question) > 60 else "") - return f'πŸ’¬ /btw: "{preview}"\nReply will appear here shortly.' - - async def _run_btw_task( - self, question: str, source, session_key: str, task_id: str, - ) -> None: - """Execute an ephemeral /btw side question and deliver the answer.""" - from run_agent import AIAgent - - adapter = self.adapters.get(source.platform) - if not adapter: - logger.warning("No adapter for platform %s in /btw task %s", source.platform, task_id) - return - - _thread_meta = {"thread_id": source.thread_id} if source.thread_id else None - - try: - user_config = _load_gateway_config() - model, runtime_kwargs = self._resolve_session_agent_runtime( - source=source, - session_key=session_key, - user_config=user_config, - ) - if not runtime_kwargs.get("api_key"): - await adapter.send( - source.chat_id, - "❌ /btw failed: no provider credentials configured.", - metadata=_thread_meta, - ) - return - - platform_key = _platform_config_key(source.platform) - reasoning_config = self._resolve_session_reasoning_config( - source=source, - session_key=session_key, - ) - self._service_tier = self._load_service_tier() - turn_route = self._resolve_turn_agent_config(question, model, runtime_kwargs) - pr = self._provider_routing - - # Snapshot history from running agent or stored transcript - running_agent = self._running_agents.get(session_key) - if running_agent and running_agent is not _AGENT_PENDING_SENTINEL: - history_snapshot = list(getattr(running_agent, "_session_messages", []) or []) - else: - session_entry = self.session_store.get_or_create_session(source) - history_snapshot = self.session_store.load_transcript(session_entry.session_id) - - btw_prompt = ( - "[Ephemeral /btw side question. Answer using the conversation " - "context. No tools available. Be direct and concise.]\n\n" - + question - ) - - def run_sync(): - agent = AIAgent( - model=turn_route["model"], - **turn_route["runtime"], - max_iterations=8, - quiet_mode=True, - verbose_logging=False, - enabled_toolsets=[], - reasoning_config=reasoning_config, - service_tier=self._service_tier, - request_overrides=turn_route.get("request_overrides"), - providers_allowed=pr.get("only"), - providers_ignored=pr.get("ignore"), - providers_order=pr.get("order"), - provider_sort=pr.get("sort"), - provider_require_parameters=pr.get("require_parameters", False), - provider_data_collection=pr.get("data_collection"), - session_id=task_id, - platform=platform_key, - session_db=None, - fallback_model=self._fallback_model, - skip_memory=True, - skip_context_files=True, - persist_session=False, - ) - try: - return agent.run_conversation( - user_message=btw_prompt, - conversation_history=history_snapshot, - task_id=task_id, - ) - finally: - self._cleanup_agent_resources(agent) - - result = await self._run_in_executor_with_context(run_sync) - - response = (result.get("final_response") or "") if result else "" - if not response and result and result.get("error"): - response = f"Error: {result['error']}" - if not response: - response = "(No response generated)" - - media_files, response = adapter.extract_media(response) - images, text_content = adapter.extract_images(response) - preview = question[:60] + ("..." if len(question) > 60 else "") - header = f'πŸ’¬ /btw: "{preview}"\n\n' - - if text_content: - await adapter.send( - chat_id=source.chat_id, - content=header + text_content, - metadata=_thread_meta, - ) - elif not images and not media_files: - await adapter.send( - chat_id=source.chat_id, - content=header + "(No response generated)", - metadata=_thread_meta, - ) - - for image_url, alt_text in (images or []): - try: - await adapter.send_image(chat_id=source.chat_id, image_url=image_url, caption=alt_text) - except Exception: - pass - - for media_path, _is_voice in (media_files or []): - try: - await adapter.send_file(chat_id=source.chat_id, file_path=media_path) - except Exception: - pass - - except Exception as e: - logger.exception("/btw task %s failed", task_id) - try: - await adapter.send( - chat_id=source.chat_id, - content=f"❌ /btw failed: {e}", - metadata=_thread_meta, - ) - except Exception: - pass - async def _handle_reasoning_command(self, event: MessageEvent) -> str: """Handle /reasoning command β€” manage reasoning effort and display toggle. diff --git a/hermes_cli/commands.py b/hermes_cli/commands.py index 4d650487b4..614d783d95 100644 --- a/hermes_cli/commands.py +++ b/hermes_cli/commands.py @@ -84,9 +84,7 @@ COMMAND_REGISTRY: list[CommandDef] = [ CommandDef("deny", "Deny a pending dangerous command", "Session", gateway_only=True), CommandDef("background", "Run a prompt in the background", "Session", - aliases=("bg",), args_hint=""), - CommandDef("btw", "Ephemeral side question using session context (no tools, not persisted)", "Session", - args_hint=""), + aliases=("bg", "btw"), args_hint=""), CommandDef("agents", "Show active agents and running tasks", "Session", aliases=("tasks",)), CommandDef("queue", "Queue a prompt for the next turn (doesn't interrupt)", "Session", diff --git a/hermes_cli/tips.py b/hermes_cli/tips.py index db66e1db1b..a93a31db13 100644 --- a/hermes_cli/tips.py +++ b/hermes_cli/tips.py @@ -10,8 +10,7 @@ import random TIPS = [ # --- Slash Commands --- - "/btw asks a quick side question without tools or history β€” great for clarifications.", - "/background runs a task in a separate session while your current one stays free.", + "/background (alias /bg or /btw) runs a task in a separate session while your current one stays free.", "/branch forks the current session so you can explore a different direction without losing progress.", "/compress manually compresses conversation context when things get long.", "/rollback lists filesystem checkpoints β€” restore files the agent modified to any prior state.", diff --git a/skills/autonomous-ai-agents/hermes-agent/SKILL.md b/skills/autonomous-ai-agents/hermes-agent/SKILL.md index 4ed03a904c..76a0e51b6c 100644 --- a/skills/autonomous-ai-agents/hermes-agent/SKILL.md +++ b/skills/autonomous-ai-agents/hermes-agent/SKILL.md @@ -281,7 +281,6 @@ Type these during an interactive chat session. ### Utility ``` /branch (/fork) Branch the current session -/btw Ephemeral side question (doesn't interrupt main task) /fast Toggle priority/fast processing /browser Open CDP browser connection /history Show conversation history (CLI) diff --git a/tui_gateway/server.py b/tui_gateway/server.py index 03631bf174..30531aab28 100644 --- a/tui_gateway/server.py +++ b/tui_gateway/server.py @@ -2550,48 +2550,6 @@ def _(rid, params: dict) -> dict: return _ok(rid, {"task_id": task_id}) -@method("prompt.btw") -def _(rid, params: dict) -> dict: - session, err = _sess(params, rid) - if err: - return err - text, sid = params.get("text", ""), params.get("session_id", "") - if not text: - return _err(rid, 4012, "text required") - snapshot = list(session.get("history", [])) - - def run(): - session_tokens = _set_session_context(session["session_key"]) - try: - from run_agent import AIAgent - - result = AIAgent( - model=_resolve_model(), - quiet_mode=True, - platform="tui", - max_iterations=8, - enabled_toolsets=[], - ).run_conversation(text, conversation_history=snapshot) - _emit( - "btw.complete", - sid, - { - "text": ( - result.get("final_response", str(result)) - if isinstance(result, dict) - else str(result) - ) - }, - ) - except Exception as e: - _emit("btw.complete", sid, {"text": f"error: {e}"}) - finally: - _clear_session_context(session_tokens) - - threading.Thread(target=run, daemon=True).start() - return _ok(rid, {"status": "running"}) - - # ── Methods: respond ───────────────────────────────────────────────── diff --git a/ui-tui/README.md b/ui-tui/README.md index 2f95a47aa2..17d57f08af 100644 --- a/ui-tui/README.md +++ b/ui-tui/README.md @@ -252,7 +252,6 @@ Primary event types the client handles today: | `sudo.request` | `{ request_id }` | | `secret.request` | `{ prompt, env_var, request_id }` | | `background.complete` | `{ task_id, text }` | -| `btw.complete` | `{ text }` | | `error` | `{ message }` | | `gateway.stderr` | synthesized from child stderr | | `gateway.protocol_error` | synthesized from malformed stdout | diff --git a/ui-tui/src/app/createGatewayEventHandler.ts b/ui-tui/src/app/createGatewayEventHandler.ts index 15cf00a5a9..0bd505078f 100644 --- a/ui-tui/src/app/createGatewayEventHandler.ts +++ b/ui-tui/src/app/createGatewayEventHandler.ts @@ -431,12 +431,6 @@ export function createGatewayEventHandler(ctx: GatewayEventHandlerContext): (ev: return - case 'btw.complete': - dropBgTask('btw:x') - sys(`[btw] ${ev.payload.text}`) - - return - case 'subagent.spawn_requested': // Child built but not yet running (waiting on ThreadPoolExecutor slot). // Preserve completed state if a later event races in before this one. diff --git a/ui-tui/src/app/slash/commands/session.ts b/ui-tui/src/app/slash/commands/session.ts index 1049ee34d8..df106e1d86 100644 --- a/ui-tui/src/app/slash/commands/session.ts +++ b/ui-tui/src/app/slash/commands/session.ts @@ -1,7 +1,6 @@ import { attachedImageNotice, introMsg, toTranscriptMessages } from '../../../domain/messages.js' import type { BackgroundStartResponse, - BtwStartResponse, ConfigGetValueResponse, ConfigSetResponse, ImageAttachResponse, @@ -18,7 +17,7 @@ import type { SlashCommand } from '../types.js' export const sessionCommands: SlashCommand[] = [ { - aliases: ['bg'], + aliases: ['bg', 'btw'], help: 'launch a background prompt', name: 'background', run: (arg, ctx) => { @@ -39,23 +38,6 @@ export const sessionCommands: SlashCommand[] = [ } }, - { - help: 'by-the-way follow-up', - name: 'btw', - run: (arg, ctx) => { - if (!arg) { - return ctx.transcript.sys('/btw ') - } - - ctx.gateway.rpc('prompt.btw', { session_id: ctx.sid, text: arg }).then( - ctx.guarded(() => { - patchUiState(state => ({ ...state, bgTasks: new Set(state.bgTasks).add('btw:x') })) - ctx.transcript.sys('btw running…') - }) - ) - } - }, - { help: 'change or show model', aliases: ['provider'], diff --git a/ui-tui/src/gatewayTypes.ts b/ui-tui/src/gatewayTypes.ts index e64d113c22..ce056040c2 100644 --- a/ui-tui/src/gatewayTypes.ts +++ b/ui-tui/src/gatewayTypes.ts @@ -178,10 +178,6 @@ export interface BackgroundStartResponse { task_id?: string } -export interface BtwStartResponse { - ok?: boolean -} - export interface ClarifyRespondResponse { ok?: boolean } @@ -403,7 +399,6 @@ export type GatewayEvent = | { payload: { request_id: string }; session_id?: string; type: 'sudo.request' } | { payload: { env_var: string; prompt: string; request_id: string }; session_id?: string; type: 'secret.request' } | { payload: { task_id: string; text: string }; session_id?: string; type: 'background.complete' } - | { payload: { text: string }; session_id?: string; type: 'btw.complete' } | { payload: SubagentEventPayload; session_id?: string; type: 'subagent.spawn_requested' } | { payload: SubagentEventPayload; session_id?: string; type: 'subagent.start' } | { payload: SubagentEventPayload; session_id?: string; type: 'subagent.thinking' } diff --git a/web/src/lib/gatewayClient.ts b/web/src/lib/gatewayClient.ts index 012482b710..fa58841ce1 100644 --- a/web/src/lib/gatewayClient.ts +++ b/web/src/lib/gatewayClient.ts @@ -32,7 +32,6 @@ export type GatewayEventName = | "sudo.request" | "secret.request" | "background.complete" - | "btw.complete" | "error" | "skin.changed" | (string & {}); diff --git a/website/docs/reference/slash-commands.md b/website/docs/reference/slash-commands.md index 6e04bcd010..ed2a2ff2fc 100644 --- a/website/docs/reference/slash-commands.md +++ b/website/docs/reference/slash-commands.md @@ -36,8 +36,7 @@ Type `/` in the CLI to open the autocomplete menu. Built-in commands are case-in | `/resume [name]` | Resume a previously-named session | | `/status` | Show session info | | `/agents` (alias: `/tasks`) | Show active agents and running tasks across the current session. | -| `/background ` (alias: `/bg`) | Run a prompt in a separate background session. The agent processes your prompt independently β€” your current session stays free for other work. Results appear as a panel when the task finishes. See [CLI Background Sessions](/docs/user-guide/cli#background-sessions). | -| `/btw ` | Ephemeral side question using session context (no tools, not persisted). Useful for quick clarifications without affecting the conversation history. | +| `/background ` (alias: `/bg`, `/btw`) | Run a prompt in a separate background session. The agent processes your prompt independently β€” your current session stays free for other work. Results appear as a panel when the task finishes. See [CLI Background Sessions](/docs/user-guide/cli#background-sessions). | | `/branch [name]` (alias: `/fork`) | Branch the current session (explore a different path) | ### Configuration diff --git a/website/docs/user-guide/skills/bundled/autonomous-ai-agents/autonomous-ai-agents-hermes-agent.md b/website/docs/user-guide/skills/bundled/autonomous-ai-agents/autonomous-ai-agents-hermes-agent.md index efd6326259..10a91f2aae 100644 --- a/website/docs/user-guide/skills/bundled/autonomous-ai-agents/autonomous-ai-agents-hermes-agent.md +++ b/website/docs/user-guide/skills/bundled/autonomous-ai-agents/autonomous-ai-agents-hermes-agent.md @@ -298,7 +298,6 @@ Type these during an interactive chat session. ### Utility ``` /branch (/fork) Branch the current session -/btw Ephemeral side question (doesn't interrupt main task) /fast Toggle priority/fast processing /browser Open CDP browser connection /history Show conversation history (CLI)