Conversation
DOsinga
left a comment
There was a problem hiding this comment.
this is somewhat vibe coded, but since @alexhancock was looking into this direction I thought I'd share
There was a problem hiding this comment.
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_TRIGGERStoCOMPACT_TRIGGERSto reflect the expanded trigger set - Created new
execute_commands.rsmodule with a unified command dispatcher - Added
build_recipe_from_template_with_positional_paramsfor recipe commands with positional arguments - Refactored
agent.rsto 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); |
There was a problem hiding this comment.
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.
| 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); |
| 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?; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I think this comment is legit; we need to manually call update_session_metrics with the is_compact.
| 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)) |
There was a problem hiding this comment.
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.
alexhancock
left a comment
There was a problem hiding this comment.
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!
* 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)
* 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) ...
…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) ...
Summary
what it says on the tin.