-
Notifications
You must be signed in to change notification settings - Fork 384
feat: Add Azure OpenAI Service Support to FastAgent #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add Azure OpenAI Service Support to FastAgent #160
Conversation
- Implement tests for chat completion handling in AzureOpenAIAugmentedLLM. - Cover scenarios including successful responses, empty choices, and choices with None content. - Utilize pytest and asyncio for asynchronous testing. - Mock Azure client responses to validate behavior of the LLM provider.
…e message handling; add integration tests for LLM responses
…ame extraction and validation; update unit tests for base URL handling
…egration & linting
|
Hi @evalstate ! I've tested this using an Azure AI Foundry deployed model (OpenAI gpt-4.1) and it's working fine
I'm considering using fast-agent but I only have the option to use Azure LLM models, so, please let me know how can I help with this Pull Request Thanks! |
…edential authentication; update configuration and tests accordingly
… authentication; update related tests for integration and formatting
…ce tests for API key handling
|
I've included also the docs at the corresponding repository evalstate/fast-agent-docs#5 |
…ledo/fast-agent into feat/azureai-integration
…improve API key checks, and remove obsolete integration tests
…and improve error messaging
|
Hello, I followed the Option 3 instructions here
Here is the simple agent: THIS DOES NOT WORK: The agent CLI interface starts, but sending a test message results in: If I substitute the line from Option 3: THIS WORKS: Any ideas? Thank you |
|
Do NOT include a api-key if you use DefaultAzureCredentials, also you need to ensure that the service account involved in AZ Login is included in the corresponding Role Group I have this script to enforce the permissions in the az account: #!/bin/bash
# This script shows how to assign the Cognitive Services User role to your account
# for Azure OpenAI, which is required for token-based authentication
# Variables - replace with your actual values
USER_ID="" # Your Azure AD object ID (from az ad signed-in-user show)
SUBSCRIPTION_ID="" # Your subscription ID
RESOURCE_GROUP="" # Your resource group name
RESOURCE_NAME="" # Your Azure OpenAI resource name
echo "=== Azure OpenAI RBAC Role Assignment ==="
echo "This script will assign the 'Cognitive Services User' role to your account"
echo "User ID: $USER_ID"
echo "Subscription: $SUBSCRIPTION_ID"
echo "Resource Group: $RESOURCE_GROUP"
echo "Resource Name: $RESOURCE_NAME"
echo ""
echo "First, let's verify your current user:"
az ad signed-in-user show --query id
echo ""
echo "Now assigning the Cognitive Services User role..."
# The following command assigns the role using object ID:
az role assignment create \
--assignee-object-id "$USER_ID" \
--role "Cognitive Services User" \
--scope "/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.CognitiveServices/accounts/$RESOURCE_NAME"
echo ""
echo "Verifying role assignment..."
az role assignment list \
--assignee-object-id "$USER_ID" \
--scope "/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.CognitiveServices/accounts/$RESOURCE_NAME" \
--output table
echo ""
echo "Note: Role assignments may take up to 30 minutes to fully propagate."
echo "If authentication still fails after role assignment, you can use API key authentication."
|




This pull request introduces Azure OpenAI Service integration into the FastAgent application, adding support for both API Key and DefaultAzureCredential authentication methods. It also includes updates to configuration, dependency management, and testing to ensure seamless integration. Below are the key changes:
Azure OpenAI Integration
AzureOpenAIAugmentedLLMclass to handle Azure OpenAI Service logic, supporting both API Key and DefaultAzureCredential authentication. It includes validation for configuration parameters likebase_url,api_key, andazure_deployment(src/mcp_agent/llm/providers/augmented_llm_azure.py, src/mcp_agent/llm/providers/augmented_llm_azure.pyR1-R137).AzureSettingsand updated theSettingsclass to include Azure-specific configuration options (src/mcp_agent/config.py, [1] [2].ModelFactoryandProviderto include Azure as a supported provider (src/mcp_agent/llm/model_factory.py, [1] [2];src/mcp_agent/llm/provider_types.py, [3].Configuration and Dependency Updates
fastagent.config.yaml, detailing three supported authentication modes (examples/azure-openai/fastagent.config.yaml, examples/azure-openai/fastagent.config.yamlR1-R54).pyproject.tomlto include theazure-identitydependency and an optionalazureextras group for DefaultAzureCredential support (pyproject.toml, [1] [2].Enhancements to Configuration Validation
check_api_keysto validate Azure configuration, supporting both API Key and DefaultAzureCredential modes. The function now checks both secrets and main configuration files for retrocompatibility (src/mcp_agent/cli/commands/check_config.py, [1] [2].show_check_summaryfunction (src/mcp_agent/cli/commands/check_config.py, [1] [2].Testing
check_api_keysto validate Azure configuration scenarios, including API Key-only, DefaultAzureCredential-only, and invalid configurations (tests/unit/mcp_agent/cli/commands/test_check_config.py, tests/unit/mcp_agent/cli/commands/test_check_config.pyR1-R69).Minor Adjustments
augmented_llm_openai.pyto include Azure as a supported provider (src/mcp_agent/llm/providers/augmented_llm_openai.py, src/mcp_agent/llm/providers/augmented_llm_openai.pyL359-R359).