Skip to content

Add agentic send helpers#632

Open
heyitsaamir wants to merge 2 commits into
agentic-api-surfacefrom
agentic-send-helpers
Open

Add agentic send helpers#632
heyitsaamir wants to merge 2 commits into
agentic-api-surfacefrom
agentic-send-helpers

Conversation

@heyitsaamir

@heyitsaamir heyitsaamir commented Jun 26, 2026

Copy link
Copy Markdown
Collaborator

Wires agentic identity into the app-layer send/reply helpers (mirrors Python PR #480):

  • app.send(conversationId, activity, options?) accepts RequestOptions
  • app.reply() supports options via isRequestOptions type guard
  • app.getAgenticIdentity(appId, userId, opts?) factory method
  • ActivitySender refactored to accept pre-built Client; merges agenticIdentity and serviceUrl into all API calls
  • Per-turn ActivitySender in $process with identity from activity.recipient
  • IActivitySender interface extended with readonly agenticIdentity?
  • ActivityContext.send() simplified — delegates to sender directly
  • examples/agent365/ — reactive echo + proactive send sample

@heyitsaamir

Copy link
Copy Markdown
Collaborator Author

Comment thread packages/apps/src/contexts/activity.ts Outdated
Comment thread packages/apps/src/activity-sender.ts Outdated
Comment thread packages/apps/src/app.process.ts Outdated
@heyitsaamir heyitsaamir marked this pull request as ready for review June 26, 2026 20:12
@heyitsaamir heyitsaamir force-pushed the agentic-api-surface branch from eb8d2e2 to c92e38c Compare June 26, 2026 20:19
@heyitsaamir heyitsaamir force-pushed the agentic-send-helpers branch 2 times, most recently from cefad04 to 9088f52 Compare June 26, 2026 20:21
@heyitsaamir heyitsaamir force-pushed the agentic-api-surface branch from c92e38c to b57702e Compare June 26, 2026 20:29
@heyitsaamir heyitsaamir force-pushed the agentic-send-helpers branch from 9088f52 to 6925d74 Compare June 26, 2026 20:29
@heyitsaamir heyitsaamir requested a review from Copilot June 26, 2026 20:30

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 PR wires agentic identity and request-level overrides into the @microsoft/teams.apps send/reply pipeline by threading RequestOptions (serviceUrl + agenticIdentity) through App, ActivityContext, and ActivitySender, and adds a new examples/agent365 sample demonstrating reactive + proactive agentic sends.

Changes:

  • Extend app-layer send() / reply() helpers to accept RequestOptions, and add an App.getAgenticIdentity() convenience factory.
  • Refactor ActivitySender to reuse a pre-built Teams API Client and pass RequestOptions into conversation activity operations.
  • Add examples/agent365 workspace showing reactive echo and proactive agentic sends.

Reviewed changes

Copilot reviewed 16 out of 19 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/apps/src/types/plugin/sender.ts Extends IActivitySender with optional agentic identity + RequestOptions support.
packages/apps/src/contexts/activity.ts Simplifies ActivityContext.send() delegation to activitySender.
packages/apps/src/app.ts Adds RequestOptions plumbing to send/reply and introduces getAgenticIdentity().
packages/apps/src/app.spec.ts Updates tests to pass valid ActivityLike payloads (explicit type).
packages/apps/src/app.process.ts Creates per-turn ApiClient/ActivitySender with agentic identity from inbound recipient.
packages/apps/src/app.process.spec.ts Adjusts serviceUrl capture tests to hook ActivitySender.send.
packages/apps/src/activity-sender.ts Refactors sender to reuse Client and forward RequestOptions into API calls.
packages/apps/src/activity-sender.spec.ts Reworks sender tests to mock the API client instead of raw HTTP.
package-lock.json Adds workspace entries for the new @examples/agent365 package.
examples/agent365/turbo.json Adds turbo task config for building the new example workspace.
examples/agent365/tsconfig.json TypeScript configuration for the new example.
examples/agent365/src/proactive.ts Proactive messaging sample using AgenticIdentity with both app.send and API client.
examples/agent365/src/main.ts Reactive echo sample demonstrating automatic propagation of inbound agentic identity/serviceUrl.
examples/agent365/README.md Documentation for running reactive and proactive samples.
examples/agent365/package.json Declares the new example workspace and scripts.
examples/agent365/eslint.config.js ESLint config for the new example workspace.
examples/agent365/appPackage/manifest.json Teams app manifest for the example agent package.

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

Comment thread packages/apps/src/app.ts
Comment thread packages/apps/src/activity-sender.ts
Comment thread packages/apps/src/activity-sender.ts
Comment thread packages/apps/src/app.process.spec.ts
Comment thread packages/apps/src/app.process.spec.ts
@heyitsaamir heyitsaamir force-pushed the agentic-api-surface branch from 76ad125 to 3cc0104 Compare June 29, 2026 21:33
@heyitsaamir heyitsaamir force-pushed the agentic-send-helpers branch from 51ca77f to e275cc8 Compare June 29, 2026 21:33
@heyitsaamir heyitsaamir requested review from corinagum and lilyydu June 29, 2026 22:21
@heyitsaamir heyitsaamir force-pushed the agentic-send-helpers branch from e275cc8 to 93776bc Compare June 29, 2026 22:22
Comment thread packages/apps/src/app.ts Outdated
* @param agenticUserId the agentic user's ID
* @param opts optional overrides (tenantId defaults to this app's configured tenant)
*/
getAgenticIdentity(agenticAppId: string, agenticUserId: string, opts?: { tenantId?: string }): AgenticIdentity {

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.

getAgenticIdentity diverges from PY.  get_agentic_identity raises if it can't resolve a tenant, and accepts agentic_app_blueprint_id . The TS version returns { tenantId: undefined } silently, and there's no way to set the blueprint id. Worth noting the TS extractor getAgenticIdentity(account) in account.ts does carry agenticAppBlueprintId , so the factory is varied even within TS. Should a tenant guard + a blueprintId option be added to match PY?

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.

Also: PY resolves tenant from credentials.tenantId  vs TS  options.tenantId , are those equivalent?)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch -

  1. Default agentic_app_blueprint_id to app client id in get_agentic_identity teams.py#494 - updated Py to default with self.id if blueprint id is not provided
  2. Updated this to accept blueprint id optionally and default to this.id if not provided.

Comment thread packages/apps/src/app.process.ts Outdated

const client = this.client.clone();
const apiClient = new ApiClient(serviceUrl, this.client.clone({ token: () => this.getBotToken() }), this.options.apiClientSettings);
const agenticIdentity = getAgenticIdentity(activity.recipient);

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.

This collides with app.ts, will this cause confusion?

Comment on lines +10 to +13
/**
* The agentic identity used for outbound requests (if any)
*/
readonly agenticIdentity?: AgenticIdentity;

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.

Is anything meant to read this? Looks like this is not set anywhere.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You're right - no longer necessary (and in fact we should just remove this sender concept, it feels legacy)

@heyitsaamir heyitsaamir force-pushed the agentic-api-surface branch from 3cc0104 to 4d38786 Compare July 1, 2026 00:04
@heyitsaamir heyitsaamir force-pushed the agentic-send-helpers branch from 93776bc to aa66b72 Compare July 1, 2026 00:04
@heyitsaamir heyitsaamir force-pushed the agentic-api-surface branch from 4d38786 to 6ddcadd Compare July 1, 2026 05:31
@heyitsaamir heyitsaamir force-pushed the agentic-send-helpers branch from aa66b72 to 155f87e Compare July 1, 2026 05:31
@heyitsaamir heyitsaamir force-pushed the agentic-api-surface branch from 6ddcadd to 711a6ac Compare July 1, 2026 21:39
@heyitsaamir heyitsaamir force-pushed the agentic-send-helpers branch from 155f87e to 499df33 Compare July 1, 2026 21:39
@heyitsaamir heyitsaamir force-pushed the agentic-api-surface branch from 711a6ac to bff3ee5 Compare July 1, 2026 21:58
@heyitsaamir heyitsaamir force-pushed the agentic-send-helpers branch 4 times, most recently from cc09eae to db6a642 Compare July 1, 2026 22:51
@heyitsaamir heyitsaamir force-pushed the agentic-api-surface branch from bff3ee5 to ef6df69 Compare July 1, 2026 22:57
@heyitsaamir heyitsaamir force-pushed the agentic-send-helpers branch from db6a642 to 2168311 Compare July 1, 2026 22:57
@heyitsaamir heyitsaamir force-pushed the agentic-api-surface branch from ef6df69 to 64922a6 Compare July 1, 2026 23:08
@heyitsaamir heyitsaamir force-pushed the agentic-send-helpers branch from 2168311 to 5188887 Compare July 1, 2026 23:08
@heyitsaamir heyitsaamir force-pushed the agentic-api-surface branch from 64922a6 to b2a0d57 Compare July 1, 2026 23:12
@heyitsaamir heyitsaamir force-pushed the agentic-send-helpers branch from 5188887 to 51a9bea Compare July 1, 2026 23:12
@heyitsaamir heyitsaamir force-pushed the agentic-api-surface branch from b2a0d57 to 56bb113 Compare July 1, 2026 23:16
@heyitsaamir heyitsaamir force-pushed the agentic-send-helpers branch from 51a9bea to 4cfa97e Compare July 1, 2026 23:16
- Add RequestOptions (agenticIdentity, serviceUrl) to app.send()
- Add isRequestOptions guard for reply() overload disambiguation
- Refactor ActivitySender to accept pre-built API Client
- Wire agentic identity from inbound recipient into per-turn sender
- Forward serviceUrl from ConversationReference in all API calls
- Add getAgenticIdentity() factory on App
- Add agenticIdentity to IActivitySender interface
- Simplify ActivityContext.send() to delegate to sender directly
- Add examples/agent365 reactive + proactive sample

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@heyitsaamir heyitsaamir force-pushed the agentic-send-helpers branch from 4cfa97e to cf3ab03 Compare July 1, 2026 23:22
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