Skip to content

feat: Add configuration provider interface#184

Open
pontemonti wants to merge 23 commits intomainfrom
users/johanb/ConfigurationImprovements
Open

feat: Add configuration provider interface#184
pontemonti wants to merge 23 commits intomainfrom
users/johanb/ConfigurationImprovements

Conversation

@pontemonti
Copy link
Contributor

@pontemonti pontemonti commented Feb 4, 2026

This pull request introduces a hierarchical, provider-based configuration pattern throughout the Agents365 SDK, deprecating direct environment variable access and legacy utility functions. It adds new configuration classes and providers for runtime, tooling, and observability settings, and applies these patterns to both documentation and code. The changes also introduce OpenAI-specific observability configuration scaffolding, update linting rules to enforce the new configuration approach, and refactor token caching to use the new provider model.

Configuration System Overhaul

  • Introduced the configuration provider pattern across the SDK, with new classes: RuntimeConfiguration, ToolingConfiguration, and ObservabilityConfiguration, each with default singleton providers (e.g., defaultRuntimeConfigurationProvider). This enables hierarchical, function-based overrides for multi-tenant support and deprecates direct use of environment utilities. [1] [2] [3] [4]
  • Updated documentation to reflect the new configuration system, replacing function-based environment utilities with configuration properties and showing usage patterns for both default and custom providers. [1] [2] [3]

OpenAI Observability Extension

  • Added OpenAIObservabilityConfiguration and associated options/types, following the provider pattern for future extensibility and type safety. Exported a singleton provider (defaultOpenAIObservabilityConfigurationProvider) for this configuration. [1] [2] [3] [4]
  • Declared a dependency on @microsoft/agents-a365-runtime in the OpenAI observability extension package.

Agentic Token Cache Refactor

  • Refactored AgenticTokenCache to accept an IConfigurationProvider<ObservabilityConfiguration>, defaulting to defaultObservabilityConfigurationProvider, enabling per-tenant configuration and improved testability. Exported both the class and a default singleton instance. [1] [2] [3] [4] [5]

Linting and Code Quality

  • Updated ESLint configuration to enforce the use of configuration classes instead of direct process.env access and to disallow deprecated API usage, with exceptions for configuration, test, and utility files. [1] [2]

Documentation and Environment Variables

  • Expanded documentation of environment variables to include new observability settings and clarified their relationship to the new configuration classes. [1] [2]

These changes collectively modernize the SDK’s configuration approach, improve extensibility and testability, and lay the groundwork for multi-tenant and advanced observability scenarios.

Johan Broberg and others added 18 commits February 3, 2026 10:02
Resolved conflicts:
- observability/src/index.ts: Combined ILogger exports with configuration exports
- observability/src/utils/logging.ts: Merged setLogger/getLogger/resetLogger pattern
  with configuration provider support for DefaultLogger
- tooling/src/McpToolServerConfigurationService.ts: Combined imports for
  IConfigurationProvider with Authorization and AgenticAuthenticationService
- tooling/src/Utility.ts: Combined imports for IConfigurationProvider with ChannelAccount

Updated tests to match merged implementation:
- Removed createLogger factory tests (replaced by setLogger/getLogger/resetLogger)
- Updated GetAgenticUserToken expectations to include scopes parameter

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The scopes parameter was added as required in main branch, which is a
breaking change for existing consumers. This adds overloads to maintain
backward compatibility:

- 3-param signature (deprecated): Uses default MCP platform scope
- 4-param signature: Explicit scopes for better control

Existing code calling GetAgenticUserToken(auth, handler, ctx) will
continue to work, but callers are encouraged to migrate to the explicit
scopes overload for clarity.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…vider

Added detailed JSDoc explaining:
- The provider creates a single cached configuration instance
- Default module-level providers are singletons
- Two approaches for multi-tenant scenarios:
  1. Dynamic override functions reading from async context (recommended)
  2. Per-tenant provider instances when needed

This clarifies that while the singleton pattern is used, multi-tenancy is
still supported through function-based overrides that resolve at runtime.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Added documentation to AgenticTokenCacheInstance explaining it uses
  default configuration and when to create custom instances
- Exported AgenticTokenCache class so consumers can create instances
  with custom IConfigurationProvider for multi-tenant scenarios
