To exit a bracket order, you need to send cancel order request with second leg order id and parent order id with variety co. You can refer to the pykiteconnect docs here.
exit_order is for placing the exit order for CO. You need to use place_order to exit the order for regular order. There you can use the tag param to specify the source.
You don't need to use generate_session for every run. You can directly set access_token kite.set_access_token("your obtained access token"), post successfully generating access toke…