-
Notifications
You must be signed in to change notification settings - Fork 5
feat: Add x-ms-agentid header #183
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
Conversation
There was a problem hiding this 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 adds support for the x-ms-agentid header in MCP platform requests to enable logging and analytics. The header value is determined using a priority-based fallback mechanism.
Changes:
- Added
x-ms-agentidheader support toGetToolRequestHeaders()with priority-based identifier resolution - Implemented new
listToolServers()signature with automatic token generation and agent identity resolution while maintaining backward compatibility with deprecated legacy signatures - Added helper methods
getAgentIdFromToken()andgetApplicationName()in the runtime package for identifier extraction
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/agents-a365-tooling/src/Utility.ts | Added x-ms-agentid header support and resolveAgentIdForHeader() method with priority fallback logic |
| packages/agents-a365-tooling/src/McpToolServerConfigurationService.ts | Added overloaded listToolServers() signature with automatic token generation, maintaining backward compatibility |
| packages/agents-a365-runtime/src/utility.ts | Added getAgentIdFromToken(), getApplicationName(), and package.json caching with eager initialization |
| tests/tooling/utility.test.ts | Comprehensive unit tests for GetToolRequestHeaders() and x-ms-agentid header logic |
| tests/tooling/mcp-tool-server-configuration-service.test.ts | Integration test verifying x-ms-agentid header is not included in sendChatHistory() |
| tests/tooling/McpToolServerConfigurationService.test.ts | Extensive tests for both legacy and new listToolServers() signatures with validation scenarios |
| tests/runtime/utility.test.ts | Unit tests for getAgentIdFromToken() and getApplicationName() with edge cases |
| docs/prd-x-ms-agentid-header.md | Comprehensive PRD documenting requirements, design, and implementation strategy |
* feat: Add x-ms-agentid header (#183) Co-authored-by: Johan Broberg <johanb@microsoft.com> * set gen_ai.caller.agent.type (#187) Co-authored-by: jsl517 <pefan@microsoft.com> * fix: update @isaacs/brace-expansion to version 5.0.1 (#181) Co-authored-by: Johan Broberg <johanb@microsoft.com> * feat: Add configuration provider interface (#184) * Add PRD for configuration provider for Agent 365 SDK * Change to dynamic resolution for configuration settings * feat: Add configuration provider interface * Update lock file * fix: add backward-compatible overloads to GetAgenticUserToken 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> * docs: clarify multi-tenant usage patterns for DefaultConfigurationProvider 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> * docs: clarify AgenticTokenCache singleton usage and export class - 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> * add utility methods for parsing environment variables in RuntimeConfiguration * add setLogger and resetLogger tests * docs: enhance JSDoc comments for RuntimeConfigurationOptions * docs: update deprecation notices and provide usage examples for environment utility functions * refactor: update McpToolRegistrationService to use ClaudeToolingConfiguration * refactor: update McpToolRegistrationService to use specific tooling configurations for LangChain and OpenAI * refactor: ensure undefined checks for tooling overrides in ToolingConfiguration * refactor: enhance ObservabilityConfiguration tests for environment variable handling * refactor: streamline McpToolRegistrationService by removing redundant utility imports and updating server listing logic * Address review feedback and discrepancies between documentation and code. * Address additional feedback; add missing tests, improve documentation * fix: add guardrails comment for PerRequestSpanProcessor default constants Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Johan Broberg <johanb@microsoft.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * Initial plan * Fix test: Add event method to custom logger mocks --------- Co-authored-by: Johan Broberg <johan@pontemonti.net> Co-authored-by: Johan Broberg <johanb@microsoft.com> Co-authored-by: PengF <126631706+fpfp100@users.noreply.github.com> Co-authored-by: jsl517 <pefan@microsoft.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
* clean up * support event logs and add events for export. * Fix test failure after adding event method to ILogger interface (#186) * Initial plan * Fix test failure by adding event method to ILogger mocks - Updated all mock ILogger objects in custom-logger.test.ts to include the event method - Updated setLogger validation to check for event method - Updated error message to include event method in validation Co-authored-by: fpfp100 <126631706+fpfp100@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: fpfp100 <126631706+fpfp100@users.noreply.github.com> * comments * comments * comments * comment * doc update * Resolve merge conflicts with main branch (#188) * feat: Add x-ms-agentid header (#183) Co-authored-by: Johan Broberg <johanb@microsoft.com> * set gen_ai.caller.agent.type (#187) Co-authored-by: jsl517 <pefan@microsoft.com> * fix: update @isaacs/brace-expansion to version 5.0.1 (#181) Co-authored-by: Johan Broberg <johanb@microsoft.com> * feat: Add configuration provider interface (#184) * Add PRD for configuration provider for Agent 365 SDK * Change to dynamic resolution for configuration settings * feat: Add configuration provider interface * Update lock file * fix: add backward-compatible overloads to GetAgenticUserToken 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> * docs: clarify multi-tenant usage patterns for DefaultConfigurationProvider 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> * docs: clarify AgenticTokenCache singleton usage and export class - 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> * add utility methods for parsing environment variables in RuntimeConfiguration * add setLogger and resetLogger tests * docs: enhance JSDoc comments for RuntimeConfigurationOptions * docs: update deprecation notices and provide usage examples for environment utility functions * refactor: update McpToolRegistrationService to use ClaudeToolingConfiguration * refactor: update McpToolRegistrationService to use specific tooling configurations for LangChain and OpenAI * refactor: ensure undefined checks for tooling overrides in ToolingConfiguration * refactor: enhance ObservabilityConfiguration tests for environment variable handling * refactor: streamline McpToolRegistrationService by removing redundant utility imports and updating server listing logic * Address review feedback and discrepancies between documentation and code. * Address additional feedback; add missing tests, improve documentation * fix: add guardrails comment for PerRequestSpanProcessor default constants Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Johan Broberg <johanb@microsoft.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> * Initial plan * Fix test: Add event method to custom logger mocks --------- Co-authored-by: Johan Broberg <johan@pontemonti.net> Co-authored-by: Johan Broberg <johanb@microsoft.com> Co-authored-by: PengF <126631706+fpfp100@users.noreply.github.com> Co-authored-by: jsl517 <pefan@microsoft.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --------- Co-authored-by: jsl517 <pefan@microsoft.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: Johan Broberg <johan@pontemonti.net> Co-authored-by: Johan Broberg <johanb@microsoft.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
No description provided.