- Added class-level documentation with usage example

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
… utility imports and updating server listing logic
@pontemonti pontemonti marked this pull request as ready for review February 5, 2026 06:36
@pontemonti pontemonti requested review from a team as code owners February 5, 2026 06:36
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

This pull request introduces a comprehensive hierarchical configuration provider pattern throughout the Agents365 SDK, replacing direct process.env access with configuration classes that support programmatic overrides and multi-tenant scenarios. The PR adds new configuration classes (RuntimeConfiguration, ToolingConfiguration, ObservabilityConfiguration) with default singleton providers, applies these patterns across runtime, tooling, and observability packages, and introduces extensive test coverage.

Changes:

  • Introduces configuration provider pattern with base RuntimeConfiguration class and package-specific extensions
  • Adds comprehensive test coverage for all configuration classes and related functionality
  • Deprecates direct environment variable access and legacy utility functions
  • Updates ESLint rules to enforce configuration usage and prevent deprecated API usage

Reviewed changes

Copilot reviewed 70 out of 71 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/agents-a365-runtime/src/configuration/* New configuration infrastructure with interfaces, base classes, and default providers
packages/agents-a365-runtime/src/power-platform-api-discovery.ts Converts ClusterCategory from type alias to enum for better type safety
packages/agents-a365-runtime/src/environment-utils.ts Deprecates utility functions and delegates to configuration classes where possible
packages/agents-a365-runtime/src/agentic-authorization-service.ts Adds overload accepting explicit scopes parameter
packages/agents-a365-tooling/src/configuration/* Tooling configuration extending runtime configuration
packages/agents-a365-tooling/src/Utility.ts Deprecates URL construction methods in favor of service usage
packages/agents-a365-tooling/src/McpToolServerConfigurationService.ts Refactored to use configuration provider
packages/agents-a365-observability/src/configuration/* Observability configuration extending runtime configuration
packages/agents-a365-observability/src/utils/logging.ts Updated to use configuration provider for dynamic log level resolution
packages/agents-a365-observability/src/tracing/* Multiple tracing utilities updated to use configuration
packages/agents-a365-observability-hosting/src/caching/AgenticTokenCache.ts Refactored to accept configuration provider
packages/agents-a365-*-extensions-*/src/configuration/* Extension-specific configurations for OpenAI, LangChain, Claude tooling and observability
tests/**/*.test.ts Comprehensive test coverage for all new configuration classes
eslint.config.mjs New rules to enforce configuration usage and prevent deprecated API usage
docs/*.md Documentation updates reflecting the new configuration pattern

tmlsousa
tmlsousa previously approved these changes Feb 5, 2026
Copilot AI review requested due to automatic review settings February 6, 2026 06:03
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

Copilot reviewed 70 out of 71 changed files in this pull request and generated no new comments.

juliomenendez
juliomenendez previously approved these changes Feb 6, 2026
nikhilNava
nikhilNava previously approved these changes Feb 6, 2026
@fpfp100
Copy link
Contributor

fpfp100 commented Feb 6, 2026

CHANGELOG.md is not updated.

…ationImprovements

# Conflicts:
#	pnpm-lock.yaml
…ants

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 6, 2026 18:58
@pontemonti pontemonti enabled auto-merge (squash) February 6, 2026 19:00
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

Copilot reviewed 70 out of 71 changed files in this pull request and generated 11 comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

return override.trim().split(/\s+/);
}

// Returns production default - use ObservabilityConfiguration for proper env var support
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

This deprecated function now ignores A365_OBSERVABILITY_SCOPES_OVERRIDE and always returns the production default, which conflicts with the file-level note about keeping these utilities for backward compatibility. If backward compatibility is still a goal, consider preserving the prior env-var override behavior (and add an eslint suppression for process.env usage here) or clearly call out the breaking change and ensure versioning reflects it.

Suggested change
// Returns production default - use ObservabilityConfiguration for proper env var support
// eslint-disable-next-line no-process-env -- Deprecated helper preserved for backward compatibility with env var override
const overrideScope = process.env.A365_OBSERVABILITY_SCOPES_OVERRIDE;
if (overrideScope && overrideScope.trim().length > 0) {
return [overrideScope];
}
// Returns production default - use ObservabilityConfiguration for full configuration support

Copilot uses AI. Check for mistakes.
Comment on lines 186 to +191
* // => "https://agent365.svc.cloud.microsoft/agents/servers/MyServer/"
*
* @param serverName - The MCP server resource name.
* @param configProvider - Optional configuration provider. Defaults to defaultToolingConfigurationProvider.
* @returns The fully-qualified MCP server URL including trailing slash.
* @deprecated This method is for internal use only. Use McpToolServerConfigurationService instead.
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The JSDoc says BuildMcpServerUrl returns a URL “including trailing slash” and the example shows a trailing /, but the implementation returns ${baseUrl}/${serverName} with no trailing slash. Please align the documentation (or the return value) to avoid confusion and subtle URL concatenation bugs in callers.

Copilot uses AI. Check for mistakes.
*
* Inherited from RuntimeConfigurationOptions:
* - clusterCategory
* - isDevelopmentEnvironment
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The comment claims isDevelopmentEnvironment is inherited from RuntimeConfigurationOptions, but that option type doesn’t include an isDevelopmentEnvironment override (it’s a derived getter on RuntimeConfiguration). Update this doc block to avoid implying consumers can provide an isDevelopmentEnvironment override function.

Suggested change
* - isDevelopmentEnvironment

Copilot uses AI. Check for mistakes.
Comment on lines +353 to +357
import {
RuntimeConfiguration,
RuntimeConfigurationOptions,
createRuntimeConfigurationProvider,
} from '@microsoft/agents-a365-runtime';
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The docs reference createRuntimeConfigurationProvider, but that symbol doesn’t exist in the runtime package (no implementation/export in the repo). Update the example to use the actual provider API (DefaultConfigurationProvider, defaultRuntimeConfigurationProvider, or constructing a provider instance directly) so the snippet is copy/pasteable.

Copilot uses AI. Check for mistakes.
// Multi-tenant: per-request configuration with dynamic overrides
const options: RuntimeConfigurationOptions = {
clusterCategory: () => getTenantCluster(currentTenantId),
mcpPlatformAuthenticationScope: () => getTenantScope(currentTenantId),
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

This example assigns mcpPlatformAuthenticationScope inside RuntimeConfigurationOptions, but runtime options don’t define that property (it belongs to ToolingConfiguration). The snippet should either show ToolingConfigurationOptions/ToolingConfiguration usage for MCP scope, or remove that property from the runtime example.

Suggested change
mcpPlatformAuthenticationScope: () => getTenantScope(currentTenantId),

Copilot uses AI. Check for mistakes.
| `ENABLE_A365_OBSERVABILITY_PER_REQUEST_EXPORT` | Enable per-request export mode | `true`, `false` (default) |
| `A365_OBSERVABILITY_USE_CUSTOM_DOMAIN` | Use custom domain for export | `true`, `false` (default) |
| `A365_OBSERVABILITY_DOMAIN_OVERRIDE` | Custom domain URL override | URL string |
| `A365_OBSERVABILITY_LOG_LEVEL` | Internal logging level | `none` (default), `error`, `warn`, `info`, `debug` |
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

A365_OBSERVABILITY_LOG_LEVEL is documented as supporting debug, but the current logger implementation only recognizes none|info|warn|error (anything else becomes none). Either add debug handling in the logger or remove debug from this table to match behavior.

Suggested change
| `A365_OBSERVABILITY_LOG_LEVEL` | Internal logging level | `none` (default), `error`, `warn`, `info`, `debug` |
| `A365_OBSERVABILITY_LOG_LEVEL` | Internal logging level | `none` (default), `info`, `warn`, `error` |

Copilot uses AI. Check for mistakes.
* import { defaultToolingConfigurationProvider } from '@microsoft/agents-a365-tooling';
* const scope = defaultToolingConfigurationProvider.getConfiguration().mcpPlatformAuthenticationScope;
*/
export function getMcpPlatformAuthenticationScope(): string {
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

getMcpPlatformAuthenticationScope() is marked deprecated but now always returns the hardcoded production scope and ignores MCP_PLATFORM_AUTHENTICATION_SCOPE. That’s a behavior change for existing callers relying on env-based overrides. Consider restoring env-var support (with an eslint suppression) or updating docs/versioning to reflect that this deprecated API no longer honors overrides.

Suggested change
export function getMcpPlatformAuthenticationScope(): string {
export function getMcpPlatformAuthenticationScope(): string {
const envScope = process.env.MCP_PLATFORM_AUTHENTICATION_SCOPE;
if (envScope && envScope.trim().length > 0) {
return envScope;
}

Copilot uses AI. Check for mistakes.
Comment on lines +61 to +66
get mcpPlatformAuthenticationScope(): string {
const override = this.toolingOverrides.mcpPlatformAuthenticationScope?.();
if (override) return override;

const envValue = process.env.MCP_PLATFORM_AUTHENTICATION_SCOPE;
if (envValue) return envValue;
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

mcpPlatformAuthenticationScope returns override/env values without trimming and treats whitespace-only strings as valid. Since this value is used as an OAuth scope, leading/trailing whitespace can cause token exchange failures. Consider trimming and treating empty/whitespace-only values as “not set” (similar to how mcpPlatformEndpoint is handled).

Copilot uses AI. Check for mistakes.
Comment on lines +19 to +22
* { clusterCategory: () => 'gov' }
*
* // Dynamic per-tenant override using async context
* { clusterCategory: () => context.active().getValue(TENANT_CONFIG_KEY)?.cluster ?? 'prod' }
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The JSDoc examples use string literals like 'gov', but clusterCategory is typed as the ClusterCategory enum. Update examples to use ClusterCategory.gov (and similarly for other categories) to match the actual type and avoid misleading consumers.

Suggested change
* { clusterCategory: () => 'gov' }
*
* // Dynamic per-tenant override using async context
* { clusterCategory: () => context.active().getValue(TENANT_CONFIG_KEY)?.cluster ?? 'prod' }
* { clusterCategory: () => ClusterCategory.gov }
*
* // Dynamic per-tenant override using async context
* { clusterCategory: () => context.active().getValue(TENANT_CONFIG_KEY)?.cluster ?? ClusterCategory.prod }

Copilot uses AI. Check for mistakes.
Comment on lines +138 to +149
// Create configuration with programmatic overrides
const config = new RuntimeConfiguration({
clusterCategory: () => 'gov',
isNodeEnvDevelopment: () => false,
});

// Dynamic per-tenant configuration
const tenantConfigs = { 'tenant-a': 'prod', 'tenant-b': 'gov' };
let currentTenant = 'tenant-a';

const dynamicConfig = new RuntimeConfiguration({
clusterCategory: () => tenantConfigs[currentTenant] as ClusterCategory,
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The docs example uses clusterCategory: () => 'gov' but clusterCategory is a ClusterCategory enum. Update the snippet to import ClusterCategory and use ClusterCategory.gov (and likewise use enum values in tenantConfigs) so it compiles without casts.

Suggested change
// Create configuration with programmatic overrides
const config = new RuntimeConfiguration({
clusterCategory: () => 'gov',
isNodeEnvDevelopment: () => false,
});
// Dynamic per-tenant configuration
const tenantConfigs = { 'tenant-a': 'prod', 'tenant-b': 'gov' };
let currentTenant = 'tenant-a';
const dynamicConfig = new RuntimeConfiguration({
clusterCategory: () => tenantConfigs[currentTenant] as ClusterCategory,
import { RuntimeConfiguration, ClusterCategory } from '@microsoft/agents-a365-runtime';
// Create configuration with programmatic overrides
const config = new RuntimeConfiguration({
clusterCategory: () => ClusterCategory.gov,
isNodeEnvDevelopment: () => false,
});
// Dynamic per-tenant configuration
const tenantConfigs: Record<string, ClusterCategory> = {
'tenant-a': ClusterCategory.prod,
'tenant-b': ClusterCategory.gov,
};
let currentTenant = 'tenant-a';
const dynamicConfig = new RuntimeConfiguration({
clusterCategory: () => tenantConfigs[currentTenant],

Copilot uses AI. Check for mistakes.
?? RuntimeConfiguration.parseEnvInt(process.env.A365_PER_REQUEST_MAX_CONCURRENT_EXPORTS, DEFAULT_MAX_CONCURRENT_EXPORTS);
return value > 0 ? value : DEFAULT_MAX_CONCURRENT_EXPORTS;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

These configurations are for PerREquestPanProcessor which is added for a particular scenario asked. We don't expect for normal case that it would be used. Therefore, we don't want to it is exposed in the common ObservabilityConfiguration . Can you create a separated configuration class for PerREquestPanProcessor?

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.

5 participants