Skip to content

Comments

Python: Fixed Anthropic and GitHub Copilot samples#4025

Merged
eavanvalkenburg merged 9 commits intomicrosoft:mainfrom
dmytrostruk:sample-fixes-2
Feb 18, 2026
Merged

Python: Fixed Anthropic and GitHub Copilot samples#4025
eavanvalkenburg merged 9 commits intomicrosoft:mainfrom
dmytrostruk:sample-fixes-2

Conversation

@dmytrostruk
Copy link
Member

Motivation and Context

  • Fixed BaseAgent.create_session() to forward service_session_id parameter, enabling session resumption in ClaudeAgent and GitHubCopilotAgent samples
  • Fixed custom agent sample: replaced invalid Role.ASSISTANT enum usage with string literal "assistant" and fixed mismatched session state key
  • Simplified Anthropic skills sample for faster execution (fewer slides, smaller token budgets)
  • Updated Anthropic shell sample to list .md files instead of .py files for more meaningful output
  • Improved Anthropic client: added MCP tool call/result handling, signature support for thinking blocks, signature_delta parsing, and name parameter for hosted tools

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@dmytrostruk dmytrostruk self-assigned this Feb 18, 2026
Copilot AI review requested due to automatic review settings February 18, 2026 02:44
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Feb 18, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/anthropic/agent_framework_anthropic
   _chat_client.py3873690%458, 545, 547, 690–691, 754, 775–776, 819–821, 823, 836–837, 844–846, 850–852, 856–859, 972, 982, 1016, 1038, 1159, 1186–1187, 1204, 1217, 1230, 1255–1256
TOTAL21171332684% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
4170 239 💤 0 ❌ 0 🔥 1m 14s ⏱️

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 fixes several issues in Python samples and improves Anthropic client functionality to enhance session management, correct API usage, and add support for new Anthropic API features.

Changes:

  • Fixed BaseAgent.create_session() to forward service_session_id parameter, enabling proper session resumption in ClaudeAgent and GitHubCopilotAgent samples
  • Corrected custom agent sample to use string literal "assistant" instead of invalid Role.ASSISTANT enum usage and fixed session state key to use InMemoryHistoryProvider.DEFAULT_SOURCE_ID
  • Enhanced Anthropic client with MCP tool call/result message preparation, signature support for thinking blocks, and name parameter for hosted tools

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
python/packages/core/agent_framework/_agents.py Added service_session_id parameter forwarding in BaseAgent.create_session() to enable session resumption
python/samples/02-agents/providers/custom/custom_agent.py Fixed invalid Role.ASSISTANT usage to "assistant" string and corrected session state key to use InMemoryHistoryProvider.DEFAULT_SOURCE_ID
python/samples/02-agents/providers/anthropic/anthropic_skills.py Reduced token budgets and slide count for faster sample execution
python/samples/02-agents/providers/anthropic/anthropic_claude_with_shell.py Changed query to list .md files instead of .py files for more meaningful output
python/samples/02-agents/providers/anthropic/anthropic_advanced.py Added null check for content.text before printing reasoning to handle signature-only deltas
python/packages/anthropic/agent_framework_anthropic/_chat_client.py Added MCP tool call/result preparation, signature support for thinking blocks, name parameter for hosted tools, and improved streaming delta handling
python/packages/anthropic/tests/test_anthropic_client.py Added tests for signature handling in thinking blocks, signature_delta parsing, and name parameter in hosted tools
python/packages/core/agent_framework/_types.py Formatting change to simplify tools type annotation
python/samples/04-hosting/azure_functions/12_workflow_hitl/function_app.py Reordered imports alphabetically

@eavanvalkenburg eavanvalkenburg added this pull request to the merge queue Feb 18, 2026
Merged via the queue into microsoft:main with commit f900feb Feb 18, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants