Skip to content

More slash commands#5858

Merged
DOsinga merged 4 commits intomainfrom
more-slash-commands
Dec 17, 2025
Merged

More slash commands#5858
DOsinga merged 4 commits intomainfrom
more-slash-commands

Conversation

@DOsinga
Copy link
Copy Markdown
Collaborator

@DOsinga DOsinga commented Nov 24, 2025

Summary

what it says on the tin.

Copilot AI review requested due to automatic review settings November 24, 2025 18:15
Copy link
Copy Markdown
Collaborator Author

@DOsinga DOsinga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is somewhat vibe coded, but since @alexhancock was looking into this direction I thought I'd share

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for additional slash commands beyond /compact. It introduces a new command execution framework that handles built-in commands (/prompts, /prompt, /compact, /clear) and dynamic recipe-based commands.

Key changes:

  • Renamed MANUAL_COMPACT_TRIGGERS to COMPACT_TRIGGERS to reflect the expanded trigger set
  • Created new execute_commands.rs module with a unified command dispatcher
  • Added build_recipe_from_template_with_positional_params for recipe commands with positional arguments
  • Refactored agent.rs to use the new command execution flow

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ui/desktop/src/components/ChatInput.tsx Updated compact trigger constant from full phrase to /compact command
crates/goose/src/recipe/build_recipe/mod.rs Added positional parameter support for recipe templates
crates/goose/src/agents/mod.rs Exported execute_commands module and updated constant exports
crates/goose/src/agents/execute_commands.rs New module implementing command dispatcher and handlers for built-in and recipe commands
crates/goose/src/agents/agent.rs Refactored reply flow to use command execution, simplified auto-compact logic
crates/goose-server/src/routes/config_management.rs Updated slash command endpoint to dynamically list commands from the new framework
crates/goose-cli/src/session/mod.rs Updated to use renamed COMPACT_TRIGGERS constant


