Commit cab61d6
committed
Fix stop generating: actually abort stream instead of draining in background
When user clicks Stop, worker_registry.stop_conversation() now marks the
conversation as explicitly stopped. The CancelledError and GeneratorExit
handlers in _execute_chat_completions_stream check this flag — if the
conversation was user-stopped, the stream is closed immediately instead
of being drained to completion in a background task.
The background drain is preserved for passive disconnects (browser close,
network drop) where the agent should continue processing so the response
is saved for when the user returns.1 parent a94d5d2 commit cab61d6
2 files changed
Lines changed: 39 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| 80 | + | |
| 81 | + | |
79 | 82 | | |
80 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
81 | 89 | | |
82 | 90 | | |
83 | 91 | | |
| |||
147 | 155 | | |
148 | 156 | | |
149 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
150 | 162 | | |
151 | 163 | | |
152 | 164 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4988 | 4988 | | |
4989 | 4989 | | |
4990 | 4990 | | |
| 4991 | + | |
| 4992 | + | |
| 4993 | + | |
| 4994 | + | |
| 4995 | + | |
| 4996 | + | |
| 4997 | + | |
| 4998 | + | |
| 4999 | + | |
| 5000 | + | |
| 5001 | + | |
| 5002 | + | |
| 5003 | + | |
| 5004 | + | |
4991 | 5005 | | |
4992 | 5006 | | |
4993 | 5007 | | |
| |||
5032 | 5046 | | |
5033 | 5047 | | |
5034 | 5048 | | |
| 5049 | + | |
| 5050 | + | |
| 5051 | + | |
| 5052 | + | |
| 5053 | + | |
| 5054 | + | |
| 5055 | + | |
| 5056 | + | |
| 5057 | + | |
| 5058 | + | |
| 5059 | + | |
| 5060 | + | |
| 5061 | + | |
5035 | 5062 | | |
5036 | 5063 | | |
5037 | 5064 | | |
| |||
0 commit comments