@@ -176,7 +176,7 @@ const mount = async (
176176
177177 // also load the tools defined the states so that when running a thread that has tools added in state, we don't lose them
178178 for ( let block of script ) {
179- if ( block . type === 'tool ') {
179+ if ( block . type !== 'text ') {
180180 block . tools = [
181181 ...new Set ( [ ...( block . tools || [ ] ) , ...( state . tools || [ ] ) ] ) ,
182182 ] ;
@@ -267,7 +267,7 @@ const mount = async (
267267
268268 // find the root tool and then add the new tool
269269 for ( let block of script ) {
270- if ( block . type === 'tool ') {
270+ if ( block . type !== 'text ') {
271271 block . tools = [ ...new Set ( [ ...( block . tools || [ ] ) , tool ] ) ] ;
272272 break ;
273273 }
@@ -296,7 +296,7 @@ const mount = async (
296296
297297 // find the root tool and then remove the tool
298298 for ( let block of script ) {
299- if ( block . type === 'tool ') {
299+ if ( block . type !== 'text ') {
300300 if ( block . tools ) {
301301 block . tools = [ ...new Set ( block . tools . filter ( ( t ) => t !== tool ) ) ] ;
302302 }
@@ -325,7 +325,7 @@ const mount = async (
325325
326326 state . tools = [ ] ;
327327 for ( let block of script ) {
328- if ( block . type === 'tool ') {
328+ if ( block . type !== 'text ') {
329329 block . name = newName || block . name ;
330330 block . tools = [
331331 ...new Set ( [
@@ -335,7 +335,7 @@ const mount = async (
335335 if ( extraTools ) {
336336 script = [ ...script , ...extraTools ] ;
337337 block . tools . push (
338- ...extraTools . filter ( ( t ) => t . type === 'tool ') . map ( ( t ) => t . name )
338+ ...extraTools . filter ( ( t ) => t . type !== 'text ') . map ( ( t ) => t . name )
339339 ) ;
340340 }
341341 break ;
0 commit comments