Menu

Your Users Click "Regenerate". Are You Paying Twice?
📰

Your Users Click "Regenerate". Are You Paying Twice?

DEV Community: typescript·KristinZ·about 16 hours ago
#DbnA5Q20
#devtotypescript#devto#dev#request#regenerate
Long article (2167 words) — no AI summary yet.
Reading 0:00
15s threshold

A user watches an answer stream in, decides it's going the wrong way, and clicks Regenerate before it finishes.

Your app starts a second generation. What happens to the first one?

There are three common answers, and they cost very different amounts:

1. You abort the first request, then start the second. 2. You start the second request and forget about the first. 3. You stop reading the first stream, but never cancel it.

Enter fullscreen mode

Exit fullscreen mode

The first is what most people intend. The second and third are what a lot of code actually does.

I measured all three against a real provider (DeepSeek, deepseek-flash , streaming Chat Completions), using the account balance as an external meter, the same method as in the previous experiment . The code is public: aiengineering-book/llm-cancellation-experiment .

The Result First

Each arm is 6 runs. Every completed answer is max_tokens=4000 .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.