Skip to content

Deprecating AgentApplication ownership of a single channel adapter - #600

Merged
Rodrigo Brandão (rodrigobr-msft) merged 19 commits into
mainfrom
users/robrandao/deprecate-app-adapter
Sep 25, 2026
Merged

Rodrigo Brandão (rodrigobr-msft) merged 19 commits into
mainfrom
users/robrandao/deprecate-app-adapter

Conversation

@rodrigobr-msft

Copy link
Copy Markdown
Contributor

This pull request refactors how the bot adapter is managed within AgentApplication to improve flexibility and error handling. The adapter is no longer stored as an internal attribute, and related methods and checks have been updated to access the adapter from the TurnContext directly. Additionally, error handler registration and long-running call management have been updated to align with this change.

Adapter Management Refactor

  • Removed the internal _adapter attribute and the adapter property from AgentApplication, shifting adapter access to use context.adapter instead. This simplifies the class and avoids potential stale references. [1] [2]
  • Updated checks and error messages in the constructor to only require bot_app_id when long_running_messages is enabled, removing the previous check for an adapter.

Error Handling Improvements

  • Changed error handler registration to append handlers to a new _turn_error_handlers list instead of setting them directly on an internal adapter, allowing for multiple error handlers and decoupling error handling from the adapter. [1] [2]

Long-Running Call and Conversation Replay

  • Updated long-running call logic and conversation replay to use context.adapter for continuing conversations, ensuring the correct adapter instance is used per turn. [1] [2]

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.

Copilot review overview

🟡 Changes recommended

Removing the adapter property leaves multiple samples and generated entry points failing with AttributeError.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 2 High severity · 2 Medium severity

Open (4)
What changed in this PR

Refactors AgentApplication to use each turn’s adapter and updates testing utilities accordingly.

Changes:

  • Moves adapter-dependent operations to TurnContext.adapter.
  • Supports multiple application error handlers.
  • Adds configurable adapter handling to AiohttpScenario.from_app.
File Description
tests/​hosting_core/​app/​test_agent_application.py Tests error-handler behavior.
libraries/​.../​app/​agent_application.py Refactors adapter and error handling.
dev/​.../​tests/​test_aiohttp_scenario.py Tests existing-app scenario construction.
dev/​.../​README.md Documents adapter selection.
dev/​.../​aiohttp_scenario.py Adds optional scenario adapter.
dev/​.../​docs/​README.md Adds usage guidance.
dev/​.../​docs/​API.md Documents the updated API.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@rodrigobr-msft Rodrigo Brandão (rodrigobr-msft) changed the title Removing AgentApplication ownership of a single channel adapter Deprecating AgentApplication ownership of a single channel adapter Sep 24, 2026

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.

Copilot review overview

🟡 Changes recommended

The long-running-message path currently calls incompatible adapter APIs and fails before executing its callback.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity · 3 Low severity

Open (4)
Resolved since last review (4)

Comment thread test_samples/fastapi/empty_agent.py

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.

Copilot review overview

🟡 Changes recommended

Long-running calls use an incompatible adapter signature, and the cards sample references an undefined adapter name.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 2 High severity

Open (2)
Resolved since last review (4)

Comment thread test_samples/cards/agent.py Outdated

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.

Copilot review overview

🟡 Changes recommended

Long-running messages currently call the adapter with an invalid keyword and omit the required callback.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 High severity

Open (1)
Resolved since last review (2)

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.

Copilot review overview

🔵 Needs a closer look

Key continuation paths lack direct coverage, and validation errors still describe a removed adapter requirement.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@rodrigobr-msft
Rodrigo Brandão (rodrigobr-msft) merged commit d2239be into main Sep 25, 2026
10 checks passed
@rodrigobr-msft
Rodrigo Brandão (rodrigobr-msft) deleted the users/robrandao/deprecate-app-adapter branch September 25, 2026 20:47
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