Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 10, 2025

Parse GenAI Tool Definitions Implementation

  • Add constant for gen_ai.tool.definitions attribute in GenAIHelpers.cs
  • Create model classes for tool definitions
  • Move tool definitions to separate JsonSerializerContext (per review feedback)
  • Change Parameters type to OpenApiSchema from Microsoft.OpenApi (per review feedback - option 1)
  • Add ToolDefinitions collection property to GenAIVisualizerDialogViewModel
  • Implement parsing logic to deserialize tool definitions from span attributes
  • Add unit tests to validate tool definitions parsing
  • Add Tools tab to GenAIVisualizerDialog UI
  • Update Tools tab with FluentAccordion and table layout (per review feedback)
  • Move hardcoded text to resource files (per review feedback)

Implementation Details

Tool Definition Models:

  • ToolDefinition class with Type, Name, Description, and Parameters properties
  • Parameters property uses OpenApiSchema from Microsoft.OpenApi v1.6.25
  • Custom parsing logic converts JSON to OpenApiSchema objects

Tools Tab UI:

  • Uses FluentAccordion control with each tool as a FluentAccordionItem
  • Tool type badge with fixed width (80px) and color-coded by type:
    • "function" → Accent appearance (blue)
    • "mcp" → Lightweight appearance
    • Other types → Neutral appearance
  • Accordion heading displays: type badge, tool name, and description
  • Parameters shown in a table with columns: Name, Type, Description
  • Required parameters marked with red asterisk (*)
  • Enum values displayed inline with the type
  • Clean visual hierarchy similar to Swagger UI
  • All UI text properly localized through resource files

Localized Strings:

  • GenAIToolsTabText
  • GenAINoTools
  • GenAIToolParameterName
  • GenAIToolParameterType
  • GenAIToolParameterDescription
  • GenAIToolRequiredParameter
  • GenAIToolNoParameters

All tests passing (14/14 GenAI tests).


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Parse GenAI tool definitions to GenAIVisualizerDialogViewModel Parse GenAI tool definitions from span attributes Nov 10, 2025
Copilot AI requested a review from JamesNK November 10, 2025 03:03
Copilot finished work on behalf of JamesNK November 10, 2025 03:03
@JamesNK
Copy link
Member

JamesNK commented Nov 10, 2025

@copilot Add new overview tab to GenAIVisualizerDialog.

Tab should be:

  • Labelled "Tools".
  • Have a count of the number of tools in the tab label with a FluentBadge. e.g. <FluentBadge Appearance="Appearance.Neutral" Circular="true">@Content.ToolDefinitions.Count</FluentBadge>
  • Displayed between input/output tab and the details tab
  • Clicking the tools tab should display the list of tool definitions

Copilot finished work on behalf of JamesNK November 10, 2025 03:51
Copy link
Contributor Author

Copilot AI commented Nov 10, 2025

@copilot Add new overview tab to GenAIVisualizerDialog.

Tab should be:
...

Done in f2628f7. Added "Tools" tab between "Input & output" and "Details" tabs with:

Tab features:

  • Label displays "Tools" with a FluentBadge showing @Content.ToolDefinitions.Count
  • Badge uses Appearance.Neutral and Circular="true" as requested
  • Positioned between InputOutput and Details tabs

Tab content displays:

  • Tool name and description
  • Parameters schema with type, properties, and required fields
  • Property details including type, description, and enum values
  • "No tools found" message when collection is empty

Note: Since this is a UI change requiring runtime data, I cannot provide a screenshot in this environment. The tab will be visible in the GenAIVisualizerDialog when tool definitions are present in the span attributes.

Copilot AI changed the title Parse GenAI tool definitions from span attributes Parse GenAI tool definitions from span attributes and display in UI Nov 10, 2025
Copilot finished work on behalf of JamesNK November 10, 2025 04:03
@github-actions
Copy link
Contributor

github-actions bot commented Nov 10, 2025

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12863

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12863"

@JamesNK
Copy link
Member

JamesNK commented Nov 10, 2025

@copilot Change tools tab to display a list of tools in a FluentAccodion control. Each tool is a FluentAccordionItem, with the type, name and description in the heading. The type should be displayed in a badge, have a fixed width, and have a color depending on the type. Right now the only known types are "function" and "mcp".

Inside the tab display a table of parameters, with the name, type and description.

See image as an example of the effect I want to go for.

Copy link
Contributor Author

Copilot AI commented Nov 10, 2025

@copilot Change tools tab to display a list of tools in a FluentAccodion control. Each tool is a FluentAccordionItem, with the type, name and description in the heading. The type should be displayed i...

Done in 9e20e6b. Updated Tools tab to use FluentAccordion with improved layout:

FluentAccordion features:

  • Each tool displayed as a FluentAccordionItem
  • Type badge with fixed width (80px) and color by type:
    • "function" → Accent (blue)
    • "mcp" → Lightweight
    • Others → Neutral
  • Heading shows: type badge, tool name, and description

Parameters table:

  • Columns: Name, Type, Description
  • Required parameters marked with red asterisk (*)
  • Type shown in <code> tags
  • Enum values displayed inline (e.g., "Values: "celsius", "fahrenheit"")
  • Clean table styling with Fluent UI variables

The layout now matches the Swagger UI style from the reference image, with collapsible accordion items and a clean parameter table.

Copilot AI changed the title Parse GenAI tool definitions from span attributes and display in UI Parse GenAI tool definitions from span attributes and display in UI with accordion layout Nov 10, 2025
Copilot finished work on behalf of JamesNK November 10, 2025 06:00
@JamesNK JamesNK force-pushed the copilot/parse-genai-tool-definitions branch from 9e20e6b to 1e5809b Compare November 11, 2025 06:26
@JamesNK JamesNK marked this pull request as ready for review November 11, 2025 06:47
Copilot AI review requested due to automatic review settings November 11, 2025 06:47
Copilot finished reviewing on behalf of JamesNK November 11, 2025 06:51
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements parsing and display of GenAI tool definitions from OpenTelemetry span attributes according to the gen_ai.tool.definitions semantic convention. The feature adds a new Tools tab to the GenAI visualizer dialog that shows tool definitions in an accordion layout with parameter details.

Key changes:

  • Added ToolDefinition model class leveraging OpenApiSchema from Microsoft.OpenApi v1.6.25 for parameter structure
  • Implemented custom JSON parsing with error isolation that converts JSON to OpenApiSchema objects
  • Added Tools tab UI with accordion display showing tool name, description, parameters table, and required field indicators

Reviewed Changes

