autogen
autogen copied to clipboard
Use External termination condition to stop execution in AGS
What
Currently AGS uses a cancellation token to stop execution. This cancellation_token is not necessarily honored down the stack (I have seen scenarious where speaker selection logic continues even after cancellation token is cancelled). The right way to stop execution would be to use an external termination condition.
How
- Component factory .. can take an
external_terminationExternalTermination arg (similar to input_func) - This external_termination if exisists is added to the termination condition as an or + .
termination_condition = termination_condition | external_termination - AGS app (team_manager) and websocket connection provide this
external_terminationand then callexternal_termination.set()when a stop message is received, instead of invalidating a cancellation token.
This setup could also provide some infrascture to "pause" a run, where a pause is a stop with some timeout ...
- stop message sent from UI
- external termination condition is set ... a timeout starts on backend and front end
- if a new message or resume message is sent within that timeout, team.run() is called again .. and things resume ...
cc: @ekzhu , @husseinmozannar