diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 389f73290895..16de53c916db 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -1025,6 +1025,12 @@
# ServiceLabel: %Elastic %Mgmt
# ServiceOwners: @ArthurMa1978
+# PRLabel: %Grafana
+/sdk/grafana/Azure.ResourceManager.*/ @qingquanzhao
+
+# ServiceLabel: %Grafana %Mgmt
+# ServiceOwners: @qingquanzhao
+
# PRLabel: %Hardware Security Modules
/sdk/hardwaresecuritymodules/Azure.ResourceManager.*/ @emmeliaAra
diff --git a/.vscode/cspell.json b/.vscode/cspell.json
index 470cebeef2cf..62370495fb4a 100644
--- a/.vscode/cspell.json
+++ b/.vscode/cspell.json
@@ -48,6 +48,7 @@
"sdk/machinelearningservices/*/api/*.cs",
"sdk/modelsrepository/*/api/*.cs",
"sdk/monitor/Azure.ResourceManager.Monitor/api/*.cs",
+ "sdk/planetarycomputer/Azure.ResourceManager.PlanetaryComputer/api/*.cs",
"sdk/objectanchors/*/api/*.cs",
"sdk/openai/Azure.AI.OpenAI/tests/Assets/playback_test_config.json",
"sdk/purview/*/api/*.cs",
@@ -159,6 +160,7 @@
"skus",
"Somaxconn",
"southcentralus",
+ "spatio",
"structs",
"Sybase",
"Sysctls",
@@ -428,14 +430,6 @@
"tibt"
]
},
- {
- "filename": "**/sdk/connectedcache/**/*",
- "words": [
- "Gbps",
- "Mbps",
- "Eflow"
- ]
- },
{
"filename": "**/sdk/connectedvmwarevsphere/**/*",
"words": [
@@ -1133,7 +1127,6 @@
"dnsprivateviewocid",
"Ords",
"Ocid",
- "Ocids",
"ncharacter",
"ocpu",
"Iorm",
@@ -1144,11 +1137,7 @@
"Tcps",
"Ezconnect",
"Ezconnectplus",
- "Oltp",
- "exadb",
- "Exadb",
- "Exascale",
- "exascale"
+ "Oltp"
]
},
{
diff --git a/eng/Packages.Data.props b/eng/Packages.Data.props
index 4704e8b2023b..41136739520b 100644
--- a/eng/Packages.Data.props
+++ b/eng/Packages.Data.props
@@ -119,7 +119,7 @@
-
+
@@ -139,7 +139,7 @@
-
+
@@ -288,7 +288,7 @@
All should have PrivateAssets="All" set so they don't become package dependencies
-->
-
+
@@ -450,7 +450,7 @@
1.0.0-dev.20250501.1
- 1.0.0-alpha.20250624.1
- 1.0.0-alpha.20250619.1
+ 1.0.0-alpha.20250625.1
+ 1.0.0-alpha.20250625.3
diff --git a/eng/common/mcp/azure-sdk-mcp.ps1 b/eng/common/mcp/azure-sdk-mcp.ps1
index 4f4fa6d03a48..b56fb4e96a28 100755
--- a/eng/common/mcp/azure-sdk-mcp.ps1
+++ b/eng/common/mcp/azure-sdk-mcp.ps1
@@ -51,7 +51,7 @@ if ($UpdateVsCodeConfig) {
}
$vscodeConfig.servers = $orderedServers
Write-Host "Updating vscode mcp config at $vscodeConfigPath"
- $vscodeConfig | ConvertTo-Json -Depth 10 | Set-Content -Path $vscodeConfig -Force
+ $vscodeConfig | ConvertTo-Json -Depth 10 | Set-Content -Path $vscodeConfigPath -Force
}
$exe = Install-Standalone-Tool `
diff --git a/eng/common/pipelines/codeowners-linter.yml b/eng/common/pipelines/codeowners-linter.yml
index 4fe03ab3f647..cf4d113414d9 100644
--- a/eng/common/pipelines/codeowners-linter.yml
+++ b/eng/common/pipelines/codeowners-linter.yml
@@ -38,13 +38,10 @@ stages:
UserOrgUri: "https://azuresdkartifacts.blob.core.windows.net/azure-sdk-write-teams/user-org-visibility-blob"
steps:
- - task: DotNetCoreCLI@2
- displayName: 'Install CodeownersLinter'
- inputs:
- command: custom
- custom: 'tool'
- arguments: 'install --global --add-source "$(DotNetDevOpsFeed)" --version "$(CodeownersLinterVersion)" "Azure.Sdk.Tools.CodeownersLinter"'
- workingDirectory: '$(Build.SourcesDirectory)/eng/common'
+ - pwsh: |
+ dotnet tool install --global --add-source "$(DotNetDevOpsFeed)" --version "$(CodeownersLinterVersion)" "Azure.Sdk.Tools.CodeownersLinter"
+ displayName: Install CodeownersLinter
+ workingDirectory: '$(Agent.WorkFolder)' # Some directory outside of the source clone to avoid hitting global.json files when any version of dotnet will work for this install
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
- pwsh: |
diff --git a/eng/emitter-package-lock.json b/eng/emitter-package-lock.json
index 27e07e5c58c0..ff37512dabdc 100644
--- a/eng/emitter-package-lock.json
+++ b/eng/emitter-package-lock.json
@@ -5,7 +5,7 @@
"packages": {
"": {
"dependencies": {
- "@azure-tools/typespec-csharp": "0.2.0-beta.20250623.2"
+ "@azure-tools/typespec-csharp": "0.2.0-beta.20250624.4"
},
"devDependencies": {
"@azure-tools/typespec-autorest": "0.57.0",
@@ -26,9 +26,9 @@
}
},
"node_modules/@autorest/csharp": {
- "version": "3.0.0-beta.20250623.2",
- "resolved": "https://registry.npmjs.org/@autorest/csharp/-/csharp-3.0.0-beta.20250623.2.tgz",
- "integrity": "sha512-nP1qyDNdEj/9nbvoSzn1RACK/zzNKvqXvGoFQy5tx+GZFEwHmZ32II+VYiXJMsytTM9k+BuZEk2yx3tgxkk5jA=="
+ "version": "3.0.0-beta.20250624.4",
+ "resolved": "https://registry.npmjs.org/@autorest/csharp/-/csharp-3.0.0-beta.20250624.4.tgz",
+ "integrity": "sha512-bAQdT0x/uGgAUhX0TTLNjIxe+8yGF8LlocZXfGW8Mc56qsAFDmM8TqsSVyrwIEYvzxnL69/TbgV4A/x3yXemcQ=="
},
"node_modules/@azure-tools/typespec-autorest": {
"version": "0.57.0",
@@ -131,12 +131,12 @@
}
},
"node_modules/@azure-tools/typespec-csharp": {
- "version": "0.2.0-beta.20250623.2",
- "resolved": "https://registry.npmjs.org/@azure-tools/typespec-csharp/-/typespec-csharp-0.2.0-beta.20250623.2.tgz",
- "integrity": "sha512-kIHGZqWr1qJBngGKIhedK1xM1dC8OCPFuSuMtyBUDl3bJMPh2nhv08hUEqDwk8Cv2WvGOPvMuQzyNF63VyK2HA==",
+ "version": "0.2.0-beta.20250624.4",
+ "resolved": "https://registry.npmjs.org/@azure-tools/typespec-csharp/-/typespec-csharp-0.2.0-beta.20250624.4.tgz",
+ "integrity": "sha512-vN7CsREnSqEMa2fY4g/DgnLEp5t4IW+SIAWwQ6zGwFjp1ltYi0m4znYeGUpkd8YxY4HtXlqOFRV8ljRaPzPAwQ==",
"license": "MIT",
"dependencies": {
- "@autorest/csharp": "3.0.0-beta.20250623.2",
+ "@autorest/csharp": "3.0.0-beta.20250624.4",
"@typespec/http-client-csharp": "1.0.0-alpha.20250618.2"
},
"peerDependencies": {
diff --git a/eng/emitter-package.json b/eng/emitter-package.json
index 48ed96a2b7a1..4e111efc1c67 100644
--- a/eng/emitter-package.json
+++ b/eng/emitter-package.json
@@ -1,7 +1,7 @@
{
"main": "dist/src/index.js",
"dependencies": {
- "@azure-tools/typespec-csharp": "0.2.0-beta.20250623.2"
+ "@azure-tools/typespec-csharp": "0.2.0-beta.20250624.4"
},
"devDependencies": {
"@azure-tools/typespec-autorest": "0.57.0",
diff --git a/eng/http-client-csharp-emitter-package-lock.json b/eng/http-client-csharp-emitter-package-lock.json
index 5f4775e4b55e..30d462081adc 100644
--- a/eng/http-client-csharp-emitter-package-lock.json
+++ b/eng/http-client-csharp-emitter-package-lock.json
@@ -5,7 +5,7 @@
"packages": {
"": {
"dependencies": {
- "@azure-typespec/http-client-csharp": "1.0.0-alpha.20250624.1"
+ "@azure-typespec/http-client-csharp": "1.0.0-alpha.20250625.3"
},
"devDependencies": {
"@azure-tools/typespec-azure-core": "0.57.0",
@@ -98,12 +98,12 @@
}
},
"node_modules/@azure-typespec/http-client-csharp": {
- "version": "1.0.0-alpha.20250624.1",
- "resolved": "https://registry.npmjs.org/@azure-typespec/http-client-csharp/-/http-client-csharp-1.0.0-alpha.20250624.1.tgz",
- "integrity": "sha512-4yIWOhGh9ihl25lPyWkuXMwP/xgcfytRdTiR5H/7PhBLRWY2No93DtW+SIrFj7KKZqDLJEa2QCKd/FxDKoGUBw==",
+ "version": "1.0.0-alpha.20250625.3",
+ "resolved": "https://registry.npmjs.org/@azure-typespec/http-client-csharp/-/http-client-csharp-1.0.0-alpha.20250625.3.tgz",
+ "integrity": "sha512-UqV4ROg1V36DXZBbdfgWj5JpIjcFnHCzVUd/1948MTFyxCDa1JrSOnLIznKmhIwsjPOX1LU0gKAnmZwSoXQMpg==",
"license": "MIT",
"dependencies": {
- "@typespec/http-client-csharp": "1.0.0-alpha.20250624.1"
+ "@typespec/http-client-csharp": "1.0.0-alpha.20250625.1"
}
},
"node_modules/@babel/code-frame": {
@@ -556,9 +556,9 @@
}
},
"node_modules/@typespec/http-client-csharp": {
- "version": "1.0.0-alpha.20250624.1",
- "resolved": "https://registry.npmjs.org/@typespec/http-client-csharp/-/http-client-csharp-1.0.0-alpha.20250624.1.tgz",
- "integrity": "sha512-6VvNTbQsASv8hJMU4GliUl6bpLEUuqAd2cQJazxhjQQZhtpMmwYxlfOKJ9DJhzsjXshyLrQu8WJLKfD5V7FByQ==",
+ "version": "1.0.0-alpha.20250625.1",
+ "resolved": "https://registry.npmjs.org/@typespec/http-client-csharp/-/http-client-csharp-1.0.0-alpha.20250625.1.tgz",
+ "integrity": "sha512-tvtFsr2cyDFfxTiKENMx17IEkzziUoSkuC2ebArYKWyz5JeFDI9Hr0byunhhtDs/yBlZF4LoKZPQMw4wK9Yo6w==",
"license": "MIT",
"dependencies": {
"json-serialize-refs": "0.1.0-0"
diff --git a/eng/http-client-csharp-emitter-package.json b/eng/http-client-csharp-emitter-package.json
index 9567f7c641a7..0ad2293a1a7a 100644
--- a/eng/http-client-csharp-emitter-package.json
+++ b/eng/http-client-csharp-emitter-package.json
@@ -1,7 +1,7 @@
{
"main": "dist/src/index.js",
"dependencies": {
- "@azure-typespec/http-client-csharp": "1.0.0-alpha.20250624.1"
+ "@azure-typespec/http-client-csharp": "1.0.0-alpha.20250625.3"
},
"devDependencies": {
"@azure-tools/typespec-azure-core": "0.57.0",
diff --git a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Providers/MockableResourceProvider.cs b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Providers/MockableResourceProvider.cs
index 7b6660d1b44e..7f6ec9814c51 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Providers/MockableResourceProvider.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/Providers/MockableResourceProvider.cs
@@ -28,6 +28,8 @@ public MockableResourceProvider(CSharpType armCoreType, IReadOnlyList $"{base.BuildNamespace()}.Mocking";
+
protected override string BuildName() => $"Mockable{ManagementClientGenerator.Instance.TypeFactory.ResourceProviderName}{ArmCoreType.Name}";
protected override string BuildRelativeFilePath() => Path.Combine("src", "Generated", "Extensions", $"{Name}.cs");
diff --git a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/ResourceVisitor.cs b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/ResourceVisitor.cs
index 343d51a24a54..e5977c5306cd 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/ResourceVisitor.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/Azure.Generator.Management/src/ResourceVisitor.cs
@@ -19,6 +19,46 @@ internal class ResourceVisitor : ScmLibraryVisitor
return type;
}
+ private void TransformResource(InputModelType model, TypeProvider type)
+ {
+ if (type is ModelProvider && ManagementClientGenerator.Instance.InputLibrary.IsResourceModel(model))
+ {
+ type.Update(
+ relativeFilePath: TransformRelativeFilePath(type),
+ name: TransformName(type));
+
+ foreach (var serialization in type.SerializationProviders)
+ {
+ serialization.Update(
+ relativeFilePath: TransformRelativeFilePathForSerialization(serialization),
+ name: TransformName(serialization));
+ }
+ }
+ }
+
+ // Because we have NamespaceVisitor with VisitType in Azure.Generater, we need to override the namespace with VisitType here
+ protected override TypeProvider? VisitType(TypeProvider type)
+ {
+ if (type is not null)
+ {
+ TransformNamespaceForResource(type);
+ }
+ return type;
+ }
+
+ private void TransformNamespaceForResource(TypeProvider type)
+ {
+ if (type is ModelProvider model && ManagementClientGenerator.Instance.OutputLibrary.IsResourceModelType(model.Type))
+ {
+ type.Update(@namespace: ManagementClientGenerator.Instance.TypeFactory.PrimaryNamespace);
+
+ foreach (var serialization in type.SerializationProviders)
+ {
+ serialization.Update(@namespace: ManagementClientGenerator.Instance.TypeFactory.PrimaryNamespace);
+ }
+ }
+ }
+
// TODO: Go back and enable this when we have a way to handle the resource model parameters renaming via VisitMethod.
// protected override MethodProvider? VisitMethod(MethodProvider method)
// {
@@ -32,20 +72,6 @@ internal class ResourceVisitor : ScmLibraryVisitor
// return base.VisitMethod(method);
// }
- private void TransformResource(InputModelType model, TypeProvider type)
- {
- if (type is ModelProvider && ManagementClientGenerator.Instance.InputLibrary.IsResourceModel(model))
- {
- type.Update(relativeFilePath: TransformRelativeFilePath(type));
- type.Update(name: TransformName(type));
- foreach (var serialization in type.SerializationProviders)
- {
- serialization.Update(relativeFilePath: TransformRelativeFilePathForSerialization(serialization));
- serialization.Update(name: TransformName(serialization));
- }
- }
- }
-
private static string TransformName(TypeProvider model) => $"{model.Name}Data";
private static string TransformRelativeFilePath(TypeProvider model)
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Extensions/MgmtTypeSpecExtensions.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Extensions/MgmtTypeSpecExtensions.cs
index 6693c8eaed40..97296c05a441 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Extensions/MgmtTypeSpecExtensions.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Extensions/MgmtTypeSpecExtensions.cs
@@ -12,6 +12,7 @@
using Azure.Core;
using Azure.ResourceManager;
using Azure.ResourceManager.Resources;
+using MgmtTypeSpec.Mocking;
namespace MgmtTypeSpec
{
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Extensions/MockableMgmtTypeSpecArmClient.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Extensions/MockableMgmtTypeSpecArmClient.cs
index dc340d98fb5c..1b56e6943127 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Extensions/MockableMgmtTypeSpecArmClient.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Extensions/MockableMgmtTypeSpecArmClient.cs
@@ -7,8 +7,9 @@
using Azure.Core;
using Azure.ResourceManager;
+using MgmtTypeSpec;
-namespace MgmtTypeSpec
+namespace MgmtTypeSpec.Mocking
{
///
public partial class MockableMgmtTypeSpecArmClient : ArmResource
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Extensions/MockableMgmtTypeSpecResourceGroupResource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Extensions/MockableMgmtTypeSpecResourceGroupResource.cs
index 1c5644f9797b..234ebf612f31 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Extensions/MockableMgmtTypeSpecResourceGroupResource.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Extensions/MockableMgmtTypeSpecResourceGroupResource.cs
@@ -12,8 +12,9 @@
using Azure.Core;
using Azure.ResourceManager;
using Azure.ResourceManager.Resources;
+using MgmtTypeSpec;
-namespace MgmtTypeSpec
+namespace MgmtTypeSpec.Mocking
{
///
public partial class MockableMgmtTypeSpecResourceGroupResource : ArmResource
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FooCollection.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FooCollection.cs
index a4087557c48a..20875613c946 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FooCollection.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FooCollection.cs
@@ -16,7 +16,6 @@
using Azure.Core.Pipeline;
using Azure.ResourceManager;
using Azure.ResourceManager.Resources;
-using MgmtTypeSpec.Models;
namespace MgmtTypeSpec
{
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FooData.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FooData.Serialization.cs
index 4a69bfd864cd..727817571ed3 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FooData.Serialization.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FooData.Serialization.cs
@@ -13,9 +13,9 @@
using Azure.Core;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Resources.Models;
-using MgmtTypeSpec;
+using MgmtTypeSpec.Models;
-namespace MgmtTypeSpec.Models
+namespace MgmtTypeSpec
{
/// Concrete tracked resource types can be created by aliasing this type using a specific property type.
public partial class FooData : IJsonModel
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FooData.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FooData.cs
index cbb1de893bf1..7714cc844c81 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FooData.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FooData.cs
@@ -10,9 +10,9 @@
using Azure.Core;
using Azure.ResourceManager.Models;
using Azure.ResourceManager.Resources.Models;
-using MgmtTypeSpec;
+using MgmtTypeSpec.Models;
-namespace MgmtTypeSpec.Models
+namespace MgmtTypeSpec
{
/// Concrete tracked resource types can be created by aliasing this type using a specific property type.
public partial class FooData : TrackedResourceData
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FooResource.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FooResource.Serialization.cs
index aedfeb439192..bbf9f0b077a9 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FooResource.Serialization.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FooResource.Serialization.cs
@@ -8,7 +8,6 @@
using System;
using System.ClientModel.Primitives;
using System.Text.Json;
-using MgmtTypeSpec.Models;
namespace MgmtTypeSpec
{
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FooResource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FooResource.cs
index 11ef07321085..b3e8ff1e404b 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FooResource.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/FooResource.cs
@@ -14,7 +14,6 @@
using Azure.Core.Pipeline;
using Azure.ResourceManager;
using Azure.ResourceManager.Resources;
-using MgmtTypeSpec.Models;
namespace MgmtTypeSpec
{
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/LongRunningOperation/FooOperationSource.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/LongRunningOperation/FooOperationSource.cs
index 75cb64659dd5..da90ef65c46c 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/LongRunningOperation/FooOperationSource.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/LongRunningOperation/FooOperationSource.cs
@@ -12,7 +12,6 @@
using Azure;
using Azure.Core;
using Azure.ResourceManager;
-using MgmtTypeSpec.Models;
namespace MgmtTypeSpec
{
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/MgmtTypeSpecModelFactory.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/MgmtTypeSpecModelFactory.cs
index e8cfc1603648..5851184f75ba 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/MgmtTypeSpecModelFactory.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/MgmtTypeSpecModelFactory.cs
@@ -28,7 +28,7 @@ public static partial class MgmtTypeSpecModelFactory
/// The resource-specific properties for this resource.
/// The name of the Foo.
///
- /// A new instance for mocking.
+ /// A new instance for mocking.
public static FooData FooData(ResourceIdentifier id = default, string @type = default, SystemData systemData = default, IDictionary tags = default, string location = default, FooProperties properties = default, string name = default, ExtendedLocation extendedLocation = default)
{
tags ??= new ChangeTrackingDictionary();
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/FooListResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/FooListResult.cs
index 047b1e3e8a1b..7a0934ed9e0e 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/FooListResult.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/FooListResult.cs
@@ -8,6 +8,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using MgmtTypeSpec;
namespace MgmtTypeSpec.Models
{
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/PrivateLinkResourceListResult.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/PrivateLinkResourceListResult.cs
index aed8edde6be9..019e541cdb65 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/PrivateLinkResourceListResult.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Models/PrivateLinkResourceListResult.cs
@@ -8,6 +8,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using MgmtTypeSpec;
namespace MgmtTypeSpec.Models
{
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/PrivateLinkResourceData.Serialization.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/PrivateLinkResourceData.Serialization.cs
index ae7c158d94c1..df1936008ed1 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/PrivateLinkResourceData.Serialization.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/PrivateLinkResourceData.Serialization.cs
@@ -11,9 +11,9 @@
using System.Text.Json;
using Azure.Core;
using Azure.ResourceManager.Models;
-using MgmtTypeSpec;
+using MgmtTypeSpec.Models;
-namespace MgmtTypeSpec.Models
+namespace MgmtTypeSpec
{
/// Concrete proxy resource types can be created by aliasing this type using a specific property type.
internal partial class PrivateLinkResourceData : IJsonModel
diff --git a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/PrivateLinkResourceData.cs b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/PrivateLinkResourceData.cs
index af6f059438fc..c9b72e60a6d8 100644
--- a/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/PrivateLinkResourceData.cs
+++ b/eng/packages/http-client-csharp-mgmt/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/PrivateLinkResourceData.cs
@@ -9,8 +9,9 @@
using System.Collections.Generic;
using Azure.Core;
using Azure.ResourceManager.Models;
+using MgmtTypeSpec.Models;
-namespace MgmtTypeSpec.Models
+namespace MgmtTypeSpec
{
/// Concrete proxy resource types can be created by aliasing this type using a specific property type.
internal partial class PrivateLinkResourceData : ResourceData
diff --git a/eng/packages/http-client-csharp-mgmt/package-lock.json b/eng/packages/http-client-csharp-mgmt/package-lock.json
index ef7f90928fdf..b5c4faba1cbc 100644
--- a/eng/packages/http-client-csharp-mgmt/package-lock.json
+++ b/eng/packages/http-client-csharp-mgmt/package-lock.json
@@ -9,7 +9,7 @@
"version": "1.0.0",
"license": "MIT",
"dependencies": {
- "@azure-typespec/http-client-csharp": "1.0.0-alpha.20250619.1"
+ "@azure-typespec/http-client-csharp": "1.0.0-alpha.20250625.3"
},
"devDependencies": {
"@azure-tools/azure-http-specs": "0.1.0-alpha.19",
@@ -215,12 +215,12 @@
"dev": true
},
"node_modules/@azure-typespec/http-client-csharp": {
- "version": "1.0.0-alpha.20250619.1",
- "resolved": "https://registry.npmjs.org/@azure-typespec/http-client-csharp/-/http-client-csharp-1.0.0-alpha.20250619.1.tgz",
- "integrity": "sha512-TTLa+lOzTVRF0Qe4K75qbcpIaUw2RD4n2tH3DlTXJUs4ct3RO8pVvR6ElI8uloyJI1CN//QwsDeEdCuq8OFh8w==",
+ "version": "1.0.0-alpha.20250625.3",
+ "resolved": "https://registry.npmjs.org/@azure-typespec/http-client-csharp/-/http-client-csharp-1.0.0-alpha.20250625.3.tgz",
+ "integrity": "sha512-UqV4ROg1V36DXZBbdfgWj5JpIjcFnHCzVUd/1948MTFyxCDa1JrSOnLIznKmhIwsjPOX1LU0gKAnmZwSoXQMpg==",
"license": "MIT",
"dependencies": {
- "@typespec/http-client-csharp": "1.0.0-alpha.20250619.2"
+ "@typespec/http-client-csharp": "1.0.0-alpha.20250625.1"
}
},
"node_modules/@azure/abort-controller": {
@@ -2513,9 +2513,9 @@
}
},
"node_modules/@typespec/http-client-csharp": {
- "version": "1.0.0-alpha.20250619.2",
- "resolved": "https://registry.npmjs.org/@typespec/http-client-csharp/-/http-client-csharp-1.0.0-alpha.20250619.2.tgz",
- "integrity": "sha512-PtJRzOYXag9WMt7dyP3lOWDcWajIG1enwLLOF9vhiD19vhbrAsZzHKAsYarpZEExvzTCH473tAw/YTp/40IMnw==",
+ "version": "1.0.0-alpha.20250625.1",
+ "resolved": "https://registry.npmjs.org/@typespec/http-client-csharp/-/http-client-csharp-1.0.0-alpha.20250625.1.tgz",
+ "integrity": "sha512-tvtFsr2cyDFfxTiKENMx17IEkzziUoSkuC2ebArYKWyz5JeFDI9Hr0byunhhtDs/yBlZF4LoKZPQMw4wK9Yo6w==",
"license": "MIT",
"dependencies": {
"json-serialize-refs": "0.1.0-0"
diff --git a/eng/packages/http-client-csharp-mgmt/package.json b/eng/packages/http-client-csharp-mgmt/package.json
index 2b1186c13f68..0c07a32a20c0 100644
--- a/eng/packages/http-client-csharp-mgmt/package.json
+++ b/eng/packages/http-client-csharp-mgmt/package.json
@@ -37,7 +37,7 @@
"dist/**"
],
"dependencies": {
- "@azure-typespec/http-client-csharp": "1.0.0-alpha.20250619.1"
+ "@azure-typespec/http-client-csharp": "1.0.0-alpha.20250625.3"
},
"devDependencies": {
"@azure-tools/azure-http-specs": "0.1.0-alpha.19",
diff --git a/eng/packages/http-client-csharp/eng/scripts/Generate.ps1 b/eng/packages/http-client-csharp/eng/scripts/Generate.ps1
index a7c152c94342..5f575b49ce80 100644
--- a/eng/packages/http-client-csharp/eng/scripts/Generate.ps1
+++ b/eng/packages/http-client-csharp/eng/scripts/Generate.ps1
@@ -84,6 +84,7 @@ $failingSpecs = @(
Join-Path 'http' 'azure' 'resource-manager' 'non-resource'
Join-Path 'http' 'azure' 'resource-manager' 'operation-templates'
Join-Path 'http' 'azure' 'resource-manager' 'resources'
+ Join-Path 'http' 'azure' 'resource-manager' 'large-header'
)
diff --git a/eng/packages/http-client-csharp/generator/Azure.Generator/src/Properties/launchSettings.json b/eng/packages/http-client-csharp/generator/Azure.Generator/src/Properties/launchSettings.json
index e2c15e45bc10..46827c1b7080 100644
--- a/eng/packages/http-client-csharp/generator/Azure.Generator/src/Properties/launchSettings.json
+++ b/eng/packages/http-client-csharp/generator/Azure.Generator/src/Properties/launchSettings.json
@@ -50,11 +50,6 @@
"commandName": "Executable",
"executablePath": "dotnet"
},
- "http-azure-resource-manager-large-header": {
- "commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/azure/resource-manager/large-header -g AzureStubGenerator",
- "commandName": "Executable",
- "executablePath": "dotnet"
- },
"http-azure-special-headers-client-request-id": {
"commandLineArgs": "$(SolutionDir)/../dist/generator/Microsoft.TypeSpec.Generator.dll $(SolutionDir)/TestProjects/Spector/http/azure/special-headers/client-request-id -g AzureStubGenerator",
"commandName": "Executable",
diff --git a/eng/packages/http-client-csharp/generator/Azure.Generator/src/Providers/CollectionResultDefinition.cs b/eng/packages/http-client-csharp/generator/Azure.Generator/src/Providers/CollectionResultDefinition.cs
index 96de3e41aa62..241a388f2498 100644
--- a/eng/packages/http-client-csharp/generator/Azure.Generator/src/Providers/CollectionResultDefinition.cs
+++ b/eng/packages/http-client-csharp/generator/Azure.Generator/src/Providers/CollectionResultDefinition.cs
@@ -266,7 +266,12 @@ private ValueExpression BuildGetNextPage(VariableExpression responseWithTypeVari
return _nextPageLocation switch
{
- InputResponseLocation.Body =>NeedsConversionToUri() ? New.Instance(responseWithTypeVariable.Property(_nextPagePropertyName)) : responseWithTypeVariable.Property(_nextPagePropertyName),
+ InputResponseLocation.Body => NeedsConversionToUri() ?
+ new TernaryConditionalExpression(
+ responseWithTypeVariable.Property(_nextPagePropertyName).NotEqual(Null),
+ New.Instance(responseWithTypeVariable.Property(_nextPagePropertyName)),
+ Null)
+ : responseWithTypeVariable.Property(_nextPagePropertyName),
InputResponseLocation.Header => new TernaryConditionalExpression(
responseVariable.Property("Headers")
.Invoke("TryGetValue", Literal(_nextPagePropertyName),
diff --git a/eng/packages/http-client-csharp/generator/Azure.Generator/src/Utilities/TypeNameUtilities.cs b/eng/packages/http-client-csharp/generator/Azure.Generator/src/Utilities/TypeNameUtilities.cs
index 38bdaeb37445..5cedd56802cd 100644
--- a/eng/packages/http-client-csharp/generator/Azure.Generator/src/Utilities/TypeNameUtilities.cs
+++ b/eng/packages/http-client-csharp/generator/Azure.Generator/src/Utilities/TypeNameUtilities.cs
@@ -8,6 +8,7 @@ namespace Azure.Generator.Utilities
internal static class TypeNameUtilities
{
private const string AzurePackageNamespacePrefix = "Azure.";
+ private const string AzureResourceManagerPackageNamespacePrefix = "Azure.ResourceManager.";
///
/// Returns the name of the RP from the package name using the following:
@@ -19,6 +20,10 @@ public static string GetResourceProviderName()
{
var packageName = AzureClientGenerator.Instance.Configuration.PackageName;
var segments = packageName.Split('.');
+ if (packageName.StartsWith(AzureResourceManagerPackageNamespacePrefix))
+ {
+ return $"Arm{string.Join("", segments.Skip(2))}";
+ }
if (packageName.StartsWith(AzurePackageNamespacePrefix))
{
if (segments.Length > 2)
diff --git a/eng/packages/http-client-csharp/generator/Azure.Generator/src/Visitors/ModelFactoryRenamerVisitor.cs b/eng/packages/http-client-csharp/generator/Azure.Generator/src/Visitors/ModelFactoryRenamerVisitor.cs
index 5f42e7826fe9..20660e9c1e34 100644
--- a/eng/packages/http-client-csharp/generator/Azure.Generator/src/Visitors/ModelFactoryRenamerVisitor.cs
+++ b/eng/packages/http-client-csharp/generator/Azure.Generator/src/Visitors/ModelFactoryRenamerVisitor.cs
@@ -13,7 +13,9 @@ internal class ModelFactoryRenamerVisitor : ScmLibraryVisitor
{
if (type is ModelFactoryProvider && type.CustomCodeView == null)
{
- type.Update(name: $"{TypeNameUtilities.GetResourceProviderName()}ModelFactory");
+ // Reset the type provider so that all the methods will be recomputed after the name change.
+ // This is necessary because the name change will impact the custom code view calculation.
+ type.Update(name: $"{TypeNameUtilities.GetResourceProviderName()}ModelFactory", reset: true);
}
return type;
diff --git a/eng/packages/http-client-csharp/generator/Azure.Generator/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyOfTWithStringProperty.cs b/eng/packages/http-client-csharp/generator/Azure.Generator/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyOfTWithStringProperty.cs
index 62ac4a47c39a..ef60cda8bf63 100644
--- a/eng/packages/http-client-csharp/generator/Azure.Generator/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyOfTWithStringProperty.cs
+++ b/eng/packages/http-client-csharp/generator/Azure.Generator/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyOfTWithStringProperty.cs
@@ -43,7 +43,7 @@ public CatClientGetCatsCollectionResultOfT(global::Samples.CatClient client, glo
yield break;
}
global::Samples.Models.Page responseWithType = ((global::Samples.Models.Page)response);
- nextPage = new global::System.Uri(responseWithType.NextCat);
+ nextPage = (responseWithType.NextCat != null) ? new global::System.Uri(responseWithType.NextCat) : null;
yield return global::Azure.Page.FromValues(((global::System.Collections.Generic.IReadOnlyList)responseWithType.Cats), nextPage?.AbsoluteUri, response);
}
while ((nextPage != null));
diff --git a/eng/packages/http-client-csharp/generator/Azure.Generator/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyWithStringProperty.cs b/eng/packages/http-client-csharp/generator/Azure.Generator/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyWithStringProperty.cs
index ea55b046a138..57b1b5d27510 100644
--- a/eng/packages/http-client-csharp/generator/Azure.Generator/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyWithStringProperty.cs
+++ b/eng/packages/http-client-csharp/generator/Azure.Generator/test/Providers/CollectionResultDefinitions/TestData/NextLinkTests/NextLinkInBodyWithStringProperty.cs
@@ -48,7 +48,7 @@ public CatClientGetCatsCollectionResult(global::Samples.CatClient client, global
{
items.Add(global::System.BinaryData.FromObjectAsJson(item));
}
- nextPage = new global::System.Uri(responseWithType.NextCat);
+ nextPage = (responseWithType.NextCat != null) ? new global::System.Uri(responseWithType.NextCat) : null;
yield return global::Azure.Page.FromValues(items, nextPage?.AbsoluteUri, response);
}
while ((nextPage != null));
diff --git a/eng/packages/http-client-csharp/generator/Azure.Generator/test/Visitors/ModelFactoryRenamerVisitorTests.cs b/eng/packages/http-client-csharp/generator/Azure.Generator/test/Visitors/ModelFactoryRenamerVisitorTests.cs
index 94f8f00d0b72..c6f1cf8fee2c 100644
--- a/eng/packages/http-client-csharp/generator/Azure.Generator/test/Visitors/ModelFactoryRenamerVisitorTests.cs
+++ b/eng/packages/http-client-csharp/generator/Azure.Generator/test/Visitors/ModelFactoryRenamerVisitorTests.cs
@@ -40,7 +40,7 @@ public void MgmtPlaneModelFactoryIsNamedCorrectly()
var modelFactory = plugin.Object.OutputLibrary.TypeProviders.OfType().SingleOrDefault();
Assert.IsNotNull(modelFactory);
- Assert.AreEqual("SomeServiceModelFactory", modelFactory!.Type.Name);
+ Assert.AreEqual("ArmSomeServiceModelFactory", modelFactory!.Type.Name);
}
[Test]
@@ -58,6 +58,42 @@ public void GenericModelFactoryIsNamedCorrectly()
Assert.AreEqual("SamplesModelFactory", modelFactory!.Type.Name);
}
+ [Test]
+ public void CachedMethodsAreResetAfterRenaming()
+ {
+ var model = InputFactory.Model("SomeModel");
+ var plugin = MockHelpers.LoadMockGenerator(
+ inputModels: () => [model],
+ configurationJson: "{ \"package-name\": \"Azure.Messaging.SomeService\" }");
+
+ var visitor = new TestModelRenamerVisitor();
+ visitor.InvokeVisitLibrary(plugin.Object.OutputLibrary);
+
+ var modelFactory = plugin.Object.OutputLibrary.TypeProviders.OfType().SingleOrDefault();
+ Assert.IsNotNull(modelFactory);
+ Assert.AreEqual(1, modelFactory!.Methods.Count);
+ Assert.AreEqual("RenamedModel", modelFactory.Methods[0].Signature.Name);
+ }
+
+ private class TestModelRenamerVisitor : ModelFactoryRenamerVisitor
+ {
+ protected override TypeProvider? VisitType(TypeProvider type)
+ {
+ if (type is ModelProvider)
+ {
+ type.Update(name: "RenamedModel");
+ return type;
+ }
+
+ return base.VisitType(type);
+ }
+
+ public void InvokeVisitLibrary(OutputLibrary library)
+ {
+ base.VisitLibrary(library);
+ }
+ }
+
private class TestModelFactoryRenamerVisitor : ModelFactoryRenamerVisitor
{
public void InvokeVisitLibrary(OutputLibrary library)
diff --git a/eng/packages/http-client-csharp/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/BasicTypeSpecClientGetWithStringNextLinkAsyncCollectionResult.cs b/eng/packages/http-client-csharp/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/BasicTypeSpecClientGetWithStringNextLinkAsyncCollectionResult.cs
index 23b30a8e54da..8fca2bd3542e 100644
--- a/eng/packages/http-client-csharp/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/BasicTypeSpecClientGetWithStringNextLinkAsyncCollectionResult.cs
+++ b/eng/packages/http-client-csharp/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/BasicTypeSpecClientGetWithStringNextLinkAsyncCollectionResult.cs
@@ -48,7 +48,7 @@ public override async IAsyncEnumerable> AsPages(string continua
{
items.Add(BinaryData.FromObjectAsJson(item));
}
- nextPage = new Uri(responseWithType.Next);
+ nextPage = responseWithType.Next != null ? new Uri(responseWithType.Next) : null;
yield return Page.FromValues(items, nextPage?.AbsoluteUri, response);
}
while (nextPage != null);
diff --git a/eng/packages/http-client-csharp/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/BasicTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT.cs b/eng/packages/http-client-csharp/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/BasicTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT.cs
index 828f5dba1c0e..9cdbf253e41f 100644
--- a/eng/packages/http-client-csharp/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/BasicTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT.cs
+++ b/eng/packages/http-client-csharp/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/BasicTypeSpecClientGetWithStringNextLinkAsyncCollectionResultOfT.cs
@@ -43,7 +43,7 @@ public override async IAsyncEnumerable> AsPages(string continua
yield break;
}
ListWithStringNextLinkResponse responseWithType = (ListWithStringNextLinkResponse)response;
- nextPage = new Uri(responseWithType.Next);
+ nextPage = responseWithType.Next != null ? new Uri(responseWithType.Next) : null;
yield return Page.FromValues((IReadOnlyList)responseWithType.Things, nextPage?.AbsoluteUri, response);
}
while (nextPage != null);
diff --git a/eng/packages/http-client-csharp/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/BasicTypeSpecClientGetWithStringNextLinkCollectionResult.cs b/eng/packages/http-client-csharp/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/BasicTypeSpecClientGetWithStringNextLinkCollectionResult.cs
index 02d51ab95f56..75724f12b964 100644
--- a/eng/packages/http-client-csharp/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/BasicTypeSpecClientGetWithStringNextLinkCollectionResult.cs
+++ b/eng/packages/http-client-csharp/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/BasicTypeSpecClientGetWithStringNextLinkCollectionResult.cs
@@ -47,7 +47,7 @@ public override IEnumerable> AsPages(string continuationToken,
{
items.Add(BinaryData.FromObjectAsJson(item));
}
- nextPage = new Uri(responseWithType.Next);
+ nextPage = responseWithType.Next != null ? new Uri(responseWithType.Next) : null;
yield return Page.FromValues(items, nextPage?.AbsoluteUri, response);
}
while (nextPage != null);
diff --git a/eng/packages/http-client-csharp/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/BasicTypeSpecClientGetWithStringNextLinkCollectionResultOfT.cs b/eng/packages/http-client-csharp/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/BasicTypeSpecClientGetWithStringNextLinkCollectionResultOfT.cs
index ca0753580626..6bdc195b97b4 100644
--- a/eng/packages/http-client-csharp/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/BasicTypeSpecClientGetWithStringNextLinkCollectionResultOfT.cs
+++ b/eng/packages/http-client-csharp/generator/TestProjects/Local/Basic-TypeSpec/src/Generated/BasicTypeSpecClientGetWithStringNextLinkCollectionResultOfT.cs
@@ -42,7 +42,7 @@ public override IEnumerable> AsPages(string continuationToken,
yield break;
}
ListWithStringNextLinkResponse responseWithType = (ListWithStringNextLinkResponse)response;
- nextPage = new Uri(responseWithType.Next);
+ nextPage = responseWithType.Next != null ? new Uri(responseWithType.Next) : null;
yield return Page.FromValues((IReadOnlyList)responseWithType.Things, nextPage?.AbsoluteUri, response);
}
while (nextPage != null);
diff --git a/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/Configuration.json b/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/Configuration.json
deleted file mode 100644
index 418c2322e066..000000000000
--- a/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/Configuration.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "package-name": "Azure.ResourceManager.LargeHeader",
- "license": {
- "name": "MIT License",
- "company": "Microsoft Corporation",
- "link": "https://mit-license.org",
- "header": "Copyright (c) Microsoft Corporation. All rights reserved.\nLicensed under the MIT License.",
- "description": "Copyright (c) Microsoft Corporation\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the “Software”), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE."
- }
-}
diff --git a/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Azure.ResourceManager.LargeHeader.csproj b/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Azure.ResourceManager.LargeHeader.csproj
deleted file mode 100644
index 320063025fae..000000000000
--- a/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Azure.ResourceManager.LargeHeader.csproj
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
- This is the Azure.ResourceManager.LargeHeader client library for developing .NET applications with rich experience.
- SDK Code Generation Azure.ResourceManager.LargeHeader
- 1.0.0-beta.1
- Azure.ResourceManager.LargeHeader
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/CancelResult.Serialization.cs b/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/CancelResult.Serialization.cs
deleted file mode 100644
index d7d050849d6f..000000000000
--- a/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/CancelResult.Serialization.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.ClientModel.Primitives;
-using System.Text.Json;
-using Azure;
-
-namespace Azure.ResourceManager.LargeHeader
-{
- public partial class CancelResult : IJsonModel
- {
- internal CancelResult() => throw null;
-
- void IJsonModel.Write(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null;
-
- protected virtual void JsonModelWriteCore(Utf8JsonWriter writer, ModelReaderWriterOptions options) => throw null;
-
- CancelResult IJsonModel.Create(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null;
-
- protected virtual CancelResult JsonModelCreateCore(ref Utf8JsonReader reader, ModelReaderWriterOptions options) => throw null;
-
- BinaryData IPersistableModel.Write(ModelReaderWriterOptions options) => throw null;
-
- protected virtual BinaryData PersistableModelWriteCore(ModelReaderWriterOptions options) => throw null;
-
- CancelResult IPersistableModel.Create(BinaryData data, ModelReaderWriterOptions options) => throw null;
-
- protected virtual CancelResult PersistableModelCreateCore(BinaryData data, ModelReaderWriterOptions options) => throw null;
-
- string IPersistableModel.GetFormatFromOptions(ModelReaderWriterOptions options) => throw null;
-
- public static explicit operator CancelResult(Response result) => throw null;
- }
-}
diff --git a/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/CancelResult.cs b/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/CancelResult.cs
deleted file mode 100644
index b6e9bab45fc2..000000000000
--- a/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/CancelResult.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-namespace Azure.ResourceManager.LargeHeader
-{
- public partial class CancelResult
- {
- public bool Succeeded => throw null;
- }
-}
diff --git a/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/LargeHeaderClient.cs b/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/LargeHeaderClient.cs
deleted file mode 100644
index f8e2a584102d..000000000000
--- a/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/LargeHeaderClient.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using Azure.Core;
-using Azure.Core.Pipeline;
-
-namespace Azure.ResourceManager.LargeHeader
-{
- public partial class LargeHeaderClient
- {
- protected LargeHeaderClient() => throw null;
-
- public LargeHeaderClient(Guid subscriptionId, TokenCredential credential) : this(new Uri("https://management.azure.com"), subscriptionId, credential, new LargeHeaderClientOptions()) => throw null;
-
- public LargeHeaderClient(Uri endpoint, Guid subscriptionId, TokenCredential credential, LargeHeaderClientOptions options) => throw null;
-
- public virtual HttpPipeline Pipeline => throw null;
-
- public virtual LargeHeaders GetLargeHeadersClient() => throw null;
- }
-}
diff --git a/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/LargeHeaderClientBuilderExtensions.cs b/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/LargeHeaderClientBuilderExtensions.cs
deleted file mode 100644
index 5b4bcf3b48e8..000000000000
--- a/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/LargeHeaderClientBuilderExtensions.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Diagnostics.CodeAnalysis;
-using Azure.Core.Extensions;
-using Azure.ResourceManager.LargeHeader;
-
-namespace Microsoft.Extensions.Azure
-{
- public static partial class LargeHeaderClientBuilderExtensions
- {
- public static IAzureClientBuilder AddLargeHeaderClient(this TBuilder builder, Uri endpoint, Guid subscriptionId)
- where TBuilder : IAzureClientFactoryBuilderWithCredential => throw null;
-
- [RequiresUnreferencedCode("Requires unreferenced code until we opt into EnableConfigurationBindingGenerator.")]
- [RequiresDynamicCode("Requires unreferenced code until we opt into EnableConfigurationBindingGenerator.")]
- public static IAzureClientBuilder AddLargeHeaderClient(this TBuilder builder, TConfiguration configuration)
- where TBuilder : IAzureClientFactoryBuilderWithConfiguration => throw null;
- }
-}
diff --git a/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/LargeHeaderClientOptions.cs b/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/LargeHeaderClientOptions.cs
deleted file mode 100644
index 46696c34d723..000000000000
--- a/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/LargeHeaderClientOptions.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using Azure.Core;
-
-namespace Azure.ResourceManager.LargeHeader
-{
- public partial class LargeHeaderClientOptions : ClientOptions
- {
- private const ServiceVersion LatestVersion = ServiceVersion.V2023_12_01_Preview;
-
- public LargeHeaderClientOptions(ServiceVersion version = LatestVersion) => throw null;
-
- public enum ServiceVersion
- {
- /// Preview API version 2023-12-01-preview.
- V2023_12_01_Preview = 1
- }
- }
-}
diff --git a/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/LargeHeaderModelFactory.cs b/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/LargeHeaderModelFactory.cs
deleted file mode 100644
index f4d65af5360f..000000000000
--- a/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/LargeHeaderModelFactory.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using Azure.ResourceManager;
-
-namespace Azure.ResourceManager.LargeHeader
-{
- public static partial class LargeHeaderModelFactory
- {
- public static CancelResult CancelResult(bool succeeded = default) => throw null;
- }
-}
diff --git a/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/LargeHeaders.cs b/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/LargeHeaders.cs
deleted file mode 100644
index 9f0e2487f292..000000000000
--- a/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/LargeHeaders.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-using Azure;
-using Azure.Core.Pipeline;
-
-namespace Azure.ResourceManager.LargeHeader
-{
- public partial class LargeHeaders
- {
- protected LargeHeaders() => throw null;
-
- public virtual HttpPipeline Pipeline => throw null;
-
- public virtual Operation Two6k(WaitUntil waitUntil, string resourceGroupName, string largeHeaderName, RequestContext context) => throw null;
-
- public virtual Task> Two6kAsync(WaitUntil waitUntil, string resourceGroupName, string largeHeaderName, RequestContext context) => throw null;
-
- public virtual Operation Two6k(WaitUntil waitUntil, string resourceGroupName, string largeHeaderName, CancellationToken cancellationToken = default) => throw null;
-
- public virtual Task> Two6kAsync(WaitUntil waitUntil, string resourceGroupName, string largeHeaderName, CancellationToken cancellationToken = default) => throw null;
- }
-}
diff --git a/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Models/AzureResourceManagerLargeHeaderContext.cs b/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Models/AzureResourceManagerLargeHeaderContext.cs
deleted file mode 100644
index 306e3facabd5..000000000000
--- a/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/src/Generated/Models/AzureResourceManagerLargeHeaderContext.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-//
-
-#nullable disable
-
-using System.ClientModel.Primitives;
-
-namespace Azure.ResourceManager.LargeHeader
-{
- public partial class AzureResourceManagerLargeHeaderContext : ModelReaderWriterContext
- {
- }
-}
diff --git a/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/tspCodeModel.json b/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/tspCodeModel.json
deleted file mode 100644
index de4cf9d05635..000000000000
--- a/eng/packages/http-client-csharp/generator/TestProjects/Spector/http/azure/resource-manager/large-header/tspCodeModel.json
+++ /dev/null
@@ -1,1069 +0,0 @@
-{
- "$id": "1",
- "name": "Azure.ResourceManager.LargeHeader",
- "apiVersions": [
- "2023-12-01-preview"
- ],
- "enums": [
- {
- "$id": "2",
- "kind": "enum",
- "name": "ResourceProvisioningState",
- "crossLanguageDefinitionId": "Azure.ResourceManager.ResourceProvisioningState",
- "valueType": {
- "$id": "3",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- },
- "values": [
- {
- "$id": "4",
- "kind": "enumvalue",
- "name": "Succeeded",
- "value": "Succeeded",
- "valueType": {
- "$id": "5",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- },
- "enumType": {
- "$ref": "2"
- },
- "doc": "Resource has been created.",
- "decorators": []
- },
- {
- "$id": "6",
- "kind": "enumvalue",
- "name": "Failed",
- "value": "Failed",
- "valueType": {
- "$id": "7",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- },
- "enumType": {
- "$ref": "2"
- },
- "doc": "Resource creation failed.",
- "decorators": []
- },
- {
- "$id": "8",
- "kind": "enumvalue",
- "name": "Canceled",
- "value": "Canceled",
- "valueType": {
- "$id": "9",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- },
- "enumType": {
- "$ref": "2"
- },
- "doc": "Resource creation was canceled.",
- "decorators": []
- }
- ],
- "namespace": "Azure.ResourceManager",
- "doc": "The provisioning state of a resource type.",
- "isFixed": false,
- "isFlags": false,
- "usage": "LroPolling",
- "decorators": []
- },
- {
- "$id": "10",
- "kind": "enum",
- "name": "Versions",
- "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.Versions",
- "valueType": {
- "$id": "11",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- },
- "values": [
- {
- "$id": "12",
- "kind": "enumvalue",
- "name": "v2023_12_01_preview",
- "value": "2023-12-01-preview",
- "valueType": {
- "$id": "13",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- },
- "enumType": {
- "$ref": "10"
- },
- "doc": "Preview API version 2023-12-01-preview.",
- "decorators": []
- }
- ],
- "namespace": "Azure.ResourceManager.LargeHeader",
- "doc": "Azure API versions.",
- "isFixed": true,
- "isFlags": false,
- "usage": "ApiVersionEnum",
- "decorators": []
- }
- ],
- "constants": [
- {
- "$id": "14",
- "kind": "constant",
- "name": "two6kContentType",
- "namespace": "",
- "usage": "None",
- "valueType": {
- "$id": "15",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- },
- "value": "application/json",
- "decorators": []
- },
- {
- "$id": "16",
- "kind": "constant",
- "name": "two6kContentType1",
- "namespace": "",
- "usage": "None",
- "valueType": {
- "$id": "17",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- },
- "value": "application/json",
- "decorators": []
- }
- ],
- "models": [
- {
- "$id": "18",
- "kind": "model",
- "name": "CancelResult",
- "namespace": "Azure.ResourceManager.LargeHeader",
- "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.CancelResult",
- "usage": "Output,Json,LroInitial,LroFinalEnvelope",
- "decorators": [],
- "properties": [
- {
- "$id": "19",
- "kind": "property",
- "name": "succeeded",
- "serializedName": "succeeded",
- "type": {
- "$id": "20",
- "kind": "boolean",
- "name": "boolean",
- "crossLanguageDefinitionId": "TypeSpec.boolean",
- "decorators": []
- },
- "optional": false,
- "readOnly": false,
- "discriminator": false,
- "flatten": false,
- "decorators": [],
- "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.CancelResult.succeeded",
- "serializationOptions": {
- "$id": "21",
- "json": {
- "$id": "22",
- "name": "succeeded"
- }
- }
- }
- ]
- },
- {
- "$id": "23",
- "kind": "model",
- "name": "ErrorResponse",
- "namespace": "Azure.ResourceManager.CommonTypes",
- "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorResponse",
- "usage": "Json,Exception",
- "doc": "Common error response for all Azure Resource Manager APIs to return error details for failed operations.",
- "summary": "Error response",
- "decorators": [],
- "properties": [
- {
- "$id": "24",
- "kind": "property",
- "name": "error",
- "serializedName": "error",
- "doc": "The error object.",
- "type": {
- "$id": "25",
- "kind": "model",
- "name": "ErrorDetail",
- "namespace": "Azure.ResourceManager.CommonTypes",
- "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail",
- "usage": "Json,Exception,LroPolling",
- "doc": "The error detail.",
- "decorators": [],
- "properties": [
- {
- "$id": "26",
- "kind": "property",
- "name": "code",
- "serializedName": "code",
- "doc": "The error code.",
- "type": {
- "$id": "27",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- },
- "optional": true,
- "readOnly": true,
- "discriminator": false,
- "flatten": false,
- "decorators": [],
- "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.code",
- "serializationOptions": {
- "$id": "28",
- "json": {
- "$id": "29",
- "name": "code"
- }
- }
- },
- {
- "$id": "30",
- "kind": "property",
- "name": "message",
- "serializedName": "message",
- "doc": "The error message.",
- "type": {
- "$id": "31",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- },
- "optional": true,
- "readOnly": true,
- "discriminator": false,
- "flatten": false,
- "decorators": [],
- "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.message",
- "serializationOptions": {
- "$id": "32",
- "json": {
- "$id": "33",
- "name": "message"
- }
- }
- },
- {
- "$id": "34",
- "kind": "property",
- "name": "target",
- "serializedName": "target",
- "doc": "The error target.",
- "type": {
- "$id": "35",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- },
- "optional": true,
- "readOnly": true,
- "discriminator": false,
- "flatten": false,
- "decorators": [],
- "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.target",
- "serializationOptions": {
- "$id": "36",
- "json": {
- "$id": "37",
- "name": "target"
- }
- }
- },
- {
- "$id": "38",
- "kind": "property",
- "name": "details",
- "serializedName": "details",
- "doc": "The error details.",
- "type": {
- "$id": "39",
- "kind": "array",
- "name": "ArrayErrorDetail",
- "valueType": {
- "$ref": "25"
- },
- "crossLanguageDefinitionId": "TypeSpec.Array",
- "decorators": []
- },
- "optional": true,
- "readOnly": true,
- "discriminator": false,
- "flatten": false,
- "decorators": [],
- "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.details",
- "serializationOptions": {
- "$id": "40",
- "json": {
- "$id": "41",
- "name": "details"
- }
- }
- },
- {
- "$id": "42",
- "kind": "property",
- "name": "additionalInfo",
- "serializedName": "additionalInfo",
- "doc": "The error additional info.",
- "type": {
- "$id": "43",
- "kind": "array",
- "name": "ArrayErrorAdditionalInfo",
- "valueType": {
- "$id": "44",
- "kind": "model",
- "name": "ErrorAdditionalInfo",
- "namespace": "Azure.ResourceManager.CommonTypes",
- "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo",
- "usage": "Json,Exception,LroPolling",
- "doc": "The resource management error additional info.",
- "decorators": [],
- "properties": [
- {
- "$id": "45",
- "kind": "property",
- "name": "type",
- "serializedName": "type",
- "doc": "The additional info type.",
- "type": {
- "$id": "46",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- },
- "optional": true,
- "readOnly": true,
- "discriminator": false,
- "flatten": false,
- "decorators": [],
- "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo.type",
- "serializationOptions": {
- "$id": "47",
- "json": {
- "$id": "48",
- "name": "type"
- }
- }
- },
- {
- "$id": "49",
- "kind": "property",
- "name": "info",
- "serializedName": "info",
- "doc": "The additional info.",
- "type": {
- "$id": "50",
- "kind": "unknown",
- "name": "unknown",
- "crossLanguageDefinitionId": "",
- "decorators": []
- },
- "optional": true,
- "readOnly": true,
- "discriminator": false,
- "flatten": false,
- "decorators": [],
- "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorAdditionalInfo.info",
- "serializationOptions": {
- "$id": "51",
- "json": {
- "$id": "52",
- "name": "info"
- }
- }
- }
- ]
- },
- "crossLanguageDefinitionId": "TypeSpec.Array",
- "decorators": []
- },
- "optional": true,
- "readOnly": true,
- "discriminator": false,
- "flatten": false,
- "decorators": [],
- "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorDetail.additionalInfo",
- "serializationOptions": {
- "$id": "53",
- "json": {
- "$id": "54",
- "name": "additionalInfo"
- }
- }
- }
- ]
- },
- "optional": true,
- "readOnly": false,
- "discriminator": false,
- "flatten": false,
- "decorators": [],
- "crossLanguageDefinitionId": "Azure.ResourceManager.CommonTypes.ErrorResponse.error",
- "serializationOptions": {
- "$id": "55",
- "json": {
- "$id": "56",
- "name": "error"
- }
- }
- }
- ]
- },
- {
- "$ref": "25"
- },
- {
- "$ref": "44"
- },
- {
- "$id": "57",
- "kind": "model",
- "name": "ArmOperationStatusResourceProvisioningState",
- "namespace": "Azure.ResourceManager",
- "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus",
- "usage": "LroPolling",
- "doc": "Standard Azure Resource Manager operation status response",
- "decorators": [],
- "properties": [
- {
- "$id": "58",
- "kind": "property",
- "name": "status",
- "serializedName": "status",
- "doc": "The operation status",
- "type": {
- "$ref": "2"
- },
- "optional": false,
- "readOnly": false,
- "discriminator": false,
- "flatten": false,
- "decorators": [],
- "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.status",
- "serializationOptions": {
- "$id": "59",
- "json": {
- "$id": "60",
- "name": "status"
- }
- }
- },
- {
- "$id": "61",
- "kind": "path",
- "name": "id",
- "serializedName": "id",
- "doc": "The unique identifier for the operationStatus resource",
- "type": {
- "$id": "62",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- },
- "optional": false,
- "readOnly": false,
- "decorators": [],
- "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.id",
- "explode": false,
- "style": "simple",
- "allowReserved": false,
- "correspondingMethodParams": []
- },
- {
- "$id": "63",
- "kind": "property",
- "name": "name",
- "serializedName": "name",
- "doc": "The name of the operationStatus resource",
- "type": {
- "$id": "64",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- },
- "optional": true,
- "readOnly": true,
- "discriminator": false,
- "flatten": false,
- "decorators": [],
- "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.name",
- "serializationOptions": {
- "$id": "65",
- "json": {
- "$id": "66",
- "name": "name"
- }
- }
- },
- {
- "$id": "67",
- "kind": "property",
- "name": "startTime",
- "serializedName": "startTime",
- "doc": "Operation start time",
- "type": {
- "$id": "68",
- "kind": "utcDateTime",
- "name": "utcDateTime",
- "encode": "rfc3339",
- "wireType": {
- "$id": "69",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- },
- "crossLanguageDefinitionId": "TypeSpec.utcDateTime",
- "decorators": []
- },
- "optional": true,
- "readOnly": true,
- "discriminator": false,
- "flatten": false,
- "decorators": [],
- "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.startTime",
- "serializationOptions": {
- "$id": "70",
- "json": {
- "$id": "71",
- "name": "startTime"
- }
- }
- },
- {
- "$id": "72",
- "kind": "property",
- "name": "endTime",
- "serializedName": "endTime",
- "doc": "Operation complete time",
- "type": {
- "$id": "73",
- "kind": "utcDateTime",
- "name": "utcDateTime",
- "encode": "rfc3339",
- "wireType": {
- "$id": "74",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- },
- "crossLanguageDefinitionId": "TypeSpec.utcDateTime",
- "decorators": []
- },
- "optional": true,
- "readOnly": true,
- "discriminator": false,
- "flatten": false,
- "decorators": [],
- "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.endTime",
- "serializationOptions": {
- "$id": "75",
- "json": {
- "$id": "76",
- "name": "endTime"
- }
- }
- },
- {
- "$id": "77",
- "kind": "property",
- "name": "percentComplete",
- "serializedName": "percentComplete",
- "doc": "The progress made toward completing the operation",
- "type": {
- "$id": "78",
- "kind": "float64",
- "name": "float64",
- "crossLanguageDefinitionId": "TypeSpec.float64",
- "decorators": []
- },
- "optional": true,
- "readOnly": true,
- "discriminator": false,
- "flatten": false,
- "decorators": [],
- "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.percentComplete",
- "serializationOptions": {
- "$id": "79",
- "json": {
- "$id": "80",
- "name": "percentComplete"
- }
- }
- },
- {
- "$id": "81",
- "kind": "property",
- "name": "error",
- "serializedName": "error",
- "doc": "Errors that occurred if the operation ended with Canceled or Failed status",
- "type": {
- "$ref": "25"
- },
- "optional": true,
- "readOnly": true,
- "discriminator": false,
- "flatten": false,
- "decorators": [],
- "crossLanguageDefinitionId": "Azure.ResourceManager.ArmOperationStatus.error",
- "serializationOptions": {
- "$id": "82",
- "json": {
- "$id": "83",
- "name": "error"
- }
- }
- }
- ]
- }
- ],
- "clients": [
- {
- "$id": "84",
- "kind": "client",
- "name": "LargeHeaderClient",
- "namespace": "Azure.ResourceManager.LargeHeader",
- "doc": "Arm Resource Provider management API.",
- "methods": [],
- "parameters": [
- {
- "$id": "85",
- "name": "endpoint",
- "nameInRequest": "endpoint",
- "doc": "Service host",
- "type": {
- "$id": "86",
- "kind": "url",
- "name": "endpoint",
- "crossLanguageDefinitionId": "TypeSpec.url"
- },
- "location": "Uri",
- "isApiVersion": false,
- "isContentType": false,
- "isRequired": true,
- "isEndpoint": true,
- "skipUrlEncoding": false,
- "explode": false,
- "kind": "Client",
- "defaultValue": {
- "$id": "87",
- "type": {
- "$id": "88",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string"
- },
- "value": "https://management.azure.com"
- },
- "serverUrlTemplate": "{endpoint}"
- }
- ],
- "decorators": [],
- "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader",
- "apiVersions": [
- "2023-12-01-preview"
- ],
- "children": [
- {
- "$id": "89",
- "kind": "client",
- "name": "LargeHeaders",
- "namespace": "Azure.ResourceManager.LargeHeader",
- "methods": [
- {
- "$id": "90",
- "kind": "lro",
- "name": "two6k",
- "accessibility": "public",
- "apiVersions": [
- "2023-12-01-preview"
- ],
- "doc": "A long-running resource action.",
- "operation": {
- "$id": "91",
- "name": "two6k",
- "resourceName": "LargeHeaders",
- "doc": "A long-running resource action.",
- "accessibility": "public",
- "parameters": [
- {
- "$id": "92",
- "name": "apiVersion",
- "nameInRequest": "api-version",
- "doc": "The API version to use for this operation.",
- "type": {
- "$id": "93",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- },
- "location": "Query",
- "isApiVersion": true,
- "isContentType": false,
- "isEndpoint": false,
- "explode": false,
- "isRequired": true,
- "kind": "Client",
- "defaultValue": {
- "$id": "94",
- "type": {
- "$id": "95",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string"
- },
- "value": "2023-12-01-preview"
- },
- "decorators": [],
- "skipUrlEncoding": false
- },
- {
- "$id": "96",
- "name": "subscriptionId",
- "nameInRequest": "subscriptionId",
- "doc": "The ID of the target subscription. The value must be an UUID.",
- "type": {
- "$id": "97",
- "kind": "string",
- "name": "uuid",
- "crossLanguageDefinitionId": "Azure.Core.uuid",
- "baseType": {
- "$id": "98",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- },
- "decorators": []
- },
- "location": "Path",
- "isApiVersion": false,
- "isContentType": false,
- "isEndpoint": false,
- "explode": false,
- "isRequired": true,
- "kind": "Client",
- "decorators": [],
- "skipUrlEncoding": false
- },
- {
- "$id": "99",
- "name": "resourceGroupName",
- "nameInRequest": "resourceGroupName",
- "doc": "The name of the resource group. The name is case insensitive.",
- "type": {
- "$id": "100",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- },
- "location": "Path",
- "isApiVersion": false,
- "isContentType": false,
- "isEndpoint": false,
- "explode": false,
- "isRequired": true,
- "kind": "Method",
- "decorators": [],
- "skipUrlEncoding": false
- },
- {
- "$id": "101",
- "name": "largeHeaderName",
- "nameInRequest": "largeHeaderName",
- "doc": "The name of the LargeHeader",
- "type": {
- "$id": "102",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- },
- "location": "Path",
- "isApiVersion": false,
- "isContentType": false,
- "isEndpoint": false,
- "explode": false,
- "isRequired": true,
- "kind": "Method",
- "decorators": [],
- "skipUrlEncoding": false
- },
- {
- "$id": "103",
- "name": "accept",
- "nameInRequest": "Accept",
- "type": {
- "$ref": "14"
- },
- "location": "Header",
- "isApiVersion": false,
- "isContentType": false,
- "isEndpoint": false,
- "explode": false,
- "isRequired": true,
- "kind": "Constant",
- "decorators": [],
- "skipUrlEncoding": false
- }
- ],
- "responses": [
- {
- "$id": "104",
- "statusCodes": [
- 202
- ],
- "headers": [
- {
- "$id": "105",
- "name": "azureAsyncOperation",
- "nameInResponse": "Azure-AsyncOperation",
- "doc": "A link to the status monitor",
- "type": {
- "$id": "106",
- "kind": "url",
- "name": "ResourceLocation",
- "crossLanguageDefinitionId": "TypeSpec.Rest.ResourceLocation",
- "baseType": {
- "$id": "107",
- "kind": "url",
- "name": "url",
- "crossLanguageDefinitionId": "TypeSpec.url",
- "decorators": []
- },
- "decorators": []
- }
- },
- {
- "$id": "108",
- "name": "location",
- "nameInResponse": "Location",
- "doc": "The Location header contains the URL where the status of the long running operation can be checked.",
- "type": {
- "$id": "109",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- }
- },
- {
- "$id": "110",
- "name": "retryAfter",
- "nameInResponse": "Retry-After",
- "doc": "The Retry-After header can indicate how long the client should wait before polling the operation status.",
- "type": {
- "$id": "111",
- "kind": "int32",
- "name": "int32",
- "crossLanguageDefinitionId": "TypeSpec.int32",
- "decorators": []
- }
- }
- ],
- "isErrorResponse": false
- },
- {
- "$id": "112",
- "statusCodes": [
- 200
- ],
- "bodyType": {
- "$ref": "18"
- },
- "headers": [],
- "isErrorResponse": false,
- "contentTypes": [
- "application/json"
- ]
- }
- ],
- "httpMethod": "POST",
- "uri": "{endpoint}",
- "path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Azure.ResourceManager.LargeHeader/largeHeaders/{largeHeaderName}/two6k",
- "bufferResponse": true,
- "generateProtocolMethod": true,
- "generateConvenienceMethod": true,
- "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.LargeHeaders.two6k",
- "decorators": []
- },
- "parameters": [
- {
- "$id": "113",
- "name": "resourceGroupName",
- "nameInRequest": "resourceGroupName",
- "doc": "The name of the resource group. The name is case insensitive.",
- "type": {
- "$id": "114",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- },
- "location": "Path",
- "isApiVersion": false,
- "isContentType": false,
- "isEndpoint": false,
- "explode": false,
- "isRequired": true,
- "kind": "Method",
- "decorators": [],
- "skipUrlEncoding": false
- },
- {
- "$id": "115",
- "name": "largeHeaderName",
- "nameInRequest": "largeHeaderName",
- "doc": "The name of the LargeHeader",
- "type": {
- "$id": "116",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string",
- "decorators": []
- },
- "location": "Path",
- "isApiVersion": false,
- "isContentType": false,
- "isEndpoint": false,
- "explode": false,
- "isRequired": true,
- "kind": "Method",
- "decorators": [],
- "skipUrlEncoding": false
- },
- {
- "$id": "117",
- "name": "accept",
- "nameInRequest": "accept",
- "type": {
- "$ref": "16"
- },
- "location": "Header",
- "isApiVersion": false,
- "isContentType": false,
- "isEndpoint": false,
- "explode": false,
- "isRequired": true,
- "kind": "Constant",
- "decorators": [],
- "skipUrlEncoding": false
- }
- ],
- "response": {
- "$id": "118",
- "type": {
- "$ref": "18"
- }
- },
- "isOverride": false,
- "generateConvenient": true,
- "generateProtocol": true,
- "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.LargeHeaders.two6k",
- "lroMetadata": {
- "$id": "119",
- "finalStateVia": 1,
- "finalResponse": {
- "$id": "120",
- "statusCodes": [
- 200
- ],
- "bodyType": {
- "$ref": "18"
- }
- }
- }
- }
- ],
- "parameters": [
- {
- "$id": "121",
- "name": "endpoint",
- "nameInRequest": "endpoint",
- "doc": "Service host",
- "type": {
- "$id": "122",
- "kind": "url",
- "name": "endpoint",
- "crossLanguageDefinitionId": "TypeSpec.url"
- },
- "location": "Uri",
- "isApiVersion": false,
- "isContentType": false,
- "isRequired": true,
- "isEndpoint": true,
- "skipUrlEncoding": false,
- "explode": false,
- "kind": "Client",
- "defaultValue": {
- "$id": "123",
- "type": {
- "$id": "124",
- "kind": "string",
- "name": "string",
- "crossLanguageDefinitionId": "TypeSpec.string"
- },
- "value": "https://management.azure.com"
- },
- "serverUrlTemplate": "{endpoint}"
- }
- ],
- "decorators": [],
- "crossLanguageDefinitionId": "Azure.ResourceManager.LargeHeader.LargeHeaders",
- "apiVersions": [
- "2023-12-01-preview"
- ],
- "parent": {
- "$ref": "84"
- }
- }
- ]
- }
- ],
- "auth": {
- "$id": "125",
- "oAuth2": {
- "$id": "126",
- "scopes": [
- "user_impersonation"
- ]
- }
- }
-}
diff --git a/eng/packages/http-client-csharp/package-lock.json b/eng/packages/http-client-csharp/package-lock.json
index b18ccec07abb..3ee842a7b687 100644
--- a/eng/packages/http-client-csharp/package-lock.json
+++ b/eng/packages/http-client-csharp/package-lock.json
@@ -9,7 +9,7 @@
"version": "1.0.0",
"license": "MIT",
"dependencies": {
- "@typespec/http-client-csharp": "1.0.0-alpha.20250624.1"
+ "@typespec/http-client-csharp": "1.0.0-alpha.20250625.1"
},
"devDependencies": {
"@azure-tools/azure-http-specs": "0.1.0-alpha.19",
@@ -2503,9 +2503,9 @@
}
},
"node_modules/@typespec/http-client-csharp": {
- "version": "1.0.0-alpha.20250624.1",
- "resolved": "https://registry.npmjs.org/@typespec/http-client-csharp/-/http-client-csharp-1.0.0-alpha.20250624.1.tgz",
- "integrity": "sha512-6VvNTbQsASv8hJMU4GliUl6bpLEUuqAd2cQJazxhjQQZhtpMmwYxlfOKJ9DJhzsjXshyLrQu8WJLKfD5V7FByQ==",
+ "version": "1.0.0-alpha.20250625.1",
+ "resolved": "https://registry.npmjs.org/@typespec/http-client-csharp/-/http-client-csharp-1.0.0-alpha.20250625.1.tgz",
+ "integrity": "sha512-tvtFsr2cyDFfxTiKENMx17IEkzziUoSkuC2ebArYKWyz5JeFDI9Hr0byunhhtDs/yBlZF4LoKZPQMw4wK9Yo6w==",
"license": "MIT",
"dependencies": {
"json-serialize-refs": "0.1.0-0"
diff --git a/eng/packages/http-client-csharp/package.json b/eng/packages/http-client-csharp/package.json
index d4e0bbd05fe3..a8c8b65e6117 100644
--- a/eng/packages/http-client-csharp/package.json
+++ b/eng/packages/http-client-csharp/package.json
@@ -38,7 +38,7 @@
"dist/generator/**"
],
"dependencies": {
- "@typespec/http-client-csharp": "1.0.0-alpha.20250624.1"
+ "@typespec/http-client-csharp": "1.0.0-alpha.20250625.1"
},
"devDependencies": {
"@azure-tools/azure-http-specs": "0.1.0-alpha.19",
diff --git a/sdk/agricultureplatform/Azure.ResourceManager.AgriculturePlatform/Azure.ResourceManager.AgriculturePlatform.sln b/sdk/agricultureplatform/Azure.ResourceManager.AgriculturePlatform/Azure.ResourceManager.AgriculturePlatform.sln
index c5d9f5f16ec0..ff43d50440cc 100644
--- a/sdk/agricultureplatform/Azure.ResourceManager.AgriculturePlatform/Azure.ResourceManager.AgriculturePlatform.sln
+++ b/sdk/agricultureplatform/Azure.ResourceManager.AgriculturePlatform/Azure.ResourceManager.AgriculturePlatform.sln
@@ -7,8 +7,6 @@ Project("{1EF4A380-C4BD-4259-A8EA-9489EDA8F220}") = "Azure.ResourceManager.Agric
EndProject
Project("{1EF4A380-C4BD-4259-A8EA-9489EDA8F220}") = "Azure.ResourceManager.AgriculturePlatform.Tests", "tests\Azure.ResourceManager.AgriculturePlatform.Tests.csproj", "{69207EE6-C513-4C3E-B4F1-3C54513BC194}"
EndProject
-Project("{1EF4A380-C4BD-4259-A8EA-9489EDA8F220}") = "Azure.ResourceManager.AgriculturePlatform.Samples", "samples\Azure.ResourceManager.AgriculturePlatform.Samples.csproj", "{D13A90DB-89BD-4F64-9C2C-43A1C6C50AFF}"
-EndProject
Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/sdk/agricultureplatform/Azure.ResourceManager.AgriculturePlatform/samples/Azure.ResourceManager.AgriculturePlatform.Samples.csproj b/sdk/agricultureplatform/Azure.ResourceManager.AgriculturePlatform/samples/Azure.ResourceManager.AgriculturePlatform.Samples.csproj
deleted file mode 100644
index 2a0d3739740c..000000000000
--- a/sdk/agricultureplatform/Azure.ResourceManager.AgriculturePlatform/samples/Azure.ResourceManager.AgriculturePlatform.Samples.csproj
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/sdk/agricultureplatform/Azure.ResourceManager.AgriculturePlatform/samples/Generated/Samples/Sample_AgricultureServiceCollection.cs b/sdk/agricultureplatform/Azure.ResourceManager.AgriculturePlatform/tests/Generated/Samples/Sample_AgricultureServiceCollection.cs
similarity index 100%
rename from sdk/agricultureplatform/Azure.ResourceManager.AgriculturePlatform/samples/Generated/Samples/Sample_AgricultureServiceCollection.cs
rename to sdk/agricultureplatform/Azure.ResourceManager.AgriculturePlatform/tests/Generated/Samples/Sample_AgricultureServiceCollection.cs
diff --git a/sdk/agricultureplatform/Azure.ResourceManager.AgriculturePlatform/samples/Generated/Samples/Sample_AgricultureServiceResource.cs b/sdk/agricultureplatform/Azure.ResourceManager.AgriculturePlatform/tests/Generated/Samples/Sample_AgricultureServiceResource.cs
similarity index 100%
rename from sdk/agricultureplatform/Azure.ResourceManager.AgriculturePlatform/samples/Generated/Samples/Sample_AgricultureServiceResource.cs
rename to sdk/agricultureplatform/Azure.ResourceManager.AgriculturePlatform/tests/Generated/Samples/Sample_AgricultureServiceResource.cs
diff --git a/sdk/agricultureplatform/Azure.ResourceManager.AgriculturePlatform/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/agricultureplatform/Azure.ResourceManager.AgriculturePlatform/tests/Generated/Samples/Sample_SubscriptionResourceExtensions.cs
similarity index 100%
rename from sdk/agricultureplatform/Azure.ResourceManager.AgriculturePlatform/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs
rename to sdk/agricultureplatform/Azure.ResourceManager.AgriculturePlatform/tests/Generated/Samples/Sample_SubscriptionResourceExtensions.cs
diff --git a/sdk/ai/Azure.AI.Agents.Persistent/CHANGELOG.md b/sdk/ai/Azure.AI.Agents.Persistent/CHANGELOG.md
index 71e9f44cec3b..0812e33ef2d0 100644
--- a/sdk/ai/Azure.AI.Agents.Persistent/CHANGELOG.md
+++ b/sdk/ai/Azure.AI.Agents.Persistent/CHANGELOG.md
@@ -4,7 +4,8 @@
### Features Added
-- Tracing for Agents
+- Tracing for Agents. More information [here](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/ai/Azure.AI.Agents.Persistent/README.md#tracing).
+- Convenience constructor for BingCustomSearchToolParameters
### Breaking Changes
@@ -14,7 +15,11 @@
### Sample updates
- The Azure function sample was simplified.
-- Added samples for file search citation with streaming.
+- Added samples for file search citation with streaming.
+- Fabric tool sample added
+- Connected Agent tool sample added
+- Multiple Connected Agent sample added.
+- Bing Custom Search sample added.
## 1.1.0-beta.2 (2025-06-04)
diff --git a/sdk/ai/Azure.AI.Agents.Persistent/README.md b/sdk/ai/Azure.AI.Agents.Persistent/README.md
index 5600d16fe27e..628cc532f670 100644
--- a/sdk/ai/Azure.AI.Agents.Persistent/README.md
+++ b/sdk/ai/Azure.AI.Agents.Persistent/README.md
@@ -32,7 +32,8 @@ managing search indexes, evaluating generative AI performance, and enabling Open
- [Code interpreter attachment](#create-message-with-code-interpreter-attachment)
- [Create Agent with Bing Grounding](#create-agent-with-bing-grounding)
- [Azure AI Search](#create-agent-with-azure-ai-search)
- - [Function call](#function-call)
+ - [Function call Executed Manually](#function-call-executed-manually)
+ - [Function call Executed Automatically](#function-call-executed-automatically)
- [Azure function Call](#azure-function-call)
- [OpenAPI](#create-agent-with-openapi)
- [Tracing](#tracing)
@@ -419,7 +420,7 @@ await foreach (PersistentThreadMessage threadMessage in messages)
}
```
-#### Function call
+#### Function call executed manually
Tools that reference caller-defined capabilities as functions can be provided to an agent to allow it to
dynamically resolve and disambiguate during a run.
@@ -644,6 +645,63 @@ do
while (toolOutputs.Count > 0);
```
+#### Function call executed automatically
+
+In addition to the manual function calls, SDK supports automatic function calling. After creating functions and`FunctionToolDefinition` according to the last section, here is the steps:
+
+When you create an agent, you can specify the function call by tools argument similar to the example of manual function calls:
+```C# Snippet:StreamingWithAutoFunctionCall_CreateAgent
+PersistentAgent agent = client.Administration.CreateAgent(
+ model: modelDeploymentName,
+ name: "SDK Test Agent - Functions",
+ instructions: "You are a weather bot. Use the provided functions to help answer questions. "
+ + "Customize your responses to the user's preferences as much as possible and use friendly "
+ + "nicknames for cities whenever possible.",
+ tools: [getCityNicknameTool, getCurrentWeatherAtLocationTool, getUserFavoriteCityTool]
+);
+```
+
+We create a thread and message similar to the example of manual function tool calls:
+```C# Snippet:StreamingWithAutoFunctionCall_CreateThreadMessage
+PersistentAgentThread thread = client.Threads.CreateThread();
+
+PersistentThreadMessage message = client.Messages.CreateMessage(
+ thread.Id,
+ MessageRole.User,
+ "What's the weather like in my favorite city?");
+```
+
+Setup `AutoFunctionCallOptions`:
+```C# Snippet:StreamingWithAutoFunctionCall_EnableAutoFunctionCalls
+List toolOutputs = new();
+Dictionary toolDelegates = new();
+toolDelegates.Add(nameof(GetWeatherAtLocation), GetWeatherAtLocation);
+toolDelegates.Add(nameof(GetCityNickname), GetCityNickname);
+toolDelegates.Add(nameof(GetUserFavoriteCity), GetUserFavoriteCity);
+AutoFunctionCallOptions autoFunctionCallOptions = new(toolDelegates, 10);
+```
+
+With autoFunctionCallOptions as parameter for `CreateRunStreamingAsync`, the agent will then call the function automatically when it is needed:
+```C# Snippet:StreamingWithAutoFunctionCallAsync
+await foreach (StreamingUpdate streamingUpdate in client.Runs.CreateRunStreamingAsync(thread.Id, agent.Id, autoFunctionCallOptions: autoFunctionCallOptions))
+{
+ if (streamingUpdate.UpdateKind == StreamingUpdateReason.RunCreated)
+ {
+ Console.WriteLine("--- Run started! ---");
+ }
+ else if (streamingUpdate is MessageContentUpdate contentUpdate)
+ {
+ Console.Write(contentUpdate.Text);
+ }
+ else if (streamingUpdate.UpdateKind == StreamingUpdateReason.RunCompleted)
+ {
+ Console.WriteLine();
+ Console.WriteLine("--- Run completed! ---");
+ }
+}
+```
+To allow the agent cast the parameters to the function call, you must use the supported argument types. They are `string`, `int`, `ushort`, `float`, `uint`, `decimal`, `double`, `long`, and `bool`. Other tpes such as array, dictionary, or classes are not supported.
+
#### Azure function call
We can use Azure Function from inside the agent. In the example below we are calling function "foo", which responds "Bar". In this example we create `AzureFunctionToolDefinition` object, with the function name, description, input and output queues, followed by function parameters. See below for the instructions on function deployment.
@@ -885,7 +943,7 @@ AppContext.SetSwitch("Azure.Experimental.TraceGenAIMessageContent", false);
```
Set the value to `true` to enable content recording.
-##### Tracing to Azure Montior
+##### Tracing to Azure Monitor
First, set the `APPLICATIONINSIGHTS_CONNECTION_STRING` environment variable to point to your Azure Monitor resource.
For tracing to Azure Monitor from your application, the preferred option is to use Azure.Monitor.OpenTelemetry.AspNetCore. Install the package with [NuGet](https://www.nuget.org/ ):
diff --git a/sdk/ai/Azure.AI.Agents.Persistent/api/Azure.AI.Agents.Persistent.net8.0.cs b/sdk/ai/Azure.AI.Agents.Persistent/api/Azure.AI.Agents.Persistent.net8.0.cs
index fee03fc84fa8..efab4fe60457 100644
--- a/sdk/ai/Azure.AI.Agents.Persistent/api/Azure.AI.Agents.Persistent.net8.0.cs
+++ b/sdk/ai/Azure.AI.Agents.Persistent/api/Azure.AI.Agents.Persistent.net8.0.cs
@@ -16,6 +16,10 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer
string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
}
+ public partial class AutoFunctionCallOptions
+ {
+ public AutoFunctionCallOptions(System.Collections.Generic.Dictionary toolDelegates, int maxRetry) { }
+ }
public partial class AzureAIAgentsPersistentContext : System.ClientModel.Primitives.ModelReaderWriterContext
{
internal AzureAIAgentsPersistentContext() { }
@@ -151,6 +155,7 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write
public partial class BingCustomSearchToolParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel
{
public BingCustomSearchToolParameters(System.Collections.Generic.IEnumerable searchConfigurations) { }
+ public BingCustomSearchToolParameters(string connectionId, string instanceName) { }
public System.Collections.Generic.IList SearchConfigurations { get { throw null; } }
protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
Azure.AI.Agents.Persistent.BingCustomSearchToolParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
@@ -2435,9 +2440,11 @@ protected ThreadRuns() { }
public virtual System.Threading.Tasks.Task> CreateRunAsync(Azure.AI.Agents.Persistent.PersistentAgentThread thread, Azure.AI.Agents.Persistent.PersistentAgent agent, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task CreateRunAsync(string threadId, Azure.Core.RequestContent content, System.Collections.Generic.IEnumerable include = null, Azure.RequestContext context = null) { throw null; }
public virtual System.Threading.Tasks.Task> CreateRunAsync(string threadId, string assistantId, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, System.Collections.Generic.IEnumerable additionalMessages = null, System.Collections.Generic.IEnumerable overrideTools = null, bool? stream = default(bool?), float? temperature = default(float?), float? topP = default(float?), int? maxPromptTokens = default(int?), int? maxCompletionTokens = default(int?), Azure.AI.Agents.Persistent.Truncation truncationStrategy = null, System.BinaryData toolChoice = null, System.BinaryData responseFormat = null, bool? parallelToolCalls = default(bool?), System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Collections.Generic.IEnumerable include = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
- public virtual System.ClientModel.CollectionResult CreateRunStreaming(string threadId, string agentId, System.Collections.Generic.IEnumerable include, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, System.Collections.Generic.IEnumerable additionalMessages = null, System.Collections.Generic.IEnumerable overrideTools = null, float? temperature = default(float?), float? topP = default(float?), int? maxPromptTokens = default(int?), int? maxCompletionTokens = default(int?), Azure.AI.Agents.Persistent.Truncation truncationStrategy = null, System.BinaryData toolChoice = null, System.BinaryData responseFormat = null, bool? parallelToolCalls = default(bool?), System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
+ public virtual System.ClientModel.CollectionResult CreateRunStreaming(string threadId, string agentId, Azure.AI.Agents.Persistent.AutoFunctionCallOptions autoFunctionCallOptions, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, System.Collections.Generic.IEnumerable additionalMessages = null, System.Collections.Generic.IEnumerable overrideTools = null, float? temperature = default(float?), float? topP = default(float?), int? maxPromptTokens = default(int?), int? maxCompletionTokens = default(int?), Azure.AI.Agents.Persistent.Truncation truncationStrategy = null, System.BinaryData toolChoice = null, System.BinaryData responseFormat = null, bool? parallelToolCalls = default(bool?), System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
+ public virtual System.ClientModel.CollectionResult CreateRunStreaming(string threadId, string agentId, System.Collections.Generic.IEnumerable include, Azure.AI.Agents.Persistent.AutoFunctionCallOptions autoFunctionCallOptions = null, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, System.Collections.Generic.IEnumerable additionalMessages = null, System.Collections.Generic.IEnumerable overrideTools = null, float? temperature = default(float?), float? topP = default(float?), int? maxPromptTokens = default(int?), int? maxCompletionTokens = default(int?), Azure.AI.Agents.Persistent.Truncation truncationStrategy = null, System.BinaryData toolChoice = null, System.BinaryData responseFormat = null, bool? parallelToolCalls = default(bool?), System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.ClientModel.CollectionResult CreateRunStreaming(string threadId, string agentId, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, System.Collections.Generic.IEnumerable additionalMessages = null, System.Collections.Generic.IEnumerable overrideTools = null, float? temperature = default(float?), float? topP = default(float?), int? maxPromptTokens = default(int?), int? maxCompletionTokens = default(int?), Azure.AI.Agents.Persistent.Truncation truncationStrategy = null, System.BinaryData toolChoice = null, System.BinaryData responseFormat = null, bool? parallelToolCalls = default(bool?), System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
- public virtual System.ClientModel.AsyncCollectionResult CreateRunStreamingAsync(string threadId, string agentId, System.Collections.Generic.IEnumerable include, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, System.Collections.Generic.IEnumerable additionalMessages = null, System.Collections.Generic.IEnumerable overrideTools = null, float? temperature = default(float?), float? topP = default(float?), int? maxPromptTokens = default(int?), int? maxCompletionTokens = default(int?), Azure.AI.Agents.Persistent.Truncation truncationStrategy = null, System.BinaryData toolChoice = null, System.BinaryData responseFormat = null, bool? parallelToolCalls = default(bool?), System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
+ public virtual System.ClientModel.AsyncCollectionResult CreateRunStreamingAsync(string threadId, string agentId, Azure.AI.Agents.Persistent.AutoFunctionCallOptions autoFunctionCallOptions, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, System.Collections.Generic.IEnumerable additionalMessages = null, System.Collections.Generic.IEnumerable overrideTools = null, float? temperature = default(float?), float? topP = default(float?), int? maxPromptTokens = default(int?), int? maxCompletionTokens = default(int?), Azure.AI.Agents.Persistent.Truncation truncationStrategy = null, System.BinaryData toolChoice = null, System.BinaryData responseFormat = null, bool? parallelToolCalls = default(bool?), System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
+ public virtual System.ClientModel.AsyncCollectionResult CreateRunStreamingAsync(string threadId, string agentId, System.Collections.Generic.IEnumerable include, Azure.AI.Agents.Persistent.AutoFunctionCallOptions autoFunctionCallOptions = null, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, System.Collections.Generic.IEnumerable additionalMessages = null, System.Collections.Generic.IEnumerable overrideTools = null, float? temperature = default(float?), float? topP = default(float?), int? maxPromptTokens = default(int?), int? maxCompletionTokens = default(int?), Azure.AI.Agents.Persistent.Truncation truncationStrategy = null, System.BinaryData toolChoice = null, System.BinaryData responseFormat = null, bool? parallelToolCalls = default(bool?), System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.ClientModel.AsyncCollectionResult CreateRunStreamingAsync(string threadId, string agentId, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, System.Collections.Generic.IEnumerable additionalMessages = null, System.Collections.Generic.IEnumerable overrideTools = null, float? temperature = default(float?), float? topP = default(float?), int? maxPromptTokens = default(int?), int? maxCompletionTokens = default(int?), Azure.AI.Agents.Persistent.Truncation truncationStrategy = null, System.BinaryData toolChoice = null, System.BinaryData responseFormat = null, bool? parallelToolCalls = default(bool?), System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response GetRun(string threadId, string runId, Azure.RequestContext context) { throw null; }
public virtual Azure.Response GetRun(string threadId, string runId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
diff --git a/sdk/ai/Azure.AI.Agents.Persistent/api/Azure.AI.Agents.Persistent.netstandard2.0.cs b/sdk/ai/Azure.AI.Agents.Persistent/api/Azure.AI.Agents.Persistent.netstandard2.0.cs
index d34c42b9eab7..881eb31a5d84 100644
--- a/sdk/ai/Azure.AI.Agents.Persistent/api/Azure.AI.Agents.Persistent.netstandard2.0.cs
+++ b/sdk/ai/Azure.AI.Agents.Persistent/api/Azure.AI.Agents.Persistent.netstandard2.0.cs
@@ -16,6 +16,10 @@ protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer
string System.ClientModel.Primitives.IPersistableModel.GetFormatFromOptions(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
System.BinaryData System.ClientModel.Primitives.IPersistableModel.Write(System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
}
+ public partial class AutoFunctionCallOptions
+ {
+ public AutoFunctionCallOptions(System.Collections.Generic.Dictionary toolDelegates, int maxRetry) { }
+ }
public partial class AzureAIAgentsPersistentContext : System.ClientModel.Primitives.ModelReaderWriterContext
{
internal AzureAIAgentsPersistentContext() { }
@@ -151,6 +155,7 @@ protected override void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter write
public partial class BingCustomSearchToolParameters : System.ClientModel.Primitives.IJsonModel, System.ClientModel.Primitives.IPersistableModel
{
public BingCustomSearchToolParameters(System.Collections.Generic.IEnumerable searchConfigurations) { }
+ public BingCustomSearchToolParameters(string connectionId, string instanceName) { }
public System.Collections.Generic.IList SearchConfigurations { get { throw null; } }
protected virtual void JsonModelWriteCore(System.Text.Json.Utf8JsonWriter writer, System.ClientModel.Primitives.ModelReaderWriterOptions options) { }
Azure.AI.Agents.Persistent.BingCustomSearchToolParameters System.ClientModel.Primitives.IJsonModel.Create(ref System.Text.Json.Utf8JsonReader reader, System.ClientModel.Primitives.ModelReaderWriterOptions options) { throw null; }
@@ -2435,9 +2440,11 @@ protected ThreadRuns() { }
public virtual System.Threading.Tasks.Task> CreateRunAsync(Azure.AI.Agents.Persistent.PersistentAgentThread thread, Azure.AI.Agents.Persistent.PersistentAgent agent, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task CreateRunAsync(string threadId, Azure.Core.RequestContent content, System.Collections.Generic.IEnumerable include = null, Azure.RequestContext context = null) { throw null; }
public virtual System.Threading.Tasks.Task> CreateRunAsync(string threadId, string assistantId, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, System.Collections.Generic.IEnumerable additionalMessages = null, System.Collections.Generic.IEnumerable overrideTools = null, bool? stream = default(bool?), float? temperature = default(float?), float? topP = default(float?), int? maxPromptTokens = default(int?), int? maxCompletionTokens = default(int?), Azure.AI.Agents.Persistent.Truncation truncationStrategy = null, System.BinaryData toolChoice = null, System.BinaryData responseFormat = null, bool? parallelToolCalls = default(bool?), System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Collections.Generic.IEnumerable include = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
- public virtual System.ClientModel.CollectionResult CreateRunStreaming(string threadId, string agentId, System.Collections.Generic.IEnumerable include, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, System.Collections.Generic.IEnumerable additionalMessages = null, System.Collections.Generic.IEnumerable overrideTools = null, float? temperature = default(float?), float? topP = default(float?), int? maxPromptTokens = default(int?), int? maxCompletionTokens = default(int?), Azure.AI.Agents.Persistent.Truncation truncationStrategy = null, System.BinaryData toolChoice = null, System.BinaryData responseFormat = null, bool? parallelToolCalls = default(bool?), System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
+ public virtual System.ClientModel.CollectionResult CreateRunStreaming(string threadId, string agentId, Azure.AI.Agents.Persistent.AutoFunctionCallOptions autoFunctionCallOptions, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, System.Collections.Generic.IEnumerable additionalMessages = null, System.Collections.Generic.IEnumerable overrideTools = null, float? temperature = default(float?), float? topP = default(float?), int? maxPromptTokens = default(int?), int? maxCompletionTokens = default(int?), Azure.AI.Agents.Persistent.Truncation truncationStrategy = null, System.BinaryData toolChoice = null, System.BinaryData responseFormat = null, bool? parallelToolCalls = default(bool?), System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
+ public virtual System.ClientModel.CollectionResult CreateRunStreaming(string threadId, string agentId, System.Collections.Generic.IEnumerable include, Azure.AI.Agents.Persistent.AutoFunctionCallOptions autoFunctionCallOptions = null, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, System.Collections.Generic.IEnumerable additionalMessages = null, System.Collections.Generic.IEnumerable overrideTools = null, float? temperature = default(float?), float? topP = default(float?), int? maxPromptTokens = default(int?), int? maxCompletionTokens = default(int?), Azure.AI.Agents.Persistent.Truncation truncationStrategy = null, System.BinaryData toolChoice = null, System.BinaryData responseFormat = null, bool? parallelToolCalls = default(bool?), System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.ClientModel.CollectionResult CreateRunStreaming(string threadId, string agentId, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, System.Collections.Generic.IEnumerable additionalMessages = null, System.Collections.Generic.IEnumerable overrideTools = null, float? temperature = default(float?), float? topP = default(float?), int? maxPromptTokens = default(int?), int? maxCompletionTokens = default(int?), Azure.AI.Agents.Persistent.Truncation truncationStrategy = null, System.BinaryData toolChoice = null, System.BinaryData responseFormat = null, bool? parallelToolCalls = default(bool?), System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
- public virtual System.ClientModel.AsyncCollectionResult CreateRunStreamingAsync(string threadId, string agentId, System.Collections.Generic.IEnumerable include, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, System.Collections.Generic.IEnumerable additionalMessages = null, System.Collections.Generic.IEnumerable overrideTools = null, float? temperature = default(float?), float? topP = default(float?), int? maxPromptTokens = default(int?), int? maxCompletionTokens = default(int?), Azure.AI.Agents.Persistent.Truncation truncationStrategy = null, System.BinaryData toolChoice = null, System.BinaryData responseFormat = null, bool? parallelToolCalls = default(bool?), System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
+ public virtual System.ClientModel.AsyncCollectionResult CreateRunStreamingAsync(string threadId, string agentId, Azure.AI.Agents.Persistent.AutoFunctionCallOptions autoFunctionCallOptions, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, System.Collections.Generic.IEnumerable additionalMessages = null, System.Collections.Generic.IEnumerable overrideTools = null, float? temperature = default(float?), float? topP = default(float?), int? maxPromptTokens = default(int?), int? maxCompletionTokens = default(int?), Azure.AI.Agents.Persistent.Truncation truncationStrategy = null, System.BinaryData toolChoice = null, System.BinaryData responseFormat = null, bool? parallelToolCalls = default(bool?), System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
+ public virtual System.ClientModel.AsyncCollectionResult CreateRunStreamingAsync(string threadId, string agentId, System.Collections.Generic.IEnumerable include, Azure.AI.Agents.Persistent.AutoFunctionCallOptions autoFunctionCallOptions = null, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, System.Collections.Generic.IEnumerable additionalMessages = null, System.Collections.Generic.IEnumerable overrideTools = null, float? temperature = default(float?), float? topP = default(float?), int? maxPromptTokens = default(int?), int? maxCompletionTokens = default(int?), Azure.AI.Agents.Persistent.Truncation truncationStrategy = null, System.BinaryData toolChoice = null, System.BinaryData responseFormat = null, bool? parallelToolCalls = default(bool?), System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.ClientModel.AsyncCollectionResult CreateRunStreamingAsync(string threadId, string agentId, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, System.Collections.Generic.IEnumerable additionalMessages = null, System.Collections.Generic.IEnumerable overrideTools = null, float? temperature = default(float?), float? topP = default(float?), int? maxPromptTokens = default(int?), int? maxCompletionTokens = default(int?), Azure.AI.Agents.Persistent.Truncation truncationStrategy = null, System.BinaryData toolChoice = null, System.BinaryData responseFormat = null, bool? parallelToolCalls = default(bool?), System.Collections.Generic.IReadOnlyDictionary metadata = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Response GetRun(string threadId, string runId, Azure.RequestContext context) { throw null; }
public virtual Azure.Response GetRun(string threadId, string runId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
diff --git a/sdk/ai/Azure.AI.Agents.Persistent/assets.json b/sdk/ai/Azure.AI.Agents.Persistent/assets.json
index f8256e61ad1b..c32106030257 100644
--- a/sdk/ai/Azure.AI.Agents.Persistent/assets.json
+++ b/sdk/ai/Azure.AI.Agents.Persistent/assets.json
@@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/ai/Azure.AI.Agents.Persistent",
- "Tag": "net/ai/Azure.AI.Agents.Persistent_2b964340aa"
+ "Tag": "net/ai/Azure.AI.Agents.Persistent_f7ce2c53dc"
}
diff --git a/sdk/ai/Azure.AI.Agents.Persistent/samples/Sample24_PersistentAgents_Multiple_Connected_Agents.md b/sdk/ai/Azure.AI.Agents.Persistent/samples/Sample24_PersistentAgents_Multiple_Connected_Agents.md
new file mode 100644
index 000000000000..d1a945f2ec5a
--- /dev/null
+++ b/sdk/ai/Azure.AI.Agents.Persistent/samples/Sample24_PersistentAgents_Multiple_Connected_Agents.md
@@ -0,0 +1,202 @@
+# Sample for use of an agent with multiple connected agent tools in Azure.AI.Agents.Persistent.
+
+To enable your Agent to use multiple other agents as tools (sub-agents), you use multiple `ConnectedAgentToolDefinition` instances, each with their own connected agent details.
+1. First we need to create an agent client and read the environment variables, which will be used in the next steps.
+
+```C# Snippet:AgentsMultipleConnectedAgents_CreateProject
+var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT");
+var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME");
+PersistentAgentsClient agentClient = new(projectEndpoint, new DefaultAzureCredential());
+```
+
+2. We will create multiple sub-agents first that will be used as connected agent tools.
+
+Synchronous sample:
+```C# Snippet:AgentsMultipleConnectedAgents_CreateSubAgents
+PersistentAgent stockPriceAgent = agentClient.Administration.CreateAgent(
+ model: modelDeploymentName,
+ name: "stock-price-bot",
+ instructions: "Your job is to get the stock price of a company. If asked for the Microsoft stock price, always return $350.");
+
+PersistentAgent weatherAgent = agentClient.Administration.CreateAgent(
+ model: modelDeploymentName,
+ name: "weather-bot",
+ instructions: "Your job is to get the weather for a given location. If asked for the weather in Seattle, always return 60 degrees and cloudy.");
+```
+
+Asynchronous sample:
+```C# Snippet:AgentsMultipleConnectedAgentsAsync_CreateSubAgents
+PersistentAgent stockPriceAgent = await agentClient.Administration.CreateAgentAsync(
+ model: modelDeploymentName,
+ name: "stock-price-bot",
+ instructions: "Your job is to get the stock price of a company. If asked for the Microsoft stock price, always return $350.");
+
+PersistentAgent weatherAgent = await agentClient.Administration.CreateAgentAsync(
+ model: modelDeploymentName,
+ name: "weather-bot",
+ instructions: "Your job is to get the weather for a given location. If asked for the weather in Seattle, always return 60 degrees and cloudy.");
+```
+
+3. We will use the sub-agents details to initialize multiple `ConnectedAgentToolDefinition` instances.
+
+```C# Snippet:AgentsMultipleConnectedAgents_GetConnectedAgents
+ConnectedAgentToolDefinition stockPriceConnectedAgentTool = new(
+ new ConnectedAgentDetails(
+ id: stockPriceAgent.Id,
+ name: "stock_price_bot",
+ description: "Gets the stock price of a company"
+ )
+);
+
+ConnectedAgentToolDefinition weatherConnectedAgentTool = new(
+ new ConnectedAgentDetails(
+ id: weatherAgent.Id,
+ name: "weather_bot",
+ description: "Gets the weather for a given location"
+ )
+);
+```
+
+4. We will use both `ConnectedAgentToolDefinition` instances during the main agent initialization.
+
+Synchronous sample:
+```C# Snippet:AgentsMultipleConnectedAgents_CreateAgent
+PersistentAgent agent = agentClient.Administration.CreateAgent(
+ model: modelDeploymentName,
+ name: "my-assistant",
+ instructions: "You are a helpful assistant, and use the connected agents to get stock prices and weather.",
+ tools: [stockPriceConnectedAgentTool, weatherConnectedAgentTool]);
+```
+
+Asynchronous sample:
+```C# Snippet:AgentsMultipleConnectedAgentsAsync_CreateAgent
+PersistentAgent agent = await agentClient.Administration.CreateAgentAsync(
+ model: modelDeploymentName,
+ name: "my-assistant",
+ instructions: "You are a helpful assistant, and use the connected agents to get stock prices and weather.",
+ tools: [stockPriceConnectedAgentTool, weatherConnectedAgentTool]);
+```
+
+5. Now we will create the thread, add the message containing a question for agent and start the run.
+
+Synchronous sample:
+```C# Snippet:AgentsMultipleConnectedAgents_CreateThreadMessage
+PersistentAgentThread thread = agentClient.Threads.CreateThread();
+
+// Create message to thread
+PersistentThreadMessage message = agentClient.Messages.CreateMessage(
+ thread.Id,
+ MessageRole.User,
+ "What is the stock price of Microsoft and the weather in Seattle?");
+
+// Run the agent
+ThreadRun run = agentClient.Runs.CreateRun(thread, agent);
+do
+{
+ Thread.Sleep(TimeSpan.FromMilliseconds(500));
+ run = agentClient.Runs.GetRun(thread.Id, run.Id);
+}
+while (run.Status == RunStatus.Queued
+ || run.Status == RunStatus.InProgress);
+
+Assert.AreEqual(
+ RunStatus.Completed,
+ run.Status,
+ run.LastError?.Message);
+```
+
+Asynchronous sample:
+```C# Snippet:AgentsMultipleConnectedAgentsAsync_CreateThreadMessage
+PersistentAgentThread thread = await agentClient.Threads.CreateThreadAsync();
+
+// Create message to thread
+PersistentThreadMessage message = await agentClient.Messages.CreateMessageAsync(
+ thread.Id,
+ MessageRole.User,
+ "What is the stock price of Microsoft and the weather in Seattle?");
+
+// Run the agent
+ThreadRun run = await agentClient.Runs.CreateRunAsync(thread, agent);
+do
+{
+ await Task.Delay(TimeSpan.FromMilliseconds(500));
+ run = await agentClient.Runs.GetRunAsync(thread.Id, run.Id);
+}
+while (run.Status == RunStatus.Queued
+ || run.Status == RunStatus.InProgress);
+
+Assert.AreEqual(
+ RunStatus.Completed,
+ run.Status,
+ run.LastError?.Message);
+```
+
+6. Print the agent messages to console in chronological order.
+
+Synchronous sample:
+```C# Snippet:AgentsMultipleConnectedAgents_Print
+Pageable messages = agentClient.Messages.GetMessages(
+ threadId: thread.Id,
+ order: ListSortOrder.Ascending
+);
+
+foreach (PersistentThreadMessage threadMessage in messages)
+{
+ Console.Write($"{threadMessage.CreatedAt:yyyy-MM-dd HH:mm:ss} - {threadMessage.Role,10}: ");
+ foreach (MessageContent contentItem in threadMessage.ContentItems)
+ {
+ if (contentItem is MessageTextContent textItem)
+ {
+ Console.Write(textItem.Text);
+ }
+ else if (contentItem is MessageImageFileContent imageFileItem)
+ {
+ Console.Write($"");
+ }
+ Console.WriteLine();
+ }
+}
+```
+
+Asynchronous sample:
+```C# Snippet:AgentsMultipleConnectedAgentsAsync_Print
+AsyncPageable messages = agentClient.Messages.GetMessagesAsync(
+ threadId: thread.Id,
+ order: ListSortOrder.Ascending
+);
+
+await foreach (PersistentThreadMessage threadMessage in messages)
+{
+ Console.Write($"{threadMessage.CreatedAt:yyyy-MM-dd HH:mm:ss} - {threadMessage.Role,10}: ");
+ foreach (MessageContent contentItem in threadMessage.ContentItems)
+ {
+ if (contentItem is MessageTextContent textItem)
+ {
+ Console.Write(textItem.Text);
+ }
+ else if (contentItem is MessageImageFileContent imageFileItem)
+ {
+ Console.Write($"");
+ }
+ Console.WriteLine();
+ }
+}
+```
+
+7. Clean up resources by deleting thread, main agent, and all sub-agents.
+
+Synchronous sample:
+```C# Snippet:AgentsMultipleConnectedAgentsCleanup
+agentClient.Threads.DeleteThread(threadId: thread.Id);
+agentClient.Administration.DeleteAgent(agentId: agent.Id);
+agentClient.Administration.DeleteAgent(agentId: stockPriceAgent.Id);
+agentClient.Administration.DeleteAgent(agentId: weatherAgent.Id);
+```
+
+Asynchronous sample:
+```C# Snippet:AgentsMultipleConnectedAgentsCleanupAsync
+await agentClient.Threads.DeleteThreadAsync(threadId: thread.Id);
+await agentClient.Administration.DeleteAgentAsync(agentId: agent.Id);
+await agentClient.Administration.DeleteAgentAsync(agentId: stockPriceAgent.Id);
+await agentClient.Administration.DeleteAgentAsync(agentId: weatherAgent.Id);
+```
diff --git a/sdk/ai/Azure.AI.Agents.Persistent/samples/Sample24_Streaming_with_Auto_Function_Calls.md b/sdk/ai/Azure.AI.Agents.Persistent/samples/Sample24_Streaming_with_Auto_Function_Calls.md
new file mode 100644
index 000000000000..ead95be448bc
--- /dev/null
+++ b/sdk/ai/Azure.AI.Agents.Persistent/samples/Sample24_Streaming_with_Auto_Function_Calls.md
@@ -0,0 +1,185 @@
+# Sample using agents streaming with auto function calls in Azure.AI.Projects.
+
+We demonstrated how to write code to call local functions with the agents in streaming scenarios in a previous example. In this example, we will demonstrate how to configure calling local functions automatically.
+
+1. First we need to create agent client and read the environment variables that will be used in the next steps.
+```C# Snippet:StreamingWithAutoFunctionCall_CreateClient
+var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT");
+var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME");
+PersistentAgentsClient client = new(projectEndpoint, new DefaultAzureCredential());
+```
+
+2 Define three toy functions: `GetUserFavoriteCity`that always returns "Seattle, WA" and `GetCityNickname`, which will handle only "Seattle, WA" and will throw exception in response to other city names. The last function `GetWeatherAtLocation` returns weather at Seattle, WA. For each function we need to create `FunctionToolDefinition`, which defines function name, description and parameters.
+```C# Snippet:StreamingWithAutoFunctionCall_DefineFunctionTools
+// Example of a function that defines no parameters
+private string GetUserFavoriteCity() => "Seattle, WA";
+private FunctionToolDefinition getUserFavoriteCityTool = new("GetUserFavoriteCity", "Gets the user's favorite city.");
+// Example of a function with a single required parameter
+private string GetCityNickname(string location) => location switch
+{
+ "Seattle, WA" => "The Emerald City",
+ _ => throw new NotImplementedException(),
+};
+private FunctionToolDefinition getCityNicknameTool = new(
+ name: "GetCityNickname",
+ description: "Gets the nickname of a city, e.g. 'LA' for 'Los Angeles, CA'.",
+ parameters: BinaryData.FromObjectAsJson(
+ new
+ {
+ Type = "object",
+ Properties = new
+ {
+ Location = new
+ {
+ Type = "string",
+ Description = "The city and state, e.g. San Francisco, CA",
+ },
+ },
+ Required = new[] { "location" },
+ },
+ new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }));
+// Example of a function with one required and one optional, enum parameter
+private string GetWeatherAtLocation(string location, string temperatureUnit = "f") => location switch
+{
+ "Seattle, WA" => temperatureUnit == "f" ? "70f" : "21c",
+ _ => throw new NotImplementedException()
+};
+private FunctionToolDefinition getCurrentWeatherAtLocationTool = new(
+ name: "GetWeatherAtLocation",
+ description: "Gets the current weather at a provided location.",
+ parameters: BinaryData.FromObjectAsJson(
+ new
+ {
+ Type = "object",
+ Properties = new
+ {
+ Location = new
+ {
+ Type = "string",
+ Description = "The city and state, e.g. San Francisco, CA",
+ },
+ Unit = new
+ {
+ Type = "string",
+ Enum = new[] { "c", "f" },
+ },
+ },
+ Required = new[] { "location" },
+ },
+ new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase }));
+```
+
+3. Create Agent with the `FunctionToolDefinitions`.
+
+Synchronous sample:
+```C# Snippet:StreamingWithAutoFunctionCall_CreateAgent
+PersistentAgent agent = client.Administration.CreateAgent(
+ model: modelDeploymentName,
+ name: "SDK Test Agent - Functions",
+ instructions: "You are a weather bot. Use the provided functions to help answer questions. "
+ + "Customize your responses to the user's preferences as much as possible and use friendly "
+ + "nicknames for cities whenever possible.",
+ tools: [getCityNicknameTool, getCurrentWeatherAtLocationTool, getUserFavoriteCityTool]
+);
+```
+
+Asynchronous sample:
+```C# Snippet:StreamingWithAutoFunctionCallAsync_CreateAgent
+PersistentAgent agent = await client.Administration.CreateAgentAsync(
+ model: modelDeploymentName,
+ name: "SDK Test Agent - Functions",
+ instructions: "You are a weather bot. Use the provided functions to help answer questions. "
+ + "Customize your responses to the user's preferences as much as possible and use friendly "
+ + "nicknames for cities whenever possible.",
+ tools: [getCityNicknameTool, getCurrentWeatherAtLocationTool, getUserFavoriteCityTool]
+);
+```
+
+4. Create `Thread` with the message.
+
+Synchronous sample:
+```C# Snippet:StreamingWithAutoFunctionCall_CreateThreadMessage
+PersistentAgentThread thread = client.Threads.CreateThread();
+
+PersistentThreadMessage message = client.Messages.CreateMessage(
+ thread.Id,
+ MessageRole.User,
+ "What's the weather like in my favorite city?");
+```
+
+Asynchronous sample:
+```C# Snippet:StreamingWithAutoFunctionCallAsync_CreateThreadMessage
+PersistentAgentThread thread = await client.Threads.CreateThreadAsync();
+
+PersistentThreadMessage message = await client.Messages.CreateMessageAsync(
+ thread.Id,
+ MessageRole.User,
+ "What's the weather like in my favorite city?");
+```
+
+5. Setup `AutoFunctionCallOptions` with the function delegates above.
+```C# Snippet:StreamingWithAutoFunctionCall_EnableAutoFunctionCalls
+List toolOutputs = new();
+Dictionary toolDelegates = new();
+toolDelegates.Add(nameof(GetWeatherAtLocation), GetWeatherAtLocation);
+toolDelegates.Add(nameof(GetCityNickname), GetCityNickname);
+toolDelegates.Add(nameof(GetUserFavoriteCity), GetUserFavoriteCity);
+AutoFunctionCallOptions autoFunctionCallOptions = new(toolDelegates, 10);
+```
+
+6. Create a stream that will allow us to receive updates from the agent. With `autoFunctionCallOptions` as parameter, the functions will be called automatically when the agent needs to call them. The `StreamingUpdate` object will contain the results of the function calls.
+
+Synchronous sample:
+```C# Snippet:StreamingWithAutoFunctionCall
+CollectionResult stream = client.Runs.CreateRunStreaming(thread.Id, agent.Id, autoFunctionCallOptions: autoFunctionCallOptions);
+foreach (StreamingUpdate streamingUpdate in stream)
+{
+ if (streamingUpdate.UpdateKind == StreamingUpdateReason.RunCreated)
+ {
+ Console.WriteLine("--- Run started! ---");
+ }
+ else if (streamingUpdate is MessageContentUpdate contentUpdate)
+ {
+ Console.Write(contentUpdate.Text);
+ }
+ else if (streamingUpdate.UpdateKind == StreamingUpdateReason.RunCompleted)
+ {
+ Console.WriteLine();
+ Console.WriteLine("--- Run completed! ---");
+ }
+}
+```
+
+Asynchronous sample:
+```C# Snippet:StreamingWithAutoFunctionCallAsync
+await foreach (StreamingUpdate streamingUpdate in client.Runs.CreateRunStreamingAsync(thread.Id, agent.Id, autoFunctionCallOptions: autoFunctionCallOptions))
+{
+ if (streamingUpdate.UpdateKind == StreamingUpdateReason.RunCreated)
+ {
+ Console.WriteLine("--- Run started! ---");
+ }
+ else if (streamingUpdate is MessageContentUpdate contentUpdate)
+ {
+ Console.Write(contentUpdate.Text);
+ }
+ else if (streamingUpdate.UpdateKind == StreamingUpdateReason.RunCompleted)
+ {
+ Console.WriteLine();
+ Console.WriteLine("--- Run completed! ---");
+ }
+}
+```
+
+7. Finally, we delete all the resources, we have created in this sample.
+
+Synchronous sample:
+```C# Snippet:StreamingWithAutoFunctionCall_Cleanup
+client.Threads.DeleteThread(thread.Id);
+client.Administration.DeleteAgent(agent.Id);
+```
+
+Asynchronous sample:
+```C# Snippet:StreamingWithAutoFunctionCallAsync_Cleanup
+await client.Threads.DeleteThreadAsync(thread.Id);
+await client.Administration.DeleteAgentAsync(agent.Id);
+```
diff --git a/sdk/ai/Azure.AI.Agents.Persistent/samples/Sample25_PersistentAgents_Bing_Custom_Search.md b/sdk/ai/Azure.AI.Agents.Persistent/samples/Sample25_PersistentAgents_Bing_Custom_Search.md
new file mode 100644
index 000000000000..594d70f356d5
--- /dev/null
+++ b/sdk/ai/Azure.AI.Agents.Persistent/samples/Sample25_PersistentAgents_Bing_Custom_Search.md
@@ -0,0 +1,181 @@
+# Sample for use of an agent with Bing custom search in Azure.AI.Agents.Persistent.
+
+To enable your Agent to perform search through Bing Custom Search API, you use `BingCustomSearchToolDefinition` along with a connection and custom search instance.
+1. First we need to create an agent client and read the environment variables, which will be used in the next steps.
+
+```C# Snippet:AgentsBingCustomSearch_CreateProject
+var projectEndpoint = System.Environment.GetEnvironmentVariable("PROJECT_ENDPOINT");
+var modelDeploymentName = System.Environment.GetEnvironmentVariable("MODEL_DEPLOYMENT_NAME");
+var connectionId = System.Environment.GetEnvironmentVariable("BING_CUSTOM_CONNECTION_ID");
+PersistentAgentsClient agentClient = new(projectEndpoint, new DefaultAzureCredential());
+```
+
+2. We will use the Bing Custom Search connection ID and instance name to initialize the `BingCustomSearchToolDefinition`.
+
+```C# Snippet:AgentsBingCustomSearch_GetConnection
+BingCustomSearchToolDefinition bingCustomSearchTool = new(
+ new BingCustomSearchToolParameters(connectionId, "your_config_instance_name") // Replace with your actual configuration instance name
+);
+```
+
+3. We will use the `BingCustomSearchToolDefinition` during the agent initialization.
+
+Synchronous sample:
+```C# Snippet:AgentsBingCustomSearch_CreateAgent
+PersistentAgent agent = agentClient.Administration.CreateAgent(
+ model: modelDeploymentName,
+ name: "my-agent",
+ instructions: "You are a helpful agent.",
+ tools: [bingCustomSearchTool]);
+```
+
+Asynchronous sample:
+```C# Snippet:AgentsBingCustomSearchAsync_CreateAgent
+PersistentAgent agent = await agentClient.Administration.CreateAgentAsync(
+ model: modelDeploymentName,
+ name: "my-agent",
+ instructions: "You are a helpful agent.",
+ tools: [ bingCustomSearchTool ]);
+```
+
+4. Now we will create the thread, add the message containing a question for agent and start the run.
+
+Synchronous sample:
+```C# Snippet:AgentsBingCustomSearch_CreateThreadMessage
+PersistentAgentThread thread = agentClient.Threads.CreateThread();
+
+// Create message to thread
+PersistentThreadMessage message = agentClient.Messages.CreateMessage(
+ thread.Id,
+ MessageRole.User,
+ "How many medals did the USA win in the 2024 summer olympics?");
+
+// Run the agent
+ThreadRun run = agentClient.Runs.CreateRun(thread, agent);
+do
+{
+ Thread.Sleep(TimeSpan.FromMilliseconds(500));
+ run = agentClient.Runs.GetRun(thread.Id, run.Id);
+}
+while (run.Status == RunStatus.Queued
+ || run.Status == RunStatus.InProgress);
+
+Assert.AreEqual(
+ RunStatus.Completed,
+ run.Status,
+ run.LastError?.Message);
+```
+
+Asynchronous sample:
+```C# Snippet:AgentsBingCustomSearchAsync_CreateThreadMessage
+PersistentAgentThread thread = await agentClient.Threads.CreateThreadAsync();
+
+// Create message to thread
+PersistentThreadMessage message = await agentClient.Messages.CreateMessageAsync(
+ thread.Id,
+ MessageRole.User,
+ "How many medals did the USA win in the 2024 summer olympics?");
+
+// Run the agent
+ThreadRun run = await agentClient.Runs.CreateRunAsync(thread, agent);
+do
+{
+ await Task.Delay(TimeSpan.FromMilliseconds(500));
+ run = await agentClient.Runs.GetRunAsync(thread.Id, run.Id);
+}
+while (run.Status == RunStatus.Queued
+ || run.Status == RunStatus.InProgress);
+
+Assert.AreEqual(
+ RunStatus.Completed,
+ run.Status,
+ run.LastError?.Message);
+```
+
+5. Print the agent messages to console in chronological order.
+
+Synchronous sample:
+```C# Snippet:AgentsBingCustomSearch_Print
+Pageable messages = agentClient.Messages.GetMessages(
+ threadId: thread.Id,
+ order: ListSortOrder.Ascending
+);
+
+foreach (PersistentThreadMessage threadMessage in messages)
+{
+ Console.Write($"{threadMessage.CreatedAt:yyyy-MM-dd HH:mm:ss} - {threadMessage.Role,10}: ");
+ foreach (MessageContent contentItem in threadMessage.ContentItems)
+ {
+ if (contentItem is MessageTextContent textItem)
+ {
+ string response = textItem.Text;
+ if (textItem.Annotations != null)
+ {
+ foreach (MessageTextAnnotation annotation in textItem.Annotations)
+ {
+ if (annotation is MessageTextUriCitationAnnotation uriAnnotation)
+ {
+ response = response.Replace(uriAnnotation.Text, $" [{uriAnnotation.UriCitation.Title}]({uriAnnotation.UriCitation.Uri})");
+ }
+ }
+ }
+ Console.Write($"Agent response: {response}");
+ }
+ else if (contentItem is MessageImageFileContent imageFileItem)
+ {
+ Console.Write($"");
+ }
+ Console.WriteLine();
+ }
+}
+```
+
+Asynchronous sample:
+```C# Snippet:AgentsBingCustomSearchAsync_Print
+AsyncPageable messages = agentClient.Messages.GetMessagesAsync(
+ threadId: thread.Id,
+ order: ListSortOrder.Ascending
+);
+
+await foreach (PersistentThreadMessage threadMessage in messages)
+{
+ Console.Write($"{threadMessage.CreatedAt:yyyy-MM-dd HH:mm:ss} - {threadMessage.Role,10}: ");
+ foreach (MessageContent contentItem in threadMessage.ContentItems)
+ {
+ if (contentItem is MessageTextContent textItem)
+ {
+ string response = textItem.Text;
+ if (textItem.Annotations != null)
+ {
+ foreach (MessageTextAnnotation annotation in textItem.Annotations)
+ {
+ if (annotation is MessageTextUriCitationAnnotation uriAnnotation)
+ {
+ response = response.Replace(uriAnnotation.Text, $" [{uriAnnotation.UriCitation.Title}]({uriAnnotation.UriCitation.Uri})");
+ }
+ }
+ }
+ Console.Write($"Agent response: {response}");
+ }
+ else if (contentItem is MessageImageFileContent imageFileItem)
+ {
+ Console.Write($"");
+ }
+ Console.WriteLine();
+ }
+}
+```
+
+6. Clean up resources by deleting thread and agent.
+
+Synchronous sample:
+```C# Snippet:AgentsBingCustomSearchCleanup
+agentClient.Threads.DeleteThread(threadId: thread.Id);
+agentClient.Administration.DeleteAgent(agentId: agent.Id);
+```
+
+Asynchronous sample:
+```C# Snippet:AgentsBingCustomSearchCleanupAsync
+await agentClient.Threads.DeleteThreadAsync(threadId: thread.Id);
+await agentClient.Administration.DeleteAgentAsync(agentId: agent.Id);
+```
diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Custom/AutoFunctionCallOptions.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Custom/AutoFunctionCallOptions.cs
new file mode 100644
index 000000000000..6c0ec80a4259
--- /dev/null
+++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Custom/AutoFunctionCallOptions.cs
@@ -0,0 +1,55 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+#nullable disable
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Azure.AI.Agents.Persistent
+{
+ public class AutoFunctionCallOptions
+ {
+ private Dictionary _autoFunctionCallDelegates = new();
+ private int _maxRetry;
+ /// The size of the client cache.
+
+ ///
+ /// Enables auto tool calls to be executed automatically during streaming. If this is not set, function must be called manually.
+ ///
+ /// Dictionary in name and delegate in pair
+ /// Maximum number of errors allowed and retry per stream. Default value is 10.
+ public AutoFunctionCallOptions(Dictionary toolDelegates, int maxRetry) {
+ ValidateAutoFunctions(toolDelegates);
+ _autoFunctionCallDelegates.Clear();
+
+ foreach (var kvp in toolDelegates)
+ {
+ _autoFunctionCallDelegates[kvp.Key] = kvp.Value;
+ }
+ _maxRetry = maxRetry;
+ }
+
+ private void ValidateAutoFunctions(Dictionary toolDelegates)
+ {
+ if (toolDelegates == null || toolDelegates.Count == 0)
+ {
+ throw new InvalidOperationException("The delegate dictionary must have at least one delegate.");
+ }
+ foreach (var kvp in toolDelegates)
+ {
+ if (kvp.Value.Method.ReturnType != typeof(string))
+ {
+ throw new InvalidOperationException($"The Delegates must have string as return type.");
+ }
+ }
+ }
+
+ internal Dictionary AutoFunctionCallDelegates => _autoFunctionCallDelegates;
+
+ internal int MaxRetry => _maxRetry;
+ }
+}
diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Custom/BingCustomSearchToolParameters.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Custom/BingCustomSearchToolParameters.cs
new file mode 100644
index 000000000000..60b0202f9281
--- /dev/null
+++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Custom/BingCustomSearchToolParameters.cs
@@ -0,0 +1,22 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+using System.Collections.Generic;
+
+namespace Azure.AI.Agents.Persistent
+{
+ public partial class BingCustomSearchToolParameters
+ {
+ public BingCustomSearchToolParameters( string connectionId, string instanceName )
+ {
+ // Additional initialization logic if needed
+ var bingCustomSearchConfiguration = new BingCustomSearchConfiguration
+ {
+ ConnectionId = connectionId,
+ InstanceName = instanceName
+ };
+
+ this.SearchConfigurations = new List { bingCustomSearchConfiguration };
+ }
+ }
+}
diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Custom/Streaming/AsyncStreamingUpdateCollection.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Custom/Streaming/AsyncStreamingUpdateCollection.cs
index 4179c431b436..beedbea0645d 100644
--- a/sdk/ai/Azure.AI.Agents.Persistent/src/Custom/Streaming/AsyncStreamingUpdateCollection.cs
+++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Custom/Streaming/AsyncStreamingUpdateCollection.cs
@@ -7,6 +7,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Net.ServerSentEvents;
+using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure.AI.Agents.Persistent.Telemetry;
@@ -16,23 +17,41 @@
namespace Azure.AI.Agents.Persistent;
///
-/// Implementation of collection abstraction over streaming agent updates.
+/// Implementation of collection abstraction over streaming assistant updates.
///
internal class AsyncStreamingUpdateCollection : AsyncCollectionResult
{
private readonly Func> _sendRequestAsync;
private readonly CancellationToken _cancellationToken;
private readonly OpenTelemetryScope? _scope;
+ private readonly ToolCallsResolver? _toolCallsResolver;
+ private readonly Func, int, AsyncCollectionResult> _submitToolOutputsToStreamAsync;
+ private readonly int _maxRetry;
+ private int _currRetry;
+ private readonly Func>> _cancelRunAsync;
- public AsyncStreamingUpdateCollection(Func> sendRequestAsync,
+ public AsyncStreamingUpdateCollection(
CancellationToken cancellationToken,
+ AutoFunctionCallOptions autoFunctionCallOptions,
+ int currentRetry,
+ Func> sendRequestAsync,
+ Func>> cancelRunAsync,
+ Func, int, AsyncCollectionResult> submitToolOutputsToStreamAsync,
OpenTelemetryScope? scope = null)
{
Argument.AssertNotNull(sendRequestAsync, nameof(sendRequestAsync));
- _sendRequestAsync = sendRequestAsync;
_cancellationToken = cancellationToken;
_scope = scope;
+ _sendRequestAsync = sendRequestAsync;
+ _submitToolOutputsToStreamAsync = submitToolOutputsToStreamAsync;
+ if (autoFunctionCallOptions != null)
+ {
+ _toolCallsResolver = new(autoFunctionCallOptions.AutoFunctionCallDelegates);
+ _maxRetry = autoFunctionCallOptions.MaxRetry;
+ }
+ _currRetry = currentRetry;
+ _cancelRunAsync = cancelRunAsync;
}
public override ContinuationToken? GetContinuationToken(ClientResult page)
@@ -51,16 +70,66 @@ public async override IAsyncEnumerable GetRawPagesAsync()
protected async override IAsyncEnumerable GetValuesFromPageAsync(ClientResult page)
{
-#pragma warning disable AZC0100 // ConfigureAwait(false) must be used.
- await using IAsyncEnumerator enumerator = new AsyncStreamingUpdateEnumerator(page, _cancellationToken, _scope);
-#pragma warning restore AZC0100 // ConfigureAwait(false) must be used.
- while (await enumerator.MoveNextAsync().ConfigureAwait(false))
+ ThreadRun? streamRun = null;
+ List toolOutputs = new();
+ do
{
- var update = enumerator.Current;
- // Send to telemetry (if needed)
- _scope?.RecordStreamingUpdate(update);
- yield return update;
+ IAsyncEnumerator enumerator = (toolOutputs.Count > 0 && streamRun != null) ?
+ _submitToolOutputsToStreamAsync(streamRun, toolOutputs, _currRetry).GetAsyncEnumerator(_cancellationToken) :
+ new AsyncStreamingUpdateEnumerator(page, _cancellationToken, _scope);
+
+ toolOutputs.Clear();
+
+ try
+ {
+ bool hasError = false;
+ while (await enumerator.MoveNextAsync().ConfigureAwait(false))
+ {
+ var streamingUpdate = enumerator.Current;
+ if (streamingUpdate is RequiredActionUpdate newActionUpdate && _toolCallsResolver != null)
+ {
+ ToolOutput toolOutput;
+ try
+ {
+ toolOutput = _toolCallsResolver.GetResolvedToolOutput(
+ newActionUpdate.FunctionName,
+ newActionUpdate.ToolCallId,
+ newActionUpdate.FunctionArguments
+ );
+ }
+ catch (Exception ex)
+ {
+ string errorJson = JsonSerializer.Serialize(new { error = ex.GetBaseException().Message });
+ toolOutput = new ToolOutput(newActionUpdate.ToolCallId, errorJson);
+ hasError = true;
+ }
+ toolOutputs.Add(toolOutput);
+
+ streamRun = newActionUpdate.Value;
+ }
+ else
+ {
+ // Send to telemetry (if needed)
+ _scope?.RecordStreamingUpdate(streamingUpdate);
+ yield return streamingUpdate;
+ }
+ }
+ _currRetry = hasError ? _currRetry + 1 : _currRetry;
+
+ if (streamRun != null && _currRetry > _maxRetry)
+ {
+ // Cancel the run if the max retry is reached
+ var cancelRunResponse = await _cancelRunAsync(streamRun.Id).ConfigureAwait(false);
+ yield return new StreamingUpdate(cancelRunResponse.Value, StreamingUpdateReason.RunCancelled);
+ yield break;
+ }
+ }
+ finally
+ {
+ await enumerator.DisposeAsync().ConfigureAwait(false);
+ }
}
+ while (toolOutputs.Count > 0);
}
private sealed class AsyncStreamingUpdateEnumerator : IAsyncEnumerator
diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Custom/Streaming/StreamingUpdateCollection.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Custom/Streaming/StreamingUpdateCollection.cs
index 4b911b2afa69..b77cc9a188cb 100644
--- a/sdk/ai/Azure.AI.Agents.Persistent/src/Custom/Streaming/StreamingUpdateCollection.cs
+++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Custom/Streaming/StreamingUpdateCollection.cs
@@ -6,33 +6,53 @@
using System.ClientModel.Primitives;
using System.Collections;
using System.Collections.Generic;
+using System.IO;
using System.Net.ServerSentEvents;
+using System.Text.Json;
using System.Threading;
using Azure.AI.Agents.Persistent.Telemetry;
+using System.Threading.Tasks;
#nullable enable
namespace Azure.AI.Agents.Persistent;
///
-/// Implementation of collection abstraction over streaming agent updates.
+/// Implementation of collection abstraction over streaming assistant updates.
///
internal class StreamingUpdateCollection : CollectionResult
{
private readonly Func _sendRequest;
private readonly CancellationToken _cancellationToken;
private readonly OpenTelemetryScope? _scope;
+ private readonly ToolCallsResolver? _toolCallsResolver;
+ private readonly Func, int, CollectionResult> _submitToolOutputsToStream;
+ private readonly int _maxRetry;
+ private int _currRetry;
+ private readonly Func> _cancelRun;
public StreamingUpdateCollection(
- Func sendRequest,
CancellationToken cancellationToken,
+ AutoFunctionCallOptions autoFunctionCallOptions,
+ int currentRetry,
+ Func sendRequest,
+ Func> cancelRun,
+ Func, int, CollectionResult> submitToolOutputsToStream,
OpenTelemetryScope? scope = null)
{
Argument.AssertNotNull(sendRequest, nameof(sendRequest));
- _sendRequest = sendRequest;
_cancellationToken = cancellationToken;
_scope = scope;
+ _sendRequest = sendRequest;
+ _submitToolOutputsToStream = submitToolOutputsToStream;
+ if (autoFunctionCallOptions != null)
+ {
+ _toolCallsResolver = new(autoFunctionCallOptions.AutoFunctionCallDelegates);
+ _maxRetry = autoFunctionCallOptions.MaxRetry;
+ }
+ _currRetry = currentRetry;
+ _cancelRun = cancelRun;
}
public override ContinuationToken? GetContinuationToken(ClientResult page)
@@ -50,14 +70,57 @@ public override IEnumerable GetRawPages()
}
protected override IEnumerable GetValuesFromPage(ClientResult page)
{
- using IEnumerator enumerator = new StreamingUpdateEnumerator(page, _cancellationToken, _scope);
- while (enumerator.MoveNext())
+ ThreadRun? streamRun = null;
+ List toolOutputs = new();
+ do
{
- var update = enumerator.Current;
- // Send to telemetry (if needed)
- _scope?.RecordStreamingUpdate(update);
- yield return update;
+ using IEnumerator enumerator = (toolOutputs.Count > 0 && streamRun != null) ?
+ _submitToolOutputsToStream(streamRun, toolOutputs, _currRetry).GetEnumerator() :
+ new StreamingUpdateEnumerator(page, _cancellationToken, _scope);
+ toolOutputs.Clear();
+ bool hasError = false;
+ while (enumerator.MoveNext())
+ {
+ var streamingUpdate = enumerator.Current;
+ if (streamingUpdate is RequiredActionUpdate newActionUpdate && _toolCallsResolver != null)
+ {
+ ToolOutput toolOutput;
+ try
+ {
+ toolOutput = _toolCallsResolver.GetResolvedToolOutput(
+ newActionUpdate.FunctionName,
+ newActionUpdate.ToolCallId,
+ newActionUpdate.FunctionArguments
+ );
+ }
+ catch (Exception ex)
+ {
+ string errorJson = JsonSerializer.Serialize(new { error = ex.GetBaseException().Message });
+ toolOutput = new ToolOutput(newActionUpdate.ToolCallId, errorJson);
+ hasError = true;
+ }
+ toolOutputs.Add(toolOutput);
+
+ streamRun = newActionUpdate.Value;
+ }
+ else
+ {
+ // Send to telemetry (if needed)
+ _scope?.RecordStreamingUpdate(streamingUpdate);
+ yield return streamingUpdate;
+ }
+ }
+ _currRetry = hasError ? _currRetry + 1 : _currRetry;
+
+ if (streamRun != null && _currRetry > _maxRetry)
+ {
+ // Cancel the run if the max retry is reached
+ var cancelRunResponse = _cancelRun(streamRun.Id);
+ yield return new StreamingUpdate(cancelRunResponse.Value, StreamingUpdateReason.RunCancelled);
+ yield break;
+ }
}
+ while (toolOutputs.Count > 0);
}
private sealed class StreamingUpdateEnumerator : IEnumerator
diff --git a/sdk/ai/Azure.AI.Agents.Persistent/src/Custom/ThreadRuns.Streaming.cs b/sdk/ai/Azure.AI.Agents.Persistent/src/Custom/ThreadRuns.Streaming.cs
index 4cbc3f81c82b..b8af13ddb7e6 100644
--- a/sdk/ai/Azure.AI.Agents.Persistent/src/Custom/ThreadRuns.Streaming.cs
+++ b/sdk/ai/Azure.AI.Agents.Persistent/src/Custom/ThreadRuns.Streaming.cs
@@ -81,7 +81,80 @@ public virtual AsyncCollectionResult CreateRunStreamingAsync(st
parallelToolCalls: parallelToolCalls,
metadata: metadata,
include: null,
- cancellationToken: cancellationToken
+ cancellationToken: cancellationToken,
+ autoFunctionCallOptions: null
+ );
+ }
+
+ ///
+ /// Begins a new streaming that evaluates a using a specified
+ /// .
+ ///
+ /// Identifier of the thread.
+ /// The ID of the agent that should run the thread.
+ /// Function calls defined in tools will be called automatically.
+ /// The overridden model name that the agent should use to run the thread.
+ /// The overridden system instructions that the agent should use to run the thread.
+ ///
+ /// Additional instructions to append at the end of the instructions for the run. This is useful for modifying the behavior
+ /// on a per-run basis without overriding other instructions.
+ ///
+ /// Adds additional messages to the thread before creating the run.
+ /// The overridden list of enabled tools that the agent should use to run the thread.
+ ///
+ /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output
+ /// more random, while lower values like 0.2 will make it more focused and deterministic.
+ ///
+ ///
+ /// An alternative to sampling with temperature, called nucleus sampling, where the model
+ /// considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens
+ /// comprising the top 10% probability mass are considered.
+ ///
+ /// We generally recommend altering this or temperature but not both.
+ ///
+ ///
+ /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only
+ /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified,
+ /// the run will end with status `incomplete`. See `incomplete_details` for more info.
+ ///
+ ///
+ /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort
+ /// to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of
+ /// completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.
+ ///
+ /// The strategy to use for dropping messages as the context windows moves forward.
+ /// Controls whether or not and which tool is called by the model.
+ /// Specifies the format that the model must output.
+ /// If `true` functions will run in parallel during tool use.
+ /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
+ /// The cancellation token to use.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+#pragma warning disable AZC0015 // Unexpected client method return type.
+ public virtual AsyncCollectionResult CreateRunStreamingAsync(string threadId, string agentId, AutoFunctionCallOptions autoFunctionCallOptions, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, IEnumerable additionalMessages = null, IEnumerable overrideTools = null, float? temperature = null, float? topP = null, int? maxPromptTokens = null, int? maxCompletionTokens = null, Truncation truncationStrategy = null, BinaryData toolChoice = null, BinaryData responseFormat = null, bool? parallelToolCalls = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default)
+#pragma warning restore AZC0015 // Unexpected client method return type.
+ {
+ // This method added for compatibility, before the include parameter support was enabled.
+ return CreateRunStreamingAsync(
+ threadId: threadId,
+ agentId: agentId,
+ overrideModelName: overrideModelName,
+ overrideInstructions: overrideInstructions,
+ additionalInstructions: additionalInstructions,
+ additionalMessages: additionalMessages,
+ overrideTools: overrideTools,
+ temperature: temperature,
+ topP: topP,
+ maxPromptTokens: maxPromptTokens,
+ maxCompletionTokens: maxCompletionTokens,
+ truncationStrategy: truncationStrategy,
+ toolChoice: toolChoice,
+ responseFormat: responseFormat,
+ parallelToolCalls: parallelToolCalls,
+ metadata: metadata,
+ include: null,
+ cancellationToken: cancellationToken,
+ autoFunctionCallOptions: autoFunctionCallOptions
);
}
///
@@ -91,6 +164,7 @@ public virtual AsyncCollectionResult CreateRunStreamingAsync(st
/// Identifier of the thread.
/// The ID of the agent that should run the thread.
///
+ /// If specified, function calls defined in tools will be called automatically.
/// A list of additional fields to include in the response.
/// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content`
/// to fetch the file search result content.
@@ -133,7 +207,7 @@ public virtual AsyncCollectionResult CreateRunStreamingAsync(st
/// or is null.
/// is an empty string, and was expected to be non-empty.
#pragma warning disable AZC0015 // Unexpected client method return type.
- public virtual AsyncCollectionResult CreateRunStreamingAsync(string threadId, string agentId, IEnumerable include, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, IEnumerable additionalMessages = null, IEnumerable overrideTools = null, float? temperature = null, float? topP = null, int? maxPromptTokens = null, int? maxCompletionTokens = null, Truncation truncationStrategy = null, BinaryData toolChoice = null, BinaryData responseFormat = null, bool? parallelToolCalls = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default)
+ public virtual AsyncCollectionResult CreateRunStreamingAsync(string threadId, string agentId, IEnumerable include, AutoFunctionCallOptions autoFunctionCallOptions = null, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, IEnumerable additionalMessages = null, IEnumerable overrideTools = null, float? temperature = null, float? topP = null, int? maxPromptTokens = null, int? maxCompletionTokens = null, Truncation truncationStrategy = null, BinaryData toolChoice = null, BinaryData responseFormat = null, bool? parallelToolCalls = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default)
#pragma warning restore AZC0015 // Unexpected client method return type.
{
var scope = OpenTelemetryScope.StartCreateRunStreaming(threadId, agentId, _endpoint);
@@ -163,7 +237,17 @@ public virtual AsyncCollectionResult CreateRunStreamingAsync(st
async Task sendRequestAsync() =>
await CreateRunStreamingAsync(threadId, createRunRequest.ToRequestContent(), context, include:include).ConfigureAwait(false);
- return new AsyncStreamingUpdateCollection(sendRequestAsync, cancellationToken, scope: scope);
+ AsyncCollectionResult submitToolOutputsToStreamAsync(ThreadRun run, IEnumerable toolOutputs, int currRetry) =>
+ this.SubmitToolOutputsToStreamWitAutoFunctionCallAsync(run, toolOutputs, currRetry, default);
+ async Task> cancelRunAsync(string runId) => await this.CancelRunAsync(threadId, runId).ConfigureAwait(false);
+ return new AsyncStreamingUpdateCollection(
+ cancellationToken,
+ autoFunctionCallOptions,
+ 0,
+ sendRequestAsync,
+ cancelRunAsync,
+ submitToolOutputsToStreamAsync,
+ scope);
}
///
/// Begins a new streaming that evaluates a using a specified
@@ -230,7 +314,78 @@ public virtual CollectionResult CreateRunStreaming(string threa
parallelToolCalls: parallelToolCalls,
metadata: metadata,
include: null,
- cancellationToken: cancellationToken);
+ cancellationToken: cancellationToken,
+ autoFunctionCallOptions: null);
+ }
+
+ ///
+ /// Begins a new streaming that evaluates a using a specified
+ /// .
+ ///
+ /// Identifier of the thread.
+ /// The ID of the agent that should run the thread.
+ /// If specified, function calls defined in tools will be called automatically.
+ /// The overridden model name that the agent should use to run the thread.
+ /// The overridden system instructions that the agent should use to run the thread.
+ ///
+ /// Additional instructions to append at the end of the instructions for the run. This is useful for modifying the behavior
+ /// on a per-run basis without overriding other instructions.
+ ///
+ /// Adds additional messages to the thread before creating the run.
+ /// The overridden list of enabled tools that the agent should use to run the thread.
+ ///
+ /// What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output
+ /// more random, while lower values like 0.2 will make it more focused and deterministic.
+ ///
+ ///
+ /// An alternative to sampling with temperature, called nucleus sampling, where the model
+ /// considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens
+ /// comprising the top 10% probability mass are considered.
+ ///
+ /// We generally recommend altering this or temperature but not both.
+ ///
+ ///
+ /// The maximum number of prompt tokens that may be used over the course of the run. The run will make a best effort to use only
+ /// the number of prompt tokens specified, across multiple turns of the run. If the run exceeds the number of prompt tokens specified,
+ /// the run will end with status `incomplete`. See `incomplete_details` for more info.
+ ///
+ ///
+ /// The maximum number of completion tokens that may be used over the course of the run. The run will make a best effort
+ /// to use only the number of completion tokens specified, across multiple turns of the run. If the run exceeds the number of
+ /// completion tokens specified, the run will end with status `incomplete`. See `incomplete_details` for more info.
+ ///
+ /// The strategy to use for dropping messages as the context windows moves forward.
+ /// Controls whether or not and which tool is called by the model.
+ /// Specifies the format that the model must output.
+ /// If `true` functions will run in parallel during tool use.
+ /// A set of up to 16 key/value pairs that can be attached to an object, used for storing additional information about that object in a structured format. Keys may be up to 64 characters in length and values may be up to 512 characters in length.
+ /// The cancellation token to use.
+ /// or is null.
+ /// is an empty string, and was expected to be non-empty.
+#pragma warning disable AZC0015 // Unexpected client method return type.
+ public virtual CollectionResult CreateRunStreaming(string threadId, string agentId, AutoFunctionCallOptions autoFunctionCallOptions, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, IEnumerable additionalMessages = null, IEnumerable overrideTools = null, float? temperature = null, float? topP = null, int? maxPromptTokens = null, int? maxCompletionTokens = null, Truncation truncationStrategy = null, BinaryData toolChoice = null, BinaryData responseFormat = null, bool? parallelToolCalls = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default)
+#pragma warning restore AZC0015 // Unexpected client method return type.
+ {
+ return CreateRunStreaming(
+ threadId: threadId,
+ agentId: agentId,
+ overrideModelName: overrideModelName,
+ overrideInstructions: overrideInstructions,
+ additionalInstructions: additionalInstructions,
+ additionalMessages: additionalMessages,
+ overrideTools: overrideTools,
+ temperature: temperature,
+ topP: topP,
+ maxPromptTokens: maxPromptTokens,
+ maxCompletionTokens: maxCompletionTokens,
+ truncationStrategy: truncationStrategy,
+ toolChoice: toolChoice,
+ responseFormat: responseFormat,
+ parallelToolCalls: parallelToolCalls,
+ metadata: metadata,
+ include: null,
+ cancellationToken: cancellationToken,
+ autoFunctionCallOptions: autoFunctionCallOptions);
}
///
@@ -244,6 +399,7 @@ public virtual CollectionResult CreateRunStreaming(string threa
/// Currently the only supported value is `step_details.tool_calls[*].file_search.results[*].content`
/// to fetch the file search result content.
///
+ /// If specified, function calls defined in tools will be called automatically.
/// The overridden model name that the agent should use to run the thread.
/// The overridden system instructions that the agent should use to run the thread.
///
@@ -282,7 +438,7 @@ public virtual CollectionResult CreateRunStreaming(string threa
/// or is null.
/// is an empty string, and was expected to be non-empty.
#pragma warning disable AZC0015 // Unexpected client method return type.
- public virtual CollectionResult CreateRunStreaming(string threadId, string agentId, IEnumerable include, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, IEnumerable additionalMessages = null, IEnumerable overrideTools = null, float? temperature = null, float? topP = null, int? maxPromptTokens = null, int? maxCompletionTokens = null, Truncation truncationStrategy = null, BinaryData toolChoice = null, BinaryData responseFormat = null, bool? parallelToolCalls = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default)
+ public virtual CollectionResult CreateRunStreaming(string threadId, string agentId, IEnumerable include, AutoFunctionCallOptions autoFunctionCallOptions = null, string overrideModelName = null, string overrideInstructions = null, string additionalInstructions = null, IEnumerable additionalMessages = null, IEnumerable overrideTools = null, float? temperature = null, float? topP = null, int? maxPromptTokens = null, int? maxCompletionTokens = null, Truncation truncationStrategy = null, BinaryData toolChoice = null, BinaryData responseFormat = null, bool? parallelToolCalls = null, IReadOnlyDictionary metadata = null, CancellationToken cancellationToken = default)
#pragma warning restore AZC0015 // Unexpected client method return type.
{
var scope = OpenTelemetryScope.StartCreateRunStreaming(threadId, agentId, _endpoint);
@@ -310,7 +466,18 @@ public virtual CollectionResult CreateRunStreaming(string threa
RequestContext context = FromCancellationToken(cancellationToken);
Response sendRequest() => CreateRunStreaming(threadId, createRunRequest.ToRequestContent(), context, include: include);
- return new StreamingUpdateCollection(sendRequest, cancellationToken, scope: scope);
+ CollectionResult submitToolOutputsToStream(ThreadRun run, IEnumerable toolOutputs, int currRetry) =>
+ this.SubmitToolOutputsToStreamWitAutoFunctionCall(run, toolOutputs, currRetry);
+ Response cancelRun(string runId) => this.CancelRun(threadId, runId);
+
+ return new StreamingUpdateCollection(
+ cancellationToken,
+ autoFunctionCallOptions,
+ 0,
+ sendRequest,
+ cancelRun,
+ submitToolOutputsToStream,
+ scope);
}
/// Submits outputs from tools as requested by tool calls in a stream. Stream updates that need submitted tool outputs will have a status of 'RunStatus.RequiresAction'.
/// The that the tool outputs should be submitted to.
@@ -319,6 +486,23 @@ public virtual CollectionResult CreateRunStreaming(string threa
/// or is null.
#pragma warning disable AZC0015 // Unexpected client method return type.
public virtual CollectionResult SubmitToolOutputsToStream(ThreadRun run, IEnumerable toolOutputs, CancellationToken cancellationToken = default)
+#pragma warning restore AZC0015 // Unexpected client method return type.
+ {
+ Argument.AssertNotNull(run, nameof(run));
+ Argument.AssertNotNull(toolOutputs, nameof(toolOutputs));
+
+ return SubmitToolOutputsToStreamWitAutoFunctionCall(run, toolOutputs, Int32.MaxValue, cancellationToken);
+ }
+
+ /// Submits outputs from tools as requested by tool calls in a stream. Stream updates that need submitted tool outputs will have a status of 'RunStatus.RequiresAction'.
+ /// The that the tool outputs should be submitted to.
+ /// A list of tools for which the outputs are being submitted.
+ /// The cancellation token to use.
+ /// The count of current retry of auto function calls. Cancel the run if reach to the maxinum.
+ /// If specified, function calls defined in tools will be called automatically.
+ /// or is null.
+#pragma warning disable AZC0015 // Unexpected client method return type.
+ internal virtual CollectionResult SubmitToolOutputsToStreamWitAutoFunctionCall(ThreadRun run, IEnumerable toolOutputs, int currentRetry = 0, CancellationToken cancellationToken = default, AutoFunctionCallOptions autoFunctionCallOptions = null)
#pragma warning restore AZC0015 // Unexpected client method return type.
{
var scope = OpenTelemetryScope.StartCreateRunStreaming(run.Id, run.AssistantId, _endpoint);
@@ -327,8 +511,19 @@ public virtual CollectionResult SubmitToolOutputsToStream(Threa
SubmitToolOutputsToRunRequest submitToolOutputsToRunRequest = new(toolOutputs.ToList(), true, null);
RequestContext context = FromCancellationToken(cancellationToken);
- Response sendRequest() => SubmitToolOutputsInternal(run.ThreadId, run.Id, true, submitToolOutputsToRunRequest.ToRequestContent(), context, scope:scope);
- return new StreamingUpdateCollection(sendRequest, cancellationToken, scope);
+ Response sendRequest() => SubmitToolOutputsInternal(run.ThreadId, run.Id, true, submitToolOutputsToRunRequest.ToRequestContent(), context);
+ CollectionResult submitToolOutputsToStream(ThreadRun run, IEnumerable toolOutputs, int currRetry) =>
+ this.SubmitToolOutputsToStreamWitAutoFunctionCall(run, toolOutputs, currentRetry);
+ Response cancelRun(string runId) => this.CancelRun(run.ThreadId, runId);
+
+ return new StreamingUpdateCollection(
+ cancellationToken,
+ autoFunctionCallOptions,
+ currentRetry,
+ sendRequest,
+ cancelRun,
+ submitToolOutputsToStream,
+ scope);
}
/// Submits outputs from tools as requested by tool calls in a stream. Stream updates that need submitted tool outputs will have a status of 'RunStatus.RequiresAction'.
@@ -338,6 +533,23 @@ public virtual CollectionResult SubmitToolOutputsToStream(Threa
///