Skip to content

Simplify setting http response after activity processing #218

Merged
heyitsaamir merged 17 commits into
mainfrom
kavin/simplify-activity-response
Dec 4, 2025
Merged

Simplify setting http response after activity processing #218
heyitsaamir merged 17 commits into
mainfrom
kavin/simplify-activity-response

Conversation

@singhk97

@singhk97 singhk97 commented Nov 20, 2025

Copy link
Copy Markdown
Contributor

Linked PR: microsoft/teams.ts#398

This is how the architecture looked like before

image

This is what it looks like now:

image

@heyitsaamir

heyitsaamir commented Nov 21, 2025

Copy link
Copy Markdown
Collaborator

Now that we aren't using events for responses, I think we should make these fundamental changes:

  1. Remove process_activity from event manager and put it back in app. There is no reason for event manager to call process activity now, since the response isn't coming through event manager anymore.
  2. So pull the above in app. Inject that function in. That function can call event_manager.on_activity if it wants, but that would be a fire and forget event.
  3. The on_activity_response can also be called from the above handler then (instead of from process_message). That would clean up that architecture.

@singhk97
singhk97 marked this pull request as ready for review November 21, 2025 21:06
Copilot AI review requested due to automatic review settings November 21, 2025 21:06
@singhk97

Copy link
Copy Markdown
Contributor Author

Refactored the activity processor out of the event manager and into the plugin processor.

@singhk97 singhk97 changed the title [WIP] Simplify setting http response after activity processing Simplify setting http response after activity processing Nov 21, 2025

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 encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Comment thread packages/apps/src/microsoft/teams/apps/http_plugin.py
Comment thread packages/apps/src/microsoft/teams/apps/app_events.py
Comment thread packages/apps/src/microsoft/teams/apps/app_plugins.py
@singhk97

singhk97 commented Dec 1, 2025

Copy link
Copy Markdown
Contributor Author

So it turns out that the error event is not even being emitted if an exception is raised by one of the handlers. I've pushed a commit to a fix that. The behavior is now:

image

for

image

(apologies for confusing error message)

Comment thread packages/apps/src/microsoft/teams/apps/app_process.py Outdated
Comment thread packages/apps/src/microsoft/teams/apps/http_plugin.py

@heyitsaamir heyitsaamir left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested

@heyitsaamir
heyitsaamir merged commit e370a68 into main Dec 4, 2025
6 checks passed
@heyitsaamir
heyitsaamir deleted the kavin/simplify-activity-response branch December 4, 2025 21:06
@heyitsaamir heyitsaamir mentioned this pull request Dec 9, 2025
heyitsaamir pushed a commit to microsoft/teams.ts that referenced this pull request Dec 9, 2025
fixes #393 

The returned `{ status: 200 }` from `app.$process` is not handled by the
plugin, and so the http response is not set causing the server to
"hang". By not short circuiting, the program execution continues leading
to `onActivityResponse` event being called and the HTTP response being
set to default status of 200.

- [x] **Is it an issue in .NET SDK?** Nope, there is no short-circuiting
being done like this.
- [x] **Is it an issue in Python SDK?** Yes, it should be fixed:
microsoft/teams.py#218
heyitsaamir added a commit that referenced this pull request Dec 9, 2025
## Release 2.0.0a7

### Changes

- update react and react-dom to 19.2.1 (#233)
- Move to microsoft_teams namespace (#226)
- Simplify setting http response after activity processing  (#218)
- Add TeamsChannelAccount type for Teams-specific APIs (#230)
- Updating mcpplugin reference in README.md (#229)
- Bring back bot builder example (#225)
- Fix choices_data alias to use "choices.data" instead of "choicesData"
(#224)
- [docs] botbuilder package README fixes (#223)
- Fix calling AI functions with no parameters (#221)
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