How to limit the number of messages or tokens that are persisted in a thread to maintain context in Open AI Assistants?

There is no “delete messages in a thread” API method.

https://platform.openai.com/docs/api-reference/messages

You get delete assistant, delete assistant file, delete thread.

The only modification you can do is to add metadata for your own use.