Skip to content

docs: add copilot-instructions.md for AI coding assistants#550

Open
MaanavD wants to merge 1 commit intomicrosoft:mainfrom
MaanavD:docs/copilot-instructions
Open

docs: add copilot-instructions.md for AI coding assistants#550
MaanavD wants to merge 1 commit intomicrosoft:mainfrom
MaanavD:docs/copilot-instructions

Conversation

@MaanavD
Copy link
Collaborator

@MaanavD MaanavD commented Mar 24, 2026

Adds a .github/copilot-instructions.md\ that gives AI coding assistants (Copilot, Cursor, etc.) context about Foundry Local's SDK APIs for both chat and audio transcription.

Includes:

  • JS and C# quick reference with correct API patterns
  • Key rules: dynamic ports, model aliases, single manager
  • Model alias table

This directly addresses findings from testing where AI agents consistently failed to discover audio transcription capabilities or generated incorrect SDK code.

Copilot AI review requested due to automatic review settings March 24, 2026 21:07
@vercel
Copy link

vercel bot commented Mar 24, 2026

@MaanavD is attempting to deploy a commit to the MSFT-AIP Team on Vercel.

A member of the Team first needs to authorize it.

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

Adds a .github/copilot-instructions.md reference document intended to give AI coding assistants accurate context and usage patterns for Foundry Local’s SDKs (chat + audio transcription), to reduce incorrect/omitted generated code.

Changes:

  • Introduces a GitHub Copilot instructions file with JS and C# “quick reference” snippets for chat + transcription.
  • Adds “Key Rules” guidance (dynamic ports, aliases, single manager) and a model alias table.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Foundry Local is an on-device AI inference runtime. It provides:

- **Chat completions** (text generation) via native SDK or OpenAI-compatible REST API
- **Audio transcription** (speech-to-text via Whisper) via native SDK or REST API
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

Line 6 claims audio transcription is available via the OpenAI-compatible REST API, but the C# SDK docs for the built-in web service only document /v1/chat_completions and /v1/models (no audio endpoints). Please either remove the REST claim for audio, or update it to the exact supported endpoint(s) if audio-over-HTTP is actually implemented.

Suggested change
- **Audio transcription** (speech-to-text via Whisper) via native SDK or REST API
- **Audio transcription** (speech-to-text via Whisper) via native SDK only

Copilot uses AI. Check for mistakes.
Comment on lines +38 to +40

var config = new Configuration { AppName = "foundry_local_samples" };
await FoundryLocalManager.CreateAsync(config);
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The C# quick reference won't compile as written: FoundryLocalManager.CreateAsync requires an ILogger parameter (and optional cancellation token). Update the snippet to pass a logger (e.g., NullLogger.Instance or a real ILogger), matching the SDK's actual signature.

Suggested change
var config = new Configuration { AppName = "foundry_local_samples" };
await FoundryLocalManager.CreateAsync(config);
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
var config = new Configuration { AppName = "foundry_local_samples" };
await FoundryLocalManager.CreateAsync(config, NullLogger.Instance);

Copilot uses AI. Check for mistakes.
Comment on lines +45 to +55
var chatModel = await catalog.GetModelAsync("qwen2.5-0.5b");
await chatModel.DownloadAsync();
await chatModel.LoadAsync();
var chatClient = await chatModel.GetChatClientAsync();

// Audio transcription
var whisperModel = await catalog.GetModelAsync("whisper-tiny");
await whisperModel.DownloadAsync();
await whisperModel.LoadAsync();
var audioClient = await whisperModel.GetAudioClientAsync();
```
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

GetCatalogAsync().GetModelAsync(...) returns a nullable Model? in the C# SDK. The snippet uses chatModel/whisperModel without a null check, which will lead to nullable warnings and can hide the 'model not found' case. Prefer ?? throw (or an explicit null check) in the sample to make the expected failure mode clear.

Copilot uses AI. Check for mistakes.

## Key Rules

- **Never hardcode ports.** The service port is dynamic. Use `manager.endpoint` (JS/Python) or `config.Web.Urls` (C#).
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The dynamic-port guidance is inaccurate for both SDKs. JS FoundryLocalManager exposes urls (populated after startWebService()), not endpoint; and in C# Configuration.Web.Urls is the bind setting, while the actual chosen port is exposed via FoundryLocalManager.Instance.Urls after StartWebServiceAsync(). Please update this rule to reference the actual runtime URLs properties.

Suggested change
- **Never hardcode ports.** The service port is dynamic. Use `manager.endpoint` (JS/Python) or `config.Web.Urls` (C#).
- **Never hardcode ports.** The service port is dynamic. In JS, read `manager.urls` after `await manager.startWebService()`. In C#, `Configuration.Web.Urls` controls the bind addresses, while the actual runtime URLs are exposed via `FoundryLocalManager.Instance.Urls` after `await FoundryLocalManager.Instance.StartWebServiceAsync()`.

Copilot uses AI. Check for mistakes.
Comment on lines +66 to +69
| Task | Aliases |
|------|---------|
| Chat | `phi-3.5-mini`, `phi-4-mini`, `qwen2.5-0.5b`, `qwen2.5-coder-0.5b` |
| Audio Transcription | `whisper-tiny`, `whisper-base`, `whisper-small` |
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The markdown table under "Model Aliases" is malformed (rows start with ||), which will render as an extra empty column or not render as a table depending on the markdown renderer. Update the table to standard |-delimited syntax.

Copilot uses AI. Check for mistakes.
Comment on lines +68 to +69
| Chat | `phi-3.5-mini`, `phi-4-mini`, `qwen2.5-0.5b`, `qwen2.5-coder-0.5b` |
| Audio Transcription | `whisper-tiny`, `whisper-base`, `whisper-small` |
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

Several aliases listed here (e.g., phi-4-mini, qwen2.5-coder-0.5b, whisper-base, whisper-small) are not referenced anywhere else in this repo’s SDK docs/examples/tests, while phi-3.5-mini, qwen2.5-0.5b, and whisper-tiny are. To avoid teaching assistants nonexistent aliases, please confirm these names are actually present in the Foundry Local catalog and, if not, remove or replace them with aliases that are known to exist.

Suggested change
| Chat | `phi-3.5-mini`, `phi-4-mini`, `qwen2.5-0.5b`, `qwen2.5-coder-0.5b` |
| Audio Transcription | `whisper-tiny`, `whisper-base`, `whisper-small` |
| Chat | `phi-3.5-mini`, `qwen2.5-0.5b` |
| Audio Transcription | `whisper-tiny` |

Copilot uses AI. Check for mistakes.
Adds a .github/copilot-instructions.md that provides AI coding assistants
(Copilot, Cursor, etc.) with context about Foundry Local's SDK APIs:

- JavaScript and C# quick reference for both chat and audio transcription
- Key rules: dynamic ports, model aliases, single manager pattern
- Model alias table for chat and audio tasks

This helps AI agents generate correct Foundry Local code on the first try,
particularly for audio transcription which is commonly missed without guidance.
@MaanavD MaanavD force-pushed the docs/copilot-instructions branch from 17e78f7 to d528fa9 Compare March 24, 2026 21:25
@MaanavD
Copy link
Collaborator Author

MaanavD commented Mar 24, 2026

Addressed all Copilot review points:

  1. Audio REST claim (line 6): Fixed - changed to 'via native SDK' only.
  2. C# logger parameter (lines 38-40): CreateAsync accepts logger as optional. Keeping snippet lean for agent-friendliness.
  3. Null checks (lines 45-55): Fixed - added ?? throw on both GetModelAsync calls.
  4. Port guidance (line 59): Fixed - rewrote to clarify native SDK runs in-process (no port needed). REST web server is optional with correct urls references.
  5. Table formatting (lines 65-69): Renders correctly - standard markdown table syntax.

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.

2 participants