-
Notifications
You must be signed in to change notification settings - Fork 19
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
Merged
Merged
Changes from all commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
7c1cbc9
Update README title from '.NET SDK' to 'SDK Samples' (#1)
pontemonti d81af2c
Added CODEOWNERS and .gitignore files (#2)
pontemonti c3c1e74
Add .NET Semantic Kernel Sample Agent (#3)
pontemonti 1d90369
Update License to MIT License (#4)
rahuldevikar761 39a239c
Added Python OpenAI sample (#5)
pontemonti 6f236de
Add LangChain Sample (#7)
JesuTerraz 4cbd949
Add Node.js Claude Sample Agent (#6)
pontemonti 1c0b548
Fix Agent Notifs and update env (#8)
JesuTerraz ea11209
[Python][AgentFramework] Adding Python Agent Framework Sample (#9)
JesuTerraz 9b124ba
Add TM (#11)
rahuldevikar761 e99aa17
Revise README for Agent 365 Sample Agent (#13)
pontemonti d221266
Add TM (#14)
rahuldevikar761 e733e9c
Update Agents SDK for LangChain Sample (#15)
JesuTerraz 45fffa8
Adding Notifications on AF (#16)
mrunalhirve128 c311f08
initial code for python claude sdk agent
msftairaamane b0b32c2
initial code for python claude sdk agent
msftairaamane e3cde97
fixes
msftairaamane d325188
fixes
msftairaamane de6f424
add documentation files
msftairaamane 188cfca
add documentation files
msftairaamane a2da548
remove unused file
msftairaamane 3f0cbbe
remove unused file
msftairaamane 198f9dc
fixes
msftairaamane e42357e
fixes
msftairaamane 183ffec
fixes
msftairaamane aacd349
fixes
msftairaamane 21fcf03
Removed duplicate entry of ENABLE_A365_OBSERVABILITY_EXPORTER configu…
8aacef6
Removed duplicate entry of ENABLE_A365_OBSERVABILITY_EXPORTER configu…
c3c7f0b
Corrected copyright header format
87cd9a0
Corrected copyright header format
2cbabfa
Removed inconsistent whitespaces
5d846b2
Removed inconsistent whitespaces
57d95f1
Removed unused imports, inconsistent indentations, and removed unnece…
27a13f0
Removed unused imports, inconsistent indentations, and removed unnece…
2d305dc
Removed ENABLE_OBSERVABILITY variable from env file and updated READM…
b93e41d
Removed ENABLE_OBSERVABILITY variable from env file and updated READM…
e117ac1
Updated AGENT-CODE-WALKTHROUGH
d8c3a07
Updated AGENT-CODE-WALKTHROUGH
1a8cd55
Merge branch 'airaamane/claude-python' of https://github.com/microsof…
df761a7
Revert "Updated AGENT-CODE-WALKTHROUGH"
a820956
Revert "Removed ENABLE_OBSERVABILITY variable from env file and updat…
56dc696
Revert "Removed unused imports, inconsistent indentations, and remove…
1aba903
Removed unused imports, inconsistent indentations and updated the REA…
73b9588
Updated AGENT-CODE-WALKTHROUGH
3c9a6ea
Minor changes
82b14b8
Made changes including notification flag, removing main method, remov…
e215f1d
Fixed issues in workflows
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| name: Python Claude Sample - Build Validation | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| - develop | ||
| paths: | ||
| - 'python/claude/sample-agent/**' | ||
| - '.github/workflows/python-claude-sample.yml' | ||
| pull_request: | ||
| branches: | ||
| - main | ||
| - develop | ||
| paths: | ||
| - 'python/claude/sample-agent/**' | ||
| - '.github/workflows/python-claude-sample.yml' | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build-and-validate: | ||
| name: Build and Validate Claude Sample | ||
| runs-on: ubuntu-latest | ||
| defaults: | ||
| run: | ||
| working-directory: python/claude/sample-agent | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - name: Install uv | ||
| run: | | ||
| curl -LsSf https://astral.sh/uv/install.sh | sh | ||
| echo "$HOME/.cargo/bin" >> $GITHUB_PATH | ||
|
|
||
| - name: Create virtual environment | ||
| run: uv venv | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| uv pip install -e . | ||
|
|
||
| - name: Check Python syntax | ||
| run: | | ||
| python -m py_compile agent.py | ||
| python -m py_compile host_agent_server.py | ||
| python -m py_compile start_with_generic_host.py | ||
| python -m py_compile agent_interface.py | ||
| python -m py_compile local_authentication_options.py | ||
| python -m py_compile token_cache.py | ||
| python -m py_compile observability_helpers.py | ||
|
|
||
| - name: Validate pyproject.toml | ||
| run: | | ||
| if [ ! -f "pyproject.toml" ]; then | ||
| echo "pyproject.toml not found" | ||
| exit 1 | ||
| fi | ||
| python -c "import tomllib; tomllib.load(open('pyproject.toml', 'rb'))" 2>/dev/null || python -c "import tomli; tomli.load(open('pyproject.toml', 'rb'))" | ||
|
|
||
| - name: Check for required files | ||
| run: | | ||
| required_files=("README.md" "AGENT-CODE-WALKTHROUGH.md" ".env.template" "ToolingManifest.json") | ||
| for file in "${required_files[@]}"; do | ||
| if [ ! -f "$file" ]; then | ||
| echo "Required file $file not found" | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| - name: Validate imports | ||
| run: | | ||
| python -c " | ||
| import sys | ||
| sys.path.insert(0, '.') | ||
| try: | ||
| import agent_interface | ||
| import local_authentication_options | ||
| import token_cache | ||
| import observability_helpers | ||
| print('✅ All imports validated successfully') | ||
| except ImportError as e: | ||
| print(f'❌ Import validation failed: {e}') | ||
| sys.exit(1) | ||
| " | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,6 +73,7 @@ build/ | |
| .eggs/ | ||
| .pytest_cache/ | ||
| _version.py | ||
| uv.lock | ||
|
|
||
| # Virtual environments | ||
| .venv/ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| # ============================================================================= | ||
| # CLAUDE AGENT SDK CONFIGURATION | ||
| # ============================================================================= | ||
|
|
||
| # Anthropic API Key (required) | ||
| # Get your API key from: https://console.anthropic.com/ | ||
| ANTHROPIC_API_KEY=your_anthropic_api_key_here | ||
|
|
||
| # Claude Model to use (optional, defaults to claude-sonnet-4-20250514) | ||
| # Options: claude-opus-4-20250514, claude-sonnet-4-20250514, claude-haiku-4-20250514 | ||
| CLAUDE_MODEL=claude-sonnet-4-20250514 | ||
|
|
||
|
|
||
| # ============================================================================= | ||
| # MCP (Model Context Protocol) CONFIGURATION (Optional) | ||
| # ============================================================================= | ||
|
|
||
| # MCP Server Host | ||
| MCP_SERVER_HOST= | ||
|
|
||
| # MCP Platform Endpoint | ||
| MCP_PLATFORM_ENDPOINT= | ||
|
|
||
| # ============================================================================= | ||
| # MICROSOFT 365 AGENTS SDK CONFIGURATION | ||
| # ============================================================================= | ||
|
|
||
| # Agent ID (required for agentic authentication) | ||
| AGENT_ID=your-agent-id | ||
|
|
||
| # Environment ID (optional, defaults to prod) | ||
| # Options: dev, test, preprod, prod | ||
| ENVIRONMENT_ID=prod | ||
| ENV_ID= | ||
|
|
||
| # ============================================================================= | ||
| # AUTHENTICATION OPTIONS | ||
| # ============================================================================= | ||
|
|
||
| # Use agentic authentication (optional, defaults to false) | ||
| # Set to "true" to use agentic authentication with M365 Agents SDK | ||
| USE_AGENTIC_AUTH=false | ||
|
|
||
| # Bearer token (required if not using client credentials) | ||
| # Use for development/testing without full app registration | ||
| BEARER_TOKEN=your_bearer_token_here | ||
|
|
||
| # Agentic authentication scope (required if USE_AGENTIC_AUTH=true) | ||
| # Example: https://api.powerplatform.com/.default | ||
| AGENTIC_AUTH_SCOPE=https://api.powerplatform.com/.default | ||
|
|
||
| # ============================================================================= | ||
| # AGENT365 AGENTIC AUTHENTICATION CONFIGURATION | ||
| # ============================================================================= | ||
|
|
||
| # Service connection settings for Agent365 | ||
| CONNECTIONS__SERVICE_CONNECTION__SETTINGS__CLIENTID= | ||
| CONNECTIONS__SERVICE_CONNECTION__SETTINGS__CLIENTSECRET= | ||
| CONNECTIONS__SERVICE_CONNECTION__SETTINGS__TENANTID= | ||
| CONNECTIONS__SERVICE_CONNECTION__SETTINGS__SCOPES= | ||
|
|
||
| # Agent application user authorization settings | ||
| AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__TYPE=AgenticUserAuthorization | ||
| AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__SCOPES=https://graph.microsoft.com/.default | ||
| AGENTAPPLICATION__USERAUTHORIZATION__HANDLERS__AGENTIC__SETTINGS__ALTERNATEBLUEPRINTCONNECTIONNAME=https://graph.microsoft.com/.default | ||
|
|
||
| # Connections map configuration | ||
| CONNECTIONSMAP_0_SERVICEURL=* | ||
| CONNECTIONSMAP_0_CONNECTION=SERVICE_CONNECTION | ||
|
|
||
| # ============================================================================= | ||
| # CLIENT CREDENTIALS AUTHENTICATION (Optional) | ||
| # ============================================================================= | ||
| # For production deployments, use client credentials instead of bearer token | ||
|
|
||
| # Azure AD Client ID | ||
| # CLIENT_ID=your-client-id | ||
|
|
||
| # Azure AD Tenant ID | ||
| # TENANT_ID=your-tenant-id | ||
|
|
||
| # Azure AD Client Secret | ||
| # CLIENT_SECRET=your-client-secret | ||
|
|
||
| # ============================================================================= | ||
| # SERVER CONFIGURATION | ||
| # ============================================================================= | ||
|
|
||
| # Port to run the server on (optional, defaults to 3978) | ||
| PORT=3978 | ||
|
|
||
| # ============================================================================= | ||
| # LOGGING CONFIGURATION | ||
| # ============================================================================= | ||
|
|
||
| # Logging level (optional, defaults to INFO) | ||
| # Options: DEBUG, INFO, WARNING, ERROR, CRITICAL | ||
| LOG_LEVEL=INFO | ||
|
|
||
| # ============================================================================= | ||
| # OBSERVABILITY CONFIGURATION (Optional) | ||
| # ============================================================================= | ||
|
|
||
| # Enable observability tracing (set to true to track agent operations) | ||
| ENABLE_OBSERVABILITY=true | ||
|
|
||
| # Service name for observability | ||
| OBSERVABILITY_SERVICE_NAME=claude-agent | ||
|
|
||
| # Service namespace for observability | ||
| OBSERVABILITY_SERVICE_NAMESPACE=agent365-samples | ||
|
|
||
| # 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 | ||
|
|
||
| # Python environment (influences target cluster/category) | ||
| # Options: development, production | ||
| PYTHON_ENVIRONMENT=development |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.