Skip to content

Updated Claude Python to use A365 oservability SDK and MCP tooling - #148

Merged
Joan Bency (JoanBency) merged 9 commits into
mainfrom
JoanBency/claude-python
Jan 15, 2026
Merged

Joan Bency (JoanBency) merged 9 commits into
mainfrom
JoanBency/claude-python

Conversation

@JoanBency

@JoanBency Joan Bency (JoanBency) commented Jan 12, 2026 •

Copy link
Copy Markdown
Contributor

Migrate Claude Python Sample to Observability SDK and Remove Configuration Flags

Summary

Migrates Claude Python sample to use Observability SDK directly (matching OpenAI Python sample) and addresses previous PR feedback by removing hardcoded auth handler names and configuration flags.

**Key Changes

Removed:**

❌ ENABLE_OBSERVABILITY and USE_AGENTIC_AUTH environment variable flags
❌ observability_helpers.py file (replaced by direct SDK usage)
❌ OBSERVABILITY_AVAILABLE and NOTIFICATIONS_AVAILABLE optional import flags
❌ Hardcoded "AGENTIC" auth handler strings
❌ Manual InvokeAgentScope and InferenceScope creation

Added:

✅ _setup_observability() method with configure() pattern (like OpenAI sample)
✅ token_resolver() method for Agent 365 Observability exporter
✅ self.auth_handler_name as configurable property
✅ BaggageBuilder context in message handlers
✅ auth_handler_name parameter to agent methods

Updated:

Method signatures: process_user_message() and handle_agent_notification_activity() now accept auth_handler_name
Dependencies: Added microsoft_agents_a365_tooling for MCP support
.env.template: Simplified observability configuration

Addresses PR Feedback

✅ Removed USE_AGENTIC_AUTH env var - auth type determined by SDK config
✅ No hardcoded auth handler names - uses configurable property
✅ Notifications always imported (not optional)
✅ Auth handler ID properly passed to exchange_token()

Breaking Changes

ENABLE_OBSERVABILITY and USE_AGENTIC_AUTH env vars no longer used
process_user_message() and handle_agent_notification_activity() signatures changed
observability_helpers.py removed

Testing

Test with agentic auth, bearer token, and client credentials
Verify observability traces generated correctly
Test notifications (email, Word @mentions)
Test with Agents Playground and Teams

Copilot AI review requested due to automatic review settings January 12, 2026 10:37
@JoanBency
Joan Bency (JoanBency) requested a review from a team as a code owner January 12, 2026 10:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the Claude Python sample to use the Agent 365 Observability SDK directly (matching the OpenAI Python sample pattern) and removes configuration complexity by eliminating environment variable flags like ENABLE_OBSERVABILITY and USE_AGENTIC_AUTH. The migration simplifies the codebase by removing the observability_helpers.py abstraction layer and adopting a direct SDK configuration approach.

Changes:

  • Removed observability_helpers.py and optional observability import patterns, replacing them with direct SDK usage via configure() method
  • Added auth_handler_name parameter to agent methods (process_user_message and handle_agent_notification_activity) to eliminate hardcoded auth handler strings
  • Integrated optional MCP tooling support with graceful fallback for enterprise M365 tool integration
  • Updated dependencies to include microsoft_agents_a365_tooling and reorganized package specifications in pyproject.toml
  • Simplified .env.template by removing ENABLE_OBSERVABILITY and USE_AGENTIC_AUTH flags
  • Added BaggageBuilder context propagation in message handlers for proper observability tracing

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pyproject.toml Updated project description, added authors section, and reorganized dependencies to include MCP tooling and observability packages
observability_helpers.py Deleted entire helper file as observability now uses SDK directly
host_agent_server.py Added auth_handler_name property, integrated BaggageBuilder context in message handler, updated token caching to use auth handler name, and removed conditional observability configuration
agent.py Added _setup_observability() and token_resolver() methods, integrated optional MCP tooling, updated method signatures to accept auth_handler_name, removed manual scope creation code
.env.template Removed ENABLE_OBSERVABILITY and USE_AGENTIC_AUTH flags, updated observability configuration comments

Comment thread python/claude/sample-agent/host_agent_server.py Outdated
Comment thread python/claude/sample-agent/pyproject.toml Outdated
Comment thread python/claude/sample-agent/agent.py Outdated
@JoanBency

Copy link
Copy Markdown
Contributor Author

Joan Bency (@JoanBency) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"

Contributor License Agreement

@microsoft-github-policy-service agree company="Microsoft"

Comment thread python/claude/sample-agent/.env.template

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good. Seems Julio has already looked at it from Obs point of view. Thanks for updating the Sample

…age- Initialize SDK once at module load to prevent duplicate configurations- Add flag to track initialization state

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Please consider fixing these in a follow up PR

Comment thread python/claude/sample-agent/host_agent_server.py Outdated
Comment thread python/claude/sample-agent/host_agent_server.py Outdated
Comment thread python/claude/sample-agent/agent.py Outdated
Comment thread python/claude/sample-agent/agent.py Outdated
@JoanBency
Joan Bency (JoanBency) merged commit ba390df into main Jan 15, 2026
6 of 7 checks passed
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