Saturday, 11 October 2025

Getting started: Declarative Agents with TypeSpec for Microsoft 365 Copilot

Declarative agents let you add focused skills to Microsoft 365 Copilot without spinning up servers or long-running code. Compared to Copilot Studio agents (full or Lite), which are great for UI-first orchestration and built-in connectors, declarative agents are repo-friendly, schema-driven artifacts you version, review, and ship like code. 

You describe instructions and capabilities in TypeSpec and the M365 Agents toolkit compiles that into a manifest and handles provisioning.

So in this post, we’ll use the TypeSpec starter in the Microsoft 365 Agents Toolkit and light up a couple of built-in capabilities.


On a high level, we’ll:

  • Install the Microsoft 365 Agents Toolkit and TypeSpec bits. 

  • Scaffold a Declarative Agent (TypeSpec) project in VS Code. 

  • Add capabilities (OneDrive/SharePoint search + People + Code Interpreter). 

  • Provision and test the agent from the toolkit.

Prereqs

  • Microsoft 365 tenant (Developer or test tenant recommended) and permission to create app registrations.

  • Visual Studio Code with Microsoft 365 Agents Toolkit extension. 

  • TypeSpec for Microsoft 365 Copilot (installed automatically by the toolkit starter). 


1) Create a TypeSpec Declarative Agent

  1. Open VS Code.

  2. From the sidebar, open Microsoft 365 Agents ToolkitCreate a New Agent/AppDeclarative AgentStart with TypeSpec for Microsoft 365 Copilot.

  3. Name it (e.g., ContosoFinder) and choose the default folder.

  4. In the Lifecycle pane, select Provision to create the Azure AD app and resources in your tenant.


2) Understand the project

The starter includes:

  • main.tsp (your agent definition)

  • Build scripts that compile TypeSpec → agent manifest JSON

  • Toolkit tasks for Provision, Deploy, Publish 



3) Add core capabilities in TypeSpec

Open main.tsp and define instructions plus capabilities. Here’s a compact example that enables OneDrive/SharePoint, People, and CodeInterpreter for simple Python math/CSV ops:

Change these values: title, instructions text, conversation starters, search resultLimit, and Code Interpreter timeout as needed. Capability names/params align with the built-in catalog.

4) Build & validate

  • In the Agents Toolkit Lifecycle pane: select Provision which will start the build, validate and deploy process.

5) Test in Microsoft 365 Copilot (tenant)

  • Once the Provisioning succeeds

  • Try prompts like:

    • “Find my last 5 QBR files” → You should see a list of SharePoint/OneDrive files with links.

    • “Who are my peers?” → The agent returns people details from the Graph.

    • “Summarize this CSV and plot top 3 values” → Code Interpreter runs Python and returns a brief summary + chart image. 



Notes

  • Prefer built-in capabilities (Search, People, OneDrive/SharePoint, Teams Messages, WebSearch, Code Interpreter) before adding custom APIs. They’re simpler and tenant-aware.

  • When you need external systems, add an API plugin to your declarative agent via TypeSpec; plugins are actions inside declarative agents (not standalone in Copilot).

  • Great learning paths: the “Build your first declarative agent using TypeSpec” module and recent open labs/samples. 

Wrapping up

With TypeSpec, declarative agents become a clean, versionable artifact you can build, validate, and ship from VS Code. Start with built-in capabilities, keep instructions focused, and only plug external APIs when the scenario demands it. 

Hope this helps!

No comments: