@@ -61,6 +61,59 @@ static string EncryptString([Description("String to encrypt")] string input)
6161 => input . ToUpperInvariant ( ) ;
6262 }
6363
64+ [ Fact ]
65+ public async Task Low_Level_Tool_Definition ( )
66+ {
67+ string currentPhase = string . Empty ;
68+
69+ var session = await CreateSessionAsync ( new SessionConfig
70+ {
71+ Tools =
72+ [
73+ AIFunctionFactory . Create ( SetCurrentPhase , new AIFunctionFactoryOptions
74+ {
75+ Name = "set_current_phase" ,
76+ Description = "Sets the current phase of the agent" ,
77+ } ) ,
78+ AIFunctionFactory . Create ( SearchItems , new AIFunctionFactoryOptions
79+ {
80+ Name = "search_items" ,
81+ Description = "Search for items by keyword" ,
82+ } ) ,
83+ ] ,
84+ AvailableTools = new ToolSet ( ) . AddCustom ( "*" ) . AddBuiltIn ( "web_fetch" ) ,
85+ OnPermissionRequest = PermissionHandler . ApproveAll ,
86+ } ) ;
87+
88+ await session . SendAsync ( new MessageOptions
89+ {
90+ Prompt = "First, set the current phase to 'analyzing'. Then search for items with keyword 'copilot'. Report the phase and search results."
91+ } ) ;
92+
93+ var assistantMessage = await TestHelper . GetFinalAssistantMessageAsync ( session ) ;
94+
95+ Assert . NotNull ( assistantMessage ) ;
96+ var content = assistantMessage ! . Data . Content ?? string . Empty ;
97+ Assert . NotEmpty ( content ) ;
98+ Assert . Contains ( "analyzing" , content , StringComparison . OrdinalIgnoreCase ) ;
99+ Assert . True ( content . Contains ( "item_alpha" , StringComparison . OrdinalIgnoreCase )
100+ || content . Contains ( "item_beta" , StringComparison . OrdinalIgnoreCase ) ,
101+ $ "Expected content to mention item_alpha or item_beta, got: { content } ") ;
102+ Assert . Equal ( "analyzing" , currentPhase ) ;
103+
104+ Task < string > SetCurrentPhase ( string phase )
105+ {
106+ currentPhase = phase ;
107+ return Task . FromResult ( $ "Phase set to { phase } ") ;
108+ }
109+
110+ Task < string > SearchItems ( AIFunctionArguments args )
111+ {
112+ Assert . Equal ( "copilot" , args [ "keyword" ] ? . ToString ( ) ) ;
113+ return Task . FromResult ( "Found: item_alpha, item_beta" ) ;
114+ }
115+ }
116+
64117 [ Fact ]
65118 public async Task Handles_Tool_Calling_Errors ( )
66119 {
0 commit comments