Skip to content

feat: give commands the ability to execute logic#63

Merged
lukealvoeiro merged 16 commits intomainfrom
lalvoeiro/execute-command
Sep 17, 2024
Merged

feat: give commands the ability to execute logic#63
lukealvoeiro merged 16 commits intomainfrom
lalvoeiro/execute-command

Conversation

@lukealvoeiro
Copy link
Contributor

@lukealvoeiro lukealvoeiro commented Sep 12, 2024

Current state of commands (before this PR)

Commands currently only serve autocompletion purposes. For example:
Screenshot 2024-09-11 at 5 31 14 PM

As it currently stands, commands do not trigger anything to occur when they are included in the prompt and enter is pressed.

Where does the /file command currently fall short?

The /file command is included in the string that we will sent to the LLM, which introduces some uncertainty in regard to the user intent. This is because the LLM does not reliably know what a command such as /file:src/* means.

How to remediate this?

1. ✅ Introduce a way for commands to modify their portion of the prompt that will be sent off
3. ❌ Indicate in the system prompt that commands exist, and that we should ignore the first portion of them (the command name)

Why did I choose 1 above?

Currently, only one command exists - /file. However, we can imagine that folks may want to contribute other commands. Some of ideas of these may include:

  • /rewind(:times) - rewinds until after the last user message. this would allow the user to remove an incorrect path the LLM went down, and instruct it in a different way.
  • /quorum:"set up 3 instances of goose that talk to this app and load test it" - this would make quorum more reliably be picked up (currently it is a toolkit that at times is not used despite indicating you want to use it)
  • /add_toolkit:<toolkit_name> - adds a toolkit midway through a session's execution
  • /checkpoint - adds a checkpoint to the exchange that you could revert back to

Across these commands, we notice different user intents:

  • /rewind and /checkpoint take an action on the exchange itself and should be scrubbed from the prompt sent to the LLM
  • /quorum performs some logic and returns a response string, which we would then add to the prompt sent to the LLM
  • /add_toolkit also takes an action on the exchange itself, but might also add onto the prompt sent to the LLM (indicating that we just added a new tool).

From these examples, I see there is value in

  1. Being able to execute some action based on the value of the command (/name:value)
  2. Being able to replace the string /name:value with a value determined by the command

This led me to the signature for the Command.execute method:

def execute(self, query: str) -> str:
    return ""

🤔 I don't like the above - what other options are there?

Option 1: instead of commands executing some logic, we could remove the execute method and only allow them to be used for autocompletion. We would need to make a small tweak so that only the value of the command is persisted in the prompt, not the command name itself.

Option 2: completely remove the idea of commands, and either scrap the idea of file completions entirely, or just keep the file completion around and don't have it inherit from Command

* main:
  fix: typo in exchange method `rewind` (#54)
  fix: remove unsafe pop of messages (#47)
  chore: Update LICENSE (#53)
  chore(docs): update is_dangerous_command method description (#48)
  refactor: improve safety rails speed and prompt (#45)
  feat: make goosehints jinja templated (#43)
  ci: enforce PR title follows conventional commit (#14)
  feat: show available toolkits (#37)
  adding in ability to provide per repo hints (#32)
  Apply ruff and add to CI (#40)
  added some regex based checks for dangerous commands (#38)
  chore: Update publish github workflow to check package versions before publishing (#19)
  chore: upgrade ai-exchange dependency (#36)
  fix: resuming sessions (#35)
  feat: upgrade `ai-exchange` to version `0.8.3` and fix tests (#34)
  fix: export metadata.plugins export should have valid module (#30)
  fix (#24)
  link to vs code extension (#20)
  Enable cli options for plugin (#22)
  Modified the readme to be more friendly to new users (#16)
@michaelneale
Copy link
Collaborator

a suggestion - would it be possible to detect and suggest a command a user could explore so they can accidentally discover it? One of the benefits of goose is that you ideally don't need to know how to drive it, commands start to bring more syntax/knowledge needed, so would be nice to be able to prompt people for that so it feels organic.

Copy link
Collaborator

@michaelneale michaelneale left a comment

Choose a reason for hiding this comment

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

am slightly wary of adding more non natural language style inputs to goose - but this seems nicely thought out

@lukealvoeiro
Copy link
Contributor Author

lukealvoeiro commented Sep 12, 2024

a suggestion - would it be possible to detect and suggest a command a user could explore so they can accidentally discover it? One of the benefits of goose is that you ideally don't need to know how to drive it, commands start to bring more syntax/knowledge needed, so would be nice to be able to prompt people for that so it feels organic.

We were probably gonna work on surfacing features to users just in time, so we could work this in (if we decide to move forward with using commands).

Copy link
Collaborator

@baxen baxen left a comment

Choose a reason for hiding this comment

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

Looks good!

@lukealvoeiro
Copy link
Contributor Author

@lifeizhou-ap I know we had some discussion topics ongoing but the rest of the team is onboard - going ahead and merging this PR and we can follow up with any changes.

@lukealvoeiro lukealvoeiro merged commit dde3366 into main Sep 17, 2024
Kvadratni added a commit to Kvadratni/goose that referenced this pull request Sep 23, 2024
* origin/main:
  docs: add in ollama (block#82)
  chore: add just command for releasing goose (block#55)
  feat: support markdown plans  (block#79)
  feat: add version options (block#74)
  docs: fixing exchange url to public version (block#67)
  docs: Update CONTRIBUTING.md (block#69)
  chore: create mkdocs for goose (block#70)
  docs: fix broken link (block#71)
  feat: give commands the ability to execute logic (block#63)
  feat: jira toolkit (block#59)
  feat: run goose in a docker-style sandbox (block#44)
@lamchau lamchau deleted the lalvoeiro/execute-command branch October 24, 2024 11:45
cbruyndoncx pushed a commit to cbruyndoncx/goose that referenced this pull request Jul 20, 2025
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.

3 participants