feat: add exit tool for agent-initiated session exit#57
Merged
Conversation
Add an ExitTool that the LLM can invoke when the user wants to quit (e.g. says 'bye', 'goodbye', 'I'm done'). The tool uses a shared AtomicBool flag checked by the REPL after each engine run. - src/tools/exit.rs: ExitTool with triggered()/reset() API - src/tools/mod.rs: register exit module - src/main.rs: register ExitTool, check flag after engine.run() - tests/tools_test.rs: integration tests for registry interaction - 6 unit tests + 2 integration tests added - AGENTS.md and README.md updated
There was a problem hiding this comment.
Pull request overview
Adds an agent-invokable exit tool so the LLM can gracefully end the REPL session when the user indicates they’re done, without requiring /quit or Ctrl+C.
Changes:
- Introduces
ExitTool(new tool module) backed by a shared atomic flag withtriggered()/reset(). - Registers the new tool and exits the REPL loop when the tool has been invoked.
- Updates docs and adds integration/unit test coverage for the new tool.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/tools/exit.rs |
Implements the new ExitTool and unit tests. |
src/tools/mod.rs |
Exposes the new exit tool module. |
src/main.rs |
Registers ExitTool and checks it after each engine.run() to break the REPL loop. |
tests/tools_test.rs |
Adds integration tests to ensure registry execution and coexistence with ShellTool. |
README.md |
Mentions the new exit tool in the architecture overview. |
AGENTS.md |
Updates module layout documentation to include ExitTool. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Remove unnecessary inner Arc<AtomicBool>; store AtomicBool directly since ExitTool is already shared via Arc<ExitTool> - Replace Ordering::Relaxed with Release (stores) and Acquire (loads) for correct cross-thread synchronization semantics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add an
ExitToolthat the LLM can invoke when the user wants to quit the session (e.g. says "bye", "goodbye", "I'm done"). This lets the agent gracefully exit instead of requiring the user to type/quitor Ctrl+C.How it works
ExitTooluses a sharedArc<AtomicBool>flagexittool, the flag is set totrueand a farewell message is returnedengine.run()completes, the REPL checks the flag and breaks the loop if setFiles changed
src/tools/exit.rsExitToolwithtriggered()/reset()APIsrc/tools/mod.rsexitmodulesrc/main.rstests/tools_test.rsAGENTS.mdREADME.mdTests
src/tools/exit.rs(flag lifecycle, name, description, default impl)tests/tools_test.rs(registry execution, coexistence with shell)cargo fmtclean