Python: Add AssistantReasoningEvent and AssistantReasoningDeltaEvent support to GitHubCopilotAgent#3566
Closed
Python: Add AssistantReasoningEvent and AssistantReasoningDeltaEvent support to GitHubCopilotAgent#3566
Conversation
…to GitHubCopilotAgent Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add mapping for AssistentReasoningEvent and AssistantReasoningDeltaEvent
Add AssistantReasoningEvent and AssistantReasoningDeltaEvent support to GitHubCopilotAgent
Jan 31, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds support for GitHub Copilot SDK's AssistantReasoningEvent and AssistantReasoningDeltaEvent to properly handle and preserve model reasoning/thinking output as TextReasoningContent instead of losing it or storing it as generic AIContent.
Changes:
- Added event handlers for reasoning events in both C# and Python implementations
- Created conversion methods to map reasoning events to
TextReasoningContent - Added comprehensive unit tests covering reasoning event handling and null safety
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs | Added case handlers and conversion methods for AssistantReasoningDeltaEvent and AssistantReasoningEvent to create TextReasoningContent |
| dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/GitHubCopilotAgentReasoningTests.cs | Added 6 unit tests covering successful conversion of reasoning events and null handling scenarios |
| python/packages/github_copilot/agent_framework_github_copilot/_agent.py | Added handlers for reasoning event types to create AgentResponseUpdate with TextReasoningContent |
| python/packages/github_copilot/tests/test_github_copilot_agent.py | Added test fixtures and 2 streaming tests for reasoning delta and complete events |
Comments suppressed due to low confidence (3)
python/packages/github_copilot/agent_framework_github_copilot/_agent.py:468
Content.from_text_reasoning()only accepts keyword arguments (note the*,in its signature at python/packages/core/agent_framework/_types.py:533). This call passes a positional argument and will fail with a TypeError. Change toContent.from_text_reasoning(text=event.data.content).
contents=[Content.from_text_reasoning(event.data.content)],
python/packages/github_copilot/tests/test_github_copilot_agent.py:531
Roleis not imported in this test file, which will cause aNameErrorwhen this test runs. Either importRolefromagent_framework, or use the string literal"assistant"directly as per the Role type documentation (python/packages/core/agent_framework/_types.py:1354-1373).
assert responses[0].role == Role.ASSISTANT
python/packages/github_copilot/agent_framework_github_copilot/_agent.py:467
Roleis not imported in this file, which will cause aNameErrorat runtime. The existing code uses string literals like"assistant"(see line 449). ChangeRole.ASSISTANTto"assistant"to match the existing pattern.
role=Role.ASSISTANT,
Member
|
@copilot address all feedback |
…rals for Role Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Copilot
AI
changed the title
.NET / Python: Add AssistantReasoningEvent and AssistantReasoningDeltaEvent support to GitHubCopilotAgent
Python: Add AssistantReasoningEvent and AssistantReasoningDeltaEvent support to GitHubCopilotAgent
Feb 22, 2026
Member
|
@copilot there are CI failures |
…ream() Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Contributor
Author
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation and Context
GitHub Copilot SDK emits
AssistantReasoningEventandAssistantReasoningDeltaEventfor model reasoning/thinking output. GitHubCopilotAgent was not handling these events, causing reasoning content to be lost or stored as genericAIContentinstead of the semantically correctTextReasoningContent.Description
C# Implementation (
GitHubCopilotAgent.cs)AssistantReasoningDeltaEventandAssistantReasoningEventAssistantReasoningDeltaEvent.Data.DeltaContent→TextReasoningContent(streaming)AssistantReasoningEvent.Data.Content→TextReasoningContent(complete)Python Implementation (
_agent.py)SessionEventType.ASSISTANT_REASONING_DELTAandSessionEventType.ASSISTANT_REASONINGAgentResponseUpdatewithContent.from_text_reasoning(text=...)using keyword arguments"assistant"for role (following Role type documentation and existing pattern)Tests
agent.run(stream=True)APIFollows existing event handling patterns (e.g.,
AssistantMessageDeltaEvent→TextContent).Contribution Checklist
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.