[azsdk-cli] Use scoped tools and helpers, add micro agent example#12017
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR changes the AI project endpoint and default model for the agent service to use a different Azure OpenAI resource and upgrades to the newer "o3-mini" model.
- Updates the default AI project endpoint to use
azsdk-engsys-openaiinstead ofazsdk-engsys-ai - Changes the default model from "gpt-4.1-mini" to "o3-mini"
- Refactors token usage tracking to use a scoped service pattern with dependency injection
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| PipelineAnalysisTool.cs | Updates to use injected TokenUsageHelper and removes manual token usage tracking |
| ExampleTool.cs | Adds TokenUsageHelper injection and usage tracking for AI operations |
| ServiceRegistrations.cs | Changes service registrations to scoped lifetime and adds TokenUsageHelper registration |
| AzureAgentServiceFactory.cs | Updates factory to inject TokenUsageHelper into created services |
| AzureAgentService.cs | Updates endpoint/model defaults and integrates TokenUsageHelper for usage tracking |
| Program.cs | Minor code formatting improvements and logging filter adjustments |
| TokenUsageHelper.cs | Complete refactor to use dependency injection and support multiple model pricing |
| ExampleToolTests.cs | Updates test to provide required TokenUsageHelper dependency |
| MCPTool.cs | Code formatting changes with no functional impact |
4234eed to
d39d995
Compare
benbp
commented
Sep 10, 2025
| } | ||
|
|
||
| [McpServerTool(Name = "azsdk_example_microagent_fibonacci"), Description("Demonstrates micro-agent computing Nth Fibonacci number via iterative tool calls")] | ||
| public async Task<DefaultCommandResponse> DemonstrateMicroagentFibonacci(int n, CancellationToken ct = default) |
Member
Author
There was a problem hiding this comment.
FYI @timovv I added this example tool and cli command to run the micro agent service in case it's useful for ad-hoc testing.
azsdk example demo microagent --fibonacci 7
d39d995 to
14d2c88
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Making all the MCP tools injected via
AddScopedinstead of as singletons. This will allow us to inject other classes that can manage state for the request scope. In this PR the token usage helper is made scoped so that we can track agent token usage across the code for an entire request, and then later consume it from multiple places like our telemetry service (FYI @praveenkuttappan).Also updating the backend foundry project endpoint for the agent service, since the legacy project has started breaking for API calls.
To play around with the scoped token usage helper, I added an example tool/cli command for the micro agent service which computes fibonacci.
Finally, this fixes an issue from last month where logs coming out of any
Azure.Sdk.Tools.*namespace were not printed to console.