@@ -682,6 +682,42 @@ test("child tool names exclude inactive registered and active phantom tools", ()
682682 assert . equal ( toolNames . includes ( "spawn" ) , false ) ;
683683} ) ;
684684
685+ test ( "buildChildToolNames (2-arg fallback) removes spawn and handoff from inherited tools" , ( ) => {
686+ const result = buildChildToolNames ( [ "read" , "bash" , "spawn" , "handoff" ] , [ ] ) ;
687+ assert . ok ( ! result . includes ( "spawn" ) , "spawn must be filtered out" ) ;
688+ assert . ok ( ! result . includes ( "handoff" ) , "handoff must be filtered out" ) ;
689+ assert . ok ( result . includes ( "read" ) , "read must be preserved" ) ;
690+ assert . ok ( result . includes ( "bash" ) , "bash must be preserved" ) ;
691+ } ) ;
692+
693+ test ( "buildChildToolNames (2-arg fallback) preserves non-spawn/handoff tools" , ( ) => {
694+ const result = buildChildToolNames ( [ "read" , "bash" , "write" , "edit" ] , [ ] ) ;
695+ assert . deepEqual ( result . sort ( ) , [ "bash" , "edit" , "read" , "write" ] ) ;
696+ } ) ;
697+
698+ test ( "buildChildToolNames (2-arg fallback) adds custom child tools to the list" , ( ) => {
699+ const result = buildChildToolNames ( [ "read" ] , [ { name : "custom-tool" , description : "" , parameters : { } } ] ) ;
700+ assert . ok ( result . includes ( "custom-tool" ) , "custom child tool must be added" ) ;
701+ assert . ok ( result . includes ( "read" ) , "inherited tool must be preserved" ) ;
702+ } ) ;
703+
704+ test ( "buildChildToolNames (2-arg fallback) deduplicates overlapping inherited and custom names" , ( ) => {
705+ const result = buildChildToolNames ( [ "read" , "bash" ] , [ { name : "bash" , description : "" , parameters : { } } ] ) ;
706+ assert . deepEqual ( result , [ "read" , "bash" ] ) ;
707+ } ) ;
708+
709+ test ( "buildChildToolNames (2-arg fallback) handles empty parent tool names" , ( ) => {
710+ assert . deepEqual ( buildChildToolNames ( [ ] , [ { name : "only-child" , description : "" , parameters : { } } ] ) , [ "only-child" ] ) ;
711+ } ) ;
712+
713+ test ( "buildChildToolNames (2-arg fallback) handles empty custom tools" , ( ) => {
714+ assert . deepEqual ( buildChildToolNames ( [ "read" , "bash" ] , [ ] ) , [ "read" , "bash" ] ) ;
715+ } ) ;
716+
717+ test ( "buildChildToolNames (2-arg fallback) handles both empty inputs" , ( ) => {
718+ assert . deepEqual ( buildChildToolNames ( [ ] , [ ] ) , [ ] ) ;
719+ } ) ;
720+
685721test ( "spawn execute short-circuits when signal is already aborted" , async ( ) => {
686722 const pi = createTestPI ( ) ;
687723 pi . setActiveTools ( [ "read" , "bash" , "spawn" ] ) ;
0 commit comments