return Ok(Box::pin(async_stream::try_stream! {
yield AgentEvent::Message(user_message);
yield AgentEvent::Message(response);
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manual compact via /compact doesn't send AgentEvent::HistoryReplaced to notify the UI that messages were compacted. Without this event, the server won't send UpdateConversation (see reply.rs:350-353), causing the UI to show stale pre-compacted messages. The conversation is replaced in the database (execute_commands.rs:99) but clients aren't notified. Need to yield AgentEvent::HistoryReplaced after the response message.

Suggested change
yield AgentEvent::Message(response);
yield AgentEvent::Message(response);
// After compact, notify UI that history was replaced
let updated_conversation = SessionManager::get_conversation(&session_config.id)
.await
.map_err(|e| anyhow!("Failed to fetch updated conversation: {}", e))?;
yield AgentEvent::HistoryReplaced(updated_conversation);

Copilot uses AI. Check for mistakes.
Comment on lines +92 to +99
let (compacted_conversation, _usage) = compact_messages(
self.provider().await?.as_ref(),
&conversation,
true, // is_manual_compact
)
.await?;

SessionManager::replace_conversation(session_id, &compacted_conversation).await?;
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manual compact discards the usage metrics from compact_messages. The auto-compact updates session metrics with this usage (agent.rs:866), but manual compact doesn't, causing token usage from compaction to be untracked. Consider updating session metrics here similar to auto-compact.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this comment is legit; we need to manually call update_session_metrics with the is_compact.

Comment on lines +244 to +256
SessionManager::add_message(session_id, &msg).await?;
}

let last_message = SessionManager::get_session(session_id, true)
.await?
.conversation
.ok_or_else(|| anyhow!("No conversation found"))?
.messages()
.last()
.cloned()
.ok_or_else(|| anyhow!("No messages in conversation"))?;

Ok(Some(last_message))
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prompt messages are added to the session twice: once in handle_prompt_command (line 244), then again in agent.rs (lines 808-811) when the returned message is processed. This causes duplicate messages in the conversation history. The command handler should either not add messages itself, or the agent.rs flow should detect that messages were already added.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator

@alexhancock alexhancock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I still think we should make prompts accessible via /<prompt> name and make them searchable, but would be a smaller change after this is in place!

@DOsinga DOsinga merged commit fd9582a into main Dec 17, 2025
18 checks passed
@DOsinga DOsinga deleted the more-slash-commands branch December 17, 2025 00:26
aharvard added a commit that referenced this pull request Dec 17, 2025
* main:
  fix: we don't need to warn about tool count when in code mode (#6149)
  deps: upgrade agent-client-protocol to 0.9.0 (#6109)
  fix(providers): fix for gemini-cli on windows to work around cmd's multiline prompt limitations #5911 (#5966)
  More slash commands (#5858)
  fix: MCP UI not rendering due to CallToolResult structure change (#6143)
  fix: display shell output as static text instead of spinner (#6041)
  fix : Custom providers with empty API keys show as configured in desktop (#6105)
  Add .agents/skills and ~/.config/agent/skills to skills discovery paths (#6139)
  fix: use instructions for system prompt and prompt for user message in subagents (#6121)
  Fix compaction loop for small models or large input (#5803)
  feat: Centralize theme management with ThemeContext (#6137)
  OpenRouter & Xai streaming (#5873)
  fix: resolve mcp-hermit cleanup path expansion issue (#5953)
  feat: add goose PR reviewer workflow (#6124)
  perf: Avoid repeated MCP queries during streaming responses (#6138)
  Fix YAML serialization for recipes with special characters (#5796)
  Add more posthog analytics (privacy aware) (#6122)
  docs: add Sugar MCP server to extensions registry (#6077)
dianed-square added a commit that referenced this pull request Dec 17, 2025
* origin/main: (57 commits)
  docs: create/edit recipe button (#6145)
  fix(google): Fix 400 Bad Request error with Gemini 3 thought signatures (#6035)
  fix: we don't need to warn about tool count when in code mode (#6149)
  deps: upgrade agent-client-protocol to 0.9.0 (#6109)
  fix(providers): fix for gemini-cli on windows to work around cmd's multiline prompt limitations #5911 (#5966)
  More slash commands (#5858)
  fix: MCP UI not rendering due to CallToolResult structure change (#6143)
  fix: display shell output as static text instead of spinner (#6041)
  fix : Custom providers with empty API keys show as configured in desktop (#6105)
  Add .agents/skills and ~/.config/agent/skills to skills discovery paths (#6139)
  fix: use instructions for system prompt and prompt for user message in subagents (#6121)
  Fix compaction loop for small models or large input (#5803)
  feat: Centralize theme management with ThemeContext (#6137)
  OpenRouter & Xai streaming (#5873)
  fix: resolve mcp-hermit cleanup path expansion issue (#5953)
  feat: add goose PR reviewer workflow (#6124)
  perf: Avoid repeated MCP queries during streaming responses (#6138)
  Fix YAML serialization for recipes with special characters (#5796)
  Add more posthog analytics (privacy aware) (#6122)
  docs: add Sugar MCP server to extensions registry (#6077)
  ...
katzdave added a commit that referenced this pull request Dec 17, 2025
…icing

* 'main' of github.com:block/goose: (35 commits)
  docs: skills (#6062)
  fix: add conditional configuration for GOOSE_BIN_DIR in PATH (#5940)
  Update dependencies to help in Fedora packaging (#5835)
  fix: make goose reviewer less bad (#6154)
  docs: create/edit recipe button (#6145)
  fix(google): Fix 400 Bad Request error with Gemini 3 thought signatures (#6035)
  fix: we don't need to warn about tool count when in code mode (#6149)
  deps: upgrade agent-client-protocol to 0.9.0 (#6109)
  fix(providers): fix for gemini-cli on windows to work around cmd's multiline prompt limitations #5911 (#5966)
  More slash commands (#5858)
  fix: MCP UI not rendering due to CallToolResult structure change (#6143)
  fix: display shell output as static text instead of spinner (#6041)
  fix : Custom providers with empty API keys show as configured in desktop (#6105)
  Add .agents/skills and ~/.config/agent/skills to skills discovery paths (#6139)
  fix: use instructions for system prompt and prompt for user message in subagents (#6121)
  Fix compaction loop for small models or large input (#5803)
  feat: Centralize theme management with ThemeContext (#6137)
  OpenRouter & Xai streaming (#5873)
  fix: resolve mcp-hermit cleanup path expansion issue (#5953)
  feat: add goose PR reviewer workflow (#6124)
  ...
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.

4 participants