File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed
Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " agents " : patch
3+ ---
4+
5+ remove isToolCallInProgress
Original file line number Diff line number Diff line change @@ -218,7 +218,6 @@ export function useAgentChat<
218218 const id = nanoid ( 8 ) ;
219219 const abortController = new AbortController ( ) ;
220220 let controller : ReadableStreamDefaultController ;
221- let isToolCallInProgress = false ;
222221 const currentAgent = agentRef . current ;
223222
224223 signal ?. addEventListener ( "abort" , ( ) => {
@@ -240,9 +239,7 @@ export function useAgentChat<
240239
241240 abortController . abort ( ) ;
242241 // Make sure to also close the stream (cf. https://github.com/cloudflare/agents-starter/issues/69)
243- if ( ! isToolCallInProgress ) {
244- controller . close ( ) ;
245- }
242+ controller . close ( ) ;
246243 } ) ;
247244
248245 currentAgent . addEventListener (
@@ -264,14 +261,11 @@ export function useAgentChat<
264261 } else {
265262 // Only enqueue non-empty data to prevent JSON parsing errors
266263 if ( data . body ?. trim ( ) ) {
267- if ( data . body . includes ( '"tool_calls"' ) ) {
268- isToolCallInProgress = true ;
269- }
270264 controller . enqueue (
271265 new TextEncoder ( ) . encode ( `data: ${ data . body } \n\n` )
272266 ) ;
273267 }
274- if ( data . done && ! isToolCallInProgress ) {
268+ if ( data . done ) {
275269 controller . close ( ) ;
276270 abortController . abort ( ) ;
277271 }
You can’t perform that action at this time.
0 commit comments