Withdrawing money after deleting a message

Why is the assistant charged after deleting a message? I don’t create a new assistant or create a new thread, but I am charged when I submit a request and delete a message. I am deleting previous messages in order to reduce the cost of the current request.
I delete the message using the following command :
= client.beta.threads.messages.delete(
message_id=message.id,
thread_id=thread_id,
)

Have you figured out the answer? I discover the same situation. It seems like deleting message will create a new session which charges $0.03.

I have not verified this; but thanks for pointing it out.

From an OpenAI standpoint it makes sense. They don’t want you to spend less money by deleting messages and also deleting messages may also be costly (as opposed to simply using an append only log).

From a dev standpoint, this might suck because you are hit with cost either if you use the full thread or attempt to physically truncate the thread.

One mitigating feature is to use the truncate_messages in the run (which does not physically truncate the thread).

The other, more advanced feature, is to use the concept of water marks (i.e. high water mark aka hwm) (betaassi/src/openai_session_handler/models/stream_thread.py at main · icdev2dev/betaassi · GitHub) to mark what you have read so far from the thread without physically truncating the thread.

Some new information that I discovered.
Deleting single or a few messages doesn’t result in new assistant session charge ($0.03).
But deleting all messages will result in new assistant session charge ($0.03).

Thanks for doing the discovery. This is welcome news!

In my use case for multiagents, I have a SystemFunction that occasionally posts the counts of times that each assistant has spoken in a thread and that SystemFunction also clears the thread of any existing AutoExecSubMessage (ie delete) that has previously reported count.

Would you be able to check if this discovery is true? I did a few rounds to verify, but it would be great if another dev also confirms this. Thanks!

Yeah…just did a few rounds myself. I do not see that cost; if I just delete one message every min (ran the test for 5 mins)

Great. This is great confirmation. Thanks.
This is what I believe, deleting all message will trigger some form of garbage collection and destruction of the assistant session.
Anyway, since there is no open source code to verify, this is just pure guess.