diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.AgentsCountDeployedAgents.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.AgentsCountDeployedAgents.g.cs
index e2ba4394..7eccae32 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.AgentsCountDeployedAgents.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.AgentsCountDeployedAgents.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -51,12 +52,14 @@ partial void ProcessAgentsCountDeployedAgentsResponseContent(
///
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task AgentsCountDeployedAgentsAsync(
global::System.Collections.Generic.IList>? search = default,
string? projectId = default,
global::Letta.AgentsCountDeployedAgentsCombinator? combinator = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -73,27 +76,48 @@ partial void ProcessAgentsCountDeployedAgentsResponseContent(
securityRequirements: s_AgentsCountDeployedAgentsSecurityRequirements,
operationName: "AgentsCountDeployedAgentsAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: "/v1/agents/search/count",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("search", search, selector: static x => x.ToString() ?? string.Empty, delimiter: ",", explode: true)
- .AddOptionalParameter("project_id", projectId)
- .AddOptionalParameter("combinator", combinator?.ToValueString())
- ;
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Get,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: "/v1/agents/search/count",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("search", search, selector: static x => x.ToString() ?? string.Empty, delimiter: ",", explode: true)
+ .AddOptionalParameter("project_id", projectId)
+ .AddOptionalParameter("combinator", combinator?.ToValueString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Get,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -103,114 +127,273 @@ partial void ProcessAgentsCountDeployedAgentsResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareAgentsCountDeployedAgentsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- search: search,
- projectId: projectId,
- combinator: combinator);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareAgentsCountDeployedAgentsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ search: search,
+ projectId: projectId,
+ combinator: combinator);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessAgentsCountDeployedAgentsResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
+ return __httpRequest;
+ }
- if (ReadResponseAsString)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AgentsCountDeployedAgents",
+ methodName: "AgentsCountDeployedAgentsAsync",
+ pathTemplate: "\"/v1/agents/search/count\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AgentsCountDeployedAgents",
+ methodName: "AgentsCountDeployedAgentsAsync",
+ pathTemplate: "\"/v1/agents/search/count\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessAgentsCountDeployedAgentsResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AgentsCountDeployedAgents",
+ methodName: "AgentsCountDeployedAgentsAsync",
+ pathTemplate: "\"/v1/agents/search/count\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::Letta.AgentsCountDeployedAgentsResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ throw new global::System.InvalidOperationException("No response received.");
}
- }
- else
- {
- try
+
+ using (__response)
{
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- return
- await global::Letta.AgentsCountDeployedAgentsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessAgentsCountDeployedAgentsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AgentsCountDeployedAgents",
+ methodName: "AgentsCountDeployedAgentsAsync",
+ pathTemplate: "\"/v1/agents/search/count\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AgentsCountDeployedAgents",
+ methodName: "AgentsCountDeployedAgentsAsync",
+ pathTemplate: "\"/v1/agents/search/count\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessAgentsCountDeployedAgentsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Letta.AgentsCountDeployedAgentsResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Letta.AgentsCountDeployedAgentsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.AgentsGetAgentVariables.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.AgentsGetAgentVariables.g.cs
index eaa10a40..0f14ecc2 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.AgentsGetAgentVariables.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.AgentsGetAgentVariables.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -45,10 +46,12 @@ partial void ProcessAgentsGetAgentVariablesResponseContent(
/// Get the variables associated with an agent
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task AgentsGetAgentVariablesAsync(
string agentId,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -63,22 +66,43 @@ partial void ProcessAgentsGetAgentVariablesResponseContent(
securityRequirements: s_AgentsGetAgentVariablesSecurityRequirements,
operationName: "AgentsGetAgentVariablesAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/core-memory/variables",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Get,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/core-memory/variables",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Get,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -88,150 +112,309 @@ partial void ProcessAgentsGetAgentVariablesResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareAgentsGetAgentVariablesRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareAgentsGetAgentVariablesRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessAgentsGetAgentVariablesResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // 404
- if ((int)__response.StatusCode == 404)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_404 = null;
- global::System.Exception? __exception_404 = null;
- global::Letta.AgentsGetAgentVariablesResponse2? __value_404 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AgentsGetAgentVariables",
+ methodName: "AgentsGetAgentVariablesAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/variables\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_404 = global::Letta.AgentsGetAgentVariablesResponse2.FromJson(__content_404, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AgentsGetAgentVariables",
+ methodName: "AgentsGetAgentVariablesAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/variables\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_404 = global::Letta.AgentsGetAgentVariablesResponse2.FromJson(__content_404, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AgentsGetAgentVariables",
+ methodName: "AgentsGetAgentVariablesAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/variables\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_404 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_404 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_404,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_404,
- ResponseObject = __value_404,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessAgentsGetAgentVariablesResponseContent(
+ response: __response);
+ ProcessAgentsGetAgentVariablesResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::Letta.AgentsGetAgentVariablesResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AgentsGetAgentVariables",
+ methodName: "AgentsGetAgentVariablesAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/variables\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AgentsGetAgentVariables",
+ methodName: "AgentsGetAgentVariablesAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/variables\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // 404
+ if ((int)__response.StatusCode == 404)
+ {
+ string? __content_404 = null;
+ global::System.Exception? __exception_404 = null;
+ global::Letta.AgentsGetAgentVariablesResponse2? __value_404 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_404 = global::Letta.AgentsGetAgentVariablesResponse2.FromJson(__content_404, JsonSerializerContext);
+ }
+ else
+ {
+ __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- await global::Letta.AgentsGetAgentVariablesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_404 = global::Letta.AgentsGetAgentVariablesResponse2.FromJson(__content_404, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_404 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_404 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_404,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_404,
+ ResponseObject = __value_404,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessAgentsGetAgentVariablesResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Letta.AgentsGetAgentVariablesResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Letta.AgentsGetAgentVariablesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.AgentsSearchDeployedAgents.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.AgentsSearchDeployedAgents.g.cs
index 8247ac7c..e8ecd687 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.AgentsSearchDeployedAgents.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.AgentsSearchDeployedAgents.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -45,11 +46,13 @@ partial void ProcessAgentsSearchDeployedAgentsResponseContent(
/// Search deployed agents
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task AgentsSearchDeployedAgentsAsync(
global::Letta.AgentsSearchDeployedAgentsRequest request,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -66,22 +69,43 @@ partial void ProcessAgentsSearchDeployedAgentsResponseContent(
securityRequirements: s_AgentsSearchDeployedAgentsSecurityRequirements,
operationName: "AgentsSearchDeployedAgentsAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: "/v1/agents/search",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: "/v1/agents/search",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -91,118 +115,277 @@ partial void ProcessAgentsSearchDeployedAgentsResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareAgentsSearchDeployedAgentsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareAgentsSearchDeployedAgentsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessAgentsSearchDeployedAgentsResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
+ return __httpRequest;
+ }
- if (ReadResponseAsString)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
+ {
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AgentsSearchDeployedAgents",
+ methodName: "AgentsSearchDeployedAgentsAsync",
+ pathTemplate: "\"/v1/agents/search\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
+ {
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ }
+ catch (global::System.Net.Http.HttpRequestException __exception)
+ {
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AgentsSearchDeployedAgents",
+ methodName: "AgentsSearchDeployedAgentsAsync",
+ pathTemplate: "\"/v1/agents/search\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessAgentsSearchDeployedAgentsResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AgentsSearchDeployedAgents",
+ methodName: "AgentsSearchDeployedAgentsAsync",
+ pathTemplate: "\"/v1/agents/search\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- return
- global::Letta.AgentsSearchDeployedAgentsResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ throw new global::System.InvalidOperationException("No response received.");
}
- }
- else
- {
- try
+
+ using (__response)
{
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- return
- await global::Letta.AgentsSearchDeployedAgentsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessAgentsSearchDeployedAgentsResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AgentsSearchDeployedAgents",
+ methodName: "AgentsSearchDeployedAgentsAsync",
+ pathTemplate: "\"/v1/agents/search\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AgentsSearchDeployedAgents",
+ methodName: "AgentsSearchDeployedAgentsAsync",
+ pathTemplate: "\"/v1/agents/search\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessAgentsSearchDeployedAgentsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Letta.AgentsSearchDeployedAgentsResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Letta.AgentsSearchDeployedAgentsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
///
/// Search Deployed Agents
@@ -215,6 +398,7 @@ partial void ProcessAgentsSearchDeployedAgentsResponseContent(
///
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task AgentsSearchDeployedAgentsAsync(
@@ -225,6 +409,7 @@ partial void ProcessAgentsSearchDeployedAgentsResponseContent(
string? after = default,
global::Letta.AgentsSearchDeployedAgentsRequestSortBy? sortBy = default,
bool? ascending = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Letta.AgentsSearchDeployedAgentsRequest
@@ -240,6 +425,7 @@ partial void ProcessAgentsSearchDeployedAgentsResponseContent(
return await AgentsSearchDeployedAgentsAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.AttachArchiveToAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.AttachArchiveToAgent.g.cs
index 4ebbcb6d..4b4eda17 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.AttachArchiveToAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.AttachArchiveToAgent.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -50,11 +51,13 @@ partial void ProcessAttachArchiveToAgentResponseContent(
///
/// The ID of the agent in the format 'agent-<uuid4>'
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task AttachArchiveToAgentAsync(
string archiveId,
string agentId,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -70,22 +73,43 @@ partial void ProcessAttachArchiveToAgentResponseContent(
securityRequirements: s_AttachArchiveToAgentSecurityRequirements,
operationName: "AttachArchiveToAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/archives/attach/{archiveId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: new global::System.Net.Http.HttpMethod("PATCH"),
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/archives/attach/{archiveId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: new global::System.Net.Http.HttpMethod("PATCH"),
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -95,147 +119,306 @@ partial void ProcessAttachArchiveToAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareAttachArchiveToAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- archiveId: archiveId,
- agentId: agentId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareAttachArchiveToAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ archiveId: archiveId,
+ agentId: agentId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessAttachArchiveToAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachArchiveToAgent",
+ methodName: "AttachArchiveToAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archives/attach/{archiveId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachArchiveToAgent",
+ methodName: "AttachArchiveToAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archives/attach/{archiveId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachArchiveToAgent",
+ methodName: "AttachArchiveToAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archives/attach/{archiveId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessAttachArchiveToAgentResponseContent(
+ response: __response);
+ ProcessAttachArchiveToAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return __content;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachArchiveToAgent",
+ methodName: "AttachArchiveToAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archives/attach/{archiveId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachArchiveToAgent",
+ methodName: "AttachArchiveToAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archives/attach/{archiveId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return __content;
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessAttachArchiveToAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.AttachCoreMemoryBlock.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.AttachCoreMemoryBlock.g.cs
index e0dc859b..fde05a48 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.AttachCoreMemoryBlock.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.AttachCoreMemoryBlock.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -52,11 +53,13 @@ partial void ProcessAttachCoreMemoryBlockResponseContent(
///
/// The ID of the agent in the format 'agent-<uuid4>'
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task AttachCoreMemoryBlockAsync(
string blockId,
string agentId,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -72,22 +75,43 @@ partial void ProcessAttachCoreMemoryBlockResponseContent(
securityRequirements: s_AttachCoreMemoryBlockSecurityRequirements,
operationName: "AttachCoreMemoryBlockAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/core-memory/blocks/attach/{blockId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: new global::System.Net.Http.HttpMethod("PATCH"),
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/core-memory/blocks/attach/{blockId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: new global::System.Net.Http.HttpMethod("PATCH"),
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -97,151 +121,310 @@ partial void ProcessAttachCoreMemoryBlockResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareAttachCoreMemoryBlockRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- blockId: blockId,
- agentId: agentId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareAttachCoreMemoryBlockRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ blockId: blockId,
+ agentId: agentId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessAttachCoreMemoryBlockResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachCoreMemoryBlock",
+ methodName: "AttachCoreMemoryBlockAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks/attach/{blockId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachCoreMemoryBlock",
+ methodName: "AttachCoreMemoryBlockAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks/attach/{blockId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachCoreMemoryBlock",
+ methodName: "AttachCoreMemoryBlockAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks/attach/{blockId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessAttachCoreMemoryBlockResponseContent(
+ response: __response);
+ ProcessAttachCoreMemoryBlockResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::Letta.AgentState.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachCoreMemoryBlock",
+ methodName: "AttachCoreMemoryBlockAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks/attach/{blockId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachCoreMemoryBlock",
+ methodName: "AttachCoreMemoryBlockAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks/attach/{blockId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- await global::Letta.AgentState.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessAttachCoreMemoryBlockResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Letta.AgentState.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Letta.AgentState.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.AttachFolderToAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.AttachFolderToAgent.g.cs
index bdf21c1a..8d6174f3 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.AttachFolderToAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.AttachFolderToAgent.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -52,11 +53,13 @@ partial void ProcessAttachFolderToAgentResponseContent(
///
/// The ID of the agent in the format 'agent-<uuid4>'
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task AttachFolderToAgentAsync(
string folderId,
string agentId,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -72,22 +75,43 @@ partial void ProcessAttachFolderToAgentResponseContent(
securityRequirements: s_AttachFolderToAgentSecurityRequirements,
operationName: "AttachFolderToAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/folders/attach/{folderId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: new global::System.Net.Http.HttpMethod("PATCH"),
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/folders/attach/{folderId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: new global::System.Net.Http.HttpMethod("PATCH"),
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -97,151 +121,310 @@ partial void ProcessAttachFolderToAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareAttachFolderToAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- folderId: folderId,
- agentId: agentId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareAttachFolderToAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ folderId: folderId,
+ agentId: agentId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessAttachFolderToAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachFolderToAgent",
+ methodName: "AttachFolderToAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/folders/attach/{folderId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachFolderToAgent",
+ methodName: "AttachFolderToAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/folders/attach/{folderId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachFolderToAgent",
+ methodName: "AttachFolderToAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/folders/attach/{folderId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessAttachFolderToAgentResponseContent(
+ response: __response);
+ ProcessAttachFolderToAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::Letta.AgentState.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachFolderToAgent",
+ methodName: "AttachFolderToAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/folders/attach/{folderId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachFolderToAgent",
+ methodName: "AttachFolderToAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/folders/attach/{folderId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- await global::Letta.AgentState.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessAttachFolderToAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Letta.AgentState.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Letta.AgentState.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.AttachIdentityToAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.AttachIdentityToAgent.g.cs
index 580b1fc5..fc4a5df6 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.AttachIdentityToAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.AttachIdentityToAgent.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -50,11 +51,13 @@ partial void ProcessAttachIdentityToAgentResponseContent(
///
/// The ID of the agent in the format 'agent-<uuid4>'
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task AttachIdentityToAgentAsync(
string identityId,
string agentId,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -70,22 +73,43 @@ partial void ProcessAttachIdentityToAgentResponseContent(
securityRequirements: s_AttachIdentityToAgentSecurityRequirements,
operationName: "AttachIdentityToAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/identities/attach/{identityId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: new global::System.Net.Http.HttpMethod("PATCH"),
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/identities/attach/{identityId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: new global::System.Net.Http.HttpMethod("PATCH"),
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -95,147 +119,306 @@ partial void ProcessAttachIdentityToAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareAttachIdentityToAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- identityId: identityId,
- agentId: agentId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareAttachIdentityToAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ identityId: identityId,
+ agentId: agentId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessAttachIdentityToAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachIdentityToAgent",
+ methodName: "AttachIdentityToAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/identities/attach/{identityId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachIdentityToAgent",
+ methodName: "AttachIdentityToAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/identities/attach/{identityId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachIdentityToAgent",
+ methodName: "AttachIdentityToAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/identities/attach/{identityId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessAttachIdentityToAgentResponseContent(
+ response: __response);
+ ProcessAttachIdentityToAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return __content;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachIdentityToAgent",
+ methodName: "AttachIdentityToAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/identities/attach/{identityId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachIdentityToAgent",
+ methodName: "AttachIdentityToAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/identities/attach/{identityId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return __content;
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessAttachIdentityToAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.AttachToolToAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.AttachToolToAgent.g.cs
index 5e2a005e..0f3ecc27 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.AttachToolToAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.AttachToolToAgent.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -52,11 +53,13 @@ partial void ProcessAttachToolToAgentResponseContent(
///
/// The ID of the agent in the format 'agent-<uuid4>'
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task AttachToolToAgentAsync(
string toolId,
string agentId,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -72,22 +75,43 @@ partial void ProcessAttachToolToAgentResponseContent(
securityRequirements: s_AttachToolToAgentSecurityRequirements,
operationName: "AttachToolToAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/tools/attach/{toolId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: new global::System.Net.Http.HttpMethod("PATCH"),
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/tools/attach/{toolId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: new global::System.Net.Http.HttpMethod("PATCH"),
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -97,151 +121,310 @@ partial void ProcessAttachToolToAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareAttachToolToAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- toolId: toolId,
- agentId: agentId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareAttachToolToAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ toolId: toolId,
+ agentId: agentId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessAttachToolToAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachToolToAgent",
+ methodName: "AttachToolToAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools/attach/{toolId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachToolToAgent",
+ methodName: "AttachToolToAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools/attach/{toolId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachToolToAgent",
+ methodName: "AttachToolToAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools/attach/{toolId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessAttachToolToAgentResponseContent(
+ response: __response);
+ ProcessAttachToolToAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::Letta.AgentState.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachToolToAgent",
+ methodName: "AttachToolToAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools/attach/{toolId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "AttachToolToAgent",
+ methodName: "AttachToolToAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools/attach/{toolId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- await global::Letta.AgentState.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessAttachToolToAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Letta.AgentState.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Letta.AgentState.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.CancelMessage.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.CancelMessage.g.cs
index 9ea1f85f..bcb2fb3b 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.CancelMessage.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.CancelMessage.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -51,12 +52,14 @@ partial void ProcessCancelMessageResponseContent(
/// The ID of the agent in the format 'agent-<uuid4>'
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task CancelMessageAsync(
string agentId,
global::Letta.CancelAgentRunRequest request,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -74,22 +77,43 @@ partial void ProcessCancelMessageResponseContent(
securityRequirements: s_CancelMessageSecurityRequirements,
operationName: "CancelMessageAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/messages/cancel",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/messages/cancel",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -99,153 +123,312 @@ partial void ProcessCancelMessageResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareCancelMessageRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId,
- request: request);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCancelMessageRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCancelMessageResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelMessage",
+ methodName: "CancelMessageAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/messages/cancel\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelMessage",
+ methodName: "CancelMessageAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/messages/cancel\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelMessage",
+ methodName: "CancelMessageAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/messages/cancel\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCancelMessageResponseContent(
+ response: __response);
+ ProcessCancelMessageResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return __content;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelMessage",
+ methodName: "CancelMessageAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/messages/cancel\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CancelMessage",
+ methodName: "CancelMessageAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/messages/cancel\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return __content;
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessCancelMessageResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
///
/// Cancel Message
@@ -258,11 +441,13 @@ partial void ProcessCancelMessageResponseContent(
///
/// Optional list of run IDs to cancel
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task CancelMessageAsync(
string agentId,
global::System.Collections.Generic.IList? runIds = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Letta.CancelAgentRunRequest
@@ -273,6 +458,7 @@ partial void ProcessCancelMessageResponseContent(
return await CancelMessageAsync(
agentId: agentId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.CloseAllFilesForAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.CloseAllFilesForAgent.g.cs
index d18d3b23..a5f0f55a 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.CloseAllFilesForAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.CloseAllFilesForAgent.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -49,10 +50,12 @@ partial void ProcessCloseAllFilesForAgentResponseContent(
///
/// The ID of the agent in the format 'agent-<uuid4>'
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task> CloseAllFilesForAgentAsync(
string agentId,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -67,22 +70,43 @@ partial void ProcessCloseAllFilesForAgentResponseContent(
securityRequirements: s_CloseAllFilesForAgentSecurityRequirements,
operationName: "CloseAllFilesForAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/files/close-all",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: new global::System.Net.Http.HttpMethod("PATCH"),
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/files/close-all",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: new global::System.Net.Http.HttpMethod("PATCH"),
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -92,150 +116,309 @@ partial void ProcessCloseAllFilesForAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareCloseAllFilesForAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCloseAllFilesForAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCloseAllFilesForAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CloseAllFilesForAgent",
+ methodName: "CloseAllFilesForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/files/close-all\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CloseAllFilesForAgent",
+ methodName: "CloseAllFilesForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/files/close-all\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CloseAllFilesForAgent",
+ methodName: "CloseAllFilesForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/files/close-all\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCloseAllFilesForAgentResponseContent(
+ response: __response);
+ ProcessCloseAllFilesForAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CloseAllFilesForAgent",
+ methodName: "CloseAllFilesForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/files/close-all\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CloseAllFilesForAgent",
+ methodName: "CloseAllFilesForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/files/close-all\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessCloseAllFilesForAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.CloseFileForAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.CloseFileForAgent.g.cs
index 1ec8048d..a606b651 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.CloseFileForAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.CloseFileForAgent.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -54,11 +55,13 @@ partial void ProcessCloseFileForAgentResponseContent(
///
/// The ID of the agent in the format 'agent-<uuid4>'
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task CloseFileForAgentAsync(
string fileId,
string agentId,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -74,22 +77,43 @@ partial void ProcessCloseFileForAgentResponseContent(
securityRequirements: s_CloseFileForAgentSecurityRequirements,
operationName: "CloseFileForAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/files/{fileId}/close",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: new global::System.Net.Http.HttpMethod("PATCH"),
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/files/{fileId}/close",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: new global::System.Net.Http.HttpMethod("PATCH"),
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -99,147 +123,306 @@ partial void ProcessCloseFileForAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareCloseFileForAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- fileId: fileId,
- agentId: agentId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCloseFileForAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ fileId: fileId,
+ agentId: agentId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCloseFileForAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CloseFileForAgent",
+ methodName: "CloseFileForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/files/{fileId}/close\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CloseFileForAgent",
+ methodName: "CloseFileForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/files/{fileId}/close\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CloseFileForAgent",
+ methodName: "CloseFileForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/files/{fileId}/close\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCloseFileForAgentResponseContent(
+ response: __response);
+ ProcessCloseFileForAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return __content;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CloseFileForAgent",
+ methodName: "CloseFileForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/files/{fileId}/close\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CloseFileForAgent",
+ methodName: "CloseFileForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/files/{fileId}/close\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return __content;
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessCloseFileForAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.CountAgents.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.CountAgents.g.cs
index a3c60d80..c55292c6 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.CountAgents.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.CountAgents.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -99,6 +100,7 @@ partial void ProcessCountAgentsResponseContent(
///
/// Filter agents by the user who created them.
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task CountAgentsAsync(
@@ -113,6 +115,7 @@ partial void ProcessCountAgentsResponseContent(
global::System.Collections.Generic.IList? identifierKeys = default,
global::Letta.StopReasonType? lastStopReason = default,
string? createdById = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -137,35 +140,56 @@ partial void ProcessCountAgentsResponseContent(
securityRequirements: s_CountAgentsSecurityRequirements,
operationName: "CountAgentsAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: "/v1/agents/count",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("name", name)
- .AddOptionalParameter("tags", tags?.ToString())
- .AddOptionalParameter("match_all_tags", matchAllTags?.ToString().ToLowerInvariant())
- .AddOptionalParameter("query_text", queryText)
- .AddOptionalParameter("project_id", projectId)
- .AddOptionalParameter("template_id", templateId)
- .AddOptionalParameter("base_template_id", baseTemplateId)
- .AddOptionalParameter("identity_id", identityId)
- .AddOptionalParameter("identifier_keys", identifierKeys?.ToString())
- .AddOptionalParameter("last_stop_reason", lastStopReason?.ToString())
- .AddOptionalParameter("created_by_id", createdById)
- ;
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Get,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: "/v1/agents/count",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("name", name)
+ .AddOptionalParameter("tags", tags?.ToString())
+ .AddOptionalParameter("match_all_tags", matchAllTags?.ToString().ToLowerInvariant())
+ .AddOptionalParameter("query_text", queryText)
+ .AddOptionalParameter("project_id", projectId)
+ .AddOptionalParameter("template_id", templateId)
+ .AddOptionalParameter("base_template_id", baseTemplateId)
+ .AddOptionalParameter("identity_id", identityId)
+ .AddOptionalParameter("identifier_keys", identifierKeys?.ToString())
+ .AddOptionalParameter("last_stop_reason", lastStopReason?.ToString())
+ .AddOptionalParameter("created_by_id", createdById)
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Get,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -175,160 +199,319 @@ partial void ProcessCountAgentsResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareCountAgentsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- name: name,
- tags: tags,
- matchAllTags: matchAllTags,
- queryText: queryText,
- projectId: projectId,
- templateId: templateId,
- baseTemplateId: baseTemplateId,
- identityId: identityId,
- identifierKeys: identifierKeys,
- lastStopReason: lastStopReason,
- createdById: createdById);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCountAgentsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ name: name,
+ tags: tags,
+ matchAllTags: matchAllTags,
+ queryText: queryText,
+ projectId: projectId,
+ templateId: templateId,
+ baseTemplateId: baseTemplateId,
+ identityId: identityId,
+ identifierKeys: identifierKeys,
+ lastStopReason: lastStopReason,
+ createdById: createdById);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCountAgentsResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CountAgents",
+ methodName: "CountAgentsAsync",
+ pathTemplate: "\"/v1/agents/count\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CountAgents",
+ methodName: "CountAgentsAsync",
+ pathTemplate: "\"/v1/agents/count\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CountAgents",
+ methodName: "CountAgentsAsync",
+ pathTemplate: "\"/v1/agents/count\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCountAgentsResponseContent(
+ response: __response);
+ ProcessCountAgentsResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- (int?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(int?), JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CountAgents",
+ methodName: "CountAgentsAsync",
+ pathTemplate: "\"/v1/agents/count\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CountAgents",
+ methodName: "CountAgentsAsync",
+ pathTemplate: "\"/v1/agents/count\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- (int?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(int?), JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessCountAgentsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ (int?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(int?), JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ (int?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(int?), JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.CreateAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.CreateAgent.g.cs
index 14973198..a5603c13 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.CreateAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.CreateAgent.g.cs
@@ -16,6 +16,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -52,12 +53,14 @@ partial void ProcessCreateAgentResponseContent(
/// The project slug to associate with the agent (cloud only).
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task CreateAgentAsync(
global::Letta.CreateAgentRequest request,
string? xProject = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -75,22 +78,43 @@ partial void ProcessCreateAgentResponseContent(
securityRequirements: s_CreateAgentSecurityRequirements,
operationName: "CreateAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: "/v1/agents/",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: "/v1/agents/",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -100,163 +124,322 @@ partial void ProcessCreateAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- if (xProject != default)
- {
- __httpRequest.Headers.TryAddWithoutValidation("X-Project", xProject.ToString());
- }
+ if (xProject != default)
+ {
+ __httpRequest.Headers.TryAddWithoutValidation("X-Project", xProject.ToString());
+ }
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareCreateAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- xProject: xProject,
- request: request);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCreateAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ xProject: xProject,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateAgent",
+ methodName: "CreateAgentAsync",
+ pathTemplate: "\"/v1/agents/\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateAgent",
+ methodName: "CreateAgentAsync",
+ pathTemplate: "\"/v1/agents/\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateAgent",
+ methodName: "CreateAgentAsync",
+ pathTemplate: "\"/v1/agents/\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCreateAgentResponseContent(
+ response: __response);
+ ProcessCreateAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::Letta.AgentState.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateAgent",
+ methodName: "CreateAgentAsync",
+ pathTemplate: "\"/v1/agents/\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateAgent",
+ methodName: "CreateAgentAsync",
+ pathTemplate: "\"/v1/agents/\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- await global::Letta.AgentState.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessCreateAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Letta.AgentState.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Letta.AgentState.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
///
/// Create Agent
@@ -352,6 +535,7 @@ partial void ProcessCreateAgentResponseContent(
///
/// The per-file view window character limit for this agent. Setting this too high may exceed the context window, which will break the agent.
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task CreateAgentAsync(
@@ -384,6 +568,7 @@ partial void ProcessCreateAgentResponseContent(
string? timezone = default,
int? maxFilesOpen = default,
int? perFileViewWindowCharLimit = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Letta.CreateAgentRequest
@@ -421,6 +606,7 @@ partial void ProcessCreateAgentResponseContent(
return await CreateAgentAsync(
xProject: xProject,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.CreateAgentMessageAsync.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.CreateAgentMessageAsync.g.cs
index 5a5b1399..77260a87 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.CreateAgentMessageAsync.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.CreateAgentMessageAsync.g.cs
@@ -16,6 +16,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -57,12 +58,14 @@ partial void ProcessCreateAgentMessageAsyncResponseContent(
/// The ID of the agent in the format 'agent-<uuid4>'
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task CreateAgentMessageAsyncAsync(
string agentId,
global::Letta.LettaAsyncRequest request,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -80,22 +83,43 @@ partial void ProcessCreateAgentMessageAsyncResponseContent(
securityRequirements: s_CreateAgentMessageAsyncSecurityRequirements,
operationName: "CreateAgentMessageAsyncAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/messages/async",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/messages/async",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -105,157 +129,316 @@ partial void ProcessCreateAgentMessageAsyncResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareCreateAgentMessageAsyncRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId,
- request: request);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCreateAgentMessageAsyncRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreateAgentMessageAsyncResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateAgentMessageAsync",
+ methodName: "CreateAgentMessageAsyncAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/messages/async\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateAgentMessageAsync",
+ methodName: "CreateAgentMessageAsyncAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/messages/async\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateAgentMessageAsync",
+ methodName: "CreateAgentMessageAsyncAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/messages/async\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCreateAgentMessageAsyncResponseContent(
+ response: __response);
+ ProcessCreateAgentMessageAsyncResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::Letta.Run.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateAgentMessageAsync",
+ methodName: "CreateAgentMessageAsyncAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/messages/async\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreateAgentMessageAsync",
+ methodName: "CreateAgentMessageAsyncAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/messages/async\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- await global::Letta.Run.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessCreateAgentMessageAsyncResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Letta.Run.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Letta.Run.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
///
/// Send Message Async
@@ -312,6 +495,7 @@ partial void ProcessCreateAgentMessageAsyncResponseContent(
///
/// Optional callback URL to POST to when the job completes
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task CreateAgentMessageAsyncAsync(
@@ -329,6 +513,7 @@ partial void ProcessCreateAgentMessageAsyncResponseContent(
bool? returnTokenIds = default,
string? overrideSystem = default,
string? callbackUrl = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Letta.LettaAsyncRequest
@@ -351,6 +536,7 @@ partial void ProcessCreateAgentMessageAsyncResponseContent(
return await CreateAgentMessageAsyncAsync(
agentId: agentId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.CreatePassage.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.CreatePassage.g.cs
index 333ef2e7..dd625458 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.CreatePassage.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.CreatePassage.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -50,12 +51,14 @@ partial void ProcessCreatePassageResponseContent(
/// The ID of the agent in the format 'agent-<uuid4>'
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task> CreatePassageAsync(
string agentId,
global::Letta.CreateArchivalMemory request,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -73,22 +76,43 @@ partial void ProcessCreatePassageResponseContent(
securityRequirements: s_CreatePassageSecurityRequirements,
operationName: "CreatePassageAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/archival-memory",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/archival-memory",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -98,157 +122,316 @@ partial void ProcessCreatePassageResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareCreatePassageRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId,
- request: request);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareCreatePassageRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessCreatePassageResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreatePassage",
+ methodName: "CreatePassageAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archival-memory\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreatePassage",
+ methodName: "CreatePassageAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archival-memory\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreatePassage",
+ methodName: "CreatePassageAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archival-memory\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessCreatePassageResponseContent(
+ response: __response);
+ ProcessCreatePassageResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreatePassage",
+ methodName: "CreatePassageAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archival-memory\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "CreatePassage",
+ methodName: "CreatePassageAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archival-memory\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessCreatePassageResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
///
/// Create Passage
@@ -266,6 +449,7 @@ partial void ProcessCreatePassageResponseContent(
///
/// Optional timestamp for the memory (defaults to current UTC time).
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task> CreatePassageAsync(
@@ -273,6 +457,7 @@ partial void ProcessCreatePassageResponseContent(
string text,
global::System.Collections.Generic.IList? tags = default,
global::System.DateTime? createdAt = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Letta.CreateArchivalMemory
@@ -285,6 +470,7 @@ partial void ProcessCreatePassageResponseContent(
return await CreatePassageAsync(
agentId: agentId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.DeleteAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.DeleteAgent.g.cs
index 7dce8ee3..a12d12c2 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.DeleteAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.DeleteAgent.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -47,10 +48,12 @@ partial void ProcessDeleteAgentResponseContent(
///
/// The ID of the agent in the format 'agent-<uuid4>'
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task DeleteAgentAsync(
string agentId,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -65,22 +68,43 @@ partial void ProcessDeleteAgentResponseContent(
securityRequirements: s_DeleteAgentSecurityRequirements,
operationName: "DeleteAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Delete,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Delete,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -90,146 +114,305 @@ partial void ProcessDeleteAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDeleteAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDeleteAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDeleteAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAgent",
+ methodName: "DeleteAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAgent",
+ methodName: "DeleteAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAgent",
+ methodName: "DeleteAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDeleteAgentResponseContent(
+ response: __response);
+ ProcessDeleteAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return __content;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAgent",
+ methodName: "DeleteAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeleteAgent",
+ methodName: "DeleteAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return __content;
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessDeleteAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.DeletePassage.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.DeletePassage.g.cs
index d5bbb678..991bb0e4 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.DeletePassage.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.DeletePassage.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -50,11 +51,13 @@ partial void ProcessDeletePassageResponseContent(
///
/// The ID of the agent in the format 'agent-<uuid4>'
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task DeletePassageAsync(
string memoryId,
string agentId,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -70,22 +73,43 @@ partial void ProcessDeletePassageResponseContent(
securityRequirements: s_DeletePassageSecurityRequirements,
operationName: "DeletePassageAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/archival-memory/{memoryId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Delete,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/archival-memory/{memoryId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Delete,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -95,147 +119,306 @@ partial void ProcessDeletePassageResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDeletePassageRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- memoryId: memoryId,
- agentId: agentId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDeletePassageRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ memoryId: memoryId,
+ agentId: agentId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDeletePassageResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeletePassage",
+ methodName: "DeletePassageAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archival-memory/{memoryId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeletePassage",
+ methodName: "DeletePassageAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archival-memory/{memoryId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeletePassage",
+ methodName: "DeletePassageAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archival-memory/{memoryId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDeletePassageResponseContent(
+ response: __response);
+ ProcessDeletePassageResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return __content;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeletePassage",
+ methodName: "DeletePassageAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archival-memory/{memoryId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DeletePassage",
+ methodName: "DeletePassageAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archival-memory/{memoryId}\"",
+ httpMethod: "DELETE",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return __content;
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessDeletePassageResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.DetachArchiveFromAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.DetachArchiveFromAgent.g.cs
index a1cf6b2f..bbc55f82 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.DetachArchiveFromAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.DetachArchiveFromAgent.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -50,11 +51,13 @@ partial void ProcessDetachArchiveFromAgentResponseContent(
///
/// The ID of the agent in the format 'agent-<uuid4>'
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task DetachArchiveFromAgentAsync(
string archiveId,
string agentId,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -70,22 +73,43 @@ partial void ProcessDetachArchiveFromAgentResponseContent(
securityRequirements: s_DetachArchiveFromAgentSecurityRequirements,
operationName: "DetachArchiveFromAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/archives/detach/{archiveId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: new global::System.Net.Http.HttpMethod("PATCH"),
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/archives/detach/{archiveId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: new global::System.Net.Http.HttpMethod("PATCH"),
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -95,147 +119,306 @@ partial void ProcessDetachArchiveFromAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDetachArchiveFromAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- archiveId: archiveId,
- agentId: agentId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDetachArchiveFromAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ archiveId: archiveId,
+ agentId: agentId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDetachArchiveFromAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachArchiveFromAgent",
+ methodName: "DetachArchiveFromAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archives/detach/{archiveId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachArchiveFromAgent",
+ methodName: "DetachArchiveFromAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archives/detach/{archiveId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachArchiveFromAgent",
+ methodName: "DetachArchiveFromAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archives/detach/{archiveId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDetachArchiveFromAgentResponseContent(
+ response: __response);
+ ProcessDetachArchiveFromAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return __content;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachArchiveFromAgent",
+ methodName: "DetachArchiveFromAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archives/detach/{archiveId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachArchiveFromAgent",
+ methodName: "DetachArchiveFromAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archives/detach/{archiveId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return __content;
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessDetachArchiveFromAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.DetachCoreMemoryBlock.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.DetachCoreMemoryBlock.g.cs
index c75a1b2d..e09ce29f 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.DetachCoreMemoryBlock.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.DetachCoreMemoryBlock.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -52,11 +53,13 @@ partial void ProcessDetachCoreMemoryBlockResponseContent(
///
/// The ID of the agent in the format 'agent-<uuid4>'
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task DetachCoreMemoryBlockAsync(
string blockId,
string agentId,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -72,22 +75,43 @@ partial void ProcessDetachCoreMemoryBlockResponseContent(
securityRequirements: s_DetachCoreMemoryBlockSecurityRequirements,
operationName: "DetachCoreMemoryBlockAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/core-memory/blocks/detach/{blockId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: new global::System.Net.Http.HttpMethod("PATCH"),
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/core-memory/blocks/detach/{blockId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: new global::System.Net.Http.HttpMethod("PATCH"),
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -97,151 +121,310 @@ partial void ProcessDetachCoreMemoryBlockResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDetachCoreMemoryBlockRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- blockId: blockId,
- agentId: agentId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDetachCoreMemoryBlockRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ blockId: blockId,
+ agentId: agentId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDetachCoreMemoryBlockResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachCoreMemoryBlock",
+ methodName: "DetachCoreMemoryBlockAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks/detach/{blockId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachCoreMemoryBlock",
+ methodName: "DetachCoreMemoryBlockAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks/detach/{blockId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachCoreMemoryBlock",
+ methodName: "DetachCoreMemoryBlockAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks/detach/{blockId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDetachCoreMemoryBlockResponseContent(
+ response: __response);
+ ProcessDetachCoreMemoryBlockResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::Letta.AgentState.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachCoreMemoryBlock",
+ methodName: "DetachCoreMemoryBlockAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks/detach/{blockId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachCoreMemoryBlock",
+ methodName: "DetachCoreMemoryBlockAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks/detach/{blockId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- await global::Letta.AgentState.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessDetachCoreMemoryBlockResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Letta.AgentState.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Letta.AgentState.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.DetachFolderFromAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.DetachFolderFromAgent.g.cs
index 89443799..a9e96b6a 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.DetachFolderFromAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.DetachFolderFromAgent.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -52,11 +53,13 @@ partial void ProcessDetachFolderFromAgentResponseContent(
///
/// The ID of the agent in the format 'agent-<uuid4>'
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task DetachFolderFromAgentAsync(
string folderId,
string agentId,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -72,22 +75,43 @@ partial void ProcessDetachFolderFromAgentResponseContent(
securityRequirements: s_DetachFolderFromAgentSecurityRequirements,
operationName: "DetachFolderFromAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/folders/detach/{folderId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: new global::System.Net.Http.HttpMethod("PATCH"),
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/folders/detach/{folderId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: new global::System.Net.Http.HttpMethod("PATCH"),
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -97,151 +121,310 @@ partial void ProcessDetachFolderFromAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDetachFolderFromAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- folderId: folderId,
- agentId: agentId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDetachFolderFromAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ folderId: folderId,
+ agentId: agentId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDetachFolderFromAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachFolderFromAgent",
+ methodName: "DetachFolderFromAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/folders/detach/{folderId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachFolderFromAgent",
+ methodName: "DetachFolderFromAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/folders/detach/{folderId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachFolderFromAgent",
+ methodName: "DetachFolderFromAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/folders/detach/{folderId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDetachFolderFromAgentResponseContent(
+ response: __response);
+ ProcessDetachFolderFromAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::Letta.AgentState.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachFolderFromAgent",
+ methodName: "DetachFolderFromAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/folders/detach/{folderId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachFolderFromAgent",
+ methodName: "DetachFolderFromAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/folders/detach/{folderId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- await global::Letta.AgentState.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessDetachFolderFromAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Letta.AgentState.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Letta.AgentState.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.DetachIdentityFromAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.DetachIdentityFromAgent.g.cs
index 47cc07f7..1b3efd73 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.DetachIdentityFromAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.DetachIdentityFromAgent.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -50,11 +51,13 @@ partial void ProcessDetachIdentityFromAgentResponseContent(
///
/// The ID of the agent in the format 'agent-<uuid4>'
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task DetachIdentityFromAgentAsync(
string identityId,
string agentId,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -70,22 +73,43 @@ partial void ProcessDetachIdentityFromAgentResponseContent(
securityRequirements: s_DetachIdentityFromAgentSecurityRequirements,
operationName: "DetachIdentityFromAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/identities/detach/{identityId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: new global::System.Net.Http.HttpMethod("PATCH"),
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/identities/detach/{identityId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: new global::System.Net.Http.HttpMethod("PATCH"),
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -95,147 +119,306 @@ partial void ProcessDetachIdentityFromAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDetachIdentityFromAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- identityId: identityId,
- agentId: agentId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDetachIdentityFromAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ identityId: identityId,
+ agentId: agentId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDetachIdentityFromAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachIdentityFromAgent",
+ methodName: "DetachIdentityFromAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/identities/detach/{identityId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachIdentityFromAgent",
+ methodName: "DetachIdentityFromAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/identities/detach/{identityId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachIdentityFromAgent",
+ methodName: "DetachIdentityFromAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/identities/detach/{identityId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDetachIdentityFromAgentResponseContent(
+ response: __response);
+ ProcessDetachIdentityFromAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return __content;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachIdentityFromAgent",
+ methodName: "DetachIdentityFromAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/identities/detach/{identityId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachIdentityFromAgent",
+ methodName: "DetachIdentityFromAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/identities/detach/{identityId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return __content;
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessDetachIdentityFromAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.DetachToolFromAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.DetachToolFromAgent.g.cs
index ad00cad1..23e03d4f 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.DetachToolFromAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.DetachToolFromAgent.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -52,11 +53,13 @@ partial void ProcessDetachToolFromAgentResponseContent(
///
/// The ID of the agent in the format 'agent-<uuid4>'
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task DetachToolFromAgentAsync(
string toolId,
string agentId,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -72,22 +75,43 @@ partial void ProcessDetachToolFromAgentResponseContent(
securityRequirements: s_DetachToolFromAgentSecurityRequirements,
operationName: "DetachToolFromAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/tools/detach/{toolId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: new global::System.Net.Http.HttpMethod("PATCH"),
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/tools/detach/{toolId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: new global::System.Net.Http.HttpMethod("PATCH"),
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -97,151 +121,310 @@ partial void ProcessDetachToolFromAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareDetachToolFromAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- toolId: toolId,
- agentId: agentId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareDetachToolFromAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ toolId: toolId,
+ agentId: agentId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessDetachToolFromAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachToolFromAgent",
+ methodName: "DetachToolFromAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools/detach/{toolId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachToolFromAgent",
+ methodName: "DetachToolFromAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools/detach/{toolId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachToolFromAgent",
+ methodName: "DetachToolFromAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools/detach/{toolId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessDetachToolFromAgentResponseContent(
+ response: __response);
+ ProcessDetachToolFromAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::Letta.AgentState.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachToolFromAgent",
+ methodName: "DetachToolFromAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools/detach/{toolId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "DetachToolFromAgent",
+ methodName: "DetachToolFromAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools/detach/{toolId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- await global::Letta.AgentState.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessDetachToolFromAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Letta.AgentState.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Letta.AgentState.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.ExportAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.ExportAgent.g.cs
index 53f96811..0a6cf244 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.ExportAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.ExportAgent.g.cs
@@ -16,6 +16,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -72,6 +73,7 @@ partial void ProcessExportAgentResponseContent(
/// Default Value: false
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task ExportAgentAsync(
@@ -82,6 +84,7 @@ partial void ProcessExportAgentResponseContent(
bool? useLegacyFormat = default,
string? conversationId = default,
bool? scrubMessages = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -103,28 +106,49 @@ partial void ProcessExportAgentResponseContent(
securityRequirements: s_ExportAgentSecurityRequirements,
operationName: "ExportAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/export",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("max_steps", maxSteps?.ToString())
- .AddOptionalParameter("use_legacy_format", useLegacyFormat?.ToString().ToLowerInvariant())
- .AddOptionalParameter("conversation_id", conversationId)
- .AddOptionalParameter("scrub_messages", scrubMessages?.ToString().ToLowerInvariant())
- ;
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Get,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/export",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("max_steps", maxSteps?.ToString())
+ .AddOptionalParameter("use_legacy_format", useLegacyFormat?.ToString().ToLowerInvariant())
+ .AddOptionalParameter("conversation_id", conversationId)
+ .AddOptionalParameter("scrub_messages", scrubMessages?.ToString().ToLowerInvariant())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Get,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -134,157 +158,316 @@ partial void ProcessExportAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareExportAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId,
- maxSteps: maxSteps,
- useLegacyFormat: useLegacyFormat,
- conversationId: conversationId,
- scrubMessages: scrubMessages,
- request: request);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareExportAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId,
+ maxSteps: maxSteps,
+ useLegacyFormat: useLegacyFormat,
+ conversationId: conversationId,
+ scrubMessages: scrubMessages,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessExportAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ExportAgent",
+ methodName: "ExportAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/export\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ExportAgent",
+ methodName: "ExportAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/export\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ExportAgent",
+ methodName: "ExportAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/export\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessExportAgentResponseContent(
+ response: __response);
+ ProcessExportAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return __content;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ExportAgent",
+ methodName: "ExportAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/export\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ExportAgent",
+ methodName: "ExportAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/export\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return __content;
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessExportAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
///
/// Export Agent
@@ -307,6 +490,7 @@ partial void ProcessExportAgentResponseContent(
///
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task ExportAgentAsync(
@@ -317,6 +501,7 @@ partial void ProcessExportAgentResponseContent(
bool? scrubMessages = default,
global::Letta.AgentFileSchema? spec = default,
global::Letta.LettaSerializeSchemasPydanticAgentSchemaAgentSchema? legacySpec = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Letta.BodyExportAgent
@@ -332,6 +517,7 @@ partial void ProcessExportAgentResponseContent(
conversationId: conversationId,
scrubMessages: scrubMessages,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.ExportAgentWithSkills.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.ExportAgentWithSkills.g.cs
index 5ecbfb0b..67bc33f0 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.ExportAgentWithSkills.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.ExportAgentWithSkills.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -50,12 +51,14 @@ partial void ProcessExportAgentWithSkillsResponseContent(
///
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task ExportAgentWithSkillsAsync(
string agentId,
global::Letta.ExportAgentRequest request,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -73,22 +76,43 @@ partial void ProcessExportAgentWithSkillsResponseContent(
securityRequirements: s_ExportAgentWithSkillsSecurityRequirements,
operationName: "ExportAgentWithSkillsAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/export",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/export",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -98,153 +122,312 @@ partial void ProcessExportAgentWithSkillsResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareExportAgentWithSkillsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId,
- request: request);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareExportAgentWithSkillsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessExportAgentWithSkillsResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ExportAgentWithSkills",
+ methodName: "ExportAgentWithSkillsAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/export\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ExportAgentWithSkills",
+ methodName: "ExportAgentWithSkillsAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/export\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ExportAgentWithSkills",
+ methodName: "ExportAgentWithSkillsAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/export\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessExportAgentWithSkillsResponseContent(
+ response: __response);
+ ProcessExportAgentWithSkillsResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return __content;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ExportAgentWithSkills",
+ methodName: "ExportAgentWithSkillsAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/export\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ExportAgentWithSkills",
+ methodName: "ExportAgentWithSkillsAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/export\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return __content;
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessExportAgentWithSkillsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
///
/// Export Agent With Skills
@@ -253,10 +436,12 @@ partial void ProcessExportAgentWithSkillsResponseContent(
/// Skills are resolved client-side and passed as SkillSchema objects containing the skill files.
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task ExportAgentWithSkillsAsync(
string agentId,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Letta.ExportAgentRequest
@@ -266,6 +451,7 @@ partial void ProcessExportAgentWithSkillsResponseContent(
return await ExportAgentWithSkillsAsync(
agentId: agentId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.GenerateCompletion.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.GenerateCompletion.g.cs
index 9c0cda2f..a40fbb85 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.GenerateCompletion.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.GenerateCompletion.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -65,12 +66,14 @@ partial void ProcessGenerateCompletionResponseContent(
/// The ID of the agent in the format 'agent-<uuid4>'
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task GenerateCompletionAsync(
string agentId,
global::Letta.GenerateRequest request,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -88,22 +91,43 @@ partial void ProcessGenerateCompletionResponseContent(
securityRequirements: s_GenerateCompletionSecurityRequirements,
operationName: "GenerateCompletionAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/generate",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/generate",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -113,218 +137,377 @@ partial void ProcessGenerateCompletionResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareGenerateCompletionRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId,
- request: request);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareGenerateCompletionRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessGenerateCompletionResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- //
- if ((int)__response.StatusCode == 404)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_404 = null;
- global::System.Exception? __exception_404 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GenerateCompletion",
+ methodName: "GenerateCompletionAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/generate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- }
- }
- catch (global::System.Exception __ex)
- {
- __exception_404 = __ex;
- }
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GenerateCompletion",
+ methodName: "GenerateCompletionAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/generate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- throw new global::Letta.ApiException(
- message: __content_404 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_404,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_404,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- //
- if ((int)__response.StatusCode == 422)
- {
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- try
- {
- if (ReadResponseAsString)
- {
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
- else
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GenerateCompletion",
+ methodName: "GenerateCompletionAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/generate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- //
- if ((int)__response.StatusCode == 502)
- {
- string? __content_502 = null;
- global::System.Exception? __exception_502 = null;
- try
+
+ ProcessResponse(
+ client: HttpClient,
+ response: __response);
+ ProcessGenerateCompletionResponse(
+ httpClient: HttpClient,
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- if (ReadResponseAsString)
- {
- __content_502 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- }
- else
- {
- __content_502 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- }
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GenerateCompletion",
+ methodName: "GenerateCompletionAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/generate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- __exception_502 = __ex;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "GenerateCompletion",
+ methodName: "GenerateCompletionAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/generate\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
+ //
+ if ((int)__response.StatusCode == 404)
+ {
+ string? __content_404 = null;
+ global::System.Exception? __exception_404 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_404 = __ex;
+ }
- throw new global::Letta.ApiException(
- message: __content_502 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_502,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content_502,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
+ throw new global::Letta.ApiException(
+ message: __content_404 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_404,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_404,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ //
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ //
+ if ((int)__response.StatusCode == 502)
+ {
+ string? __content_502 = null;
+ global::System.Exception? __exception_502 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_502 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ else
+ {
+ __content_502 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_502 = __ex;
+ }
- ProcessResponseContent(
- client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessGenerateCompletionResponseContent(
- httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
+ throw new global::Letta.ApiException(
+ message: __content_502 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_502,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_502,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
- try
- {
- __response.EnsureSuccessStatusCode();
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
- return
- global::Letta.GenerateResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
- }
- catch (global::System.Exception __ex)
- {
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessGenerateCompletionResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
- return
- await global::Letta.GenerateResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Letta.GenerateResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Letta.GenerateResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
///
/// Generate Completion
@@ -360,6 +543,7 @@ partial void ProcessGenerateCompletionResponseContent(
///
/// JSON schema for structured output. When provided, the LLM will be forced to return a response matching this schema via tool calling. The schema should follow JSON Schema format with 'properties' and optionally 'required' fields.
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task GenerateCompletionAsync(
@@ -368,6 +552,7 @@ partial void ProcessGenerateCompletionResponseContent(
string? systemPrompt = default,
string? overrideModel = default,
object? responseSchema = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Letta.GenerateRequest
@@ -381,6 +566,7 @@ partial void ProcessGenerateCompletionResponseContent(
return await GenerateCompletionAsync(
agentId: agentId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.ImportAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.ImportAgent.g.cs
index a254b46f..137914b3 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.ImportAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.ImportAgent.g.cs
@@ -16,6 +16,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -51,12 +52,14 @@ partial void ProcessImportAgentResponseContent(
///
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task ImportAgentAsync(
global::Letta.BodyImportAgent request,
string? xOverrideEmbeddingModel = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -74,22 +77,43 @@ partial void ProcessImportAgentResponseContent(
securityRequirements: s_ImportAgentSecurityRequirements,
operationName: "ImportAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: "/v1/agents/import",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: "/v1/agents/import",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -99,259 +123,418 @@ partial void ProcessImportAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- if (xOverrideEmbeddingModel != default)
- {
- __httpRequest.Headers.TryAddWithoutValidation("x-override-embedding-model", xOverrideEmbeddingModel.ToString());
- }
+ if (xOverrideEmbeddingModel != default)
+ {
+ __httpRequest.Headers.TryAddWithoutValidation("x-override-embedding-model", xOverrideEmbeddingModel.ToString());
+ }
- using var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
- if (xOverrideEmbeddingModel != default)
- {
+ var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent();
+ if (xOverrideEmbeddingModel != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{xOverrideEmbeddingModel}"),
+ name: "\"x-override-embedding-model\"");
+ }
+ var __contentFile = new global::System.Net.Http.ByteArrayContent(request.File ?? global::System.Array.Empty());
+ __httpRequestContent.Add(
+ content: __contentFile,
+ name: "\"file\"",
+ fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty);
+ if (__contentFile.Headers.ContentDisposition != null)
+ {
+ __contentFile.Headers.ContentDisposition.FileNameStar = null;
+ }
+ if (request.OverrideExistingTools != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.OverrideExistingTools}"),
+ name: "\"override_existing_tools\"");
+ }
+ if (request.StripMessages != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.StripMessages}"),
+ name: "\"strip_messages\"");
+ }
+ if (request.Secrets != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.Secrets}"),
+ name: "\"secrets\"");
+ }
+ if (request.Name != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.Name}"),
+ name: "\"name\"");
+ }
+ if (request.Embedding != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.Embedding}"),
+ name: "\"embedding\"");
+ }
+ if (request.Model != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.Model}"),
+ name: "\"model\"");
+ }
+ if (request.AppendCopySuffix != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.AppendCopySuffix}"),
+ name: "\"append_copy_suffix\"");
+ }
+ if (request.OverrideName != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.OverrideName}"),
+ name: "\"override_name\"");
+ }
+ if (request.OverrideEmbeddingHandle != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.OverrideEmbeddingHandle}"),
+ name: "\"override_embedding_handle\"");
+ }
+ if (request.OverrideModelHandle != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.OverrideModelHandle}"),
+ name: "\"override_model_handle\"");
+ }
+ if (request.ProjectId != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.ProjectId}"),
+ name: "\"project_id\"");
+ }
+ if (request.EnvVarsJson != default)
+ {
+
+ __httpRequestContent.Add(
+ content: new global::System.Net.Http.StringContent($"{request.EnvVarsJson}"),
+ name: "\"env_vars_json\"");
+ }
+ __httpRequest.Content = __httpRequestContent;
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
+
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareImportAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ xOverrideEmbeddingModel: xOverrideEmbeddingModel,
+ request: request);
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{xOverrideEmbeddingModel}"),
- name: "\"x-override-embedding-model\"");
+ return __httpRequest;
}
- var __contentFile = new global::System.Net.Http.ByteArrayContent(request.File ?? global::System.Array.Empty());
- __httpRequestContent.Add(
- content: __contentFile,
- name: "\"file\"",
- fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty);
- if (__contentFile.Headers.ContentDisposition != null)
- {
- __contentFile.Headers.ContentDisposition.FileNameStar = null;
- }
- if (request.OverrideExistingTools != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.OverrideExistingTools}"),
- name: "\"override_existing_tools\"");
- }
- if (request.StripMessages != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.StripMessages}"),
- name: "\"strip_messages\"");
- }
- if (request.Secrets != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.Secrets}"),
- name: "\"secrets\"");
- }
- if (request.Name != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.Name}"),
- name: "\"name\"");
- }
- if (request.Embedding != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.Embedding}"),
- name: "\"embedding\"");
- }
- if (request.Model != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.Model}"),
- name: "\"model\"");
- }
- if (request.AppendCopySuffix != default)
- {
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.AppendCopySuffix}"),
- name: "\"append_copy_suffix\"");
- }
- if (request.OverrideName != default)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.OverrideName}"),
- name: "\"override_name\"");
- }
- if (request.OverrideEmbeddingHandle != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.OverrideEmbeddingHandle}"),
- name: "\"override_embedding_handle\"");
- }
- if (request.OverrideModelHandle != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.OverrideModelHandle}"),
- name: "\"override_model_handle\"");
- }
- if (request.ProjectId != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.ProjectId}"),
- name: "\"project_id\"");
- }
- if (request.EnvVarsJson != default)
- {
-
- __httpRequestContent.Add(
- content: new global::System.Net.Http.StringContent($"{request.EnvVarsJson}"),
- name: "\"env_vars_json\"");
- }
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareImportAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- xOverrideEmbeddingModel: xOverrideEmbeddingModel,
- request: request);
-
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
-
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessImportAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
- {
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ImportAgent",
+ methodName: "ImportAgentAsync",
+ pathTemplate: "\"/v1/agents/import\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ImportAgent",
+ methodName: "ImportAgentAsync",
+ pathTemplate: "\"/v1/agents/import\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ImportAgent",
+ methodName: "ImportAgentAsync",
+ pathTemplate: "\"/v1/agents/import\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessImportAgentResponseContent(
+ response: __response);
+ ProcessImportAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::Letta.ImportedAgentsResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ImportAgent",
+ methodName: "ImportAgentAsync",
+ pathTemplate: "\"/v1/agents/import\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ImportAgent",
+ methodName: "ImportAgentAsync",
+ pathTemplate: "\"/v1/agents/import\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- return
- await global::Letta.ImportedAgentsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessImportAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Letta.ImportedAgentsResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Letta.ImportedAgentsResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
///
/// Import Agent
@@ -381,6 +564,7 @@ partial void ProcessImportAgentResponseContent(
///
/// Model handle to override the agent's default model. This allows the imported agent to use a different model while keeping other defaults (e.g., context size) from the original configuration.
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task ImportAgentAsync(
@@ -393,6 +577,7 @@ partial void ProcessImportAgentResponseContent(
string? name = default,
string? embedding = default,
string? model = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Letta.BodyImportAgent
@@ -410,6 +595,7 @@ partial void ProcessImportAgentResponseContent(
return await ImportAgentAsync(
xOverrideEmbeddingModel: xOverrideEmbeddingModel,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.ListAgents.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.ListAgents.g.cs
index 7879e8a8..37675bdd 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.ListAgents.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.ListAgents.g.cs
@@ -16,6 +16,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -151,6 +152,7 @@ partial void ProcessListAgentsResponseContent(
///
/// Filter agents by the user who created them.
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task> ListAgentsAsync(
@@ -174,6 +176,7 @@ partial void ProcessListAgentsResponseContent(
string? sortBy = default,
global::Letta.StopReasonType? lastStopReason = default,
string? createdById = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -207,44 +210,65 @@ partial void ProcessListAgentsResponseContent(
securityRequirements: s_ListAgentsSecurityRequirements,
operationName: "ListAgentsAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: "/v1/agents/",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("name", name)
- .AddOptionalParameter("tags", tags?.ToString())
- .AddOptionalParameter("match_all_tags", matchAllTags?.ToString().ToLowerInvariant())
- .AddOptionalParameter("before", before)
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("query_text", queryText)
- .AddOptionalParameter("project_id", projectId)
- .AddOptionalParameter("template_id", templateId)
- .AddOptionalParameter("base_template_id", baseTemplateId)
- .AddOptionalParameter("identity_id", identityId)
- .AddOptionalParameter("identifier_keys", identifierKeys?.ToString())
- .AddOptionalParameter("include_relationships", includeRelationships?.ToString())
- .AddOptionalParameter("include", include, selector: static x => x.ToValueString(), delimiter: ",", explode: true)
- .AddOptionalParameter("order", order?.ToValueString())
- .AddOptionalParameter("order_by", orderBy?.ToValueString())
- .AddOptionalParameter("ascending", ascending?.ToString().ToLowerInvariant())
- .AddOptionalParameter("sort_by", sortBy)
- .AddOptionalParameter("last_stop_reason", lastStopReason?.ToString())
- .AddOptionalParameter("created_by_id", createdById)
- ;
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Get,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: "/v1/agents/",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("name", name)
+ .AddOptionalParameter("tags", tags?.ToString())
+ .AddOptionalParameter("match_all_tags", matchAllTags?.ToString().ToLowerInvariant())
+ .AddOptionalParameter("before", before)
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("query_text", queryText)
+ .AddOptionalParameter("project_id", projectId)
+ .AddOptionalParameter("template_id", templateId)
+ .AddOptionalParameter("base_template_id", baseTemplateId)
+ .AddOptionalParameter("identity_id", identityId)
+ .AddOptionalParameter("identifier_keys", identifierKeys?.ToString())
+ .AddOptionalParameter("include_relationships", includeRelationships?.ToString())
+ .AddOptionalParameter("include", include, selector: static x => x.ToValueString(), delimiter: ",", explode: true)
+ .AddOptionalParameter("order", order?.ToValueString())
+ .AddOptionalParameter("order_by", orderBy?.ToValueString())
+ .AddOptionalParameter("ascending", ascending?.ToString().ToLowerInvariant())
+ .AddOptionalParameter("sort_by", sortBy)
+ .AddOptionalParameter("last_stop_reason", lastStopReason?.ToString())
+ .AddOptionalParameter("created_by_id", createdById)
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Get,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -254,169 +278,328 @@ partial void ProcessListAgentsResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListAgentsRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- name: name,
- tags: tags,
- matchAllTags: matchAllTags,
- before: before,
- after: after,
- limit: limit,
- queryText: queryText,
- projectId: projectId,
- templateId: templateId,
- baseTemplateId: baseTemplateId,
- identityId: identityId,
- identifierKeys: identifierKeys,
- includeRelationships: includeRelationships,
- include: include,
- order: order,
- orderBy: orderBy,
- ascending: ascending,
- sortBy: sortBy,
- lastStopReason: lastStopReason,
- createdById: createdById);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListAgentsRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ name: name,
+ tags: tags,
+ matchAllTags: matchAllTags,
+ before: before,
+ after: after,
+ limit: limit,
+ queryText: queryText,
+ projectId: projectId,
+ templateId: templateId,
+ baseTemplateId: baseTemplateId,
+ identityId: identityId,
+ identifierKeys: identifierKeys,
+ includeRelationships: includeRelationships,
+ include: include,
+ order: order,
+ orderBy: orderBy,
+ ascending: ascending,
+ sortBy: sortBy,
+ lastStopReason: lastStopReason,
+ createdById: createdById);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListAgentsResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListAgents",
+ methodName: "ListAgentsAsync",
+ pathTemplate: "\"/v1/agents/\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListAgents",
+ methodName: "ListAgentsAsync",
+ pathTemplate: "\"/v1/agents/\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListAgents",
+ methodName: "ListAgentsAsync",
+ pathTemplate: "\"/v1/agents/\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListAgentsResponseContent(
+ response: __response);
+ ProcessListAgentsResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListAgents",
+ methodName: "ListAgentsAsync",
+ pathTemplate: "\"/v1/agents/\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListAgents",
+ methodName: "ListAgentsAsync",
+ pathTemplate: "\"/v1/agents/\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessListAgentsResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.ListCoreMemoryBlocks.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.ListCoreMemoryBlocks.g.cs
index f9ae7a84..22f3295c 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.ListCoreMemoryBlocks.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.ListCoreMemoryBlocks.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -75,6 +76,7 @@ partial void ProcessListCoreMemoryBlocksResponseContent(
/// Field to sort by
/// Default Value: created_at
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task> ListCoreMemoryBlocksAsync(
@@ -84,6 +86,7 @@ partial void ProcessListCoreMemoryBlocksResponseContent(
int? limit = default,
global::Letta.ListCoreMemoryBlocksOrder? order = default,
string? orderBy = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -103,29 +106,50 @@ partial void ProcessListCoreMemoryBlocksResponseContent(
securityRequirements: s_ListCoreMemoryBlocksSecurityRequirements,
operationName: "ListCoreMemoryBlocksAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/core-memory/blocks",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("before", before)
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("order", order?.ToValueString())
- .AddOptionalParameter("order_by", orderBy)
- ;
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Get,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/core-memory/blocks",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("before", before)
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("order", order?.ToValueString())
+ .AddOptionalParameter("order_by", orderBy)
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Get,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -135,155 +159,314 @@ partial void ProcessListCoreMemoryBlocksResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListCoreMemoryBlocksRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId,
- before: before,
- after: after,
- limit: limit,
- order: order,
- orderBy: orderBy);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListCoreMemoryBlocksRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId,
+ before: before,
+ after: after,
+ limit: limit,
+ order: order,
+ orderBy: orderBy);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListCoreMemoryBlocksResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListCoreMemoryBlocks",
+ methodName: "ListCoreMemoryBlocksAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListCoreMemoryBlocks",
+ methodName: "ListCoreMemoryBlocksAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListCoreMemoryBlocks",
+ methodName: "ListCoreMemoryBlocksAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListCoreMemoryBlocksResponseContent(
+ response: __response);
+ ProcessListCoreMemoryBlocksResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListCoreMemoryBlocks",
+ methodName: "ListCoreMemoryBlocksAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListCoreMemoryBlocks",
+ methodName: "ListCoreMemoryBlocksAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessListCoreMemoryBlocksResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.ListFilesForAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.ListFilesForAgent.g.cs
index f5b136e7..094006cd 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.ListFilesForAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.ListFilesForAgent.g.cs
@@ -16,6 +16,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -87,6 +88,7 @@ partial void ProcessListFilesForAgentResponseContent(
///
/// Filter by open status (true for open files, false for closed files)
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task ListFilesForAgentAsync(
@@ -98,6 +100,7 @@ partial void ProcessListFilesForAgentResponseContent(
string? orderBy = default,
string? cursor = default,
bool? isOpen = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -119,31 +122,52 @@ partial void ProcessListFilesForAgentResponseContent(
securityRequirements: s_ListFilesForAgentSecurityRequirements,
operationName: "ListFilesForAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/files",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("before", before)
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("order", order?.ToValueString())
- .AddOptionalParameter("order_by", orderBy)
- .AddOptionalParameter("cursor", cursor)
- .AddOptionalParameter("is_open", isOpen?.ToString().ToLowerInvariant())
- ;
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Get,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/files",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("before", before)
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("order", order?.ToValueString())
+ .AddOptionalParameter("order_by", orderBy)
+ .AddOptionalParameter("cursor", cursor)
+ .AddOptionalParameter("is_open", isOpen?.ToString().ToLowerInvariant())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Get,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -153,157 +177,316 @@ partial void ProcessListFilesForAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListFilesForAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId,
- before: before,
- after: after,
- limit: limit,
- order: order,
- orderBy: orderBy,
- cursor: cursor,
- isOpen: isOpen);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListFilesForAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId,
+ before: before,
+ after: after,
+ limit: limit,
+ order: order,
+ orderBy: orderBy,
+ cursor: cursor,
+ isOpen: isOpen);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListFilesForAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFilesForAgent",
+ methodName: "ListFilesForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/files\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFilesForAgent",
+ methodName: "ListFilesForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/files\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFilesForAgent",
+ methodName: "ListFilesForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/files\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListFilesForAgentResponseContent(
+ response: __response);
+ ProcessListFilesForAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::Letta.PaginatedAgentFiles.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFilesForAgent",
+ methodName: "ListFilesForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/files\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFilesForAgent",
+ methodName: "ListFilesForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/files\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- await global::Letta.PaginatedAgentFiles.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessListFilesForAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Letta.PaginatedAgentFiles.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Letta.PaginatedAgentFiles.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.ListFoldersForAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.ListFoldersForAgent.g.cs
index cd921bd3..a696aa97 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.ListFoldersForAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.ListFoldersForAgent.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -75,6 +76,7 @@ partial void ProcessListFoldersForAgentResponseContent(
/// Field to sort by
/// Default Value: created_at
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task> ListFoldersForAgentAsync(
@@ -84,6 +86,7 @@ partial void ProcessListFoldersForAgentResponseContent(
int? limit = default,
global::Letta.ListFoldersForAgentOrder? order = default,
string? orderBy = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -103,29 +106,50 @@ partial void ProcessListFoldersForAgentResponseContent(
securityRequirements: s_ListFoldersForAgentSecurityRequirements,
operationName: "ListFoldersForAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/folders",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("before", before)
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("order", order?.ToValueString())
- .AddOptionalParameter("order_by", orderBy)
- ;
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Get,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/folders",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("before", before)
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("order", order?.ToValueString())
+ .AddOptionalParameter("order_by", orderBy)
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Get,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -135,155 +159,314 @@ partial void ProcessListFoldersForAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListFoldersForAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId,
- before: before,
- after: after,
- limit: limit,
- order: order,
- orderBy: orderBy);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListFoldersForAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId,
+ before: before,
+ after: after,
+ limit: limit,
+ order: order,
+ orderBy: orderBy);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListFoldersForAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFoldersForAgent",
+ methodName: "ListFoldersForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/folders\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFoldersForAgent",
+ methodName: "ListFoldersForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/folders\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFoldersForAgent",
+ methodName: "ListFoldersForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/folders\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListFoldersForAgentResponseContent(
+ response: __response);
+ ProcessListFoldersForAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFoldersForAgent",
+ methodName: "ListFoldersForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/folders\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListFoldersForAgent",
+ methodName: "ListFoldersForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/folders\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessListFoldersForAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.ListGroupsForAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.ListGroupsForAgent.g.cs
index 1ff3ad77..22edef54 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.ListGroupsForAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.ListGroupsForAgent.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -80,6 +81,7 @@ partial void ProcessListGroupsForAgentResponseContent(
/// Field to sort by
/// Default Value: created_at
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task> ListGroupsForAgentAsync(
@@ -90,6 +92,7 @@ partial void ProcessListGroupsForAgentResponseContent(
int? limit = default,
global::Letta.ListGroupsForAgentOrder? order = default,
string? orderBy = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -110,30 +113,51 @@ partial void ProcessListGroupsForAgentResponseContent(
securityRequirements: s_ListGroupsForAgentSecurityRequirements,
operationName: "ListGroupsForAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/groups",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("manager_type", managerType)
- .AddOptionalParameter("before", before)
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("order", order?.ToValueString())
- .AddOptionalParameter("order_by", orderBy)
- ;
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Get,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/groups",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("manager_type", managerType)
+ .AddOptionalParameter("before", before)
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("order", order?.ToValueString())
+ .AddOptionalParameter("order_by", orderBy)
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Get,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -143,156 +167,315 @@ partial void ProcessListGroupsForAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListGroupsForAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId,
- managerType: managerType,
- before: before,
- after: after,
- limit: limit,
- order: order,
- orderBy: orderBy);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListGroupsForAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId,
+ managerType: managerType,
+ before: before,
+ after: after,
+ limit: limit,
+ order: order,
+ orderBy: orderBy);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListGroupsForAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListGroupsForAgent",
+ methodName: "ListGroupsForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/groups\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListGroupsForAgent",
+ methodName: "ListGroupsForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/groups\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListGroupsForAgent",
+ methodName: "ListGroupsForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/groups\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListGroupsForAgentResponseContent(
+ response: __response);
+ ProcessListGroupsForAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListGroupsForAgent",
+ methodName: "ListGroupsForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/groups\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListGroupsForAgent",
+ methodName: "ListGroupsForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/groups\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessListGroupsForAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.ListMessages.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.ListMessages.g.cs
index 96a6c7e2..fbda8144 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.ListMessages.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.ListMessages.g.cs
@@ -16,6 +16,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -115,6 +116,7 @@ partial void ProcessListMessagesResponseContent(
///
/// Message types to include in response. When null, all message types are returned.
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task> ListMessagesAsync(
@@ -131,6 +133,7 @@ partial void ProcessListMessagesResponseContent(
string? assistantMessageToolKwarg = default,
bool? includeErr = default,
global::System.Collections.Generic.IList? includeReturnMessageTypes = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -157,36 +160,57 @@ partial void ProcessListMessagesResponseContent(
securityRequirements: s_ListMessagesSecurityRequirements,
operationName: "ListMessagesAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/messages",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("before", before)
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("order", order?.ToValueString())
- .AddOptionalParameter("order_by", orderBy)
- .AddOptionalParameter("group_id", groupId)
- .AddOptionalParameter("conversation_id", conversationId)
- .AddOptionalParameter("use_assistant_message", useAssistantMessage?.ToString().ToLowerInvariant())
- .AddOptionalParameter("assistant_message_tool_name", assistantMessageToolName)
- .AddOptionalParameter("assistant_message_tool_kwarg", assistantMessageToolKwarg)
- .AddOptionalParameter("include_err", includeErr?.ToString().ToLowerInvariant())
- .AddOptionalParameter("include_return_message_types", includeReturnMessageTypes?.ToString())
- ;
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Get,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/messages",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("before", before)
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("order", order?.ToValueString())
+ .AddOptionalParameter("order_by", orderBy)
+ .AddOptionalParameter("group_id", groupId)
+ .AddOptionalParameter("conversation_id", conversationId)
+ .AddOptionalParameter("use_assistant_message", useAssistantMessage?.ToString().ToLowerInvariant())
+ .AddOptionalParameter("assistant_message_tool_name", assistantMessageToolName)
+ .AddOptionalParameter("assistant_message_tool_kwarg", assistantMessageToolKwarg)
+ .AddOptionalParameter("include_err", includeErr?.ToString().ToLowerInvariant())
+ .AddOptionalParameter("include_return_message_types", includeReturnMessageTypes?.ToString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Get,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -196,162 +220,321 @@ partial void ProcessListMessagesResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListMessagesRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId,
- before: before,
- after: after,
- limit: limit,
- order: order,
- orderBy: orderBy,
- groupId: groupId,
- conversationId: conversationId,
- useAssistantMessage: useAssistantMessage,
- assistantMessageToolName: assistantMessageToolName,
- assistantMessageToolKwarg: assistantMessageToolKwarg,
- includeErr: includeErr,
- includeReturnMessageTypes: includeReturnMessageTypes);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListMessagesRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId,
+ before: before,
+ after: after,
+ limit: limit,
+ order: order,
+ orderBy: orderBy,
+ groupId: groupId,
+ conversationId: conversationId,
+ useAssistantMessage: useAssistantMessage,
+ assistantMessageToolName: assistantMessageToolName,
+ assistantMessageToolKwarg: assistantMessageToolKwarg,
+ includeErr: includeErr,
+ includeReturnMessageTypes: includeReturnMessageTypes);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListMessagesResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListMessages",
+ methodName: "ListMessagesAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/messages\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListMessages",
+ methodName: "ListMessagesAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/messages\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListMessages",
+ methodName: "ListMessagesAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/messages\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListMessagesResponseContent(
+ response: __response);
+ ProcessListMessagesResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListMessages",
+ methodName: "ListMessagesAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/messages\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListMessages",
+ methodName: "ListMessagesAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/messages\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessListMessagesResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.ListPassages.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.ListPassages.g.cs
index 1b7ec579..5f43951a 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.ListPassages.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.ListPassages.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -74,6 +75,7 @@ partial void ProcessListPassagesResponseContent(
/// Whether to sort passages oldest to newest (True, default) or newest to oldest (False)
/// Default Value: true
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task> ListPassagesAsync(
@@ -83,6 +85,7 @@ partial void ProcessListPassagesResponseContent(
int? limit = default,
string? search = default,
bool? ascending = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -102,29 +105,50 @@ partial void ProcessListPassagesResponseContent(
securityRequirements: s_ListPassagesSecurityRequirements,
operationName: "ListPassagesAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/archival-memory",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("before", before)
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("search", search)
- .AddOptionalParameter("ascending", ascending?.ToString().ToLowerInvariant())
- ;
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Get,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/archival-memory",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("before", before)
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("search", search)
+ .AddOptionalParameter("ascending", ascending?.ToString().ToLowerInvariant())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Get,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -134,155 +158,314 @@ partial void ProcessListPassagesResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListPassagesRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId,
- after: after,
- before: before,
- limit: limit,
- search: search,
- ascending: ascending);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListPassagesRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId,
+ after: after,
+ before: before,
+ limit: limit,
+ search: search,
+ ascending: ascending);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListPassagesResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListPassages",
+ methodName: "ListPassagesAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archival-memory\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListPassages",
+ methodName: "ListPassagesAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archival-memory\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListPassages",
+ methodName: "ListPassagesAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archival-memory\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListPassagesResponseContent(
+ response: __response);
+ ProcessListPassagesResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListPassages",
+ methodName: "ListPassagesAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archival-memory\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListPassages",
+ methodName: "ListPassagesAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archival-memory\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessListPassagesResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.ListToolsForAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.ListToolsForAgent.g.cs
index 19709918..969dce46 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.ListToolsForAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.ListToolsForAgent.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -75,6 +76,7 @@ partial void ProcessListToolsForAgentResponseContent(
/// Field to sort by
/// Default Value: created_at
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task> ListToolsForAgentAsync(
@@ -84,6 +86,7 @@ partial void ProcessListToolsForAgentResponseContent(
int? limit = default,
global::Letta.ListToolsForAgentOrder? order = default,
string? orderBy = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -103,29 +106,50 @@ partial void ProcessListToolsForAgentResponseContent(
securityRequirements: s_ListToolsForAgentSecurityRequirements,
operationName: "ListToolsForAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/tools",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("before", before)
- .AddOptionalParameter("after", after)
- .AddOptionalParameter("limit", limit?.ToString())
- .AddOptionalParameter("order", order?.ToValueString())
- .AddOptionalParameter("order_by", orderBy)
- ;
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Get,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/tools",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("before", before)
+ .AddOptionalParameter("after", after)
+ .AddOptionalParameter("limit", limit?.ToString())
+ .AddOptionalParameter("order", order?.ToValueString())
+ .AddOptionalParameter("order_by", orderBy)
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Get,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -135,155 +159,314 @@ partial void ProcessListToolsForAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareListToolsForAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId,
- before: before,
- after: after,
- limit: limit,
- order: order,
- orderBy: orderBy);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareListToolsForAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId,
+ before: before,
+ after: after,
+ limit: limit,
+ order: order,
+ orderBy: orderBy);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessListToolsForAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListToolsForAgent",
+ methodName: "ListToolsForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListToolsForAgent",
+ methodName: "ListToolsForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListToolsForAgent",
+ methodName: "ListToolsForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessListToolsForAgentResponseContent(
+ response: __response);
+ ProcessListToolsForAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListToolsForAgent",
+ methodName: "ListToolsForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ListToolsForAgent",
+ methodName: "ListToolsForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessListToolsForAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.ModifyAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.ModifyAgent.g.cs
index 7705aca2..d68b87e4 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.ModifyAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.ModifyAgent.g.cs
@@ -16,6 +16,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -52,12 +53,14 @@ partial void ProcessModifyAgentResponseContent(
/// The ID of the agent in the format 'agent-<uuid4>'
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task ModifyAgentAsync(
string agentId,
global::Letta.UpdateAgent request,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -75,22 +78,43 @@ partial void ProcessModifyAgentResponseContent(
securityRequirements: s_ModifyAgentSecurityRequirements,
operationName: "ModifyAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: new global::System.Net.Http.HttpMethod("PATCH"),
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: new global::System.Net.Http.HttpMethod("PATCH"),
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -100,157 +124,316 @@ partial void ProcessModifyAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareModifyAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId,
- request: request);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareModifyAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessModifyAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyAgent",
+ methodName: "ModifyAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyAgent",
+ methodName: "ModifyAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyAgent",
+ methodName: "ModifyAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessModifyAgentResponseContent(
+ response: __response);
+ ProcessModifyAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::Letta.AgentState.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyAgent",
+ methodName: "ModifyAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyAgent",
+ methodName: "ModifyAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- await global::Letta.AgentState.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessModifyAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Letta.AgentState.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Letta.AgentState.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
///
/// Modify Agent
@@ -352,6 +535,7 @@ partial void ProcessModifyAgentResponseContent(
///
/// If set to True, the agent will be hidden.
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task ModifyAgentAsync(
@@ -387,6 +571,7 @@ partial void ProcessModifyAgentResponseContent(
int? maxFilesOpen = default,
int? perFileViewWindowCharLimit = default,
bool? hidden = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Letta.UpdateAgent
@@ -427,6 +612,7 @@ partial void ProcessModifyAgentResponseContent(
return await ModifyAgentAsync(
agentId: agentId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.ModifyApprovalForTool.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.ModifyApprovalForTool.g.cs
index df33e7dd..f112faf5 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.ModifyApprovalForTool.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.ModifyApprovalForTool.g.cs
@@ -16,6 +16,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -61,6 +62,7 @@ partial void ProcessModifyApprovalForToolResponseContent(
/// Whether the tool requires approval before execution
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task ModifyApprovalForToolAsync(
@@ -69,6 +71,7 @@ partial void ProcessModifyApprovalForToolResponseContent(
global::Letta.ModifyApprovalRequest request,
bool? requiresApproval = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -88,25 +91,46 @@ partial void ProcessModifyApprovalForToolResponseContent(
securityRequirements: s_ModifyApprovalForToolSecurityRequirements,
operationName: "ModifyApprovalForToolAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/tools/approval/{toolName}",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("requires_approval", requiresApproval?.ToString().ToLowerInvariant())
- ;
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: new global::System.Net.Http.HttpMethod("PATCH"),
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/tools/approval/{toolName}",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("requires_approval", requiresApproval?.ToString().ToLowerInvariant())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: new global::System.Net.Http.HttpMethod("PATCH"),
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -116,159 +140,318 @@ partial void ProcessModifyApprovalForToolResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareModifyApprovalForToolRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- toolName: toolName,
- agentId: agentId,
- requiresApproval: requiresApproval,
- request: request);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareModifyApprovalForToolRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ toolName: toolName,
+ agentId: agentId,
+ requiresApproval: requiresApproval,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessModifyApprovalForToolResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyApprovalForTool",
+ methodName: "ModifyApprovalForToolAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools/approval/{toolName}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyApprovalForTool",
+ methodName: "ModifyApprovalForToolAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools/approval/{toolName}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyApprovalForTool",
+ methodName: "ModifyApprovalForToolAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools/approval/{toolName}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
-
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessModifyApprovalForToolResponseContent(
+ response: __response);
+ ProcessModifyApprovalForToolResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::Letta.AgentState.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyApprovalForTool",
+ methodName: "ModifyApprovalForToolAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools/approval/{toolName}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyApprovalForTool",
+ methodName: "ModifyApprovalForToolAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools/approval/{toolName}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- await global::Letta.AgentState.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessModifyApprovalForToolResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Letta.AgentState.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Letta.AgentState.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
///
/// Modify Approval For Tool
@@ -282,12 +465,14 @@ partial void ProcessModifyApprovalForToolResponseContent(
///
/// Whether the tool requires approval before execution
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task ModifyApprovalForToolAsync(
string toolName,
string agentId,
bool? requiresApproval = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Letta.ModifyApprovalRequest
@@ -299,6 +484,7 @@ partial void ProcessModifyApprovalForToolResponseContent(
agentId: agentId,
requiresApproval: requiresApproval,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.ModifyCoreMemoryBlock.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.ModifyCoreMemoryBlock.g.cs
index 1b4a405d..92156a4b 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.ModifyCoreMemoryBlock.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.ModifyCoreMemoryBlock.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -53,6 +54,7 @@ partial void ProcessModifyCoreMemoryBlockResponseContent(
/// The ID of the agent in the format 'agent-<uuid4>'
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task ModifyCoreMemoryBlockAsync(
@@ -60,6 +62,7 @@ partial void ProcessModifyCoreMemoryBlockResponseContent(
string agentId,
global::Letta.BlockUpdate request,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -78,22 +81,43 @@ partial void ProcessModifyCoreMemoryBlockResponseContent(
securityRequirements: s_ModifyCoreMemoryBlockSecurityRequirements,
operationName: "ModifyCoreMemoryBlockAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/core-memory/blocks/{blockLabel}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: new global::System.Net.Http.HttpMethod("PATCH"),
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/core-memory/blocks/{blockLabel}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: new global::System.Net.Http.HttpMethod("PATCH"),
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -103,158 +127,317 @@ partial void ProcessModifyCoreMemoryBlockResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareModifyCoreMemoryBlockRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- blockLabel: blockLabel,
- agentId: agentId,
- request: request);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareModifyCoreMemoryBlockRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ blockLabel: blockLabel,
+ agentId: agentId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessModifyCoreMemoryBlockResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyCoreMemoryBlock",
+ methodName: "ModifyCoreMemoryBlockAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks/{blockLabel}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyCoreMemoryBlock",
+ methodName: "ModifyCoreMemoryBlockAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks/{blockLabel}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyCoreMemoryBlock",
+ methodName: "ModifyCoreMemoryBlockAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks/{blockLabel}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessModifyCoreMemoryBlockResponseContent(
+ response: __response);
+ ProcessModifyCoreMemoryBlockResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::Letta.BlockResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyCoreMemoryBlock",
+ methodName: "ModifyCoreMemoryBlockAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks/{blockLabel}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ModifyCoreMemoryBlock",
+ methodName: "ModifyCoreMemoryBlockAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks/{blockLabel}\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- await global::Letta.BlockResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessModifyCoreMemoryBlockResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Letta.BlockResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Letta.BlockResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
///
/// Modify Block For Agent
@@ -316,6 +499,7 @@ partial void ProcessModifyCoreMemoryBlockResponseContent(
///
/// The tags to associate with the block.
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task ModifyCoreMemoryBlockAsync(
@@ -337,6 +521,7 @@ partial void ProcessModifyCoreMemoryBlockResponseContent(
object? metadata = default,
bool? hidden = default,
global::System.Collections.Generic.IList? tags = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Letta.BlockUpdate
@@ -363,6 +548,7 @@ partial void ProcessModifyCoreMemoryBlockResponseContent(
blockLabel: blockLabel,
agentId: agentId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.OpenFileForAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.OpenFileForAgent.g.cs
index 7a5bf8dc..c676072d 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.OpenFileForAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.OpenFileForAgent.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -55,11 +56,13 @@ partial void ProcessOpenFileForAgentResponseContent(
///
/// The ID of the agent in the format 'agent-<uuid4>'
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task> OpenFileForAgentAsync(
string fileId,
string agentId,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -75,22 +78,43 @@ partial void ProcessOpenFileForAgentResponseContent(
securityRequirements: s_OpenFileForAgentSecurityRequirements,
operationName: "OpenFileForAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/files/{fileId}/open",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: new global::System.Net.Http.HttpMethod("PATCH"),
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/files/{fileId}/open",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: new global::System.Net.Http.HttpMethod("PATCH"),
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -100,151 +124,310 @@ partial void ProcessOpenFileForAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareOpenFileForAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- fileId: fileId,
- agentId: agentId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareOpenFileForAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ fileId: fileId,
+ agentId: agentId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessOpenFileForAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OpenFileForAgent",
+ methodName: "OpenFileForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/files/{fileId}/open\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OpenFileForAgent",
+ methodName: "OpenFileForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/files/{fileId}/open\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OpenFileForAgent",
+ methodName: "OpenFileForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/files/{fileId}/open\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessOpenFileForAgentResponseContent(
+ response: __response);
+ ProcessOpenFileForAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OpenFileForAgent",
+ methodName: "OpenFileForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/files/{fileId}/open\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "OpenFileForAgent",
+ methodName: "OpenFileForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/files/{fileId}/open\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessOpenFileForAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.PreviewModelRequest.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.PreviewModelRequest.g.cs
index 96717130..57d483d5 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.PreviewModelRequest.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.PreviewModelRequest.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -53,12 +54,14 @@ partial void ProcessPreviewModelRequestResponseContent(
/// The ID of the agent in the format 'agent-<uuid4>'
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task PreviewModelRequestAsync(
string agentId,
global::Letta.AnyOf request,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -74,22 +77,43 @@ partial void ProcessPreviewModelRequestResponseContent(
securityRequirements: s_PreviewModelRequestSecurityRequirements,
operationName: "PreviewModelRequestAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/messages/preview-raw-payload",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/messages/preview-raw-payload",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -99,153 +123,312 @@ partial void ProcessPreviewModelRequestResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PreparePreviewModelRequestRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId,
- request: request);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PreparePreviewModelRequestRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId,
+ request: request);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessPreviewModelRequestResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PreviewModelRequest",
+ methodName: "PreviewModelRequestAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/messages/preview-raw-payload\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PreviewModelRequest",
+ methodName: "PreviewModelRequestAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/messages/preview-raw-payload\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PreviewModelRequest",
+ methodName: "PreviewModelRequestAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/messages/preview-raw-payload\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessPreviewModelRequestResponseContent(
+ response: __response);
+ ProcessPreviewModelRequestResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return __content;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PreviewModelRequest",
+ methodName: "PreviewModelRequestAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/messages/preview-raw-payload\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "PreviewModelRequest",
+ methodName: "PreviewModelRequestAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/messages/preview-raw-payload\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return __content;
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessPreviewModelRequestResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
///
/// Preview Model Request
@@ -257,10 +440,12 @@ partial void ProcessPreviewModelRequestResponseContent(
///
/// The ID of the agent in the format 'agent-<uuid4>'
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task PreviewModelRequestAsync(
string agentId,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Letta.AnyOf
@@ -270,6 +455,7 @@ partial void ProcessPreviewModelRequestResponseContent(
return await PreviewModelRequestAsync(
agentId: agentId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.RecompileAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.RecompileAgent.g.cs
index aa78e49f..b0d30b1d 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.RecompileAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.RecompileAgent.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -59,12 +60,14 @@ partial void ProcessRecompileAgentResponseContent(
/// If True, do not persist changes; still returns the compiled system prompt.
/// Default Value: false
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task RecompileAgentAsync(
string agentId,
bool? updateTimestamp = default,
bool? dryRun = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -81,26 +84,47 @@ partial void ProcessRecompileAgentResponseContent(
securityRequirements: s_RecompileAgentSecurityRequirements,
operationName: "RecompileAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/recompile",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("update_timestamp", updateTimestamp?.ToString().ToLowerInvariant())
- .AddOptionalParameter("dry_run", dryRun?.ToString().ToLowerInvariant())
- ;
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/recompile",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("update_timestamp", updateTimestamp?.ToString().ToLowerInvariant())
+ .AddOptionalParameter("dry_run", dryRun?.ToString().ToLowerInvariant())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -110,148 +134,307 @@ partial void ProcessRecompileAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareRecompileAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId,
- updateTimestamp: updateTimestamp,
- dryRun: dryRun);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareRecompileAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId,
+ updateTimestamp: updateTimestamp,
+ dryRun: dryRun);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessRecompileAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RecompileAgent",
+ methodName: "RecompileAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/recompile\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RecompileAgent",
+ methodName: "RecompileAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/recompile\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RecompileAgent",
+ methodName: "RecompileAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/recompile\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessRecompileAgentResponseContent(
+ response: __response);
+ ProcessRecompileAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return __content;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RecompileAgent",
+ methodName: "RecompileAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/recompile\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RecompileAgent",
+ methodName: "RecompileAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/recompile\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return __content;
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessRecompileAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return __content;
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.ResetMessages.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.ResetMessages.g.cs
index dcfc2e74..82eeabc1 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.ResetMessages.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.ResetMessages.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -50,12 +51,14 @@ partial void ProcessResetMessagesResponseContent(
/// The ID of the agent in the format 'agent-<uuid4>'
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task ResetMessagesAsync(
string agentId,
global::Letta.ResetMessagesRequest request,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -73,22 +76,43 @@ partial void ProcessResetMessagesResponseContent(
securityRequirements: s_ResetMessagesSecurityRequirements,
operationName: "ResetMessagesAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/reset-messages",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: new global::System.Net.Http.HttpMethod("PATCH"),
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/reset-messages",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: new global::System.Net.Http.HttpMethod("PATCH"),
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -98,157 +122,316 @@ partial void ProcessResetMessagesResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareResetMessagesRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId,
- request: request);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareResetMessagesRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessResetMessagesResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ResetMessages",
+ methodName: "ResetMessagesAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/reset-messages\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ResetMessages",
+ methodName: "ResetMessagesAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/reset-messages\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ResetMessages",
+ methodName: "ResetMessagesAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/reset-messages\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessResetMessagesResponseContent(
+ response: __response);
+ ProcessResetMessagesResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::Letta.AgentState.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ResetMessages",
+ methodName: "ResetMessagesAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/reset-messages\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "ResetMessages",
+ methodName: "ResetMessagesAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/reset-messages\"",
+ httpMethod: "PATCH",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- await global::Letta.AgentState.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessResetMessagesResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Letta.AgentState.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Letta.AgentState.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
///
/// Reset Messages
@@ -261,11 +444,13 @@ partial void ProcessResetMessagesResponseContent(
/// If true, adds the default initial messages after resetting.
/// Default Value: false
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task ResetMessagesAsync(
string agentId,
bool? addDefaultInitialMessages = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Letta.ResetMessagesRequest
@@ -276,6 +461,7 @@ partial void ProcessResetMessagesResponseContent(
return await ResetMessagesAsync(
agentId: agentId,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.RetrieveAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.RetrieveAgent.g.cs
index 78b40f17..0bfbca53 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.RetrieveAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.RetrieveAgent.g.cs
@@ -16,6 +16,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -60,12 +61,14 @@ partial void ProcessRetrieveAgentResponseContent(
/// Specify which relational fields to include in the response. No relationships are included by default.
/// Default Value: []
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task RetrieveAgentAsync(
string agentId,
global::System.Collections.Generic.IList? includeRelationships = default,
global::System.Collections.Generic.IList? include = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -82,26 +85,47 @@ partial void ProcessRetrieveAgentResponseContent(
securityRequirements: s_RetrieveAgentSecurityRequirements,
operationName: "RetrieveAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddOptionalParameter("include_relationships", includeRelationships?.ToString())
- .AddOptionalParameter("include", include, selector: static x => x.ToValueString(), delimiter: ",", explode: true)
- ;
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Get,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddOptionalParameter("include_relationships", includeRelationships?.ToString())
+ .AddOptionalParameter("include", include, selector: static x => x.ToValueString(), delimiter: ",", explode: true)
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Get,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -111,152 +135,311 @@ partial void ProcessRetrieveAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareRetrieveAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId,
- includeRelationships: includeRelationships,
- include: include);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareRetrieveAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId,
+ includeRelationships: includeRelationships,
+ include: include);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessRetrieveAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveAgent",
+ methodName: "RetrieveAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveAgent",
+ methodName: "RetrieveAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveAgent",
+ methodName: "RetrieveAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessRetrieveAgentResponseContent(
+ response: __response);
+ ProcessRetrieveAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::Letta.AgentState.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveAgent",
+ methodName: "RetrieveAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveAgent",
+ methodName: "RetrieveAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- await global::Letta.AgentState.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessRetrieveAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Letta.AgentState.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Letta.AgentState.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.RetrieveCoreMemoryBlock.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.RetrieveCoreMemoryBlock.g.cs
index 9eff8454..55adc308 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.RetrieveCoreMemoryBlock.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.RetrieveCoreMemoryBlock.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -50,11 +51,13 @@ partial void ProcessRetrieveCoreMemoryBlockResponseContent(
///
/// The ID of the agent in the format 'agent-<uuid4>'
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task RetrieveCoreMemoryBlockAsync(
string blockLabel,
string agentId,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -70,22 +73,43 @@ partial void ProcessRetrieveCoreMemoryBlockResponseContent(
securityRequirements: s_RetrieveCoreMemoryBlockSecurityRequirements,
operationName: "RetrieveCoreMemoryBlockAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/core-memory/blocks/{blockLabel}",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Get,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/core-memory/blocks/{blockLabel}",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Get,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -95,151 +119,310 @@ partial void ProcessRetrieveCoreMemoryBlockResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareRetrieveCoreMemoryBlockRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- blockLabel: blockLabel,
- agentId: agentId);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareRetrieveCoreMemoryBlockRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ blockLabel: blockLabel,
+ agentId: agentId);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessRetrieveCoreMemoryBlockResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveCoreMemoryBlock",
+ methodName: "RetrieveCoreMemoryBlockAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks/{blockLabel}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveCoreMemoryBlock",
+ methodName: "RetrieveCoreMemoryBlockAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks/{blockLabel}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
+
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveCoreMemoryBlock",
+ methodName: "RetrieveCoreMemoryBlockAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks/{blockLabel}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessRetrieveCoreMemoryBlockResponseContent(
+ response: __response);
+ ProcessRetrieveCoreMemoryBlockResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::Letta.BlockResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveCoreMemoryBlock",
+ methodName: "RetrieveCoreMemoryBlockAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks/{blockLabel}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RetrieveCoreMemoryBlock",
+ methodName: "RetrieveCoreMemoryBlockAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/core-memory/blocks/{blockLabel}\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- await global::Letta.BlockResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessRetrieveCoreMemoryBlockResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Letta.BlockResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Letta.BlockResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.RunToolForAgent.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.RunToolForAgent.g.cs
index aa37d672..85513116 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.RunToolForAgent.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.RunToolForAgent.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -55,6 +56,7 @@ partial void ProcessRunToolForAgentResponseContent(
///
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task RunToolForAgentAsync(
@@ -62,6 +64,7 @@ partial void ProcessRunToolForAgentResponseContent(
string toolName,
global::Letta.LettaSchemasMcpServerToolExecuteRequest request,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -80,22 +83,43 @@ partial void ProcessRunToolForAgentResponseContent(
securityRequirements: s_RunToolForAgentSecurityRequirements,
operationName: "RunToolForAgentAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/tools/{toolName}/run",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/tools/{toolName}/run",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -105,158 +129,317 @@ partial void ProcessRunToolForAgentResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareRunToolForAgentRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId,
- toolName: toolName,
- request: request);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareRunToolForAgentRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId,
+ toolName: toolName,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessRunToolForAgentResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RunToolForAgent",
+ methodName: "RunToolForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools/{toolName}/run\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RunToolForAgent",
+ methodName: "RunToolForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools/{toolName}/run\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RunToolForAgent",
+ methodName: "RunToolForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools/{toolName}/run\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessRunToolForAgentResponseContent(
+ response: __response);
+ ProcessRunToolForAgentResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::Letta.ToolExecutionResult.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RunToolForAgent",
+ methodName: "RunToolForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools/{toolName}/run\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "RunToolForAgent",
+ methodName: "RunToolForAgentAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/tools/{toolName}/run\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- await global::Letta.ToolExecutionResult.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessRunToolForAgentResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Letta.ToolExecutionResult.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Letta.ToolExecutionResult.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
///
/// Run Tool For Agent
@@ -271,12 +454,14 @@ partial void ProcessRunToolForAgentResponseContent(
///
/// Arguments to pass to the tool
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task RunToolForAgentAsync(
string agentId,
string toolName,
object? args = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Letta.LettaSchemasMcpServerToolExecuteRequest
@@ -288,6 +473,7 @@ partial void ProcessRunToolForAgentResponseContent(
agentId: agentId,
toolName: toolName,
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.SearchArchivalMemory.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.SearchArchivalMemory.g.cs
index 1dbe686a..b9aa731f 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.SearchArchivalMemory.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.SearchArchivalMemory.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -81,6 +82,7 @@ partial void ProcessSearchArchivalMemoryResponseContent(
///
/// Filter results to passages created before this datetime
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task SearchArchivalMemoryAsync(
@@ -91,6 +93,7 @@ partial void ProcessSearchArchivalMemoryResponseContent(
int? topK = default,
global::System.DateTime? startDatetime = default,
global::System.DateTime? endDatetime = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
@@ -111,30 +114,51 @@ partial void ProcessSearchArchivalMemoryResponseContent(
securityRequirements: s_SearchArchivalMemorySecurityRequirements,
operationName: "SearchArchivalMemoryAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: $"/v1/agents/{agentId}/archival-memory/search",
- baseUri: HttpClient.BaseAddress);
- __pathBuilder
- .AddRequiredParameter("query", query)
- .AddOptionalParameter("tags", tags?.ToString())
- .AddOptionalParameter("tag_match_mode", tagMatchMode?.ToValueString())
- .AddOptionalParameter("top_k", topK?.ToString())
- .AddOptionalParameter("start_datetime", startDatetime?.ToString())
- .AddOptionalParameter("end_datetime", endDatetime?.ToString())
- ;
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Get,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: $"/v1/agents/{agentId}/archival-memory/search",
+ baseUri: HttpClient.BaseAddress);
+ __pathBuilder
+ .AddRequiredParameter("query", query)
+ .AddOptionalParameter("tags", tags?.ToString())
+ .AddOptionalParameter("tag_match_mode", tagMatchMode?.ToValueString())
+ .AddOptionalParameter("top_k", topK?.ToString())
+ .AddOptionalParameter("start_datetime", startDatetime?.ToString())
+ .AddOptionalParameter("end_datetime", endDatetime?.ToString())
+ ;
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Get,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -144,156 +168,315 @@ partial void ProcessSearchArchivalMemoryResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareSearchArchivalMemoryRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- agentId: agentId,
- query: query,
- tags: tags,
- tagMatchMode: tagMatchMode,
- topK: topK,
- startDatetime: startDatetime,
- endDatetime: endDatetime);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareSearchArchivalMemoryRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ agentId: agentId,
+ query: query,
+ tags: tags,
+ tagMatchMode: tagMatchMode,
+ topK: topK,
+ startDatetime: startDatetime,
+ endDatetime: endDatetime);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ return __httpRequest;
+ }
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessSearchArchivalMemoryResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "SearchArchivalMemory",
+ methodName: "SearchArchivalMemoryAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archival-memory/search\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "SearchArchivalMemory",
+ methodName: "SearchArchivalMemoryAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archival-memory/search\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "SearchArchivalMemory",
+ methodName: "SearchArchivalMemoryAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archival-memory/search\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessSearchArchivalMemoryResponseContent(
+ response: __response);
+ ProcessSearchArchivalMemoryResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- global::Letta.ArchivalMemorySearchResponse.FromJson(__content, JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "SearchArchivalMemory",
+ methodName: "SearchArchivalMemoryAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archival-memory/search\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "SearchArchivalMemory",
+ methodName: "SearchArchivalMemoryAsync",
+ pathTemplate: "$\"/v1/agents/{agentId}/archival-memory/search\"",
+ httpMethod: "GET",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- await global::Letta.ArchivalMemorySearchResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessSearchArchivalMemoryResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ global::Letta.ArchivalMemorySearchResponse.FromJson(__content, JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ await global::Letta.ArchivalMemorySearchResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
}
}
\ No newline at end of file
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.SearchMessages.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.SearchMessages.g.cs
index bd3d2af4..83b34adc 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.SearchMessages.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.SearchMessages.g.cs
@@ -14,6 +14,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -46,11 +47,13 @@ partial void ProcessSearchMessagesResponseContent(
/// This is a cloud-only feature.
///
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task> SearchMessagesAsync(
global::Letta.MessageSearchRequest request,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
@@ -67,22 +70,43 @@ partial void ProcessSearchMessagesResponseContent(
securityRequirements: s_SearchMessagesSecurityRequirements,
operationName: "SearchMessagesAsync");
- var __pathBuilder = new global::Letta.PathBuilder(
- path: "/v1/agents/messages/search",
- baseUri: HttpClient.BaseAddress);
- var __path = __pathBuilder.ToString();
- using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
- method: global::System.Net.Http.HttpMethod.Post,
- requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
+ using var __timeoutCancellationTokenSource = global::Letta.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: cancellationToken);
+ var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken;
+ var __effectiveReadResponseAsString = global::Letta.AutoSDKRequestOptionsSupport.GetReadResponseAsString(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ fallbackValue: ReadResponseAsString);
+ var __maxAttempts = global::Letta.AutoSDKRequestOptionsSupport.GetMaxAttempts(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ supportsRetry: true);
+
+ global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
+ {
+ var __pathBuilder = new global::Letta.PathBuilder(
+ path: "/v1/agents/messages/search",
+ baseUri: HttpClient.BaseAddress);
+ var __path = __pathBuilder.ToString();
+ __path = global::Letta.AutoSDKRequestOptionsSupport.AppendQueryParameters(
+ path: __path,
+ clientParameters: Options.QueryParameters,
+ requestParameters: requestOptions?.QueryParameters);
+ var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
+ method: global::System.Net.Http.HttpMethod.Post,
+ requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
- __httpRequest.Version = global::System.Net.HttpVersion.Version11;
- __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
+ __httpRequest.Version = global::System.Net.HttpVersion.Version11;
+ __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif
foreach (var __authorization in __authorizations)
{
if (__authorization.Type == "Http" ||
- __authorization.Type == "OAuth2")
+ __authorization.Type == "OAuth2" ||
+ __authorization.Type == "OpenIdConnect")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
@@ -92,156 +116,315 @@ partial void ProcessSearchMessagesResponseContent(
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
- }
+ }
}
- var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
- var __httpRequestContent = new global::System.Net.Http.StringContent(
- content: __httpRequestContentBody,
- encoding: global::System.Text.Encoding.UTF8,
- mediaType: "application/json");
- __httpRequest.Content = __httpRequestContent;
-
- PrepareRequest(
- client: HttpClient,
- request: __httpRequest);
- PrepareSearchMessagesRequest(
- httpClient: HttpClient,
- httpRequestMessage: __httpRequest,
- request: request);
+ var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
+ var __httpRequestContent = new global::System.Net.Http.StringContent(
+ content: __httpRequestContentBody,
+ encoding: global::System.Text.Encoding.UTF8,
+ mediaType: "application/json");
+ __httpRequest.Content = __httpRequestContent;
+ global::Letta.AutoSDKRequestOptionsSupport.ApplyHeaders(
+ request: __httpRequest,
+ clientHeaders: Options.Headers,
+ requestHeaders: requestOptions?.Headers);
- using var __response = await HttpClient.SendAsync(
- request: __httpRequest,
- completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
- cancellationToken: cancellationToken).ConfigureAwait(false);
+ PrepareRequest(
+ client: HttpClient,
+ request: __httpRequest);
+ PrepareSearchMessagesRequest(
+ httpClient: HttpClient,
+ httpRequestMessage: __httpRequest,
+ request: request);
- ProcessResponse(
- client: HttpClient,
- response: __response);
- ProcessSearchMessagesResponse(
- httpClient: HttpClient,
- httpResponseMessage: __response);
- // Validation Error
- if ((int)__response.StatusCode == 422)
+ return __httpRequest;
+ }
+
+ global::System.Net.Http.HttpRequestMessage? __httpRequest = null;
+ global::System.Net.Http.HttpResponseMessage? __response = null;
+ var __attemptNumber = 0;
+ try
{
- string? __content_422 = null;
- global::System.Exception? __exception_422 = null;
- global::Letta.HTTPValidationError? __value_422 = null;
- try
+ for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++)
{
- if (ReadResponseAsString)
+ __attemptNumber = __attempt;
+ __httpRequest = __CreateHttpRequest();
+ await global::Letta.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "SearchMessages",
+ methodName: "SearchMessagesAsync",
+ pathTemplate: "\"/v1/agents/messages/search\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ try
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __response = await HttpClient.SendAsync(
+ request: __httpRequest,
+ completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
}
- else
+ catch (global::System.Net.Http.HttpRequestException __exception)
{
- __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
+ var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "SearchMessages",
+ methodName: "SearchMessagesAsync",
+ pathTemplate: "\"/v1/agents/messages/search\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: null,
+ exception: __exception,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: __willRetry,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ if (!__willRetry)
+ {
+ throw;
+ }
- __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
+ }
+
+ if (__response != null &&
+ __attempt < __maxAttempts &&
+ global::Letta.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
+ {
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "SearchMessages",
+ methodName: "SearchMessagesAsync",
+ pathTemplate: "\"/v1/agents/messages/search\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attempt,
+ maxAttempts: __maxAttempts,
+ willRetry: true,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
+ __response.Dispose();
+ __response = null;
+ __httpRequest.Dispose();
+ __httpRequest = null;
+ await global::Letta.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
+ continue;
}
+
+ break;
}
- catch (global::System.Exception __ex)
+
+ if (__response == null)
{
- __exception_422 = __ex;
+ throw new global::System.InvalidOperationException("No response received.");
}
- throw new global::Letta.ApiException(
- message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __exception_422,
- statusCode: __response.StatusCode)
+ using (__response)
{
- ResponseBody = __content_422,
- ResponseObject = __value_422,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
- }
-
- if (ReadResponseAsString)
- {
- var __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- ProcessResponseContent(
+ ProcessResponse(
client: HttpClient,
- response: __response,
- content: ref __content);
- ProcessSearchMessagesResponseContent(
+ response: __response);
+ ProcessSearchMessagesResponse(
httpClient: HttpClient,
- httpResponseMessage: __response,
- content: ref __content);
-
- try
+ httpResponseMessage: __response);
+ if (__response.IsSuccessStatusCode)
{
- __response.EnsureSuccessStatusCode();
-
- return
- (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
- throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "SearchMessages",
+ methodName: "SearchMessagesAsync",
+ pathTemplate: "\"/v1/agents/messages/search\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- catch (global::System.Exception __ex)
+ else
{
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
+ await global::Letta.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
+ clientOptions: Options,
+ context: global::Letta.AutoSDKRequestOptionsSupport.CreateHookContext(
+ operationId: "SearchMessages",
+ methodName: "SearchMessagesAsync",
+ pathTemplate: "\"/v1/agents/messages/search\"",
+ httpMethod: "POST",
+ baseUri: BaseUri,
+ request: __httpRequest!,
+ response: __response,
+ exception: null,
+ clientOptions: Options,
+ requestOptions: requestOptions,
+ attempt: __attemptNumber,
+ maxAttempts: __maxAttempts,
+ willRetry: false,
+ cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
}
- }
- else
- {
- try
- {
- __response.EnsureSuccessStatusCode();
- using var __content = await __response.Content.ReadAsStreamAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
+ // Validation Error
+ if ((int)__response.StatusCode == 422)
+ {
+ string? __content_422 = null;
+ global::System.Exception? __exception_422 = null;
+ global::Letta.HTTPValidationError? __value_422 = null;
+ try
+ {
+ if (__effectiveReadResponseAsString)
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ else
+ {
+ __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false);
- return
- (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ??
- throw new global::System.InvalidOperationException("Response deserialization failed.");
- }
- catch (global::System.Exception __ex)
- {
- string? __content = null;
- try
- {
- __content = await __response.Content.ReadAsStringAsync(
-#if NET5_0_OR_GREATER
- cancellationToken
-#endif
- ).ConfigureAwait(false);
- }
- catch (global::System.Exception)
- {
- }
+ __value_422 = global::Letta.HTTPValidationError.FromJson(__content_422, JsonSerializerContext);
+ }
+ }
+ catch (global::System.Exception __ex)
+ {
+ __exception_422 = __ex;
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content_422 ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __exception_422,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content_422,
+ ResponseObject = __value_422,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+
+ if (__effectiveReadResponseAsString)
+ {
+ var __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ ProcessResponseContent(
+ client: HttpClient,
+ response: __response,
+ content: ref __content);
+ ProcessSearchMessagesResponseContent(
+ httpClient: HttpClient,
+ httpResponseMessage: __response,
+ content: ref __content);
+
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+
+ return
+ (global::System.Collections.Generic.IList?)global::System.Text.Json.JsonSerializer.Deserialize(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext) ??
+ throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
+ }
+ catch (global::System.Exception __ex)
+ {
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
+ else
+ {
+ try
+ {
+ __response.EnsureSuccessStatusCode();
+ using var __content = await __response.Content.ReadAsStreamAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+
+ return
+ (global::System.Collections.Generic.IList?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(__content, typeof(global::System.Collections.Generic.IList), JsonSerializerContext).ConfigureAwait(false) ??
+ throw new global::System.InvalidOperationException("Response deserialization failed.");
+ }
+ catch (global::System.Exception __ex)
+ {
+ string? __content = null;
+ try
+ {
+ __content = await __response.Content.ReadAsStringAsync(
+ #if NET5_0_OR_GREATER
+ __effectiveCancellationToken
+ #endif
+ ).ConfigureAwait(false);
+ }
+ catch (global::System.Exception)
+ {
+ }
+
+ throw new global::Letta.ApiException(
+ message: __content ?? __response.ReasonPhrase ?? string.Empty,
+ innerException: __ex,
+ statusCode: __response.StatusCode)
+ {
+ ResponseBody = __content,
+ ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
+ __response.Headers,
+ h => h.Key,
+ h => h.Value),
+ };
+ }
+ }
- throw new global::Letta.ApiException(
- message: __content ?? __response.ReasonPhrase ?? string.Empty,
- innerException: __ex,
- statusCode: __response.StatusCode)
- {
- ResponseBody = __content,
- ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
- __response.Headers,
- h => h.Key,
- h => h.Value),
- };
}
}
+ finally
+ {
+ __httpRequest?.Dispose();
+ }
}
///
/// Search Messages
@@ -280,6 +463,7 @@ partial void ProcessSearchMessagesResponseContent(
///
/// Filter messages created on or before this date
///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.
/// The token to cancel the operation with
///
public async global::System.Threading.Tasks.Task> SearchMessagesAsync(
@@ -293,6 +477,7 @@ partial void ProcessSearchMessagesResponseContent(
int? limit = default,
global::System.DateTime? startDate = default,
global::System.DateTime? endDate = default,
+ global::Letta.AutoSDKRequestOptions? requestOptions = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Letta.MessageSearchRequest
@@ -311,6 +496,7 @@ partial void ProcessSearchMessagesResponseContent(
return await SearchMessagesAsync(
request: __request,
+ requestOptions: requestOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
diff --git a/src/libs/Letta/Generated/Letta.AgentsClient.SendMessage.g.cs b/src/libs/Letta/Generated/Letta.AgentsClient.SendMessage.g.cs
index 81a2fbfb..616de256 100644
--- a/src/libs/Letta/Generated/Letta.AgentsClient.SendMessage.g.cs
+++ b/src/libs/Letta/Generated/Letta.AgentsClient.SendMessage.g.cs
@@ -16,6 +16,7 @@ public partial class AgentsClient
{ new global::Letta.EndPointAuthorizationRequirement
{
Type = "Http",
+ SchemeId = "BearerAuth",
Location = "Header",
Name = "Bearer",
FriendlyName = "Bearer",
@@ -63,12 +64,14 @@ partial void ProcessSendMessageResponseContent(
/// The ID of the agent in the format 'agent-<uuid4>'
///
///