Skip to content

feat: add exit tool for agent-initiated session exit#57

Merged
assapir merged 2 commits into
mainfrom
feature/exit-tool
Mar 4, 2026
Merged

feat: add exit tool for agent-initiated session exit#57
assapir merged 2 commits into
mainfrom
feature/exit-tool

Conversation

@assapir

@assapir assapir commented Mar 2, 2026

Copy link
Copy Markdown
Owner

Summary

Add an ExitTool that 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 /quit or Ctrl+C.

How it works

  1. ExitTool uses a shared Arc<AtomicBool> flag
  2. When the agent calls the exit tool, the flag is set to true and a farewell message is returned
  3. After each engine.run() completes, the REPL checks the flag and breaks the loop if set

Files changed

File Change
src/tools/exit.rs New ExitTool with triggered()/reset() API
src/tools/mod.rs Register exit module
src/main.rs Register tool, check flag after engine run
tests/tools_test.rs 2 integration tests (registry execution, coexistence with shell)
AGENTS.md Updated module layout
README.md Updated tool description

Tests

  • 6 unit tests in src/tools/exit.rs (flag lifecycle, name, description, default impl)
  • 2 integration tests in tests/tools_test.rs (registry execution, coexistence with shell)
  • All 222 tests pass, zero clippy warnings, cargo fmt clean

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 with triggered()/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.

Comment thread src/tools/exit.rs
Comment thread src/tools/exit.rs
Comment thread src/tools/exit.rs
- 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
@assapir assapir merged commit bd7adba into main Mar 4, 2026
4 checks passed
@assapir assapir deleted the feature/exit-tool branch March 4, 2026 12:06
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.

2 participants