AI

Build a simple AI-powered weather assistant using the GitHub Copilot SDK and .NET

Medhat Elmasry Medhat Elmasry
AI

A .NET console tutorial walks through the GitHub Copilot SDK: declaring a callable weather tool, registering it on an AIAgent, letting the user pick from the models their Copilot subscription exposes, and authenticating a deployed app with a fine-grained token.

Key points

  • Two packages do the work: `GitHub.Copilot.SDK` and `Microsoft.Agents.AI.GitHub.Copilot`, added to a plain `dotnet new console` project.
  • The tool is declared with `CopilotTool.DefineTool` plus `AIFunctionFactoryOptions`, where Name and Description steer model tool selection.
  • `CopilotClient.AsAIAgent` wires tools and instructions together, and `RunAsync` returns an `AgentResponse` whose `Text` you print.
  • `ListModelsAsync` returns the models your GitHub subscription unlocks; `SessionConfig` then carries Model, Tools and SystemMessage.
  • `SkipPermission = true` on `CopilotToolOptions` lets the agent invoke the tool without a confirmation step.
  • For deployment, a fine-grained PAT with Copilot Requests scope goes into `COPILOT_GITHUB_TOKEN`, with `UseLoggedInUser = false`.

Real-world use

  • a console assistant that replaces hard-coded weather data with a real REST weather API
  • a school or course project that runs inference on an Azure-hosted model instead of GitHub Copilot
  • an app where each user signs in with GitHub and supplies their own Copilot token
  • an agent that grows from one tool to several, such as wind speed, report generation or database queries

This summary was generated by the agent from the original post on Medhat Elmasry. The full text and all rights belong to its author and publisher. Go to original

Report this story

Is something wrong with the summary, or do you own this content? Your message comes straight to my inbox.

Type of message

Related stories

Feedback

Found a bug or have an idea? Your message lands straight in my inbox.

Type of message