Skip to content

Conversation

@msftairaamane
Copy link
Collaborator

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 Agent SDK Integration - Uses claude-sonnet-4-20250514 with extended thinking
  • Built-in Tools - Read, Write, WebSearch, Bash, Grep (no MCP setup yet)
  • Notification Support - Full @mention handling from Outlook, Word, and Teams
  • Observability Support
  • Dual Authentication - Anonymous mode for testing, agentic mode for production
  • Extended Thinking - Transparency into AI reasoning process

Files 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.py

Docs: README.md, AGENT-CODE-WALKTHROUGH.md, PARITY_ANALYSIS.md, NOTIFICATION_IMPLEMENTATION.md

Config: pyproject.toml, .env.template, ToolingManifest.json

Quick Start

npm install -g @anthropic-ai/claude-code && claude login
cp .env.template .env  # Add ANTHROPIC_API_KEY
uv venv && uv pip install -e .
uv run python start_with_generic_host.py

Testing

  • ✅ Server starts on http://localhost:3978
  • ✅ Extended thinking visible in responses
  • ✅ Notifications route correctly (both channels)
  • ✅ Built-in tools work (Read, Write, WebSearch, Bash, Grep)

Breaking Changes

None - new sample addition.

Future Work

  • P0: MCP support for Mail/Calendar/SharePoint tools
  • P1: Auto-instrumentation when SDK supports it
  • P2: Adaptive cards, response streaming

@msftairaamane msftairaamane requested a review from a team as a code owner November 11, 2025 00:37
@joaoolr1 joaoolr1 self-assigned this Nov 11, 2025
Copy link
Contributor

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 ?

Copilot AI review requested due to automatic review settings November 12, 2025 22:45
Copilot finished reviewing on behalf of msftairaamane November 12, 2025 22:48
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 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

Comment on lines +122 to +125
# 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
Copy link

Copilot AI Nov 12, 2025

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.

Suggested change
# 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 uses AI. Check for mistakes.
@@ -0,0 +1,53 @@
# Copyright (c) Microsoft. All rights reserved.
Copy link

Copilot AI Nov 12, 2025

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.

Copilot generated this review using guidance from repository custom instructions.
@@ -0,0 +1,163 @@
# Copyright (c) Microsoft. All rights reserved.
Copy link

Copilot AI Nov 12, 2025

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.

Copilot generated this review using guidance from repository custom instructions.
@@ -0,0 +1,36 @@
# Copyright (c) Microsoft. All rights reserved.
Copy link

Copilot AI Nov 12, 2025

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.

Copilot generated this review using guidance from repository custom instructions.
@@ -0,0 +1,549 @@
# Copyright (c) Microsoft. All rights reserved.
Copy link

Copilot AI Nov 12, 2025

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.

Copilot generated this review using guidance from repository custom instructions.
InferenceScope,
InvokeAgentDetails,
InvokeAgentScope,
ExecuteToolScope,
Copy link

Copilot AI Nov 12, 2025

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.

Suggested change
ExecuteToolScope,

Copilot uses AI. Check for mistakes.
ExecuteToolScope,
)
from microsoft_agents_a365.observability.core.middleware.baggage_builder import BaggageBuilder
from microsoft_agents_a365.observability.core.tool_type import ToolType
Copy link

Copilot AI Nov 12, 2025

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.

Suggested change
from microsoft_agents_a365.observability.core.tool_type import ToolType

Copilot uses AI. Check for mistakes.
create_tenant_details,
create_request_details,
create_inference_details,
create_tool_call_details,
Copy link

Copilot AI Nov 12, 2025

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.

Suggested change
create_tool_call_details,

Copilot uses AI. Check for mistakes.
invoke_scope.__exit__(type(e), e, e.__traceback__)
if baggage_context is not None:
baggage_context.__exit__(None, None, None)
except:
Copy link

Copilot AI Nov 12, 2025

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.

Suggested change
except:
except Exception:

Copilot uses AI. Check for mistakes.
Comment on lines +324 to +325
except:
pass
Copy link

Copilot AI Nov 12, 2025

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.

Suggested change
except:
pass
except Exception as cleanup_error:
logger.warning(f"Failed to clean up invoke/baggage context after error: {cleanup_error}")

Copilot uses AI. Check for mistakes.
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