Skip to content

Commit e6121da

Browse files
msftairaamanepontemontiJohan Brobergrahuldevikar761JesuTerraz
authored
Add Python Claude Agent SDK Sample (#20)
* Update README title from '.NET SDK' to 'SDK Samples' (#1) * Added CODEOWNERS and .gitignore files (#2) * Added CODEOWNERS * Added .gitignore --------- Co-authored-by: Johan Broberg <johanb@microsoft.com> * Add .NET Semantic Kernel Sample Agent (#3) Co-authored-by: Johan Broberg <johanb@microsoft.com> * Update License to MIT License (#4) * Added Python OpenAI sample (#5) Co-authored-by: Johan Broberg <johanb@microsoft.com> * Add LangChain Sample (#7) Co-authored-by: Jesus Terrazas <jterrazas@microsoft.com> * Add Node.js Claude Sample Agent (#6) Co-authored-by: Johan Broberg <johanb@microsoft.com> * Fix Agent Notifs and update env (#8) Co-authored-by: Jesus Terrazas <jterrazas@microsoft.com> * [Python][AgentFramework] Adding Python Agent Framework Sample (#9) * Adding Python Agent Framework Sample * update to latest --------- Co-authored-by: Jesus Terrazas <jterrazas@microsoft.com> * Add TM (#11) Co-authored-by: Rahul Devikar <radevika@microsoft.com> * Revise README for Agent 365 Sample Agent (#13) * Revise README for Agent 365 Sample Agent Updated the README to improve clarity and correct typos. Added sections on prerequisites, running the sample, and troubleshooting. * Update README to remove external sample reference Removed reference to the semantic-kernel-multiturn sample. * Add TM (#14) Co-authored-by: Rahul Devikar <radevika@microsoft.com> * Update Agents SDK for LangChain Sample (#15) * update agents sdk version for langchain * Accept more recent versions * remove authority field, this is set by default --------- Co-authored-by: Jesus Terrazas <jterrazas@microsoft.com> * Adding Notifications on AF (#16) * Adding Notifications on AF * Update readme * PR comments * small fix * removed observability * update manifest * changes * setup fix * initial code for python claude sdk agent * initial code for python claude sdk agent * fixes * fixes * add documentation files * add documentation files * remove unused file * remove unused file * fixes * fixes * fixes * fixes * Removed duplicate entry of ENABLE_A365_OBSERVABILITY_EXPORTER configurstion key * Removed duplicate entry of ENABLE_A365_OBSERVABILITY_EXPORTER configurstion key * Corrected copyright header format * Corrected copyright header format * Removed inconsistent whitespaces * Removed inconsistent whitespaces * Removed unused imports, inconsistent indentations, and removed unnecessary flags, and cleaned up the logic around observability * Removed unused imports, inconsistent indentations, and removed unnecessary flags, and cleaned up the logic around observability * Removed ENABLE_OBSERVABILITY variable from env file and updated README file * Removed ENABLE_OBSERVABILITY variable from env file and updated README file * Updated AGENT-CODE-WALKTHROUGH * Updated AGENT-CODE-WALKTHROUGH * Revert "Updated AGENT-CODE-WALKTHROUGH" This reverts commit e117ac1. * Revert "Removed ENABLE_OBSERVABILITY variable from env file and updated README file" This reverts commit 2d305dc. * Revert "Removed unused imports, inconsistent indentations, and removed unnecessary flags, and cleaned up the logic around observability" This reverts commit 57d95f1. * Removed unused imports, inconsistent indentations and updated the README file * Updated AGENT-CODE-WALKTHROUGH * Minor changes * Made changes including notification flag, removing main method, removed unwanted files, etc * Fixed issues in workflows --------- Co-authored-by: Johan Broberg <johan@pontemonti.net> Co-authored-by: Johan Broberg <johanb@microsoft.com> Co-authored-by: rahuldevikar761 <19936206+rahuldevikar761@users.noreply.github.com> Co-authored-by: Jesus Daniel Terrazas <96103167+JesuTerraz@users.noreply.github.com> Co-authored-by: Jesus Terrazas <jterrazas@microsoft.com> Co-authored-by: Rahul Devikar <radevika@microsoft.com> Co-authored-by: Mrunal Suyoga Hirve <112517572+mrunalhirve128@users.noreply.github.com> Co-authored-by: Joan Bency <joanbency@microsoft.com>
1 parent 014a3ce commit e6121da

12 files changed

Lines changed: 2609 additions & 0 deletions
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Python Claude Sample - Build Validation
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
paths:
9+
- 'python/claude/sample-agent/**'
10+
- '.github/workflows/python-claude-sample.yml'
11+
pull_request:
12+
branches:
13+
- main
14+
- develop
15+
paths:
16+
- 'python/claude/sample-agent/**'
17+
- '.github/workflows/python-claude-sample.yml'
18+
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
build-and-validate:
24+
name: Build and Validate Claude Sample
25+
runs-on: ubuntu-latest
26+
defaults:
27+
run:
28+
working-directory: python/claude/sample-agent
29+
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@v4
33+
34+
- name: Set up Python
35+
uses: actions/setup-python@v5
36+
with:
37+
python-version: '3.11'
38+
39+
- name: Install uv
40+
run: |
41+
curl -LsSf https://astral.sh/uv/install.sh | sh
42+
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
43+
44+
- name: Create virtual environment
45+
run: uv venv
46+
47+
- name: Install dependencies
48+
run: |
49+
uv pip install -e .
50+
51+
- name: Check Python syntax
52+
run: |
53+
python -m py_compile agent.py
54+
python -m py_compile host_agent_server.py
55+
python -m py_compile start_with_generic_host.py
56+
python -m py_compile agent_interface.py
57+
python -m py_compile local_authentication_options.py
58+
python -m py_compile token_cache.py
59+
python -m py_compile observability_helpers.py
60+
61+
- name: Validate pyproject.toml
62+
run: |
63+
if [ ! -f "pyproject.toml" ]; then
64+
echo "pyproject.toml not found"
65+
exit 1
66+
fi
67+
python -c "import tomllib; tomllib.load(open('pyproject.toml', 'rb'))" 2>/dev/null || python -c "import tomli; tomli.load(open('pyproject.toml', 'rb'))"
68+
69+
- name: Check for required files
70+
run: |
71+
required_files=("README.md" "AGENT-CODE-WALKTHROUGH.md" ".env.template" "ToolingManifest.json")
72+
for file in "${required_files[@]}"; do
73+
if [ ! -f "$file" ]; then
74+
echo "Required file $file not found"
75+
exit 1
76+
fi
77+
done
78+
79+
- name: Validate imports
80+
run: |
81+
python -c "
82+
import sys
83+
sys.path.insert(0, '.')
84+
try:
85+
import agent_interface
86+
import local_authentication_options
87+
import token_cache
88+
import observability_helpers
89+
print('✅ All imports validated successfully')
90+
except ImportError as e:
91+
print(f'❌ Import validation failed: {e}')
92+
sys.exit(1)
93+
"
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# =============================================================================
2+
# CLAUDE AGENT SDK CONFIGURATION
3+
# =============================================================================
4+
5+
# Anthropic API Key (required)
6+
# Get your API key from: https://console.anthropic.com/
7+
ANTHROPIC_API_KEY=your_anthropic_api_key_here
8+
9+
# Claude Model to use (optional, defaults to claude-sonnet-4-20250514)
10+
# Options: claude-opus-4-20250514, claude-sonnet-4-20250514, claude-haiku-4-20250514
11+
CLAUDE_MODEL=claude-sonnet-4-20250514
12+
13+
14+
# =============================================================================
15+
# MCP (Model Context Protocol) CONFIGURATION (Optional)
16+
# =============================================================================
17+
18+
# MCP Server Host
19+
MCP_SERVER_HOST=
20+
21+
# MCP Platform Endpoint
22+
MCP_PLATFORM_ENDPOINT=
23+
24+
# =============================================================================
25+
# MICROSOFT 365 AGENTS SDK CONFIGURATION
26+
# =============================================================================
27+
28+
# Agent ID (required for agentic authentication)
29+
AGENT_ID=your-agent-id
30+
31+
# Environment ID (optional, defaults to prod)
32+
# Options: dev, test, preprod, prod
33+
ENVIRONMENT_ID=prod
34+
ENV_ID=
35+
36+
# =============================================================================
37+
# AUTHENTICATION OPTIONS
38+
# =============================================================================
39+
40+
# Use agentic authentication (optional, defaults to false)
41+
# Set to "true" to use agentic authentication with M365 Agents SDK
42+
USE_AGENTIC_AUTH=false
43+
44+
# Bearer token (required if not using client credentials)
45+
# Use for development/testing without full app registration
46+
BEARER_TOKEN=your_bearer_token_here
47+
48+
# Agentic authentication scope (required if USE_AGENTIC_AUTH=true)
49+
# Example: https://api.powerplatform.com/.default
50+
AGENTIC_AUTH_SCOPE=https://api.powerplatform.com/.default
51+
52+
# =============================================================================
53+
# AGENT365 AGENTIC AUTHENTICATION CONFIGURATION
54+
# =============================================================================
55+
56+
# Service connection settings for Agent365
57+
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__CLIENTID=
58+
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__CLIENTSECRET=
59+
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__TENANTID=
60+
CONNECTIONS__SERVICE_CONNECTION__SETTINGS__SCOPES=
61+
62+
# Agent application user authorization settings
63+
AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__TYPE=AgenticUserAuthorization
64+
AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__SCOPES=https://graph.microsoft.com/.default
65+
AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__ALTERNATEBLUEPRINTCONNECTIONNAME=https://graph.microsoft.com/.default
66+
67+
# Connections map configuration
68+
CONNECTIONSMAP_0_SERVICEURL=*
69+
CONNECTIONSMAP_0_CONNECTION=SERVICE_CONNECTION
70+
71+
# =============================================================================
72+
# CLIENT CREDENTIALS AUTHENTICATION (Optional)
73+
# =============================================================================
74+
# For production deployments, use client credentials instead of bearer token
75+
76+
# Azure AD Client ID
77+
# CLIENT_ID=your-client-id
78+
79+
# Azure AD Tenant ID
80+
# TENANT_ID=your-tenant-id
81+
82+
# Azure AD Client Secret
83+
# CLIENT_SECRET=your-client-secret
84+
85+
# =============================================================================
86+
# SERVER CONFIGURATION
87+
# =============================================================================
88+
89+
# Port to run the server on (optional, defaults to 3978)
90+
PORT=3978
91+
92+
# =============================================================================
93+
# LOGGING CONFIGURATION
94+
# =============================================================================
95+
96+
# Logging level (optional, defaults to INFO)
97+
# Options: DEBUG, INFO, WARNING, ERROR, CRITICAL
98+
LOG_LEVEL=INFO
99+
100+
# =============================================================================
101+
# OBSERVABILITY CONFIGURATION (Optional)
102+
# =============================================================================
103+
104+
# Enable observability tracing (set to true to track agent operations)
105+
ENABLE_OBSERVABILITY=true
106+
107+
# Service name for observability
108+
OBSERVABILITY_SERVICE_NAME=claude-agent
109+
110+
# Service namespace for observability
111+
OBSERVABILITY_SERVICE_NAMESPACE=agent365-samples
112+
113+
# Enable Agent 365 Observability Exporter (optional, defaults to false)
114+
# Set to "true" to export telemetry to Agent 365 backend
115+
# When false, uses ConsoleSpanExporter for local debugging
116+
ENABLE_A365_OBSERVABILITY_EXPORTER=false
117+
118+
# Python environment (influences target cluster/category)
119+
# Options: development, production
120+
PYTHON_ENVIRONMENT=development

0 commit comments

Comments
 (0)