Skip to content

feat: support slash commands in ACP adapter (#1402)#1518

Closed
solo386 wants to merge 2 commits into
NousResearch:mainfrom
solo386:feat/issue-1402-acp-slash-commands
Closed

feat: support slash commands in ACP adapter (#1402)#1518
solo386 wants to merge 2 commits into
NousResearch:mainfrom
solo386:feat/issue-1402-acp-slash-commands

Conversation

@solo386

@solo386 solo386 commented Mar 16, 2026

Copy link
Copy Markdown

What does this PR do?
This PR adds support for slash commands (/help, /model, etc.) in the ACP adapter. It intercepts prompts starting with / and routes them to the existing CLI logic instead of the LLM.

Related Issue
Fixes #1402

Changes Made
acp_adapter/server.py:
Intercepts / commands in the prompt method.
Uses contextlib.redirect_stdout to capture output from ChatConsole.process_command (cli.py).
Passes the current agent instance to ensure state consistency (e.g., for /model).

How to Test
Run hermes acp.
Connect a client and send /help or /model.
Verify you receive formatted CLI output instead of an LLM response.

Checklist
[x] Read Contributing Guide
[x] Followed Conventional Commits
[x] PR contains only related changes
[x] Tested on Codespaces/Linux

solo386 added 2 commits March 16, 2026 12:11
Added logic to detect leading '/' in prompts and route them to a local command handler instead of the LLM. This fixes issue NousResearch#1402.
…ousResearch#1402)

Implemented a layer in `acp_adapter/server.py` to intercept prompts starting with a forward slash. 

Key changes:
- Detects slash commands in the `prompt` method.
- Routes detected commands to the existing `ChatConsole.process_command` logic from `cli.py`.
- Uses `contextlib.redirect_stdout` to capture TUI output and return it as a string to the ACP client.
- Ensures consistency by passing the current session's agent to the console instance.

This allows IDE integrations to natively use commands like /help, /tools, /model, etc.

Closes NousResearch#1402
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for working on this! The concept is right but the implementation has some issues that would cause runtime crashes:

  1. ChatConsole (imported from cli.py) is a Rich display adapter, not the CLI class. The actual CLI class is HermesCLI, but it can't be instantiated headlessly — it sets up the full interactive TUI (prompt_toolkit, Rich Console, config loading, provider resolution, etc.)

  2. redirect_stdout won't capture Rich Console output since Rich renders through its own file handle

  3. Neither class accepts an agent= kwarg

The correct approach is to handle commands directly in the ACP adapter without going through the TUI layer:

  • Intercept /-prefixed prompts in prompt()
  • For info commands (/help, /tools, /context, /model), query the agent's state directly and format the response
  • For state-changing commands (/model <name>, /reset, /compact), modify the agent state and return confirmation
  • Use the existing set_session_model() method as a pattern — it already handles /model switching in the ACP context
  • The gateway (gateway/run.py) has a similar headless command dispatcher that can serve as reference

I'll be opening a follow-up PR with a correct implementation. Appreciate you surfacing the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Support Slash Commands via ACP Adapter

2 participants