Add ability to force a TERMINATE from assistant agent
Why is this needed?
Autogen TERMINATE mode and max iterations is very useful but sometimes it gets stuck in a loop and allowing the user to use a keyboard short cut (or some other way) to intervene and force a TERMINATE can be useful.
What about catching KeyboardInterruptError in UserProxyAgent.initiate_chat()?
To add the ability to force a TERMINATE from an assistant agent, you would need to implement a mechanism in your code that allows the user to trigger this action. Here's a solution to add this functionality:
-
Create a User Interface Element: Add a user interface element, such as a button or a keyboard shortcut, that users can interact with to force a TERMINATE action.
-
Define a TERMINATE Action Function: Implement a function in your code that handles the TERMINATE action. This function should initiate the termination process or break the current operation.
-
Listen for User Input: If you're using a button, add an event listener to the button element to detect when it's clicked. If you're using a keyboard shortcut, listen for the corresponding keyboard event (e.g., a specific key combination) using JavaScript.
-
Call the TERMINATE Action Function: When the user triggers the UI element or keyboard shortcut, call the TERMINATE action function you defined earlier. This function should take the necessary steps to terminate the current operation or loop.
Here's a simplified example using JavaScript for a button that allows users to force a termination action:
<!-- HTML -->
<button id="terminateButton">Force Terminate</button>
// JavaScript
const terminateButton = document.getElementById('terminateButton');
function forceTerminate() {
// Add your code here to initiate the termination process.
// This might involve stopping a loop or canceling an operation.
console.log('Force termination initiated.');
}
terminateButton.addEventListener('click', forceTerminate);
In this example, when the "Force Terminate" button is clicked, the forceTerminate function is called, and you can add your specific code to handle the termination action within that function.
Please adapt this example to your specific codebase and application, as the implementation details may vary depending on your project's structure and requirements.
@victordibia this is of interest to autogen studio.
I'd love a way to force termination via a button click without forcing human input after each iteration.
If using Autogen Studio, where should I add the code above?
@victordibia - if you don't plan to add this for 0.2, please close won't-fix
Yes. 0.4 addresses this better. Unlikely this will be fixed in 0.2