-
Notifications
You must be signed in to change notification settings - Fork 103
Add ESC interrupt support to CLI #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add ESC interrupt support to CLI #23
Conversation
6d8da5b to
6b97abc
Compare
|
Thanks for this PR! The ESC interrupt feature is very useful. However, there's a potential issue when ESC is pressed during tool execution: Problem: If the user presses ESC after Incomplete state: call2 and call3 missing ❌This will cause the next LLM call to fail since most LLM APIs require each Suggestion: Don't check stop request during tool execution loop (lines 332-404). Only check at safe checkpoints:
This ensures conversation history integrity while adding minimal delay (most tools execute in <1s). Please add test cases in |
|
Addressed the cache/history issue AkairoDev pointed out:
Let me know if you want me to expand coverage further, but the current suite demonstrates both conversation integrity and successful resumption. |
|
Thank you so much for this PR and the thoughtful implementation! 🙏 |
|
Totally understand—really appreciate you digging into it. I’m glad the state-management approach was useful, and I’m looking forward to seeing the official cross-platform version land. Happy to help test early builds or experiment with alternate signaling strategies if that’s helpful. Thanks again for the thoughtful review! |
Summary
agent.run()resumes from the original step until the task finishes or errorsEscapeKeyListenerin the CLI that switches the terminal to cbreak mode (when supported) and watches for ESC viaasyncio.add_reader, callingagent.request_stop()as soon as the key is pressed/helpso users know they can press ESC to halt long tool runs while keeping the session aliveTesting
mini-agent, kicked off a multi-step task, pressed ESC mid-run, observed "Agent paused" message and that the next command resumed at the prior step rather than starting over