-
Notifications
You must be signed in to change notification settings - Fork 3
Add Python Claude Agent SDK Sample #20
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
base: main
Are you sure you want to change the base?
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.
What's will be the plan for observability sdk's instead of creating helpers ?
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 PR introduces a new Python-based sample agent implementation using Anthropic's Claude Agent SDK, providing an alternative AI framework option within the Agent365 ecosystem. The sample demonstrates integration with Microsoft 365 Agents SDK for enterprise hosting, authentication, notifications, and observability.
Key Changes:
- Claude Agent SDK integration with extended thinking capabilities and built-in tools (Read, Write, WebSearch, Bash, Grep)
- Generic agent host server with dual authentication modes (anonymous for testing, agentic for production)
- Notification support for @mentions from Outlook, Word, and Teams with dual channel routing
- Observability implementation using Microsoft Agent 365 telemetry patterns
Reviewed Changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 21 comments.
Show a summary per file
| File | Description |
|---|---|
| agent.py | Core Claude agent implementation with message processing, notification handling, and observability integration |
| host_agent_server.py | Generic HTTP server host supporting any agent implementing AgentInterface with notification routing |
| start_with_generic_host.py | Entry point script to start the server with ClaudeAgent |
| agent_interface.py | Abstract base class defining required methods for hosted agents |
| local_authentication_options.py | Configuration dataclass for loading authentication settings from environment |
| observability_helpers.py | Helper utilities for creating observability objects (agent details, tenant details, inference details, tool call details) |
| token_cache.py | In-memory token caching for observability exporter authentication |
| pyproject.toml | Project dependencies and build configuration using uv package manager |
| README.md | Sample documentation with setup instructions, architecture overview, and troubleshooting guide |
| AGENT-CODE-WALKTHROUGH.md | Detailed code explanation and walkthrough for developers |
| .env.template | Environment variable template with configuration examples for Claude API, authentication, and observability settings |
| # Enable Agent 365 Observability Exporter (optional, defaults to false) | ||
| # Set to "true" to export telemetry to Agent 365 backend | ||
| # When false, uses ConsoleSpanExporter for local debugging | ||
| ENABLE_A365_OBSERVABILITY_EXPORTER=false |
Copilot
AI
Nov 12, 2025
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.
Duplicate configuration key detected. Lines 113-116 and 122-125 both define ENABLE_A365_OBSERVABILITY_EXPORTER with identical values. Remove the duplicate entry.
| # Enable Agent 365 Observability Exporter (optional, defaults to false) | |
| # Set to "true" to export telemetry to Agent 365 backend | |
| # When false, uses ConsoleSpanExporter for local debugging | |
| ENABLE_A365_OBSERVABILITY_EXPORTER=false |
| @@ -0,0 +1,53 @@ | |||
| # Copyright (c) Microsoft. All rights reserved. | |||
Copilot
AI
Nov 12, 2025
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.
The copyright header format is incorrect. According to the copyright header guidelines, Python files should use # Copyright (c) Microsoft Corporation. (with "Corporation", not just "Microsoft"). The correct format should be:
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.| @@ -0,0 +1,163 @@ | |||
| # Copyright (c) Microsoft. All rights reserved. | |||
Copilot
AI
Nov 12, 2025
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.
The copyright header format is incorrect. According to the copyright header guidelines, Python files should use # Copyright (c) Microsoft Corporation. (with "Corporation", not just "Microsoft"). The correct format should be:
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.| @@ -0,0 +1,36 @@ | |||
| # Copyright (c) Microsoft. All rights reserved. | |||
Copilot
AI
Nov 12, 2025
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.
The copyright header format is incorrect. According to the copyright header guidelines, Python files should use # Copyright (c) Microsoft Corporation. (with "Corporation", not just "Microsoft"). The correct format should be:
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.| @@ -0,0 +1,549 @@ | |||
| # Copyright (c) Microsoft. All rights reserved. | |||
Copilot
AI
Nov 12, 2025
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.
The copyright header format is incorrect. According to the copyright header guidelines, Python files should use # Copyright (c) Microsoft Corporation. (with "Corporation", not just "Microsoft"). The correct format should be:
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.| InferenceScope, | ||
| InvokeAgentDetails, | ||
| InvokeAgentScope, | ||
| ExecuteToolScope, |
Copilot
AI
Nov 12, 2025
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.
Import of 'ExecuteToolScope' is not used.
| ExecuteToolScope, |
| ExecuteToolScope, | ||
| ) | ||
| from microsoft_agents_a365.observability.core.middleware.baggage_builder import BaggageBuilder | ||
| from microsoft_agents_a365.observability.core.tool_type import ToolType |
Copilot
AI
Nov 12, 2025
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.
Import of 'ToolType' is not used.
| from microsoft_agents_a365.observability.core.tool_type import ToolType |
| create_tenant_details, | ||
| create_request_details, | ||
| create_inference_details, | ||
| create_tool_call_details, |
Copilot
AI
Nov 12, 2025
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.
Import of 'create_tool_call_details' is not used.
| create_tool_call_details, |
| invoke_scope.__exit__(type(e), e, e.__traceback__) | ||
| if baggage_context is not None: | ||
| baggage_context.__exit__(None, None, None) | ||
| except: |
Copilot
AI
Nov 12, 2025
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.
Except block directly handles BaseException.
| except: | |
| except Exception: |
| except: | ||
| pass |
Copilot
AI
Nov 12, 2025
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.
'except' clause does nothing but pass and there is no explanatory comment.
| except: | |
| pass | |
| except Exception as cleanup_error: | |
| logger.warning(f"Failed to clean up invoke/baggage context after error: {cleanup_error}") |
Add Python Claude Agent SDK Sample
Summary
This PR adds a new sample agent implementation using Anthropic's Claude Agent SDK with extended thinking capabilities, providing an alternative AI framework option alongside the existing samples.
claude-sonnet-4-20250514with extended thinkingFiles Added
Core:
agent.py,host_agent_server.py,start_with_generic_host.py,agent_interface.py,local_authentication_options.py,observability_helpers.py,token_cache.pyDocs:
README.md,AGENT-CODE-WALKTHROUGH.md,PARITY_ANALYSIS.md,NOTIFICATION_IMPLEMENTATION.mdConfig:
pyproject.toml,.env.template,ToolingManifest.jsonQuick Start
Testing
http://localhost:3978Breaking Changes
None - new sample addition.
Future Work