Skip to content

Handling invoke responses with empty body#437

Merged
rodrigobr-msft merged 3 commits into
mainfrom
users/robrandao/invoke-response-handling
Jul 10, 2026
Merged

Handling invoke responses with empty body#437
rodrigobr-msft merged 3 commits into
mainfrom
users/robrandao/invoke-response-handling

Conversation

@rodrigobr-msft

@rodrigobr-msft rodrigobr-msft commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

This pull request improves the handling of empty response bodies for invoke activities in the Exchange.from_request method and adds tests to ensure correct behavior. The main changes are:

Bug Fixes:

  • Updated Exchange.from_request in exchange.py to return None for the body field in InvokeResponse when the response body is empty or contains only whitespace, preventing JSON parsing errors.

Testing Improvements:

  • Added a parameterized test test_from_request_with_empty_invoke_response_body in test_exchange.py to verify that empty or whitespace-only response bodies are correctly handled and result in None in invoke_response.body.

Copilot AI review requested due to automatic review settings July 2, 2026 15:16

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

This pull request updates the transcript transport layer’s Exchange.from_request parsing for invoke activities to safely handle responses that have an empty/whitespace-only body, and adds a regression test to ensure this behavior remains correct.

Changes:

  • Adjusted Exchange.from_request to treat empty/whitespace-only invoke response bodies as {} (instead of attempting json.loads and failing).
  • Added a parameterized test to cover both empty-string and whitespace-only invoke response bodies.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
dev/testing/microsoft-agents-testing/microsoft_agents/testing/core/transport/transcript/exchange.py Avoids JSON parsing on empty/whitespace invoke response bodies by defaulting InvokeResponse.body to {}.
dev/testing/microsoft-agents-testing/tests/core/transport/transcript/test_exchange.py Adds parameterized coverage ensuring empty/whitespace invoke bodies yield invoke_response.body == {}.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rodrigobr-msft
rodrigobr-msft marked this pull request as ready for review July 2, 2026 15:20
@rodrigobr-msft
rodrigobr-msft requested a review from a team as a code owner July 2, 2026 15:20
Copilot AI review requested due to automatic review settings July 2, 2026 15:20
@rodrigobr-msft
rodrigobr-msft enabled auto-merge (squash) July 2, 2026 15:20

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 10, 2026 17:50

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@rodrigobr-msft
rodrigobr-msft merged commit ab57341 into main Jul 10, 2026
11 of 12 checks passed
@rodrigobr-msft
rodrigobr-msft deleted the users/robrandao/invoke-response-handling branch July 10, 2026 17:52
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.

3 participants