Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/skills/foundry-agent/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
name: foundry-agent
description: >
Enables GitHub Copilot to send user prompts to a Microsoft Foundry Agent for advanced Q&A,
complex reasoning, or data processing tasks that require specialized AI capabilities.
location: project
tools:
- name: query_foundry_agent
description: >
Sends a user prompt to the Microsoft Foundry Agent endpoint for advanced AI processing.
Use this when the user explicitly requests Foundry agent capabilities or when complex
reasoning beyond standard Copilot is needed.
parameters:
- name: prompt
description: The user's question or request to send to the Foundry Agent
type: string
required: true
- name: conversation_id
description: Optional conversation ID for maintaining context across multiple requests
type: string
required: false
implementation: python
---

# Foundry Agent Skill

This skill allows GitHub Copilot to interact with a Microsoft Foundry Agent application for tasks that require:
- Complex reasoning and analysis
- Advanced natural language understanding
- Specialized domain knowledge
- Integration with external data sources
- Custom AI workflows and processing

## When to Use

Use this skill when:
- The user explicitly mentions "Foundry" or "Foundry agent"
- The user's request requires advanced AI capabilities beyond standard Copilot functionality
- Complex data analysis or processing is needed
- Integration with Microsoft Foundry's specialized models is beneficial
- The task involves multi-step reasoning or orchestration

## Tool: query_foundry_agent

Sends a prompt to the configured Microsoft Foundry Agent endpoint.

### Parameters
- **prompt** (required): The user's question or request
- **conversation_id** (optional): Conversation ID for maintaining context

## Configuration

To use this skill, you need to:

1. **Set up Azure authentication**: The skill uses `DefaultAzureCredential` which supports multiple authentication methods:
- Azure CLI: `az login`
- Environment variables: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`
- Managed Identity (when running in Azure)
- Visual Studio Code Azure account

2. **Configure the Foundry Agent endpoint** (optional):
- Set `FOUNDRY_AGENT_ENDPOINT` environment variable to your Foundry Agent URL
- If not set, uses the default endpoint shown in the implementation

3. **Install required Python packages**:
```bash
pip install requests azure-identity
```

## Example Usage

In GitHub Copilot, you can invoke this skill by asking:
- "Use the Foundry agent to analyze this code"
- "Ask the Foundry agent what's new in Foundry"
- "Query the Foundry agent about cloud computing trends"

## Additional Resources

- [Microsoft Foundry Documentation](https://learn.microsoft.com/azure/ai-foundry/)
- [GitHub Copilot Agent Skills Documentation](https://code.visualstudio.com/docs/copilot/customization/agent-skills)
- [Azure Identity Library](https://learn.microsoft.com/python/api/azure-identity/)
- [Foundry Agent Webapp Example](https://github.com/microsoft-foundry/foundry-agent-webapp)
97 changes: 97 additions & 0 deletions .github/skills/foundry-agent/query_foundry_agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env python3
"""
GitHub Copilot Agent Skill tool: query_foundry_agent
Sends a prompt to Microsoft Foundry Agent for advanced AI processing.
"""

import os
import sys
import json
import argparse
import requests
from azure.identity import DefaultAzureCredential


def query_foundry_agent(prompt: str, conversation_id: str = None):
"""
Query the Microsoft Foundry Agent with a user prompt.

Args:
prompt: The user's question or request to send to the Foundry Agent
conversation_id: Optional conversation ID for maintaining context across multiple requests

Returns:
dict: The Foundry Agent response or error information
"""
try:
# Initialize Azure credential
credential = DefaultAzureCredential()

# Get endpoint from environment (required)
# Example: "https://<foundry-account-name>.services.ai.azure.com/api/projects/<project-name>/applications/<application-name>/protocols/openai/responses?api-version=2025-11-15-preview"
endpoint = os.getenv("FOUNDRY_AGENT_APPLICATION_ENDPOINT")
if not endpoint:
raise ValueError("FOUNDRY_AGENT_APPLICATION_ENDPOINT environment variable is required but not set")

# Get access token
token = credential.get_token("https://ai.azure.com/.default")

# Prepare request
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {token.token}"
}

payload = {
"input": prompt,
}

if conversation_id:
payload["previous_response_id"] = conversation_id

# Send request to Foundry Agent
response = requests.post(endpoint, json=payload, headers=headers, timeout=30)
response.raise_for_status()
result = response.json()

# Return the response
return result

except requests.exceptions.RequestException as e:
return {
"error": f"Failed to call Foundry Agent: {str(e)}",
"endpoint": endpoint
}
except Exception as e:
return {
"error": f"Unexpected error: {str(e)}",
"type": type(e).__name__
}


def main():
"""Main entry point for the tool when called by GitHub Copilot."""
try:
# Parse command-line arguments
parser = argparse.ArgumentParser(description="Query Microsoft Foundry Agent")
parser.add_argument("prompt", help="The user's question or request to send to the Foundry Agent")
parser.add_argument("--conversation_id", "-c", help="Optional conversation ID for maintaining context", default=None)

args = parser.parse_args()

prompt = args.prompt
conversation_id = args.conversation_id

# Call the Foundry Agent
result = query_foundry_agent(prompt, conversation_id)

# Output result as JSON
print(json.dumps(result))

except Exception as e:
print(json.dumps({"error": f"Tool execution failed: {str(e)}"}))
sys.exit(1)


if __name__ == "__main__":
main()
155 changes: 153 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,153 @@
# foundry-github-copilot-skill
Foundry Github copilot skill
# foundry-github-copilot-skill

This repository contains a GitHub Copilot Agent Skill that enables GitHub Copilot to call a Microsoft Foundry Agent application for advanced AI capabilities.

## Overview

The Foundry Agent Skill enables GitHub Copilot to interact with Microsoft Foundry Agent applications for:

- Complex reasoning and analysis
- Advanced natural language understanding
- Specialized domain knowledge integration
- Custom AI workflows and processing
- Multi-step task orchestration

## Installation

### Step 1: Copy the Skill to Your Repository

Copy the `.github/skills/foundry-agent/` folder to your target repository.

**macOS/Linux:**
```bash
# From your target repository
mkdir -p .github/skills
cp -r /path/to/foundry-github-copilot-skill/.github/skills/foundry-agent .github/skills/
```

**Windows (PowerShell):**
```powershell
# From your target repository
New-Item -ItemType Directory -Force -Path .github\skills
Copy-Item -Recurse -Path C:\path\to\foundry-github-copilot-skill\.github\skills\foundry-agent -Destination .github\skills\
```

Or manually copy these files to your repository:
```
your-repo/
└── .github/
└── skills/
└── foundry-agent/
├── SKILL.md
└── query_foundry_agent.py
```

### Step 2: Install Python Dependencies

The skill requires Python 3.8+ and the following packages.

**macOS:**
```bash
# Install Python if needed (using Homebrew)
brew install python

# Install dependencies
pip3 install requests>=2.31.0 azure-identity>=1.15.0
```

**Windows:**
```powershell
# Install Python from https://www.python.org/downloads/ or using winget
winget install Python.Python.3.11

# Install dependencies
pip install requests>=2.31.0 azure-identity>=1.15.0
```

### Step 3: Install and Configure Azure CLI

**macOS:**
```bash
# Install Azure CLI using Homebrew
brew install azure-cli

# Sign in to Azure
az login
```

**Windows:**
```powershell
# Install Azure CLI using winget
winget install Microsoft.AzureCLI

# Or download from: https://aka.ms/installazurecliwindows

# Sign in to Azure
az login
```

### Step 4: Configure Azure Authentication

The skill uses Azure `DefaultAzureCredential` for secure, passwordless authentication.

```bash
az login
```


### Step 5: Configure Your Foundry Agent Endpoint

Set the `FOUNDRY_AGENT_APPLICATION_ENDPOINT` environment variable to point to your Foundry Agent.

**macOS/Linux:**
```bash
export FOUNDRY_AGENT_APPLICATION_ENDPOINT="https://your-project.services.ai.azure.com/api/projects/your-project/applications/your-agent/protocols/openai/responses?api-version=2025-11-15-preview"
```

**Windows (PowerShell):**
```powershell
$env:FOUNDRY_AGENT_APPLICATION_ENDPOINT = "https://your-project.services.ai.azure.com/api/projects/your-project/applications/your-agent/protocols/openai/responses?api-version=2025-11-15-preview"
```

**Windows (Command Prompt):**
```cmd
set FOUNDRY_AGENT_APPLICATION_ENDPOINT=https://your-project.services.ai.azure.com/api/projects/your-project/applications/your-agent/protocols/openai/responses?api-version=2025-11-15-preview
```

## Skill Structure

```
.github/skills/foundry-agent/
├── SKILL.md # Skill definition and metadata
└── query_foundry_agent.py # Python implementation
```

## Usage

Once installed and configured, the Foundry Agent skill is automatically available in GitHub Copilot.

### Invoking the Skill

Invoke the skill by mentioning "Foundry" or "Foundry agent" in your Copilot prompts:

```
"Use the Foundry agent to analyze this code"
"Ask the Foundry agent what's new in Microsoft Foundry"
"Query the Foundry agent about cloud architecture best practices"
"Call the Foundry agent to explain this algorithm"
```

### How It Works

1. **You make a request** in GitHub Copilot mentioning the Foundry agent
2. **Copilot detects the intent** and loads the `foundry-agent` skill
3. **The skill authenticates** using Azure DefaultAzureCredential
4. **Sends your prompt** to the configured Foundry Agent endpoint
5. **Returns the response** from the Foundry Agent back to you in Copilot


## Resources

- [Microsoft Foundry Documentation](https://learn.microsoft.com/azure/ai-foundry/)
- [GitHub Copilot Agent Skills Documentation](https://code.visualstudio.com/docs/copilot/customization/agent-skills)
- [Foundry Agent Webapp Example](https://github.com/microsoft-foundry/foundry-agent-webapp)
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
requests>=2.31.0
azure-identity>=1.15.0
Loading