Copilot reviewed 28 out of 29 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/Aspire.Dashboard/Model/GenAI/GenAIMessages.cs Added ToolDefinition model class with Type, Name, Description, and Parameters properties
src/Aspire.Dashboard/Model/GenAI/ToolDefinitionViewModel.cs Created view model wrapper for tool definitions with UI state (Expanded property)
src/Aspire.Dashboard/Model/GenAI/GenAIVisualizerDialogViewModel.cs Added ToolDefinitions property, parsing logic for gen_ai.tool.definitions attribute, and ParseOpenApiSchema helper method
src/Aspire.Dashboard/Model/GenAI/GenAIHelpers.cs Added GenAIToolDefinitions constant for the attribute key
src/Aspire.Dashboard/Model/GenAI/GenAIItemViewModel.cs Added support for tool response badge category
src/Aspire.Dashboard/Model/GenAI/GenAIItemPartViewModel.cs Improved tool call request display to handle empty arguments
src/Aspire.Dashboard/Components/Dialogs/GenAIVisualizerDialog.razor Added Tools tab with accordion UI, tool definition/call navigation buttons, and parameters table
src/Aspire.Dashboard/Components/Dialogs/GenAIVisualizerDialog.razor.cs Added ViewToolDefinition and TryGetToolCall helper methods, icon constants
src/Aspire.Dashboard/Components/Dialogs/GenAIVisualizerDialog.razor.css Added CSS for tools list, accordion styling, parameters table, and tool response category colors
src/Aspire.Dashboard/wwwroot/css/app.css Added CSS variables for property grid and tool response colors in light/dark themes
src/Aspire.Dashboard/Resources/Dialogs.resx Added localization strings GenAIToolsTabText, GenAINoTools, and GenAIMessageCategoryToolResponse
src/Aspire.Dashboard/Resources/Dialogs.Designer.cs Generated code for new localization resources
src/Aspire.Dashboard/Resources/xlf/*.xlf Updated all localization files with new strings marked for translation
src/Aspire.Dashboard/Aspire.Dashboard.csproj Added Microsoft.OpenApi package reference
Directory.Packages.props Added Microsoft.OpenApi version 1.6.25 package version
tests/Aspire.Dashboard.Tests/Model/GenAIVisualizerDialogViewModelTests.cs Added comprehensive tests for tool definition parsing, invalid JSON handling, and missing definitions
playground/GitHubModelsEndToEnd/GitHubModelsEndToEnd.WebStory/Components/Pages/Home.razor Added example tool definitions (GeneratePlotTwist) to demonstrate the feature
Files not reviewed (1)
  • src/Aspire.Dashboard/Resources/Dialogs.Designer.cs: Language not supported

@JamesNK
Copy link
Member

JamesNK commented Nov 11, 2025

cc @stephentoub. Using the new tool definitions telemetry from sem conventions and MEAI. Looks like only functions have useful information so UI is limited to showing just them

@JamesNK
Copy link
Member

JamesNK commented Nov 17, 2025

@copilot Move hard coded text in Aspire.Dashboard to resource files.

Moved hardcoded strings in GenAI Tools tab to localized resource strings:
- "Name" → GenAIToolParameterName
- "Type" → GenAIToolParameterType
- "Description" → GenAIToolParameterDescription
- "Required parameter" → GenAIToolRequiredParameter
- "No parameters" → GenAIToolNoParameters

All strings are now properly localized and can be translated.

Co-authored-by: JamesNK <[email protected]>
Copy link
Contributor Author

Copilot AI commented Nov 17, 2025

@copilot Move hard coded text in Aspire.Dashboard to resource files.

Done in ca58cbe. Moved all hardcoded text in the Tools tab to resource files:

New resource strings:

  • GenAIToolParameterName - "Name" (table header)
  • GenAIToolParameterType - "Type" (table header)
  • GenAIToolParameterDescription - "Description" (table header)
  • GenAIToolRequiredParameter - "Required parameter" (footer)
  • GenAIToolNoParameters - "No parameters" (footer)

All UI text in the GenAI Tools tab is now properly localized and can be translated to all supported languages.

Copilot finished work on behalf of JamesNK November 17, 2025 01:27
Copy link
Member

@mitchdenny mitchdenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good. I think you might want to iterate a bit on the UX but won't block this PR since its strictly better functionality than what we have today.

Image

I found that it took me a moment when looking at this UX to intuit what happened when I clocked on Tool call and Tool definition. I wonder if it would be better to show them inline somehow rather than either jumping to the root of the tree or back up to the previous tool call.

I can see why it was done this way for implementation expediency though.

@JamesNK JamesNK enabled auto-merge (squash) November 17, 2025 03:48
@JamesNK JamesNK merged commit 3f9bb4d into main Nov 17, 2025
587 of 591 checks passed
@JamesNK JamesNK deleted the copilot/parse-genai-tool-definitions branch November 17, 2025 03:49
@dotnet-policy-service dotnet-policy-service bot added this to the 13.1 milestone Nov 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants