@@ -185,18 +185,19 @@ public async Task IntegrationTestStreaming()
185185 { "system" , "You are a helpful assistant that uses all available tools to answer questions accurately." } ,
186186 { "user" ,
187187 $$ """
188- Current timestamp is {{ DateTimeOffset . UtcNow . ToUnixTimeMilliseconds ( ) }} .
189-
190188 Please answer the following questions using the appropriate tools:
191189 1. What is today's date? (use get_date tool)
192- 2. What is the current price of Tesla (TSLA) stock? (use Yahoo news web search)
193- 3. Calculate the earnings that would be produced by compound interest to $5k at 4% annually for 5 years (use code interpreter)
194- 4. What is the latest release version of the {{ ThisAssembly . Git . Url }} repository? (use GitHub MCP tool)
190+ 2. What is the current price of Tesla (TSLA) stock? (use Yahoo news web search, always include citations)
191+ 3. What is the top news from Tesla on X?
192+ 4. Calculate the earnings that would be produced by compound interest to $5k savings at 4% annually for 5 years (use code interpreter).
193+ Return just the earnings, not the grand total of savings plus earnings).
194+ 5. What is the latest release version of the {{ ThisAssembly . Git . Url }} repository? (use GitHub MCP tool)
195195
196196 Respond with a JSON object in this exact format:
197197 {
198198 "today": "[date from get_date in YYYY-MM-DD format]",
199199 "tesla_price": [numeric price from web search],
200+ "tesla_news": "[top news from X]",
200201 "compound_interest": [numeric result from code interpreter],
201202 "latest_release": "[version string from GitHub]"
202203 }
@@ -215,33 +216,32 @@ 2. What is the current price of Tesla (TSLA) stock? (use Yahoo news web search)
215216
216217 var options = new GrokChatOptions
217218 {
219+ ResponseFormat = ChatResponseFormat . Json ,
218220 Include =
219221 [
220222 IncludeOption . InlineCitations ,
221223 IncludeOption . WebSearchCallOutput ,
222224 IncludeOption . CodeExecutionCallOutput ,
223- IncludeOption . McpCallOutput
225+ IncludeOption . McpCallOutput ,
226+ IncludeOption . XSearchCallOutput ,
224227 ] ,
225228 Tools =
226229 [
227- // Client-side tool
228230 AIFunctionFactory . Create ( ( ) =>
229231 {
230232 getDateCalls ++ ;
231233 return DateTime . Now . ToString ( "yyyy-MM-dd" ) ;
232234 } , "get_date" , "Gets the current date in YYYY-MM-DD format" ) ,
233-
234- // Hosted web search tool
235235 new HostedWebSearchTool ( ) ,
236-
237- // Hosted code interpreter tool
238236 new HostedCodeInterpreterTool ( ) ,
239-
240- // Hosted MCP server tool (GitHub)
241237 new HostedMcpServerTool ( "GitHub" , "https://api.githubcopilot.com/mcp/" )
242238 {
243239 AuthorizationToken = Environment . GetEnvironmentVariable ( "GITHUB_TOKEN" ) ! ,
244240 AllowedTools = [ "list_releases" , "get_release_by_tag" ] ,
241+ } ,
242+ new GrokXSearchTool
243+ {
244+ AllowedHandles = [ "tesla" ]
245245 }
246246 ]
247247 } ;
@@ -339,6 +339,10 @@ void AssertIntegrationTest(ChatResponse response, Func<int> getDateCalls)
339339
340340 output . WriteLine ( $ "Parsed response: Today={ result . Today } , TeslaPrice={ result . TeslaPrice } , CompoundInterest={ result . CompoundInterest } , LatestRelease={ result . LatestRelease } ") ;
341341 }
342+ else
343+ {
344+ Assert . Fail ( "Response did not contain expected JSON output" ) ;
345+ }
342346
343347 output . WriteLine ( $ "Code interpreter calls: { codeInterpreterCalls . Count } ") ;
344348 output . WriteLine ( $ "MCP calls: { mcpCalls . Count } ") ;
@@ -347,6 +351,7 @@ void AssertIntegrationTest(ChatResponse response, Func<int> getDateCalls)
347351 record IntegrationTestResponse (
348352 string Today ,
349353 decimal TeslaPrice ,
354+ string TeslaNews ,
350355 decimal CompoundInterest ,
351356 string LatestRelease ) ;
352357}
0 commit comments