diff --git a/core/src/Microsoft.Teams.Apps/Diagnostics/TeamsBaggageBuilder.cs b/core/src/Microsoft.Teams.Apps/Diagnostics/TeamsBaggageBuilder.cs
index 49aff4f8..23d4190c 100644
--- a/core/src/Microsoft.Teams.Apps/Diagnostics/TeamsBaggageBuilder.cs
+++ b/core/src/Microsoft.Teams.Apps/Diagnostics/TeamsBaggageBuilder.cs
@@ -96,7 +96,7 @@ public TeamsBaggageBuilder Set(string key, string? value)
///
/// Populates every baggage key reachable from ctx.Activity — including the Apps-only keys
/// backed by . Tenant fallback uses the typed
- /// when is null.
+ /// when is null.
///
public TeamsBaggageBuilder FromTeamsContext(Context ctx) where TActivity : TeamsActivity
{
diff --git a/core/src/Microsoft.Teams.Apps/Schema/TeamsChannelAccount.cs b/core/src/Microsoft.Teams.Apps/Schema/TeamsChannelAccount.cs
index df0544bf..09e366e7 100644
--- a/core/src/Microsoft.Teams.Apps/Schema/TeamsChannelAccount.cs
+++ b/core/src/Microsoft.Teams.Apps/Schema/TeamsChannelAccount.cs
@@ -54,7 +54,7 @@ public TeamsChannelAccount()
result.Email = result.Properties.Extract("email");
result.UserPrincipalName = result.Properties.Extract("userPrincipalName");
result.UserRole = result.Properties.Extract("userRole");
- result.TenantId = result.Properties.Extract("tenantId");
+ result.TenantId = channelAccount.TenantId;
if (string.IsNullOrEmpty(result.AadObjectId))
{
result.AadObjectId = result.ObjectId;
@@ -103,10 +103,4 @@ public TeamsChannelAccount()
///
[JsonPropertyName("userRole")]
public string? UserRole { get; set; }
-
- ///
- /// Gets or sets the Microsoft Entra tenant ID associated with this account.
- ///
- [JsonPropertyName("tenantId")]
- public string? TenantId { get; set; }
}
diff --git a/core/src/Microsoft.Teams.Core/Schema/AgenticIdentity.cs b/core/src/Microsoft.Teams.Core/Schema/AgenticIdentity.cs
index 2f43804f..faf676ce 100644
--- a/core/src/Microsoft.Teams.Core/Schema/AgenticIdentity.cs
+++ b/core/src/Microsoft.Teams.Core/Schema/AgenticIdentity.cs
@@ -17,6 +17,11 @@ public sealed class AgenticIdentity
///
public string? AgenticUserId { get; set; }
+ ///
+ /// Tenant ID associated with the agentic identity.
+ ///
+ public string? TenantId { get; set; }
+
///
/// Agentic application blueprint ID.
///
@@ -37,7 +42,8 @@ public sealed class AgenticIdentity
{
AgenticAppId = account.AgenticAppId,
AgenticUserId = account.AgenticUserId,
- AgenticAppBlueprintId = account.AgenticAppBlueprintId
+ AgenticAppBlueprintId = account.AgenticAppBlueprintId,
+ TenantId = account.TenantId
};
}
}
diff --git a/core/src/Microsoft.Teams.Core/Schema/ChannelAccount.cs b/core/src/Microsoft.Teams.Core/Schema/ChannelAccount.cs
index d2e3849e..7e466b46 100644
--- a/core/src/Microsoft.Teams.Core/Schema/ChannelAccount.cs
+++ b/core/src/Microsoft.Teams.Core/Schema/ChannelAccount.cs
@@ -49,6 +49,12 @@ public class ChannelAccount()
[JsonPropertyName("agenticAppBlueprintId")]
public string? AgenticAppBlueprintId { get; set; }
+ ///
+ /// Gets or sets the tenant ID associated with the account.
+ ///
+ [JsonPropertyName("tenantId")]
+ public string? TenantId { get; set; }
+
///
/// Gets the extension data dictionary for storing additional properties not defined in the schema.
///
@@ -71,7 +77,8 @@ public class ChannelAccount()
{
AgenticAppId = AgenticAppId,
AgenticUserId = AgenticUserId,
- AgenticAppBlueprintId = AgenticAppBlueprintId
+ AgenticAppBlueprintId = AgenticAppBlueprintId,
+ TenantId = TenantId
};
}
}
diff --git a/core/test/Microsoft.Teams.Core.UnitTests/Schema/CoreActivityTests.cs b/core/test/Microsoft.Teams.Core.UnitTests/Schema/CoreActivityTests.cs
index e56f475a..fc6d0fb8 100644
--- a/core/test/Microsoft.Teams.Core.UnitTests/Schema/CoreActivityTests.cs
+++ b/core/test/Microsoft.Teams.Core.UnitTests/Schema/CoreActivityTests.cs
@@ -330,4 +330,49 @@ public void IsTargeted_DeserializedFromJson()
Assert.Equal("user-123", activity.Recipient.Id);
Assert.True(activity.Recipient.IsTargeted);
}
+
+ [Fact]
+ public void AgenticIdentity_IncludesTenantId_FromRecipient()
+ {
+ string json = """
+ {
+ "type": "message",
+ "recipient": {
+ "id": "28:bot-id",
+ "agenticAppId": "agentic-app",
+ "agenticUserId": "agentic-user",
+ "agenticAppBlueprintId": "blueprint",
+ "tenantId": "tenant-abc"
+ }
+ }
+ """;
+
+ CoreActivity activity = CoreActivity.FromJsonString(json);
+
+ AgenticIdentity? identity = activity.Recipient?.GetAgenticIdentity();
+ Assert.NotNull(identity);
+ Assert.Equal("agentic-app", identity!.AgenticAppId);
+ Assert.Equal("agentic-user", identity.AgenticUserId);
+ Assert.Equal("blueprint", identity.AgenticAppBlueprintId);
+ Assert.Equal("tenant-abc", identity.TenantId);
+ }
+
+ [Fact]
+ public void AgenticIdentity_TenantIdAlone_DoesNotCreateIdentity()
+ {
+ string json = """
+ {
+ "type": "message",
+ "recipient": {
+ "id": "user-123",
+ "tenantId": "tenant-abc"
+ }
+ }
+ """;
+
+ CoreActivity activity = CoreActivity.FromJsonString(json);
+
+ Assert.Equal("tenant-abc", activity.Recipient?.TenantId);
+ Assert.Null(activity.Recipient?.GetAgenticIdentity());
+ }
}