Skip to content

Claude python sample - #275

Merged
Grant Harris (gwharris7) merged 10 commits into
mainfrom
users/gwharris7/claude-python
Apr 17, 2026
Merged

Claude python sample#275
Grant Harris (gwharris7) merged 10 commits into
mainfrom
users/gwharris7/claude-python

Conversation

@gwharris7

Copy link
Copy Markdown
Contributor

Update the Claude python sample to use the SDK, clarify setup, and remove custom code when possible.

This pull request refactors and simplifies the configuration, authentication, and observability setup for the Claude sample agent, aligning environment variables and SDK usage with current best practices. It removes deprecated or redundant configuration options, streamlines MCP (Model Context Protocol) tool discovery, and updates dependencies and code to use canonical sources and naming conventions. The changes also improve error handling and robustness in agent message processing.

Configuration and Environment Variable Refactoring:

  • Overhauled .env.template to remove deprecated MCP and authentication variables, consolidate configuration under canonical CONNECTIONS__SERVICE_CONNECTION__SETTINGS__* keys, and clarify usage for agentic authentication and observability. Updated connection map and MCP configuration to use double-underscore naming for compatibility. [1] [2]
  • Updated create_auth_configuration to read client credentials from the canonical CONNECTIONS__SERVICE_CONNECTION__SETTINGS__* environment variables, eliminating duplication and potential misconfiguration.

MCP Tooling and Agent Logic Simplification:

  • Simplified MCP tool discovery and registration in agent.py by removing unused code, unnecessary comments, and redundant tool listing logic. Now relies on the SDK for agent identity resolution and tool registration. [1] [2]
  • Updated agent identity resolution in host_agent_server.py to use get_agentic_instance_id() for consistency with the SDK.

Observability and Dependency Updates:

  • Removed configuration and setup for observability from the host startup path, delegating observability enablement to other mechanisms. Updated package names in pyproject.toml to use the correct dash-separated format for Agent 365 SDK dependencies. [1] [2] [3]

Message Processing and Error Handling Improvements:

  • Improved error handling in activity handlers, especially for sending welcome and removal messages, by wrapping sends in try/except blocks and logging failures.
  • Refactored baggage and scope management in message processing to remove unnecessary tenant details, streamline context propagation, and clarify scope argument usage. [1] [2] [3]

These changes collectively modernize the sample agent, reduce configuration errors, and improve maintainability and clarity for future development.

@gwharris7
Grant Harris (gwharris7) requested a review from a team as a code owner April 14, 2026 23:23
Copilot AI review requested due to automatic review settings April 14, 2026 23:23

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

Note

Copilot was unable to run its full agentic suite in this review.

This PR modernizes the Claude Python sample agent by aligning configuration and runtime behavior with the Agent 365 SDK, simplifying MCP tool discovery/registration, and updating observability context propagation.

Changes:

  • Refactors observability context helpers to use newer SDK models (e.g., UserDetails, InvokeAgentScopeDetails) and updated agent identity resolution.
  • Replaces custom MCP server/tool discovery/execution logic with an SDK-backed discovery wrapper that exposes Claude-compatible MCP config.
  • Updates sample configuration and dependencies to use canonical env var keys and normalized package names.

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
python/claude/sample-agent/turn_context_utils.py Updates observability detail builders and agent identity extraction to match newer SDK types.
python/claude/sample-agent/pyproject.toml Renames Agent 365 dependency distributions to dash-separated names and updates comments.
python/claude/sample-agent/mcp_tool_registration_service.py Replaces custom MCP logic with a thin SDK-backed wrapper returning Claude MCP server configs + allowed tool patterns.
python/claude/sample-agent/host_agent_server.py Improves handler robustness, switches agent ID resolution to get_agentic_instance_id(), and reads auth config from canonical CONNECTIONS__... keys.
python/claude/sample-agent/agent.py Simplifies MCP setup to rely on the SDK wrapper; adjusts observability scope construction to new APIs.
python/claude/sample-agent/.env.template Clarifies canonical auth/service-connection env vars and updates MCP/observability knobs.
.github/workflows/python-claude-sample.yml Fixes indentation for import validation step.

Comment thread python/claude/sample-agent/mcp_tool_registration_service.py
Comment thread python/claude/sample-agent/mcp_tool_registration_service.py
Comment thread python/claude/sample-agent/mcp_tool_registration_service.py
Comment thread python/claude/sample-agent/turn_context_utils.py
Comment thread python/claude/sample-agent/turn_context_utils.py
Comment thread python/claude/sample-agent/turn_context_utils.py
Comment thread python/claude/sample-agent/turn_context_utils.py
Comment thread python/claude/sample-agent/pyproject.toml Outdated
@github-actions

github-actions Bot commented Apr 15, 2026

Copy link
Copy Markdown

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Comment thread python/claude/sample-agent/host_agent_server.py Fixed
Comment thread python/claude/sample-agent/host_agent_server.py Fixed
@gwharris7
Grant Harris (gwharris7) enabled auto-merge (squash) April 17, 2026 02:36
@gwharris7
Grant Harris (gwharris7) merged commit 83f646f into main Apr 17, 2026
34 checks passed
@gwharris7
Grant Harris (gwharris7) deleted the users/gwharris7/claude-python branch April 17, 2026 21:05
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.

4 participants