Add Zod Activity validation in TurnContext methods#883
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds Zod schema validation to TurnContext methods by integrating Activity.fromObject() calls, which validates activities against the defined Zod schema. This ensures that malformed activities are caught early with clear validation errors.
Changes:
- Integrated
Activity.fromObject()validation insendActivities()andupdateActivity()methods - Refactored variable naming for clarity (e.g.,
activityObject→activity,traceActivityObj→traceActivity) - Added comprehensive tests for validation in both success and failure scenarios
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/agents-hosting/src/turnContext.ts | Added Activity.fromObject validation in sendActivities() and updateActivity() methods to validate activities via Zod schema |
| packages/agents-hosting/test/hosting/adapter/turnContext.test.ts | Added test cases to verify validation works correctly for both valid and invalid activities |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…odes Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
benbrown
reviewed
Jan 20, 2026
benbrown
approved these changes
Jan 20, 2026
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.
Fixes #261
Description
This PR adds the Zod schema validation in TurnContext updateActivity, sendActivity, sendTraceActivity, and sendActivities methods by using the Activity.fromObject utility.
Testing
The following image shows the error shown when passing a wrong activity to updateActivity.
