diff --git a/sdk/ai/azure-ai-agents/README.md b/sdk/ai/azure-ai-agents/README.md
index a52231658900..911837ba0645 100644
--- a/sdk/ai/azure-ai-agents/README.md
+++ b/sdk/ai/azure-ai-agents/README.md
@@ -25,7 +25,7 @@ Various documentation is available to help you get started
Request Body Schema
@@ -73,7 +76,7 @@ public final class AgentSessionFilesAsyncClient { * * * @param agentName The name of the agent. - * @param sessionId The session ID. + * @param agentSessionId The session ID. * @param path The destination file path within the sandbox, relative to the session home directory. * @param content The content parameter. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. @@ -86,9 +89,9 @@ public final class AgentSessionFilesAsyncClient { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public MonoResponse Body Schema
@@ -112,7 +118,7 @@ public MonoResponse Body Schema
@@ -354,7 +383,7 @@ public MonoRequest Body Schema
@@ -71,7 +74,7 @@ public final class AgentSessionFilesClient { * * * @param agentName The name of the agent. - * @param sessionId The session ID. + * @param agentSessionId The session ID. * @param path The destination file path within the sandbox, relative to the session home directory. * @param content The content parameter. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. @@ -83,9 +86,10 @@ public final class AgentSessionFilesClient { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseResponse Body Schema
@@ -108,7 +115,7 @@ public ResponseResponse Body Schema
@@ -346,7 +374,7 @@ public void deleteSessionFile(String agentName, String sessionId, String path) { * name: String (Required) * size: long (Required) * is_directory: boolean (Required) - * modified_time: OffsetDateTime (Required) + * modified_time: long (Required) * } * ] * } @@ -354,7 +382,7 @@ public void deleteSessionFile(String agentName, String sessionId, String path) { * * * @param agentName The name of the agent. - * @param sessionId The session ID. + * @param agentSessionId The session ID. * @param path The directory path to list, relative to the session home directory. * @param requestOptions The options to configure the HTTP request before HTTP client sends it. * @throws HttpResponseException thrown if the request is rejected by server. @@ -365,9 +393,9 @@ public void deleteSessionFile(String agentName, String sessionId, String path) { */ @Generated @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseRequest Body Schema
@@ -173,7 +186,7 @@ public MonoRequest Body Schema
@@ -490,7 +506,7 @@ public MonoRequest Body Schema
@@ -651,7 +669,7 @@ MonoHeader Parameters
+ *| Name | Type | Required | Description |
|---|---|---|---|
| x-ms-user-isolation-key | String | No | Opaque per-user isolation key used to scope + * endpoint-scoped data (responses, conversations, sessions) to a specific end user. |
Response Body Schema
* *@@ -1659,70 +1691,6 @@ public PagedFluxlistAgentConversations(RequestOptions requestOption return this.serviceClient.listAgentConversationsAsync(requestOptions); } - /** - * Returns the list of all conversations. - * - * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the - * default is 20. - * @param order Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` - * for descending order. - * @param after A cursor for use in pagination. `after` is an object ID that defines your place in the list. - * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - * subsequent call can include after=obj_foo in order to fetch the next page of the list. - * @param before A cursor for use in pagination. `before` is an object ID that defines your place in the list. - * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - * subsequent call can include before=obj_foo in order to fetch the previous page of the list. - * @param agentName Filter by agent name. If provided, only items associated with the specified agent will be - * returned. - * @param agentId Filter by agent ID in the format `name:version`. If provided, only items associated with the - * specified agent ID will be returned. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. - */ - @Generated - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listAgentConversations(Integer limit, PageOrder order, String after, String before, - String agentName, String agentId) { - // Generated convenience method for listAgentConversations - RequestOptions requestOptions = new RequestOptions(); - if (limit != null) { - requestOptions.addQueryParam("limit", String.valueOf(limit), false); - } - if (order != null) { - requestOptions.addQueryParam("order", order.toString(), false); - } - if (after != null) { - requestOptions.addQueryParam("after", after, false); - } - if (before != null) { - requestOptions.addQueryParam("before", before, false); - } - if (agentName != null) { - requestOptions.addQueryParam("agent_name", agentName, false); - } - if (agentId != null) { - requestOptions.addQueryParam("agent_id", agentId, false); - } - PagedFlux pagedFluxResponse = listAgentConversations(requestOptions); - return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { - Flux > flux = (continuationTokenParam == null) - ? pagedFluxResponse.byPage().take(1) - : pagedFluxResponse.byPage(continuationTokenParam).take(1); - return flux.map(pagedResponse -> new PagedResponseBase (pagedResponse.getRequest(), - pagedResponse.getStatusCode(), pagedResponse.getHeaders(), - pagedResponse.getValue() - .stream() - .map(protocolMethodData -> protocolMethodData.toObject(Conversation.class)) - .collect(Collectors.toList()), - pagedResponse.getContinuationToken(), null)); - }); - } - /** * Returns the list of all conversations. * @@ -1799,7 +1767,18 @@ public Mono > deleteAgentWithResponse(String agentName, RequestOpt } /** - * Deletes an agent. + * Deletes an agent. For hosted agents, if any version has active sessions, the request + * is rejected with HTTP 409 unless `force` is set to true. When force is true, all + * associated sessions are cascade-deleted along with the agent and its versions. + * Query Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addQueryParam} *Query Parameters + *+ * Name Type Required Description + * force Boolean No For Hosted Agents, if true, force-deletes the agent even if its + * versions have active sessions, cascading deletion to all associated sessions. This value is not relevant for + * other Agent types. Defaults to false. Response Body Schema
* *@@ -1827,7 +1806,18 @@ Mono> internalDeleteAgentWithResponse(String agentName, Req } /** - * Deletes a specific version of an agent. + * Deletes a specific version of an agent. For hosted agents, if the version has active + * sessions, the request is rejected with HTTP 409 unless `force` is set to true. When + * force is true, all sessions associated with this version are cascade-deleted. + * Query Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addQueryParam} *Query Parameters + *+ * Name Type Required Description + * force Boolean No For Hosted Agents, if true, force-deletes the version even if it + * has active sessions, cascading deletion to all associated sessions. This value is not relevant for other Agent + * types. Defaults to false. Response Body Schema
* *@@ -1857,69 +1847,6 @@ Mono> internalDeleteAgentVersionWithResponse(String agentNa return this.serviceClient.internalDeleteAgentVersionWithResponseAsync(agentName, agentVersion, requestOptions); } - /** - * Creates a new session for an agent endpoint. - * The endpoint resolves the backing agent version from `version_indicator` and - * enforces session ownership using the provided isolation key for session-mutating operations. - * Header Parameters
- *- *
- * You can add these to a request with {@link RequestOptions#addHeader} - *Header Parameters - *- * Name Type Required Description - * Foundry-Features String No A feature flag opt-in required when using preview - * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", - * "WorkflowAgents=V1Preview", "ContainerAgents=V1Preview", "AgentEndpoints=V1Preview". Request Body Schema
- * - *- * {@code - * { - * agent_session_id: String (Optional) - * version_indicator (Required): { - * type: String(version_ref) (Required) - * } - * } - * } - *- * - *Response Body Schema
- * - *- * {@code - * { - * agent_session_id: String (Required) - * version_indicator (Required): { - * type: String(version_ref) (Required) - * } - * status: String(creating/active/idle/updating/failed/deleting/deleted/expired) (Required) - * created_at: long (Required) - * last_accessed_at: long (Required) - * expires_at: long (Required) - * } - * } - *- * - * @param agentName The name of the agent to create a session for. - * @param isolationKey Isolation key used by the agent endpoint to enforce session ownership for session-mutating - * operations. - * @param createSessionRequest The createSessionRequest parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return an agent session providing a long-lived compute sandbox for hosted agent invocations along with - * {@link Response} on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono> createSessionWithResponse(String agentName, String isolationKey, - BinaryData createSessionRequest, RequestOptions requestOptions) { - return this.serviceClient.createSessionWithResponseAsync(agentName, isolationKey, createSessionRequest, - requestOptions); - } - /** * Retrieves a session by ID. * Header Parameters
@@ -1928,7 +1855,8 @@ public Mono> createSessionWithResponse(String agentName, St * * Name Type Required Description + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". * * You can add these to a request with {@link RequestOptions#addHeader} * Foundry-Features String No A feature flag opt-in required when using preview * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", - * "WorkflowAgents=V1Preview", "ContainerAgents=V1Preview", "AgentEndpoints=V1Preview". Response Body Schema
@@ -1965,37 +1893,6 @@ public Mono> getSessionWithResponse(String agentName, Strin return this.serviceClient.getSessionWithResponseAsync(agentName, sessionId, requestOptions); } - /** - * Deletes a session synchronously. - * Returns 204 No Content when the session is deleted or does not exist. - * Header Parameters
- *- *
- * You can add these to a request with {@link RequestOptions#addHeader} - * - * @param agentName The name of the agent. - * @param sessionId The session identifier. - * @param isolationKey Isolation key used by the agent endpoint to enforce session ownership for session-mutating - * operations. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response} on successful completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public MonoHeader Parameters - *- * Name Type Required Description - * Foundry-Features String No A feature flag opt-in required when using preview - * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", - * "WorkflowAgents=V1Preview", "ContainerAgents=V1Preview", "AgentEndpoints=V1Preview". > deleteSessionWithResponse(String agentName, String sessionId, String isolationKey, - RequestOptions requestOptions) { - return this.serviceClient.deleteSessionWithResponseAsync(agentName, sessionId, isolationKey, requestOptions); - } - /** * Returns a list of sessions for the specified agent. * Query Parameters
@@ -2024,7 +1921,8 @@ public Mono> deleteSessionWithResponse(String agentName, String s * * Name Type Required Description + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". * * You can add these to a request with {@link RequestOptions#addHeader} * Foundry-Features String No A feature flag opt-in required when using preview * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", - * "WorkflowAgents=V1Preview", "ContainerAgents=V1Preview", "AgentEndpoints=V1Preview". Response Body Schema
@@ -2178,71 +2076,6 @@ public MonocreateAgentVersion(String agentName, AgentDefin .map(protocolMethodData -> protocolMethodData.toObject(AgentVersionDetails.class)); } - /** - * Creates a new session for an agent endpoint. - * The endpoint resolves the backing agent version from `version_indicator` and - * enforces session ownership using the provided isolation key for session-mutating operations. - * - * @param agentName The name of the agent to create a session for. - * @param isolationKey Isolation key used by the agent endpoint to enforce session ownership for session-mutating - * operations. - * @param versionIndicator Determines which agent version backs the session. - * @param agentSessionId Optional caller-provided session ID. If specified, it must be unique within the agent - * endpoint. Auto-generated if omitted. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an agent session providing a long-lived compute sandbox for hosted agent invocations on successful - * completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createSession(String agentName, String isolationKey, - VersionIndicator versionIndicator, String agentSessionId) { - // Generated convenience method for createSessionWithResponse - RequestOptions requestOptions = new RequestOptions(); - CreateSessionRequest createSessionRequestObj - = new CreateSessionRequest(versionIndicator).setAgentSessionId(agentSessionId); - BinaryData createSessionRequest = BinaryData.fromObject(createSessionRequestObj); - return createSessionWithResponse(agentName, isolationKey, createSessionRequest, requestOptions) - .flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(AgentSessionResource.class)); - } - - /** - * Creates a new session for an agent endpoint. - * The endpoint resolves the backing agent version from `version_indicator` and - * enforces session ownership using the provided isolation key for session-mutating operations. - * - * @param agentName The name of the agent to create a session for. - * @param isolationKey Isolation key used by the agent endpoint to enforce session ownership for session-mutating - * operations. - * @param versionIndicator Determines which agent version backs the session. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an agent session providing a long-lived compute sandbox for hosted agent invocations on successful - * completion of {@link Mono}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono createSession(String agentName, String isolationKey, - VersionIndicator versionIndicator) { - // Generated convenience method for createSessionWithResponse - RequestOptions requestOptions = new RequestOptions(); - CreateSessionRequest createSessionRequestObj = new CreateSessionRequest(versionIndicator); - BinaryData createSessionRequest = BinaryData.fromObject(createSessionRequestObj); - return createSessionWithResponse(agentName, isolationKey, createSessionRequest, requestOptions) - .flatMap(FluxUtil::toMono) - .map(protocolMethodData -> protocolMethodData.toObject(AgentSessionResource.class)); - } - /** * Retrieves a session by ID. * @@ -2296,88 +2129,34 @@ public Mono getSession(String agentName, String sessionId) } /** - * Deletes a session synchronously. - * Returns 204 No Content when the session is deleted or does not exist. + * Returns a list of sessions for the specified agent. * * @param agentName The name of the agent. - * @param sessionId The session identifier. - * @param isolationKey Isolation key used by the agent endpoint to enforce session ownership for session-mutating - * operations. * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted * preview resources. + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the + * default is 20. + * @param order Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` + * for descending order. + * @param after A cursor for use in pagination. `after` is an object ID that defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include after=obj_foo in order to fetch the next page of the list. + * @param before A cursor for use in pagination. `before` is an object ID that defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include before=obj_foo in order to fetch the previous page of the list. * @throws IllegalArgumentException thrown if parameters fail the validation. * @throws HttpResponseException thrown if the request is rejected by server. * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. */ @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteSession(String agentName, String sessionId, String isolationKey, - AgentDefinitionOptInKeys foundryFeatures) { - // Generated convenience method for deleteSessionWithResponse - RequestOptions requestOptions = new RequestOptions(); - if (foundryFeatures != null) { - requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); - } - return deleteSessionWithResponse(agentName, sessionId, isolationKey, requestOptions).flatMap(FluxUtil::toMono); - } - - /** - * Deletes a session synchronously. - * Returns 204 No Content when the session is deleted or does not exist. - * - * @param agentName The name of the agent. - * @param sessionId The session identifier. - * @param isolationKey Isolation key used by the agent endpoint to enforce session ownership for session-mutating - * operations. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return A {@link Mono} that completes when a successful response is received. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public Mono deleteSession(String agentName, String sessionId, String isolationKey) { - // Generated convenience method for deleteSessionWithResponse - RequestOptions requestOptions = new RequestOptions(); - return deleteSessionWithResponse(agentName, sessionId, isolationKey, requestOptions).flatMap(FluxUtil::toMono); - } - - /** - * Returns a list of sessions for the specified agent. - * - * @param agentName The name of the agent. - * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted - * preview resources. - * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the - * default is 20. - * @param order Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` - * for descending order. - * @param after A cursor for use in pagination. `after` is an object ID that defines your place in the list. - * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - * subsequent call can include after=obj_foo in order to fetch the next page of the list. - * @param before A cursor for use in pagination. `before` is an object ID that defines your place in the list. - * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - * subsequent call can include before=obj_foo in order to fetch the previous page of the list. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. - */ - @Generated - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedFlux listSessions(String agentName, AgentDefinitionOptInKeys foundryFeatures, - Integer limit, PageOrder order, String after, String before) { - // Generated convenience method for listSessions + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listSessions(String agentName, AgentDefinitionOptInKeys foundryFeatures, + Integer limit, PageOrder order, String after, String before) { + // Generated convenience method for listSessions RequestOptions requestOptions = new RequestOptions(); if (foundryFeatures != null) { requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); @@ -2511,7 +2290,8 @@ public Flux getSessionLogStream(String agentName, String agentV * * Name Type Required Description + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". * * You can add these to a request with {@link RequestOptions#addHeader} * Foundry-Features String No A feature flag opt-in required when using preview * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", - * "WorkflowAgents=V1Preview", "ContainerAgents=V1Preview", "AgentEndpoints=V1Preview". Response Body Schema
@@ -2554,7 +2334,8 @@ public Mono> getSessionLogStreamWithResponse(String agentNa * * Name Type Required Description + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". * * You can add these to a request with {@link RequestOptions#addHeader} * Foundry-Features String No A feature flag opt-in required when using preview * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", - * "WorkflowAgents=V1Preview", "ContainerAgents=V1Preview", "AgentEndpoints=V1Preview". Request Body Schema
@@ -2572,7 +2353,7 @@ public Mono> getSessionLogStreamWithResponse(String agentNa * ] * } * protocols (Optional): [ - * String(activity/responses/a2a/invocations) (Optional) + * String(activity/responses/a2a/mcp/invocations) (Optional) * ] * authorization_schemes (Optional): [ * (Optional){ @@ -2621,11 +2402,12 @@ public Mono > getSessionLogStreamWithResponse(String agentNa * description: String (Optional) * created_at: long (Required) * definition (Required): { - * kind: String(prompt/hosted/workflow) (Required) + * kind: String(prompt/hosted/workflow/external) (Required) * rai_config (Optional): { * rai_policy_name: String (Required) * } * } + * status: String(creating/active/failed/deleting/deleted) (Optional) * instance_identity (Optional): { * principal_id: String (Required) * client_id: String (Required) @@ -2647,7 +2429,7 @@ public Mono > getSessionLogStreamWithResponse(String agentNa * ] * } * protocols (Optional): [ - * String(activity/responses/a2a/invocations) (Optional) + * String(activity/responses/a2a/mcp/invocations) (Optional) * ] * authorization_schemes (Optional): [ * (Optional){ @@ -2834,4 +2616,2897 @@ public Mono updateAgentDetails(String agentName, UpdateAgentDetail .flatMap(FluxUtil::toMono) .map(protocolMethodData -> protocolMethodData.toObject(AgentDetails.class)); } + + /** + * Creates a new code-based agent. Uploads the code zip and creates the agent in a single call. + * The agent name is provided in the `x-ms-agent-name` header since POST /agents has no name in the URL path. + * The SHA-256 hex digest of the zip is provided in the `x-ms-code-zip-sha256` header for integrity and dedup. + * The request body is multipart/form-data with a JSON metadata part and a binary code part (part order is + * irrelevant). + * Maximum upload size is 250 MB. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". Response Body Schema
+ * + *+ * {@code + * { + * object: String(agent/agent.version/agent.deleted/agent.version.deleted/agent.container) (Required) + * id: String (Required) + * name: String (Required) + * versions (Required): { + * latest (Required): { + * metadata (Required): { + * String: String (Required) + * } + * object: String(agent/agent.version/agent.deleted/agent.version.deleted/agent.container) (Required) + * id: String (Required) + * name: String (Required) + * version: String (Required) + * description: String (Optional) + * created_at: long (Required) + * definition (Required): { + * kind: String(prompt/hosted/workflow/external) (Required) + * rai_config (Optional): { + * rai_policy_name: String (Required) + * } + * } + * status: String(creating/active/failed/deleting/deleted) (Optional) + * instance_identity (Optional): { + * principal_id: String (Required) + * client_id: String (Required) + * } + * blueprint (Optional): (recursive schema, see blueprint above) + * blueprint_reference (Optional): { + * type: String(ManagedAgentIdentityBlueprint) (Required) + * } + * agent_guid: String (Optional) + * } + * } + * agent_endpoint (Optional): { + * version_selector (Optional): { + * version_selection_rules (Optional, Required on create): [ + * (Optional, Required on create){ + * type: String(FixedRatio) (Required) + * agent_version: String (Optional, Required on create) + * } + * ] + * } + * protocols (Optional): [ + * String(activity/responses/a2a/mcp/invocations) (Optional) + * ] + * authorization_schemes (Optional): [ + * (Optional){ + * type: String(Entra/BotService/BotServiceRbac) (Required) + * } + * ] + * } + * instance_identity (Optional): (recursive schema, see instance_identity above) + * blueprint (Optional): (recursive schema, see blueprint above) + * blueprint_reference (Optional): (recursive schema, see blueprint_reference above) + * agent_card (Optional): { + * version: String (Optional, Required on create) + * description: String (Optional) + * skills (Optional, Required on create): [ + * (Optional, Required on create){ + * id: String (Optional, Required on create) + * name: String (Optional, Required on create) + * description: String (Optional) + * tags (Optional): [ + * String (Optional) + * ] + * examples (Optional): [ + * String (Optional) + * ] + * } + * ] + * } + * } + * } + *+ * + * @param agentName The unique name that identifies the agent. Max 63 chars, must start and end with alphanumeric, + * hyphens allowed in the middle. + * @param codeZipSha256 SHA-256 hex digest of the uploaded code zip. Used for change detection (dedup) and integrity + * verification. + * @param content The content parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono> createAgentFromCodeWithResponse(String agentName, String codeZipSha256, + BinaryData content, RequestOptions requestOptions) { + // Operation 'createAgentFromCode' is of content-type 'multipart/form-data'. Protocol API is not usable and + // hence not generated. + return this.serviceClient.createAgentFromCodeWithResponseAsync(agentName, codeZipSha256, content, + requestOptions); + } + + /** + * Updates a code-based agent by uploading new code and creating a new version. + * If the code and definition are unchanged (matched by x-ms-code-zip-sha256 header), returns the existing version. + * The request body is multipart/form-data with a JSON metadata part and a binary code part (part order is + * irrelevant). + * Maximum upload size is 250 MB. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". Response Body Schema
+ * + *+ * {@code + * { + * object: String(agent/agent.version/agent.deleted/agent.version.deleted/agent.container) (Required) + * id: String (Required) + * name: String (Required) + * versions (Required): { + * latest (Required): { + * metadata (Required): { + * String: String (Required) + * } + * object: String(agent/agent.version/agent.deleted/agent.version.deleted/agent.container) (Required) + * id: String (Required) + * name: String (Required) + * version: String (Required) + * description: String (Optional) + * created_at: long (Required) + * definition (Required): { + * kind: String(prompt/hosted/workflow/external) (Required) + * rai_config (Optional): { + * rai_policy_name: String (Required) + * } + * } + * status: String(creating/active/failed/deleting/deleted) (Optional) + * instance_identity (Optional): { + * principal_id: String (Required) + * client_id: String (Required) + * } + * blueprint (Optional): (recursive schema, see blueprint above) + * blueprint_reference (Optional): { + * type: String(ManagedAgentIdentityBlueprint) (Required) + * } + * agent_guid: String (Optional) + * } + * } + * agent_endpoint (Optional): { + * version_selector (Optional): { + * version_selection_rules (Optional, Required on create): [ + * (Optional, Required on create){ + * type: String(FixedRatio) (Required) + * agent_version: String (Optional, Required on create) + * } + * ] + * } + * protocols (Optional): [ + * String(activity/responses/a2a/mcp/invocations) (Optional) + * ] + * authorization_schemes (Optional): [ + * (Optional){ + * type: String(Entra/BotService/BotServiceRbac) (Required) + * } + * ] + * } + * instance_identity (Optional): (recursive schema, see instance_identity above) + * blueprint (Optional): (recursive schema, see blueprint above) + * blueprint_reference (Optional): (recursive schema, see blueprint_reference above) + * agent_card (Optional): { + * version: String (Optional, Required on create) + * description: String (Optional) + * skills (Optional, Required on create): [ + * (Optional, Required on create){ + * id: String (Optional, Required on create) + * name: String (Optional, Required on create) + * description: String (Optional) + * tags (Optional): [ + * String (Optional) + * ] + * examples (Optional): [ + * String (Optional) + * ] + * } + * ] + * } + * } + * } + *+ * + * @param agentName The unique name that identifies the agent. Name can be used to retrieve/update/delete the agent. + * - Must start and end with alphanumeric characters, + * - Can contain hyphens in the middle + * - Must not exceed 63 characters. + * @param codeZipSha256 SHA-256 hex digest of the uploaded code zip. Used for change detection (dedup) and integrity + * verification. + * @param content The content parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono> updateAgentFromCodeWithResponse(String agentName, String codeZipSha256, + BinaryData content, RequestOptions requestOptions) { + // Operation 'updateAgentFromCode' is of content-type 'multipart/form-data'. Protocol API is not usable and + // hence not generated. + return this.serviceClient.updateAgentFromCodeWithResponseAsync(agentName, codeZipSha256, content, + requestOptions); + } + + /** + * The createAgentVersionFromCode operation. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". Response Body Schema
+ * + *+ * {@code + * { + * metadata (Required): { + * String: String (Required) + * } + * object: String(agent/agent.version/agent.deleted/agent.version.deleted/agent.container) (Required) + * id: String (Required) + * name: String (Required) + * version: String (Required) + * description: String (Optional) + * created_at: long (Required) + * definition (Required): { + * kind: String(prompt/hosted/workflow/external) (Required) + * rai_config (Optional): { + * rai_policy_name: String (Required) + * } + * } + * status: String(creating/active/failed/deleting/deleted) (Optional) + * instance_identity (Optional): { + * principal_id: String (Required) + * client_id: String (Required) + * } + * blueprint (Optional): (recursive schema, see blueprint above) + * blueprint_reference (Optional): { + * type: String(ManagedAgentIdentityBlueprint) (Required) + * } + * agent_guid: String (Optional) + * } + * } + *+ * + * @param agentName The unique name that identifies the agent. Name can be used to retrieve/update/delete the agent. + * - Must start and end with alphanumeric characters, + * - Can contain hyphens in the middle + * - Must not exceed 63 characters. + * @param codeZipSha256 SHA-256 hex digest of the uploaded code zip. Used for change detection (dedup) and integrity + * verification. + * @param content The content parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono> createAgentVersionFromCodeWithResponse(String agentName, String codeZipSha256, + BinaryData content, RequestOptions requestOptions) { + // Operation 'createAgentVersionFromCode' is of content-type 'multipart/form-data'. Protocol API is not usable + // and hence not generated. + return this.serviceClient.createAgentVersionFromCodeWithResponseAsync(agentName, codeZipSha256, content, + requestOptions); + } + + /** + * Download the code zip for a code-based hosted agent. + * Returns the previously-uploaded zip (`application/zip`). + * + * If `agent_version` is supplied, returns that version's code zip; otherwise + * returns the latest version's code zip. + * + * The SHA-256 digest of the returned bytes matches the `content_hash` on the + * resolved version's `code_configuration`. + * Query Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *Query Parameters + *+ * Name Type Required Description + * agent_version String No The version of the agent whose code zip should be + * downloaded. + * If omitted, the latest version's code zip is returned. Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". Response Body Schema
+ * + *+ * {@code + * BinaryData + * } + *+ * + * @param agentName The name of the agent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> downloadAgentCodeWithResponse(String agentName, RequestOptions requestOptions) { + return this.serviceClient.downloadAgentCodeWithResponseAsync(agentName, requestOptions); + } + + /** + * Creates a new session for an agent endpoint. + * The endpoint resolves the backing agent version from `version_indicator` and + * enforces session ownership using the provided isolation key for session-mutating operations. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". Request Body Schema
+ * + *+ * {@code + * { + * agent_session_id: String (Optional) + * version_indicator (Required): { + * type: String(version_ref) (Required) + * } + * } + * } + *+ * + *Response Body Schema
+ * + *+ * {@code + * { + * agent_session_id: String (Required) + * version_indicator (Required): { + * type: String(version_ref) (Required) + * } + * status: String(creating/active/idle/updating/failed/deleting/deleted/expired) (Required) + * created_at: long (Required) + * last_accessed_at: long (Required) + * expires_at: long (Required) + * } + * } + *+ * + * @param agentName The name of the agent to create a session for. + * @param createSessionRequest The createSessionRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return an agent session providing a long-lived compute sandbox for hosted agent invocations along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createSessionWithResponse(String agentName, BinaryData createSessionRequest, + RequestOptions requestOptions) { + return this.serviceClient.createSessionWithResponseAsync(agentName, createSessionRequest, requestOptions); + } + + /** + * Deletes a session synchronously. + * Returns 204 No Content when the session is deleted or does not exist. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param agentName The name of the agent. + * @param sessionId The session identifier. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public MonoHeader Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". > deleteSessionWithResponse(String agentName, String sessionId, + RequestOptions requestOptions) { + return this.serviceClient.deleteSessionWithResponseAsync(agentName, sessionId, requestOptions); + } + + /** + * Creates a new code-based agent. Uploads the code zip and creates the agent in a single call. + * The agent name is provided in the `x-ms-agent-name` header since POST /agents has no name in the URL path. + * The SHA-256 hex digest of the zip is provided in the `x-ms-code-zip-sha256` header for integrity and dedup. + * The request body is multipart/form-data with a JSON metadata part and a binary code part (part order is + * irrelevant). + * Maximum upload size is 250 MB. + * + * @param agentName The unique name that identifies the agent. Max 63 chars, must start and end with alphanumeric, + * hyphens allowed in the middle. + * @param codeZipSha256 SHA-256 hex digest of the uploaded code zip. Used for change detection (dedup) and integrity + * verification. + * @param content The content parameter. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono createAgentFromCode(String agentName, String codeZipSha256, CreateAgentFromCodeContent content, + AgentDefinitionOptInKeys foundryFeatures) { + // Generated convenience method for createAgentFromCodeWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + return createAgentFromCodeWithResponse(agentName, codeZipSha256, + new MultipartFormDataHelper(requestOptions).serializeJsonField("metadata", content.getMetadata()) + .serializeFileField("code", content.getCode().getContent(), content.getCode().getContentType(), + content.getCode().getFilename()) + .end() + .getRequestBody(), + requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AgentDetails.class)); + } + + /** + * Creates a new code-based agent. Uploads the code zip and creates the agent in a single call. + * The agent name is provided in the `x-ms-agent-name` header since POST /agents has no name in the URL path. + * The SHA-256 hex digest of the zip is provided in the `x-ms-code-zip-sha256` header for integrity and dedup. + * The request body is multipart/form-data with a JSON metadata part and a binary code part (part order is + * irrelevant). + * Maximum upload size is 250 MB. + * + * @param agentName The unique name that identifies the agent. Max 63 chars, must start and end with alphanumeric, + * hyphens allowed in the middle. + * @param codeZipSha256 SHA-256 hex digest of the uploaded code zip. Used for change detection (dedup) and integrity + * verification. + * @param content The content parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + Mono createAgentFromCode(String agentName, String codeZipSha256, CreateAgentFromCodeContent content) { + // Generated convenience method for createAgentFromCodeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createAgentFromCodeWithResponse(agentName, codeZipSha256, + new MultipartFormDataHelper(requestOptions).serializeJsonField("metadata", content.getMetadata()) + .serializeFileField("code", content.getCode().getContent(), content.getCode().getContentType(), + content.getCode().getFilename()) + .end() + .getRequestBody(), + requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AgentDetails.class)); + } + + /** + * Updates a code-based agent by uploading new code and creating a new version. + * If the code and definition are unchanged (matched by x-ms-code-zip-sha256 header), returns the existing version. + * The request body is multipart/form-data with a JSON metadata part and a binary code part (part order is + * irrelevant). + * Maximum upload size is 250 MB. + * + * @param agentName The unique name that identifies the agent. Name can be used to retrieve/update/delete the agent. + * - Must start and end with alphanumeric characters, + * - Can contain hyphens in the middle + * - Must not exceed 63 characters. + * @param codeZipSha256 SHA-256 hex digest of the uploaded code zip. Used for change detection (dedup) and integrity + * verification. + * @param content The content parameter. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono updateAgentFromCode(String agentName, String codeZipSha256, + CreateAgentVersionFromCodeContent content, AgentDefinitionOptInKeys foundryFeatures) { + // Generated convenience method for updateAgentFromCodeWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + return updateAgentFromCodeWithResponse(agentName, codeZipSha256, + new MultipartFormDataHelper(requestOptions).serializeJsonField("metadata", content.getMetadata()) + .serializeFileField("code", content.getCode().getContent(), content.getCode().getContentType(), + content.getCode().getFilename()) + .end() + .getRequestBody(), + requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AgentDetails.class)); + } + + /** + * Updates a code-based agent by uploading new code and creating a new version. + * If the code and definition are unchanged (matched by x-ms-code-zip-sha256 header), returns the existing version. + * The request body is multipart/form-data with a JSON metadata part and a binary code part (part order is + * irrelevant). + * Maximum upload size is 250 MB. + * + * @param agentName The unique name that identifies the agent. Name can be used to retrieve/update/delete the agent. + * - Must start and end with alphanumeric characters, + * - Can contain hyphens in the middle + * - Must not exceed 63 characters. + * @param codeZipSha256 SHA-256 hex digest of the uploaded code zip. Used for change detection (dedup) and integrity + * verification. + * @param content The content parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono updateAgentFromCode(String agentName, String codeZipSha256, + CreateAgentVersionFromCodeContent content) { + // Generated convenience method for updateAgentFromCodeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return updateAgentFromCodeWithResponse(agentName, codeZipSha256, + new MultipartFormDataHelper(requestOptions).serializeJsonField("metadata", content.getMetadata()) + .serializeFileField("code", content.getCode().getContent(), content.getCode().getContentType(), + content.getCode().getFilename()) + .end() + .getRequestBody(), + requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AgentDetails.class)); + } + + /** + * The createAgentVersionFromCode operation. + * + * @param agentName The unique name that identifies the agent. Name can be used to retrieve/update/delete the agent. + * - Must start and end with alphanumeric characters, + * - Can contain hyphens in the middle + * - Must not exceed 63 characters. + * @param codeZipSha256 SHA-256 hex digest of the uploaded code zip. Used for change detection (dedup) and integrity + * verification. + * @param content The content parameter. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createAgentVersionFromCode(String agentName, String codeZipSha256, + CreateAgentVersionFromCodeContent content, AgentDefinitionOptInKeys foundryFeatures) { + // Generated convenience method for createAgentVersionFromCodeWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + return createAgentVersionFromCodeWithResponse(agentName, codeZipSha256, + new MultipartFormDataHelper(requestOptions).serializeJsonField("metadata", content.getMetadata()) + .serializeFileField("code", content.getCode().getContent(), content.getCode().getContentType(), + content.getCode().getFilename()) + .end() + .getRequestBody(), + requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AgentVersionDetails.class)); + } + + /** + * The createAgentVersionFromCode operation. + * + * @param agentName The unique name that identifies the agent. Name can be used to retrieve/update/delete the agent. + * - Must start and end with alphanumeric characters, + * - Can contain hyphens in the middle + * - Must not exceed 63 characters. + * @param codeZipSha256 SHA-256 hex digest of the uploaded code zip. Used for change detection (dedup) and integrity + * verification. + * @param content The content parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createAgentVersionFromCode(String agentName, String codeZipSha256, + CreateAgentVersionFromCodeContent content) { + // Generated convenience method for createAgentVersionFromCodeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createAgentVersionFromCodeWithResponse(agentName, codeZipSha256, + new MultipartFormDataHelper(requestOptions).serializeJsonField("metadata", content.getMetadata()) + .serializeFileField("code", content.getCode().getContent(), content.getCode().getContentType(), + content.getCode().getFilename()) + .end() + .getRequestBody(), + requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AgentVersionDetails.class)); + } + + /** + * Download the code zip for a code-based hosted agent. + * Returns the previously-uploaded zip (`application/zip`). + * + * If `agent_version` is supplied, returns that version's code zip; otherwise + * returns the latest version's code zip. + * + * The SHA-256 digest of the returned bytes matches the `content_hash` on the + * resolved version's `code_configuration`. + * + * @param agentName The name of the agent. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono downloadAgentCode(String agentName) { + // Generated convenience method for downloadAgentCodeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return downloadAgentCodeWithResponse(agentName, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Creates a new session for an agent endpoint. + * The endpoint resolves the backing agent version from `version_indicator` and + * enforces session ownership using the provided isolation key for session-mutating operations. + * + * @param agentName The name of the agent to create a session for. + * @param versionIndicator Determines which agent version backs the session. + * @param agentSessionId Optional caller-provided session ID. If specified, it must be unique within the agent + * endpoint. Auto-generated if omitted. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an agent session providing a long-lived compute sandbox for hosted agent invocations on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createSession(String agentName, VersionIndicator versionIndicator, + String agentSessionId) { + // Generated convenience method for createSessionWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateSessionRequest createSessionRequestObj + = new CreateSessionRequest(versionIndicator).setAgentSessionId(agentSessionId); + BinaryData createSessionRequest = BinaryData.fromObject(createSessionRequestObj); + return createSessionWithResponse(agentName, createSessionRequest, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AgentSessionResource.class)); + } + + /** + * Creates a new session for an agent endpoint. + * The endpoint resolves the backing agent version from `version_indicator` and + * enforces session ownership using the provided isolation key for session-mutating operations. + * + * @param agentName The name of the agent to create a session for. + * @param versionIndicator Determines which agent version backs the session. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an agent session providing a long-lived compute sandbox for hosted agent invocations on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createSession(String agentName, VersionIndicator versionIndicator) { + // Generated convenience method for createSessionWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateSessionRequest createSessionRequestObj = new CreateSessionRequest(versionIndicator); + BinaryData createSessionRequest = BinaryData.fromObject(createSessionRequestObj); + return createSessionWithResponse(agentName, createSessionRequest, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AgentSessionResource.class)); + } + + /** + * Deletes a session synchronously. + * Returns 204 No Content when the session is deleted or does not exist. + * + * @param agentName The name of the agent. + * @param sessionId The session identifier. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteSession(String agentName, String sessionId, AgentDefinitionOptInKeys foundryFeatures) { + // Generated convenience method for deleteSessionWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + return deleteSessionWithResponse(agentName, sessionId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Deletes a session synchronously. + * Returns 204 No Content when the session is deleted or does not exist. + * + * @param agentName The name of the agent. + * @param sessionId The session identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteSession(String agentName, String sessionId) { + // Generated convenience method for deleteSessionWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteSessionWithResponse(agentName, sessionId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Download the code zip for a code-based hosted agent. + * Returns the previously-uploaded zip (`application/zip`). + * + * If `agent_version` is supplied, returns that version's code zip; otherwise + * returns the latest version's code zip. + * + * The SHA-256 digest of the returned bytes matches the `content_hash` on the + * resolved version's `code_configuration`. + * + * @param agentName The name of the agent. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @param agentVersion The version of the agent whose code zip should be downloaded. + * If omitted, the latest version's code zip is returned. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response body on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono downloadAgentCode(String agentName, AgentDefinitionOptInKeys foundryFeatures, + String agentVersion) { + // Generated convenience method for downloadAgentCodeWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + if (agentVersion != null) { + requestOptions.addQueryParam("agent_version", agentVersion, false); + } + return downloadAgentCodeWithResponse(agentName, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Returns the list of all conversations. + * + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the + * default is 20. + * @param order Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` + * for descending order. + * @param after A cursor for use in pagination. `after` is an object ID that defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include after=obj_foo in order to fetch the next page of the list. + * @param before A cursor for use in pagination. `before` is an object ID that defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include before=obj_foo in order to fetch the previous page of the list. + * @param agentName Filter by agent name. If provided, only items associated with the specified agent will be + * returned. + * @param agentId Filter by agent ID in the format `name:version`. If provided, only items associated with the + * specified agent ID will be returned. + * @param userIsolationKey Opaque per-user isolation key used to scope endpoint-scoped data (responses, + * conversations, sessions) to a specific end user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listAgentConversations(Integer limit, PageOrder order, String after, String before, + String agentName, String agentId, String userIsolationKey) { + // Generated convenience method for listAgentConversations + RequestOptions requestOptions = new RequestOptions(); + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + if (agentName != null) { + requestOptions.addQueryParam("agent_name", agentName, false); + } + if (agentId != null) { + requestOptions.addQueryParam("agent_id", agentId, false); + } + if (userIsolationKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-user-isolation-key"), userIsolationKey); + } + PagedFlux pagedFluxResponse = listAgentConversations(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux > flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase (pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(Conversation.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Returns the list of all conversations. + * + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the + * default is 20. + * @param order Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` + * for descending order. + * @param after A cursor for use in pagination. `after` is an object ID that defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include after=obj_foo in order to fetch the next page of the list. + * @param before A cursor for use in pagination. `before` is an object ID that defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include before=obj_foo in order to fetch the previous page of the list. + * @param agentName Filter by agent name. If provided, only items associated with the specified agent will be + * returned. + * @param agentId Filter by agent ID in the format `name:version`. If provided, only items associated with the + * specified agent ID will be returned. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listAgentConversations(Integer limit, PageOrder order, String after, String before, + String agentName, String agentId) { + // Generated convenience method for listAgentConversations + RequestOptions requestOptions = new RequestOptions(); + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + if (agentName != null) { + requestOptions.addQueryParam("agent_name", agentName, false); + } + if (agentId != null) { + requestOptions.addQueryParam("agent_id", agentId, false); + } + PagedFlux pagedFluxResponse = listAgentConversations(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux > flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase (pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(Conversation.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Creates an agent optimization job. + * + * Create an optimization job. Returns 201 with the queued job. Honours `Operation-Id` for idempotent retry. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "Evaluations=V1Preview", + * "Schedules=V1Preview", "RedTeams=V1Preview", "Insights=V1Preview", "MemoryStores=V1Preview", + * "Routines=V1Preview", "Skills=V1Preview", "DataGenerationJobs=V1Preview", "Models=V1Preview", + * "AgentsOptimization=V1Preview". + * Operation-Id String No Client-generated unique ID for idempotent retries. When + * absent, the server creates the job unconditionally. Request Body Schema
+ * + *+ * {@code + * { + * id: String (Required) + * inputs (Optional): { + * agent (Required): { + * agent_name: String (Required) + * agent_version: String (Optional) + * model: String (Optional) + * system_prompt: String (Optional) + * skills (Optional): [ + * (Optional){ + * name: String (Required) + * description: String (Optional) + * } + * ] + * } + * dataset (Optional): [ + * (Optional){ + * name: String (Required) + * query: String (Required) + * ground_truth: String (Optional) + * criteria (Optional): [ + * (Optional){ + * name: String (Required) + * instruction: String (Required) + * } + * ] + * eval_results (Optional): [ + * (Optional){ + * name: String (Required) + * type: String (Optional) + * score: double (Required) + * passed: boolean (Required) + * sample (Optional): { + * String: BinaryData (Required) + * } + * status: String(completed/errored/skipped) (Optional) + * metric: String (Optional) + * label: String (Optional) + * threshold: Double (Optional) + * reason: String (Optional) + * properties (Optional): { + * String: String (Required) + * } + * (Optional): { + * String: BinaryData (Required) + * } + * } + * ] + * response_items (Optional): [ + * BinaryData (Optional) + * ] + * } + * ] + * train_dataset_reference (Optional): { + * name: String (Required) + * version: String (Optional) + * } + * validation_dataset_reference (Optional): (recursive schema, see validation_dataset_reference above) + * evaluators (Optional): [ + * String (Optional) + * ] + * criteria (Optional): [ + * (recursive schema, see above) + * ] + * options (Optional): { + * strategies (Optional): [ + * String(instruction/model/skill) (Optional) + * ] + * budget: Integer (Optional) + * max_iterations: Integer (Optional) + * tasks_per_iteration: Integer (Optional) + * max_reflection_tasks: Integer (Optional) + * min_improvement: Double (Optional) + * pass_threshold: Double (Optional) + * improvement_threshold: Double (Optional) + * mode: String(optimize) (Optional) + * eval_model: String (Optional) + * reflection_model: String (Optional) + * task_timeout_seconds: Long (Optional) + * keep_versions: Boolean (Optional) + * } + * } + * result (Optional): { + * baseline (Optional): { + * candidate_id: String (Optional) + * name: String (Required) + * config (Required): (recursive schema, see config above) + * mutations (Required): { + * String: BinaryData (Required) + * } + * rationale: String (Required) + * avg_score: double (Required) + * avg_tokens: double (Required) + * pass_rate: double (Required) + * task_scores (Required): [ + * (Required){ + * task_name: String (Required) + * query: String (Optional) + * scores (Required): { + * String: double (Required) + * } + * composite_score: double (Required) + * tokens: int (Required) + * duration_seconds: double (Required) + * passed: boolean (Required) + * error_message: String (Optional) + * rationales (Optional): { + * String: String (Required) + * } + * response: String (Optional) + * run_id: String (Optional) + * } + * ] + * is_pareto_optimal: boolean (Required) + * sample_avg_score: Double (Optional) + * sample_size: Integer (Optional) + * evaluation_type: String (Optional) + * strategy: String(instruction/model/skill) (Optional) + * eval_id: String (Optional) + * eval_run_id: String (Optional) + * } + * best (Optional): (recursive schema, see best above) + * candidates (Optional): [ + * (recursive schema, see above) + * ] + * pareto_frontier (Optional): [ + * (recursive schema, see above) + * ] + * validation_score (Optional): (recursive schema, see validation_score above) + * options (Optional): (recursive schema, see options above) + * sample_size: Integer (Optional) + * warnings (Optional): [ + * String (Optional) + * ] + * all_strategies_failed: Boolean (Optional) + * } + * status: String(queued/in_progress/succeeded/failed/cancelled) (Required) + * error (Optional): { + * code: String (Required) + * message: String (Required) + * param: String (Optional) + * type: String (Optional) + * details (Optional): [ + * (recursive schema, see above) + * ] + * additionalInfo (Optional): { + * String: BinaryData (Required) + * } + * debugInfo (Optional): { + * String: BinaryData (Required) + * } + * } + * created_at: long (Required) + * updated_at: Long (Optional) + * progress (Optional): { + * current_strategy: String(instruction/model/skill) (Required) + * current_iteration: int (Required) + * tasks_completed: int (Required) + * tasks_total: int (Required) + * best_score: double (Required) + * elapsed_seconds: double (Required) + * } + * } + * } + *+ * + *Response Body Schema
+ * + *+ * {@code + * { + * id: String (Required) + * inputs (Optional): { + * agent (Required): { + * agent_name: String (Required) + * agent_version: String (Optional) + * model: String (Optional) + * system_prompt: String (Optional) + * skills (Optional): [ + * (Optional){ + * name: String (Required) + * description: String (Optional) + * } + * ] + * } + * dataset (Optional): [ + * (Optional){ + * name: String (Required) + * query: String (Required) + * ground_truth: String (Optional) + * criteria (Optional): [ + * (Optional){ + * name: String (Required) + * instruction: String (Required) + * } + * ] + * eval_results (Optional): [ + * (Optional){ + * name: String (Required) + * type: String (Optional) + * score: double (Required) + * passed: boolean (Required) + * sample (Optional): { + * String: BinaryData (Required) + * } + * status: String(completed/errored/skipped) (Optional) + * metric: String (Optional) + * label: String (Optional) + * threshold: Double (Optional) + * reason: String (Optional) + * properties (Optional): { + * String: String (Required) + * } + * (Optional): { + * String: BinaryData (Required) + * } + * } + * ] + * response_items (Optional): [ + * BinaryData (Optional) + * ] + * } + * ] + * train_dataset_reference (Optional): { + * name: String (Required) + * version: String (Optional) + * } + * validation_dataset_reference (Optional): (recursive schema, see validation_dataset_reference above) + * evaluators (Optional): [ + * String (Optional) + * ] + * criteria (Optional): [ + * (recursive schema, see above) + * ] + * options (Optional): { + * strategies (Optional): [ + * String(instruction/model/skill) (Optional) + * ] + * budget: Integer (Optional) + * max_iterations: Integer (Optional) + * tasks_per_iteration: Integer (Optional) + * max_reflection_tasks: Integer (Optional) + * min_improvement: Double (Optional) + * pass_threshold: Double (Optional) + * improvement_threshold: Double (Optional) + * mode: String(optimize) (Optional) + * eval_model: String (Optional) + * reflection_model: String (Optional) + * task_timeout_seconds: Long (Optional) + * keep_versions: Boolean (Optional) + * } + * } + * result (Optional): { + * baseline (Optional): { + * candidate_id: String (Optional) + * name: String (Required) + * config (Required): (recursive schema, see config above) + * mutations (Required): { + * String: BinaryData (Required) + * } + * rationale: String (Required) + * avg_score: double (Required) + * avg_tokens: double (Required) + * pass_rate: double (Required) + * task_scores (Required): [ + * (Required){ + * task_name: String (Required) + * query: String (Optional) + * scores (Required): { + * String: double (Required) + * } + * composite_score: double (Required) + * tokens: int (Required) + * duration_seconds: double (Required) + * passed: boolean (Required) + * error_message: String (Optional) + * rationales (Optional): { + * String: String (Required) + * } + * response: String (Optional) + * run_id: String (Optional) + * } + * ] + * is_pareto_optimal: boolean (Required) + * sample_avg_score: Double (Optional) + * sample_size: Integer (Optional) + * evaluation_type: String (Optional) + * strategy: String(instruction/model/skill) (Optional) + * eval_id: String (Optional) + * eval_run_id: String (Optional) + * } + * best (Optional): (recursive schema, see best above) + * candidates (Optional): [ + * (recursive schema, see above) + * ] + * pareto_frontier (Optional): [ + * (recursive schema, see above) + * ] + * validation_score (Optional): (recursive schema, see validation_score above) + * options (Optional): (recursive schema, see options above) + * sample_size: Integer (Optional) + * warnings (Optional): [ + * String (Optional) + * ] + * all_strategies_failed: Boolean (Optional) + * } + * status: String(queued/in_progress/succeeded/failed/cancelled) (Required) + * error (Optional): { + * code: String (Required) + * message: String (Required) + * param: String (Optional) + * type: String (Optional) + * details (Optional): [ + * (recursive schema, see above) + * ] + * additionalInfo (Optional): { + * String: BinaryData (Required) + * } + * debugInfo (Optional): { + * String: BinaryData (Required) + * } + * } + * created_at: long (Required) + * updated_at: Long (Optional) + * progress (Optional): { + * current_strategy: String(instruction/model/skill) (Required) + * current_iteration: int (Required) + * tasks_completed: int (Required) + * tasks_total: int (Required) + * best_score: double (Required) + * elapsed_seconds: double (Required) + * } + * } + * } + *+ * + * @param job The job to create. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return agent optimization job resource — a long-running job that optimizes an agent's configuration + * (instructions, model, skills) to maximize evaluation scores along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createOptimizationJobWithResponse(BinaryData job, RequestOptions requestOptions) { + return this.serviceClient.createOptimizationJobWithResponseAsync(job, requestOptions); + } + + /** + * Get info about an agent optimization job. + * + * Get an optimization job by id. Emits `Retry-After` while the job is non-terminal. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "Evaluations=V1Preview", + * "Schedules=V1Preview", "RedTeams=V1Preview", "Insights=V1Preview", "MemoryStores=V1Preview", + * "Routines=V1Preview", "Skills=V1Preview", "DataGenerationJobs=V1Preview", "Models=V1Preview", + * "AgentsOptimization=V1Preview". Response Body Schema
+ * + *+ * {@code + * { + * id: String (Required) + * inputs (Optional): { + * agent (Required): { + * agent_name: String (Required) + * agent_version: String (Optional) + * model: String (Optional) + * system_prompt: String (Optional) + * skills (Optional): [ + * (Optional){ + * name: String (Required) + * description: String (Optional) + * } + * ] + * } + * dataset (Optional): [ + * (Optional){ + * name: String (Required) + * query: String (Required) + * ground_truth: String (Optional) + * criteria (Optional): [ + * (Optional){ + * name: String (Required) + * instruction: String (Required) + * } + * ] + * eval_results (Optional): [ + * (Optional){ + * name: String (Required) + * type: String (Optional) + * score: double (Required) + * passed: boolean (Required) + * sample (Optional): { + * String: BinaryData (Required) + * } + * status: String(completed/errored/skipped) (Optional) + * metric: String (Optional) + * label: String (Optional) + * threshold: Double (Optional) + * reason: String (Optional) + * properties (Optional): { + * String: String (Required) + * } + * (Optional): { + * String: BinaryData (Required) + * } + * } + * ] + * response_items (Optional): [ + * BinaryData (Optional) + * ] + * } + * ] + * train_dataset_reference (Optional): { + * name: String (Required) + * version: String (Optional) + * } + * validation_dataset_reference (Optional): (recursive schema, see validation_dataset_reference above) + * evaluators (Optional): [ + * String (Optional) + * ] + * criteria (Optional): [ + * (recursive schema, see above) + * ] + * options (Optional): { + * strategies (Optional): [ + * String(instruction/model/skill) (Optional) + * ] + * budget: Integer (Optional) + * max_iterations: Integer (Optional) + * tasks_per_iteration: Integer (Optional) + * max_reflection_tasks: Integer (Optional) + * min_improvement: Double (Optional) + * pass_threshold: Double (Optional) + * improvement_threshold: Double (Optional) + * mode: String(optimize) (Optional) + * eval_model: String (Optional) + * reflection_model: String (Optional) + * task_timeout_seconds: Long (Optional) + * keep_versions: Boolean (Optional) + * } + * } + * result (Optional): { + * baseline (Optional): { + * candidate_id: String (Optional) + * name: String (Required) + * config (Required): (recursive schema, see config above) + * mutations (Required): { + * String: BinaryData (Required) + * } + * rationale: String (Required) + * avg_score: double (Required) + * avg_tokens: double (Required) + * pass_rate: double (Required) + * task_scores (Required): [ + * (Required){ + * task_name: String (Required) + * query: String (Optional) + * scores (Required): { + * String: double (Required) + * } + * composite_score: double (Required) + * tokens: int (Required) + * duration_seconds: double (Required) + * passed: boolean (Required) + * error_message: String (Optional) + * rationales (Optional): { + * String: String (Required) + * } + * response: String (Optional) + * run_id: String (Optional) + * } + * ] + * is_pareto_optimal: boolean (Required) + * sample_avg_score: Double (Optional) + * sample_size: Integer (Optional) + * evaluation_type: String (Optional) + * strategy: String(instruction/model/skill) (Optional) + * eval_id: String (Optional) + * eval_run_id: String (Optional) + * } + * best (Optional): (recursive schema, see best above) + * candidates (Optional): [ + * (recursive schema, see above) + * ] + * pareto_frontier (Optional): [ + * (recursive schema, see above) + * ] + * validation_score (Optional): (recursive schema, see validation_score above) + * options (Optional): (recursive schema, see options above) + * sample_size: Integer (Optional) + * warnings (Optional): [ + * String (Optional) + * ] + * all_strategies_failed: Boolean (Optional) + * } + * status: String(queued/in_progress/succeeded/failed/cancelled) (Required) + * error (Optional): { + * code: String (Required) + * message: String (Required) + * param: String (Optional) + * type: String (Optional) + * details (Optional): [ + * (recursive schema, see above) + * ] + * additionalInfo (Optional): { + * String: BinaryData (Required) + * } + * debugInfo (Optional): { + * String: BinaryData (Required) + * } + * } + * created_at: long (Required) + * updated_at: Long (Optional) + * progress (Optional): { + * current_strategy: String(instruction/model/skill) (Required) + * current_iteration: int (Required) + * tasks_completed: int (Required) + * tasks_total: int (Required) + * best_score: double (Required) + * elapsed_seconds: double (Required) + * } + * } + * } + *+ * + * @param jobId The ID of the job. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return info about an agent optimization job. + * + * Get an optimization job by id along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getOptimizationJobWithResponse(String jobId, RequestOptions requestOptions) { + return this.serviceClient.getOptimizationJobWithResponseAsync(jobId, requestOptions); + } + + /** + * Returns a list of agent optimization jobs. + * + * List optimization jobs. Supports cursor pagination and optional `status` / `agent_name` filters. + * Query Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *Query Parameters + *+ * Name Type Required Description + * limit Integer No A limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the + * default is 20. + * order String No Sort order by the `created_at` timestamp of the objects. `asc` + * for ascending order and`desc` + * for descending order. Allowed values: "asc", "desc". + * after String No A cursor for use in pagination. `after` is an object ID that + * defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include after=obj_foo in order to fetch the next page of the list. + * before String No A cursor for use in pagination. `before` is an object ID that + * defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include before=obj_foo in order to fetch the previous page of the list. + * status String No Filter to jobs in this lifecycle state. Allowed values: + * "queued", "in_progress", "succeeded", "failed", "cancelled". + * agent_name String No Filter to jobs targeting this agent name. Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "Evaluations=V1Preview", + * "Schedules=V1Preview", "RedTeams=V1Preview", "Insights=V1Preview", "MemoryStores=V1Preview", + * "Routines=V1Preview", "Skills=V1Preview", "DataGenerationJobs=V1Preview", "Models=V1Preview", + * "AgentsOptimization=V1Preview". Response Body Schema
+ * + *+ * {@code + * { + * id: String (Required) + * inputs (Optional): { + * agent (Required): { + * agent_name: String (Required) + * agent_version: String (Optional) + * model: String (Optional) + * system_prompt: String (Optional) + * skills (Optional): [ + * (Optional){ + * name: String (Required) + * description: String (Optional) + * } + * ] + * } + * dataset (Optional): [ + * (Optional){ + * name: String (Required) + * query: String (Required) + * ground_truth: String (Optional) + * criteria (Optional): [ + * (Optional){ + * name: String (Required) + * instruction: String (Required) + * } + * ] + * eval_results (Optional): [ + * (Optional){ + * name: String (Required) + * type: String (Optional) + * score: double (Required) + * passed: boolean (Required) + * sample (Optional): { + * String: BinaryData (Required) + * } + * status: String(completed/errored/skipped) (Optional) + * metric: String (Optional) + * label: String (Optional) + * threshold: Double (Optional) + * reason: String (Optional) + * properties (Optional): { + * String: String (Required) + * } + * (Optional): { + * String: BinaryData (Required) + * } + * } + * ] + * response_items (Optional): [ + * BinaryData (Optional) + * ] + * } + * ] + * train_dataset_reference (Optional): { + * name: String (Required) + * version: String (Optional) + * } + * validation_dataset_reference (Optional): (recursive schema, see validation_dataset_reference above) + * evaluators (Optional): [ + * String (Optional) + * ] + * criteria (Optional): [ + * (recursive schema, see above) + * ] + * options (Optional): { + * strategies (Optional): [ + * String(instruction/model/skill) (Optional) + * ] + * budget: Integer (Optional) + * max_iterations: Integer (Optional) + * tasks_per_iteration: Integer (Optional) + * max_reflection_tasks: Integer (Optional) + * min_improvement: Double (Optional) + * pass_threshold: Double (Optional) + * improvement_threshold: Double (Optional) + * mode: String(optimize) (Optional) + * eval_model: String (Optional) + * reflection_model: String (Optional) + * task_timeout_seconds: Long (Optional) + * keep_versions: Boolean (Optional) + * } + * } + * result (Optional): { + * baseline (Optional): { + * candidate_id: String (Optional) + * name: String (Required) + * config (Required): (recursive schema, see config above) + * mutations (Required): { + * String: BinaryData (Required) + * } + * rationale: String (Required) + * avg_score: double (Required) + * avg_tokens: double (Required) + * pass_rate: double (Required) + * task_scores (Required): [ + * (Required){ + * task_name: String (Required) + * query: String (Optional) + * scores (Required): { + * String: double (Required) + * } + * composite_score: double (Required) + * tokens: int (Required) + * duration_seconds: double (Required) + * passed: boolean (Required) + * error_message: String (Optional) + * rationales (Optional): { + * String: String (Required) + * } + * response: String (Optional) + * run_id: String (Optional) + * } + * ] + * is_pareto_optimal: boolean (Required) + * sample_avg_score: Double (Optional) + * sample_size: Integer (Optional) + * evaluation_type: String (Optional) + * strategy: String(instruction/model/skill) (Optional) + * eval_id: String (Optional) + * eval_run_id: String (Optional) + * } + * best (Optional): (recursive schema, see best above) + * candidates (Optional): [ + * (recursive schema, see above) + * ] + * pareto_frontier (Optional): [ + * (recursive schema, see above) + * ] + * validation_score (Optional): (recursive schema, see validation_score above) + * options (Optional): (recursive schema, see options above) + * sample_size: Integer (Optional) + * warnings (Optional): [ + * String (Optional) + * ] + * all_strategies_failed: Boolean (Optional) + * } + * status: String(queued/in_progress/succeeded/failed/cancelled) (Required) + * error (Optional): { + * code: String (Required) + * message: String (Required) + * param: String (Optional) + * type: String (Optional) + * details (Optional): [ + * (recursive schema, see above) + * ] + * additionalInfo (Optional): { + * String: BinaryData (Required) + * } + * debugInfo (Optional): { + * String: BinaryData (Required) + * } + * } + * created_at: long (Required) + * updated_at: Long (Optional) + * progress (Optional): { + * current_strategy: String(instruction/model/skill) (Required) + * current_iteration: int (Required) + * tasks_completed: int (Required) + * tasks_total: int (Required) + * best_score: double (Required) + * elapsed_seconds: double (Required) + * } + * } + * } + *+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFluxlistOptimizationJobs(RequestOptions requestOptions) { + return this.serviceClient.listOptimizationJobsAsync(requestOptions); + } + + /** + * Cancels an agent optimization job. + * + * Request cancellation. Idempotent on terminal states. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "Evaluations=V1Preview", + * "Schedules=V1Preview", "RedTeams=V1Preview", "Insights=V1Preview", "MemoryStores=V1Preview", + * "Routines=V1Preview", "Skills=V1Preview", "DataGenerationJobs=V1Preview", "Models=V1Preview", + * "AgentsOptimization=V1Preview". Response Body Schema
+ * + *+ * {@code + * { + * id: String (Required) + * inputs (Optional): { + * agent (Required): { + * agent_name: String (Required) + * agent_version: String (Optional) + * model: String (Optional) + * system_prompt: String (Optional) + * skills (Optional): [ + * (Optional){ + * name: String (Required) + * description: String (Optional) + * } + * ] + * } + * dataset (Optional): [ + * (Optional){ + * name: String (Required) + * query: String (Required) + * ground_truth: String (Optional) + * criteria (Optional): [ + * (Optional){ + * name: String (Required) + * instruction: String (Required) + * } + * ] + * eval_results (Optional): [ + * (Optional){ + * name: String (Required) + * type: String (Optional) + * score: double (Required) + * passed: boolean (Required) + * sample (Optional): { + * String: BinaryData (Required) + * } + * status: String(completed/errored/skipped) (Optional) + * metric: String (Optional) + * label: String (Optional) + * threshold: Double (Optional) + * reason: String (Optional) + * properties (Optional): { + * String: String (Required) + * } + * (Optional): { + * String: BinaryData (Required) + * } + * } + * ] + * response_items (Optional): [ + * BinaryData (Optional) + * ] + * } + * ] + * train_dataset_reference (Optional): { + * name: String (Required) + * version: String (Optional) + * } + * validation_dataset_reference (Optional): (recursive schema, see validation_dataset_reference above) + * evaluators (Optional): [ + * String (Optional) + * ] + * criteria (Optional): [ + * (recursive schema, see above) + * ] + * options (Optional): { + * strategies (Optional): [ + * String(instruction/model/skill) (Optional) + * ] + * budget: Integer (Optional) + * max_iterations: Integer (Optional) + * tasks_per_iteration: Integer (Optional) + * max_reflection_tasks: Integer (Optional) + * min_improvement: Double (Optional) + * pass_threshold: Double (Optional) + * improvement_threshold: Double (Optional) + * mode: String(optimize) (Optional) + * eval_model: String (Optional) + * reflection_model: String (Optional) + * task_timeout_seconds: Long (Optional) + * keep_versions: Boolean (Optional) + * } + * } + * result (Optional): { + * baseline (Optional): { + * candidate_id: String (Optional) + * name: String (Required) + * config (Required): (recursive schema, see config above) + * mutations (Required): { + * String: BinaryData (Required) + * } + * rationale: String (Required) + * avg_score: double (Required) + * avg_tokens: double (Required) + * pass_rate: double (Required) + * task_scores (Required): [ + * (Required){ + * task_name: String (Required) + * query: String (Optional) + * scores (Required): { + * String: double (Required) + * } + * composite_score: double (Required) + * tokens: int (Required) + * duration_seconds: double (Required) + * passed: boolean (Required) + * error_message: String (Optional) + * rationales (Optional): { + * String: String (Required) + * } + * response: String (Optional) + * run_id: String (Optional) + * } + * ] + * is_pareto_optimal: boolean (Required) + * sample_avg_score: Double (Optional) + * sample_size: Integer (Optional) + * evaluation_type: String (Optional) + * strategy: String(instruction/model/skill) (Optional) + * eval_id: String (Optional) + * eval_run_id: String (Optional) + * } + * best (Optional): (recursive schema, see best above) + * candidates (Optional): [ + * (recursive schema, see above) + * ] + * pareto_frontier (Optional): [ + * (recursive schema, see above) + * ] + * validation_score (Optional): (recursive schema, see validation_score above) + * options (Optional): (recursive schema, see options above) + * sample_size: Integer (Optional) + * warnings (Optional): [ + * String (Optional) + * ] + * all_strategies_failed: Boolean (Optional) + * } + * status: String(queued/in_progress/succeeded/failed/cancelled) (Required) + * error (Optional): { + * code: String (Required) + * message: String (Required) + * param: String (Optional) + * type: String (Optional) + * details (Optional): [ + * (recursive schema, see above) + * ] + * additionalInfo (Optional): { + * String: BinaryData (Required) + * } + * debugInfo (Optional): { + * String: BinaryData (Required) + * } + * } + * created_at: long (Required) + * updated_at: Long (Optional) + * progress (Optional): { + * current_strategy: String(instruction/model/skill) (Required) + * current_iteration: int (Required) + * tasks_completed: int (Required) + * tasks_total: int (Required) + * best_score: double (Required) + * elapsed_seconds: double (Required) + * } + * } + * } + *+ * + * @param jobId The ID of the job to cancel. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return agent optimization job resource — a long-running job that optimizes an agent's configuration + * (instructions, model, skills) to maximize evaluation scores along with {@link Response} on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> cancelOptimizationJobWithResponse(String jobId, RequestOptions requestOptions) { + return this.serviceClient.cancelOptimizationJobWithResponseAsync(jobId, requestOptions); + } + + /** + * Deletes an agent optimization job. + * + * Delete the job and its candidate artifacts. Cancels first if non-terminal. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param jobId The ID of the job to delete. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public MonoHeader Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "Evaluations=V1Preview", + * "Schedules=V1Preview", "RedTeams=V1Preview", "Insights=V1Preview", "MemoryStores=V1Preview", + * "Routines=V1Preview", "Skills=V1Preview", "DataGenerationJobs=V1Preview", "Models=V1Preview", + * "AgentsOptimization=V1Preview". > deleteOptimizationJobWithResponse(String jobId, RequestOptions requestOptions) { + return this.serviceClient.deleteOptimizationJobWithResponseAsync(jobId, requestOptions); + } + + /** + * Returns a list of candidates for an optimization job. + * + * List candidates produced by a job. + * Query Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *Query Parameters + *+ * Name Type Required Description + * limit Integer No A limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the + * default is 20. + * order String No Sort order by the `created_at` timestamp of the objects. `asc` + * for ascending order and`desc` + * for descending order. Allowed values: "asc", "desc". + * after String No A cursor for use in pagination. `after` is an object ID that + * defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include after=obj_foo in order to fetch the next page of the list. + * before String No A cursor for use in pagination. `before` is an object ID that + * defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include before=obj_foo in order to fetch the previous page of the list. Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "Evaluations=V1Preview", + * "Schedules=V1Preview", "RedTeams=V1Preview", "Insights=V1Preview", "MemoryStores=V1Preview", + * "Routines=V1Preview", "Skills=V1Preview", "DataGenerationJobs=V1Preview", "Models=V1Preview", + * "AgentsOptimization=V1Preview". Response Body Schema
+ * + *+ * {@code + * { + * data (Required): [ + * (Required){ + * candidate_id: String (Optional) + * name: String (Required) + * config (Required): { + * agent_name: String (Required) + * agent_version: String (Optional) + * model: String (Optional) + * system_prompt: String (Optional) + * skills (Optional): [ + * (Optional){ + * name: String (Required) + * description: String (Optional) + * } + * ] + * } + * mutations (Required): { + * String: BinaryData (Required) + * } + * rationale: String (Required) + * avg_score: double (Required) + * avg_tokens: double (Required) + * pass_rate: double (Required) + * task_scores (Required): [ + * (Required){ + * task_name: String (Required) + * query: String (Optional) + * scores (Required): { + * String: double (Required) + * } + * composite_score: double (Required) + * tokens: int (Required) + * duration_seconds: double (Required) + * passed: boolean (Required) + * error_message: String (Optional) + * rationales (Optional): { + * String: String (Required) + * } + * response: String (Optional) + * run_id: String (Optional) + * } + * ] + * is_pareto_optimal: boolean (Required) + * sample_avg_score: Double (Optional) + * sample_size: Integer (Optional) + * evaluation_type: String (Optional) + * strategy: String(instruction/model/skill) (Optional) + * eval_id: String (Optional) + * eval_run_id: String (Optional) + * } + * ] + * first_id: String (Optional) + * last_id: String (Optional) + * has_more: boolean (Required) + * } + * } + *+ * + * @param jobId The optimization job id. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> listOptimizationCandidatesWithResponse(String jobId, + RequestOptions requestOptions) { + return this.serviceClient.listOptimizationCandidatesWithResponseAsync(jobId, requestOptions); + } + + /** + * Get a candidate by id. + * + * Get a single candidate manifest and aggregated evaluation summary. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "Evaluations=V1Preview", + * "Schedules=V1Preview", "RedTeams=V1Preview", "Insights=V1Preview", "MemoryStores=V1Preview", + * "Routines=V1Preview", "Skills=V1Preview", "DataGenerationJobs=V1Preview", "Models=V1Preview", + * "AgentsOptimization=V1Preview". Response Body Schema
+ * + *+ * {@code + * { + * candidate_id: String (Optional) + * name: String (Required) + * config (Required): { + * agent_name: String (Required) + * agent_version: String (Optional) + * model: String (Optional) + * system_prompt: String (Optional) + * skills (Optional): [ + * (Optional){ + * name: String (Required) + * description: String (Optional) + * } + * ] + * } + * mutations (Required): { + * String: BinaryData (Required) + * } + * rationale: String (Required) + * avg_score: double (Required) + * avg_tokens: double (Required) + * pass_rate: double (Required) + * task_scores (Required): [ + * (Required){ + * task_name: String (Required) + * query: String (Optional) + * scores (Required): { + * String: double (Required) + * } + * composite_score: double (Required) + * tokens: int (Required) + * duration_seconds: double (Required) + * passed: boolean (Required) + * error_message: String (Optional) + * rationales (Optional): { + * String: String (Required) + * } + * response: String (Optional) + * run_id: String (Optional) + * } + * ] + * is_pareto_optimal: boolean (Required) + * sample_avg_score: Double (Optional) + * sample_size: Integer (Optional) + * evaluation_type: String (Optional) + * strategy: String(instruction/model/skill) (Optional) + * eval_id: String (Optional) + * eval_run_id: String (Optional) + * } + * } + *+ * + * @param jobId The optimization job id. + * @param candidateId The candidate id. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a candidate by id. + * + * Get a single candidate manifest and aggregated evaluation summary along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getOptimizationCandidateWithResponse(String jobId, String candidateId, + RequestOptions requestOptions) { + return this.serviceClient.getOptimizationCandidateWithResponseAsync(jobId, candidateId, requestOptions); + } + + /** + * Get candidate deploy config. + * + * Get the candidate's deploy config JSON. Used to compose `agents.create_version(...)` from a candidate. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "Evaluations=V1Preview", + * "Schedules=V1Preview", "RedTeams=V1Preview", "Insights=V1Preview", "MemoryStores=V1Preview", + * "Routines=V1Preview", "Skills=V1Preview", "DataGenerationJobs=V1Preview", "Models=V1Preview", + * "AgentsOptimization=V1Preview". Response Body Schema
+ * + *+ * {@code + * { + * instructions: String (Optional) + * model: String (Optional) + * temperature: Double (Optional) + * skills (Optional): [ + * (Optional){ + * name: String (Required) + * description: String (Optional) + * } + * ] + * } + * } + *+ * + * @param jobId The optimization job id. + * @param candidateId The candidate id. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return candidate deploy config. + * + * Get the candidate's deploy config JSON along with {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getOptimizationCandidateConfigWithResponse(String jobId, String candidateId, + RequestOptions requestOptions) { + return this.serviceClient.getOptimizationCandidateConfigWithResponseAsync(jobId, candidateId, requestOptions); + } + + /** + * Get candidate evaluation results. + * + * Get full per-task evaluation results for a candidate. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "Evaluations=V1Preview", + * "Schedules=V1Preview", "RedTeams=V1Preview", "Insights=V1Preview", "MemoryStores=V1Preview", + * "Routines=V1Preview", "Skills=V1Preview", "DataGenerationJobs=V1Preview", "Models=V1Preview", + * "AgentsOptimization=V1Preview". Response Body Schema
+ * + *+ * {@code + * { + * candidate_id: String (Required) + * results (Required): [ + * (Required){ + * task_name: String (Required) + * query: String (Optional) + * scores (Required): { + * String: double (Required) + * } + * composite_score: double (Required) + * tokens: int (Required) + * duration_seconds: double (Required) + * passed: boolean (Required) + * error_message: String (Optional) + * rationales (Optional): { + * String: String (Required) + * } + * response: String (Optional) + * run_id: String (Optional) + * } + * ] + * } + * } + *+ * + * @param jobId The optimization job id. + * @param candidateId The candidate id. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return candidate evaluation results. + * + * Get full per-task evaluation results for a candidate along with {@link Response} on successful completion of + * {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getOptimizationCandidateResultsWithResponse(String jobId, String candidateId, + RequestOptions requestOptions) { + return this.serviceClient.getOptimizationCandidateResultsWithResponseAsync(jobId, candidateId, requestOptions); + } + + /** + * Creates an agent optimization job. + * + * Create an optimization job. Returns 201 with the queued job. Honours `Operation-Id` for idempotent retry. + * + * @param job The job to create. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @param operationId Client-generated unique ID for idempotent retries. When absent, the server creates the job + * unconditionally. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return agent optimization job resource — a long-running job that optimizes an agent's configuration + * (instructions, model, skills) to maximize evaluation scores on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createOptimizationJob(OptimizationJob job, FoundryFeaturesOptInKeys foundryFeatures, + String operationId) { + // Generated convenience method for createOptimizationJobWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + if (operationId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Operation-Id"), operationId); + } + return createOptimizationJobWithResponse(BinaryData.fromObject(job), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(OptimizationJob.class)); + } + + /** + * Creates an agent optimization job. + * + * Create an optimization job. Returns 201 with the queued job. Honours `Operation-Id` for idempotent retry. + * + * @param job The job to create. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return agent optimization job resource — a long-running job that optimizes an agent's configuration + * (instructions, model, skills) to maximize evaluation scores on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createOptimizationJob(OptimizationJob job) { + // Generated convenience method for createOptimizationJobWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createOptimizationJobWithResponse(BinaryData.fromObject(job), requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(OptimizationJob.class)); + } + + /** + * Get info about an agent optimization job. + * + * Get an optimization job by id. Emits `Retry-After` while the job is non-terminal. + * + * @param jobId The ID of the job. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return info about an agent optimization job. + * + * Get an optimization job by id on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getOptimizationJob(String jobId, FoundryFeaturesOptInKeys foundryFeatures) { + // Generated convenience method for getOptimizationJobWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + return getOptimizationJobWithResponse(jobId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(OptimizationJob.class)); + } + + /** + * Get info about an agent optimization job. + * + * Get an optimization job by id. Emits `Retry-After` while the job is non-terminal. + * + * @param jobId The ID of the job. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return info about an agent optimization job. + * + * Get an optimization job by id on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getOptimizationJob(String jobId) { + // Generated convenience method for getOptimizationJobWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getOptimizationJobWithResponse(jobId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(OptimizationJob.class)); + } + + /** + * Returns a list of agent optimization jobs. + * + * List optimization jobs. Supports cursor pagination and optional `status` / `agent_name` filters. + * + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the + * default is 20. + * @param order Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` + * for descending order. + * @param after A cursor for use in pagination. `after` is an object ID that defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include after=obj_foo in order to fetch the next page of the list. + * @param before A cursor for use in pagination. `before` is an object ID that defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include before=obj_foo in order to fetch the previous page of the list. + * @param status Filter to jobs in this lifecycle state. + * @param agentName Filter to jobs targeting this agent name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listOptimizationJobs(FoundryFeaturesOptInKeys foundryFeatures, Integer limit, + PageOrder order, String after, String before, JobStatus status, String agentName) { + // Generated convenience method for listOptimizationJobs + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + if (status != null) { + requestOptions.addQueryParam("status", status.toString(), false); + } + if (agentName != null) { + requestOptions.addQueryParam("agent_name", agentName, false); + } + PagedFlux pagedFluxResponse = listOptimizationJobs(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux > flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase (pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(OptimizationJob.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Returns a list of agent optimization jobs. + * + * List optimization jobs. Supports cursor pagination and optional `status` / `agent_name` filters. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listOptimizationJobs() { + // Generated convenience method for listOptimizationJobs + RequestOptions requestOptions = new RequestOptions(); + PagedFlux pagedFluxResponse = listOptimizationJobs(requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux > flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase (pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(OptimizationJob.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } + + /** + * Cancels an agent optimization job. + * + * Request cancellation. Idempotent on terminal states. + * + * @param jobId The ID of the job to cancel. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return agent optimization job resource — a long-running job that optimizes an agent's configuration + * (instructions, model, skills) to maximize evaluation scores on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono cancelOptimizationJob(String jobId, FoundryFeaturesOptInKeys foundryFeatures) { + // Generated convenience method for cancelOptimizationJobWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + return cancelOptimizationJobWithResponse(jobId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(OptimizationJob.class)); + } + + /** + * Cancels an agent optimization job. + * + * Request cancellation. Idempotent on terminal states. + * + * @param jobId The ID of the job to cancel. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return agent optimization job resource — a long-running job that optimizes an agent's configuration + * (instructions, model, skills) to maximize evaluation scores on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono cancelOptimizationJob(String jobId) { + // Generated convenience method for cancelOptimizationJobWithResponse + RequestOptions requestOptions = new RequestOptions(); + return cancelOptimizationJobWithResponse(jobId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(OptimizationJob.class)); + } + + /** + * Deletes an agent optimization job. + * + * Delete the job and its candidate artifacts. Cancels first if non-terminal. + * + * @param jobId The ID of the job to delete. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteOptimizationJob(String jobId, FoundryFeaturesOptInKeys foundryFeatures) { + // Generated convenience method for deleteOptimizationJobWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + return deleteOptimizationJobWithResponse(jobId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Deletes an agent optimization job. + * + * Delete the job and its candidate artifacts. Cancels first if non-terminal. + * + * @param jobId The ID of the job to delete. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return A {@link Mono} that completes when a successful response is received. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteOptimizationJob(String jobId) { + // Generated convenience method for deleteOptimizationJobWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteOptimizationJobWithResponse(jobId, requestOptions).flatMap(FluxUtil::toMono); + } + + /** + * Returns a list of candidates for an optimization job. + * + * List candidates produced by a job. + * + * @param jobId The optimization job id. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the + * default is 20. + * @param order Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` + * for descending order. + * @param after A cursor for use in pagination. `after` is an object ID that defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include after=obj_foo in order to fetch the next page of the list. + * @param before A cursor for use in pagination. `before` is an object ID that defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include before=obj_foo in order to fetch the previous page of the list. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono listOptimizationCandidates(String jobId, + FoundryFeaturesOptInKeys foundryFeatures, Integer limit, PageOrder order, String after, String before) { + // Generated convenience method for listOptimizationCandidatesWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + return listOptimizationCandidatesWithResponse(jobId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AgentsPagedResultOptimizationCandidate.class)); + } + + /** + * Returns a list of candidates for an optimization job. + * + * List candidates produced by a job. + * + * @param jobId The optimization job id. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono listOptimizationCandidates(String jobId) { + // Generated convenience method for listOptimizationCandidatesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return listOptimizationCandidatesWithResponse(jobId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(AgentsPagedResultOptimizationCandidate.class)); + } + + /** + * Get a candidate by id. + * + * Get a single candidate manifest and aggregated evaluation summary. + * + * @param jobId The optimization job id. + * @param candidateId The candidate id. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a candidate by id. + * + * Get a single candidate manifest and aggregated evaluation summary on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getOptimizationCandidate(String jobId, String candidateId, + FoundryFeaturesOptInKeys foundryFeatures) { + // Generated convenience method for getOptimizationCandidateWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + return getOptimizationCandidateWithResponse(jobId, candidateId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(OptimizationCandidate.class)); + } + + /** + * Get a candidate by id. + * + * Get a single candidate manifest and aggregated evaluation summary. + * + * @param jobId The optimization job id. + * @param candidateId The candidate id. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a candidate by id. + * + * Get a single candidate manifest and aggregated evaluation summary on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getOptimizationCandidate(String jobId, String candidateId) { + // Generated convenience method for getOptimizationCandidateWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getOptimizationCandidateWithResponse(jobId, candidateId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(OptimizationCandidate.class)); + } + + /** + * Get candidate deploy config. + * + * Get the candidate's deploy config JSON. Used to compose `agents.create_version(...)` from a candidate. + * + * @param jobId The optimization job id. + * @param candidateId The candidate id. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return candidate deploy config. + * + * Get the candidate's deploy config JSON on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getOptimizationCandidateConfig(String jobId, String candidateId, + FoundryFeaturesOptInKeys foundryFeatures) { + // Generated convenience method for getOptimizationCandidateConfigWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + return getOptimizationCandidateConfigWithResponse(jobId, candidateId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CandidateDeployConfig.class)); + } + + /** + * Get candidate deploy config. + * + * Get the candidate's deploy config JSON. Used to compose `agents.create_version(...)` from a candidate. + * + * @param jobId The optimization job id. + * @param candidateId The candidate id. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return candidate deploy config. + * + * Get the candidate's deploy config JSON on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getOptimizationCandidateConfig(String jobId, String candidateId) { + // Generated convenience method for getOptimizationCandidateConfigWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getOptimizationCandidateConfigWithResponse(jobId, candidateId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CandidateDeployConfig.class)); + } + + /** + * Get candidate evaluation results. + * + * Get full per-task evaluation results for a candidate. + * + * @param jobId The optimization job id. + * @param candidateId The candidate id. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return candidate evaluation results. + * + * Get full per-task evaluation results for a candidate on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getOptimizationCandidateResults(String jobId, String candidateId, + FoundryFeaturesOptInKeys foundryFeatures) { + // Generated convenience method for getOptimizationCandidateResultsWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + return getOptimizationCandidateResultsWithResponse(jobId, candidateId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CandidateResults.class)); + } + + /** + * Get candidate evaluation results. + * + * Get full per-task evaluation results for a candidate. + * + * @param jobId The optimization job id. + * @param candidateId The candidate id. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return candidate evaluation results. + * + * Get full per-task evaluation results for a candidate on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getOptimizationCandidateResults(String jobId, String candidateId) { + // Generated convenience method for getOptimizationCandidateResultsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getOptimizationCandidateResultsWithResponse(jobId, candidateId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(CandidateResults.class)); + } } diff --git a/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/AgentsClient.java b/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/AgentsClient.java index 2013e3c9c1ca..e6788a407c72 100644 --- a/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/AgentsClient.java +++ b/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/AgentsClient.java @@ -5,7 +5,9 @@ import com.azure.ai.agents.implementation.AgentsImpl; import com.azure.ai.agents.implementation.JsonMergePatchHelper; +import com.azure.ai.agents.implementation.MultipartFormDataHelper; import com.azure.ai.agents.implementation.SessionLogStreamHelper; +import com.azure.ai.agents.implementation.models.CreateAgentFromCodeContent; import com.azure.ai.agents.implementation.models.CreateAgentFromManifestRequest; import com.azure.ai.agents.implementation.models.CreateAgentOptions; import com.azure.ai.agents.implementation.models.CreateAgentRequest; @@ -21,7 +23,16 @@ import com.azure.ai.agents.models.AgentKind; import com.azure.ai.agents.models.AgentSessionResource; import com.azure.ai.agents.models.AgentVersionDetails; +import com.azure.ai.agents.models.AgentsPagedResultOptimizationCandidate; +import com.azure.ai.agents.models.CandidateDeployConfig; +import com.azure.ai.agents.models.CandidateResults; +import com.azure.ai.agents.models.CreateAgentFromCodeContent; +import com.azure.ai.agents.models.CreateAgentVersionFromCodeContent; import com.azure.ai.agents.models.CreateAgentVersionInput; +import com.azure.ai.agents.models.FoundryFeaturesOptInKeys; +import com.azure.ai.agents.models.JobStatus; +import com.azure.ai.agents.models.OptimizationCandidate; +import com.azure.ai.agents.models.OptimizationJob; import com.azure.ai.agents.models.PageOrder; import com.azure.ai.agents.models.SessionLogEvent; import com.azure.ai.agents.models.UpdateAgentDetailsOptions; @@ -75,11 +86,12 @@ public final class AgentsClient { * description: String (Optional) * created_at: long (Required) * definition (Required): { - * kind: String(prompt/hosted/workflow) (Required) + * kind: String(prompt/hosted/workflow/external) (Required) * rai_config (Optional): { * rai_policy_name: String (Required) * } * } + * status: String(creating/active/failed/deleting/deleted) (Optional) * instance_identity (Optional): { * principal_id: String (Required) * client_id: String (Required) @@ -101,7 +113,7 @@ public final class AgentsClient { * ] * } * protocols (Optional): [ - * String(activity/responses/a2a/invocations) (Optional) + * String(activity/responses/a2a/mcp/invocations) (Optional) * ] * authorization_schemes (Optional): [ * (Optional){ @@ -155,7 +167,8 @@ public Response getAgentWithResponse(String agentName, RequestOption * * Name Type Required Description + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". * * You can add these to a request with {@link RequestOptions#addHeader} * Foundry-Features String No A feature flag opt-in required when using preview * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", - * "WorkflowAgents=V1Preview", "ContainerAgents=V1Preview", "AgentEndpoints=V1Preview". Request Body Schema
@@ -168,7 +181,7 @@ public ResponsegetAgentWithResponse(String agentName, RequestOption * } * description: String (Optional) * definition (Required): { - * kind: String(prompt/hosted/workflow) (Required) + * kind: String(prompt/hosted/workflow/external) (Required) * rai_config (Optional): { * rai_policy_name: String (Required) * } @@ -195,11 +208,12 @@ public Response getAgentWithResponse(String agentName, RequestOption * description: String (Optional) * created_at: long (Required) * definition (Required): { - * kind: String(prompt/hosted/workflow) (Required) + * kind: String(prompt/hosted/workflow/external) (Required) * rai_config (Optional): { * rai_policy_name: String (Required) * } * } + * status: String(creating/active/failed/deleting/deleted) (Optional) * instance_identity (Optional): { * principal_id: String (Required) * client_id: String (Required) @@ -317,11 +331,12 @@ public void deleteAgentVersion(String agentName, String agentVersion) { * description: String (Optional) * created_at: long (Required) * definition (Required): { - * kind: String(prompt/hosted/workflow) (Required) + * kind: String(prompt/hosted/workflow/external) (Required) * rai_config (Optional): { * rai_policy_name: String (Required) * } * } + * status: String(creating/active/failed/deleting/deleted) (Optional) * instance_identity (Optional): { * principal_id: String (Required) * client_id: String (Required) @@ -444,7 +459,8 @@ public AgentVersionDetails createAgentVersion(String agentName, AgentDefinition * * Name Type Required Description + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". * * You can add these to a request with {@link RequestOptions#addHeader} * Foundry-Features String No A feature flag opt-in required when using preview * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", - * "WorkflowAgents=V1Preview", "ContainerAgents=V1Preview", "AgentEndpoints=V1Preview". Request Body Schema
@@ -458,7 +474,7 @@ public AgentVersionDetails createAgentVersion(String agentName, AgentDefinition * } * description: String (Optional) * definition (Required): { - * kind: String(prompt/hosted/workflow) (Required) + * kind: String(prompt/hosted/workflow/external) (Required) * rai_config (Optional): { * rai_policy_name: String (Required) * } @@ -476,7 +492,7 @@ public AgentVersionDetails createAgentVersion(String agentName, AgentDefinition * ] * } * protocols (Optional): [ - * String(activity/responses/a2a/invocations) (Optional) + * String(activity/responses/a2a/mcp/invocations) (Optional) * ] * authorization_schemes (Optional): [ * (Optional){ @@ -525,11 +541,12 @@ public AgentVersionDetails createAgentVersion(String agentName, AgentDefinition * description: String (Optional) * created_at: long (Required) * definition (Required): { - * kind: String(prompt/hosted/workflow) (Required) + * kind: String(prompt/hosted/workflow/external) (Required) * rai_config (Optional): { * rai_policy_name: String (Required) * } * } + * status: String(creating/active/failed/deleting/deleted) (Optional) * instance_identity (Optional): { * principal_id: String (Required) * client_id: String (Required) @@ -551,7 +568,7 @@ public AgentVersionDetails createAgentVersion(String agentName, AgentDefinition * ] * } * protocols (Optional): [ - * String(activity/responses/a2a/invocations) (Optional) + * String(activity/responses/a2a/mcp/invocations) (Optional) * ] * authorization_schemes (Optional): [ * (Optional){ @@ -606,7 +623,8 @@ ResponsecreateAgentWithResponse(BinaryData createAgentRequest, Requ * * Name Type Required Description + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". * * You can add these to a request with {@link RequestOptions#addHeader} * Foundry-Features String No A feature flag opt-in required when using preview * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", - * "WorkflowAgents=V1Preview", "ContainerAgents=V1Preview", "AgentEndpoints=V1Preview". Request Body Schema
@@ -619,7 +637,7 @@ ResponsecreateAgentWithResponse(BinaryData createAgentRequest, Requ * } * description: String (Optional) * definition (Required): { - * kind: String(prompt/hosted/workflow) (Required) + * kind: String(prompt/hosted/workflow/external) (Required) * rai_config (Optional): { * rai_policy_name: String (Required) * } @@ -651,11 +669,12 @@ Response createAgentWithResponse(BinaryData createAgentRequest, Requ * description: String (Optional) * created_at: long (Required) * definition (Required): { - * kind: String(prompt/hosted/workflow) (Required) + * kind: String(prompt/hosted/workflow/external) (Required) * rai_config (Optional): { * rai_policy_name: String (Required) * } * } + * status: String(creating/active/failed/deleting/deleted) (Optional) * instance_identity (Optional): { * principal_id: String (Required) * client_id: String (Required) @@ -677,7 +696,7 @@ Response createAgentWithResponse(BinaryData createAgentRequest, Requ * ] * } * protocols (Optional): [ - * String(activity/responses/a2a/invocations) (Optional) + * String(activity/responses/a2a/mcp/invocations) (Optional) * ] * authorization_schemes (Optional): [ * (Optional){ @@ -800,11 +819,12 @@ AgentDetails updateAgent(String agentName, AgentDefinition definition) { * description: String (Optional) * created_at: long (Required) * definition (Required): { - * kind: String(prompt/hosted/workflow) (Required) + * kind: String(prompt/hosted/workflow/external) (Required) * rai_config (Optional): { * rai_policy_name: String (Required) * } * } + * status: String(creating/active/failed/deleting/deleted) (Optional) * instance_identity (Optional): { * principal_id: String (Required) * client_id: String (Required) @@ -826,7 +846,7 @@ AgentDetails updateAgent(String agentName, AgentDefinition definition) { * ] * } * protocols (Optional): [ - * String(activity/responses/a2a/invocations) (Optional) + * String(activity/responses/a2a/mcp/invocations) (Optional) * ] * authorization_schemes (Optional): [ * (Optional){ @@ -913,11 +933,12 @@ Response createAgentFromManifestWithResponse(BinaryData createAgentF * description: String (Optional) * created_at: long (Required) * definition (Required): { - * kind: String(prompt/hosted/workflow) (Required) + * kind: String(prompt/hosted/workflow/external) (Required) * rai_config (Optional): { * rai_policy_name: String (Required) * } * } + * status: String(creating/active/failed/deleting/deleted) (Optional) * instance_identity (Optional): { * principal_id: String (Required) * client_id: String (Required) @@ -939,7 +960,7 @@ Response createAgentFromManifestWithResponse(BinaryData createAgentF * ] * } * protocols (Optional): [ - * String(activity/responses/a2a/invocations) (Optional) + * String(activity/responses/a2a/mcp/invocations) (Optional) * ] * authorization_schemes (Optional): [ * (Optional){ @@ -1022,11 +1043,12 @@ Response updateAgentFromManifestWithResponse(String agentName, * description: String (Optional) * created_at: long (Required) * definition (Required): { - * kind: String(prompt/hosted/workflow) (Required) + * kind: String(prompt/hosted/workflow/external) (Required) * rai_config (Optional): { * rai_policy_name: String (Required) * } * } + * status: String(creating/active/failed/deleting/deleted) (Optional) * instance_identity (Optional): { * principal_id: String (Required) * client_id: String (Required) @@ -1239,11 +1261,12 @@ public AgentVersionDetails createAgentVersionFromManifest(String agentName, Stri * description: String (Optional) * created_at: long (Required) * definition (Required): { - * kind: String(prompt/hosted/workflow) (Required) + * kind: String(prompt/hosted/workflow/external) (Required) * rai_config (Optional): { * rai_policy_name: String (Required) * } * } + * status: String(creating/active/failed/deleting/deleted) (Optional) * instance_identity (Optional): { * principal_id: String (Required) * client_id: String (Required) @@ -1393,7 +1416,7 @@ public PagedIterable listAgentVersions(String agentName, In * Query Parameters ** Name Type Required Description + * Allowed values: "prompt", "hosted", "workflow", "external". * kind String No Filter agents by kind. If not provided, all agents are returned. - * Allowed values: "prompt", "hosted", "workflow". @@ -1430,11 +1453,12 @@ public PagedIterable limit Integer No A limit on the number of objects to be returned. Limit can range * between 1 and 100, and the * default is 20. listAgentVersions(String agentName, In * description: String (Optional) * created_at: long (Required) * definition (Required): { - * kind: String(prompt/hosted/workflow) (Required) + * kind: String(prompt/hosted/workflow/external) (Required) * rai_config (Optional): { * rai_policy_name: String (Required) * } * } + * status: String(creating/active/failed/deleting/deleted) (Optional) * instance_identity (Optional): { * principal_id: String (Required) * client_id: String (Required) @@ -1456,7 +1480,7 @@ public PagedIterable listAgentVersions(String agentName, In * ] * } * protocols (Optional): [ - * String(activity/responses/a2a/invocations) (Optional) + * String(activity/responses/a2a/mcp/invocations) (Optional) * ] * authorization_schemes (Optional): [ * (Optional){ @@ -1565,6 +1589,14 @@ AgentDetails createAgentFromManifest(String agentName, String manifestId, Map * * You can add these to a request with {@link RequestOptions#addQueryParam} + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} *Header Parameters + *+ * Name Type Required Description + * x-ms-user-isolation-key String No Opaque per-user isolation key used to scope + * endpoint-scoped data (responses, conversations, sessions) to a specific end user. Response Body Schema
* *@@ -1595,59 +1627,6 @@ public PagedIterablelistAgentConversations(RequestOptions requestOp return this.serviceClient.listAgentConversations(requestOptions); } - /** - * Returns the list of all conversations. - * - * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the - * default is 20. - * @param order Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` - * for descending order. - * @param after A cursor for use in pagination. `after` is an object ID that defines your place in the list. - * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - * subsequent call can include after=obj_foo in order to fetch the next page of the list. - * @param before A cursor for use in pagination. `before` is an object ID that defines your place in the list. - * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - * subsequent call can include before=obj_foo in order to fetch the previous page of the list. - * @param agentName Filter by agent name. If provided, only items associated with the specified agent will be - * returned. - * @param agentId Filter by agent ID in the format `name:version`. If provided, only items associated with the - * specified agent ID will be returned. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return the response data for a requested list of items as paginated response with {@link PagedIterable}. - */ - @Generated - @ServiceMethod(returns = ReturnType.COLLECTION) - public PagedIterable listAgentConversations(Integer limit, PageOrder order, String after, - String before, String agentName, String agentId) { - // Generated convenience method for listAgentConversations - RequestOptions requestOptions = new RequestOptions(); - if (limit != null) { - requestOptions.addQueryParam("limit", String.valueOf(limit), false); - } - if (order != null) { - requestOptions.addQueryParam("order", order.toString(), false); - } - if (after != null) { - requestOptions.addQueryParam("after", after, false); - } - if (before != null) { - requestOptions.addQueryParam("before", before, false); - } - if (agentName != null) { - requestOptions.addQueryParam("agent_name", agentName, false); - } - if (agentId != null) { - requestOptions.addQueryParam("agent_id", agentId, false); - } - return serviceClient.listAgentConversations(requestOptions) - .mapPage(bodyItemValue -> bodyItemValue.toObject(Conversation.class)); - } - /** * Returns the list of all conversations. * @@ -1711,7 +1690,18 @@ public Response deleteAgentWithResponse(String agentName, RequestOptions r } /** - * Deletes an agent. + * Deletes an agent. For hosted agents, if any version has active sessions, the request + * is rejected with HTTP 409 unless `force` is set to true. When force is true, all + * associated sessions are cascade-deleted along with the agent and its versions. + * Query Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addQueryParam} *Query Parameters + *+ * Name Type Required Description + * force Boolean No For Hosted Agents, if true, force-deletes the agent even if its + * versions have active sessions, cascading deletion to all associated sessions. This value is not relevant for + * other Agent types. Defaults to false. Response Body Schema
* *@@ -1739,7 +1729,18 @@ ResponseinternalDeleteAgentWithResponse(String agentName, RequestOp } /** - * Deletes a specific version of an agent. + * Deletes a specific version of an agent. For hosted agents, if the version has active + * sessions, the request is rejected with HTTP 409 unless `force` is set to true. When + * force is true, all sessions associated with this version are cascade-deleted. + * Query Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addQueryParam} *Query Parameters + *+ * Name Type Required Description + * force Boolean No For Hosted Agents, if true, force-deletes the version even if it + * has active sessions, cascading deletion to all associated sessions. This value is not relevant for other Agent + * types. Defaults to false. Response Body Schema
* *@@ -1769,69 +1770,6 @@ ResponseinternalDeleteAgentVersionWithResponse(String agentName, St return this.serviceClient.internalDeleteAgentVersionWithResponse(agentName, agentVersion, requestOptions); } - /** - * Creates a new session for an agent endpoint. - * The endpoint resolves the backing agent version from `version_indicator` and - * enforces session ownership using the provided isolation key for session-mutating operations. - * Header Parameters
- *- *
- * You can add these to a request with {@link RequestOptions#addHeader} - *Header Parameters - *- * Name Type Required Description - * Foundry-Features String No A feature flag opt-in required when using preview - * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", - * "WorkflowAgents=V1Preview", "ContainerAgents=V1Preview", "AgentEndpoints=V1Preview". Request Body Schema
- * - *- * {@code - * { - * agent_session_id: String (Optional) - * version_indicator (Required): { - * type: String(version_ref) (Required) - * } - * } - * } - *- * - *Response Body Schema
- * - *- * {@code - * { - * agent_session_id: String (Required) - * version_indicator (Required): { - * type: String(version_ref) (Required) - * } - * status: String(creating/active/idle/updating/failed/deleting/deleted/expired) (Required) - * created_at: long (Required) - * last_accessed_at: long (Required) - * expires_at: long (Required) - * } - * } - *- * - * @param agentName The name of the agent to create a session for. - * @param isolationKey Isolation key used by the agent endpoint to enforce session ownership for session-mutating - * operations. - * @param createSessionRequest The createSessionRequest parameter. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return an agent session providing a long-lived compute sandbox for hosted agent invocations along with - * {@link Response}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponsecreateSessionWithResponse(String agentName, String isolationKey, - BinaryData createSessionRequest, RequestOptions requestOptions) { - return this.serviceClient.createSessionWithResponse(agentName, isolationKey, createSessionRequest, - requestOptions); - } - /** * Retrieves a session by ID. * Header Parameters
@@ -1840,7 +1778,8 @@ public ResponsecreateSessionWithResponse(String agentName, String i * * Name Type Required Description + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". * * You can add these to a request with {@link RequestOptions#addHeader} * Foundry-Features String No A feature flag opt-in required when using preview * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", - * "WorkflowAgents=V1Preview", "ContainerAgents=V1Preview", "AgentEndpoints=V1Preview". Response Body Schema
@@ -1877,37 +1816,6 @@ public ResponsegetSessionWithResponse(String agentName, String sess return this.serviceClient.getSessionWithResponse(agentName, sessionId, requestOptions); } - /** - * Deletes a session synchronously. - * Returns 204 No Content when the session is deleted or does not exist. - * Header Parameters
- *- *
- * You can add these to a request with {@link RequestOptions#addHeader} - * - * @param agentName The name of the agent. - * @param sessionId The session identifier. - * @param isolationKey Isolation key used by the agent endpoint to enforce session ownership for session-mutating - * operations. - * @param requestOptions The options to configure the HTTP request before HTTP client sends it. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @return the {@link Response}. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public ResponseHeader Parameters - *- * Name Type Required Description - * Foundry-Features String No A feature flag opt-in required when using preview - * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", - * "WorkflowAgents=V1Preview", "ContainerAgents=V1Preview", "AgentEndpoints=V1Preview". deleteSessionWithResponse(String agentName, String sessionId, String isolationKey, - RequestOptions requestOptions) { - return this.serviceClient.deleteSessionWithResponse(agentName, sessionId, isolationKey, requestOptions); - } - /** * Returns a list of sessions for the specified agent. * Query Parameters
@@ -1936,7 +1844,8 @@ public ResponsedeleteSessionWithResponse(String agentName, String session * * Name Type Required Description + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". * * You can add these to a request with {@link RequestOptions#addHeader} * Foundry-Features String No A feature flag opt-in required when using preview * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", - * "WorkflowAgents=V1Preview", "ContainerAgents=V1Preview", "AgentEndpoints=V1Preview". Response Body Schema
@@ -2087,67 +1996,6 @@ public AgentVersionDetails createAgentVersion(String agentName, AgentDefinition .toObject(AgentVersionDetails.class); } - /** - * Creates a new session for an agent endpoint. - * The endpoint resolves the backing agent version from `version_indicator` and - * enforces session ownership using the provided isolation key for session-mutating operations. - * - * @param agentName The name of the agent to create a session for. - * @param isolationKey Isolation key used by the agent endpoint to enforce session ownership for session-mutating - * operations. - * @param versionIndicator Determines which agent version backs the session. - * @param agentSessionId Optional caller-provided session ID. If specified, it must be unique within the agent - * endpoint. Auto-generated if omitted. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an agent session providing a long-lived compute sandbox for hosted agent invocations. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public AgentSessionResource createSession(String agentName, String isolationKey, VersionIndicator versionIndicator, - String agentSessionId) { - // Generated convenience method for createSessionWithResponse - RequestOptions requestOptions = new RequestOptions(); - CreateSessionRequest createSessionRequestObj - = new CreateSessionRequest(versionIndicator).setAgentSessionId(agentSessionId); - BinaryData createSessionRequest = BinaryData.fromObject(createSessionRequestObj); - return createSessionWithResponse(agentName, isolationKey, createSessionRequest, requestOptions).getValue() - .toObject(AgentSessionResource.class); - } - - /** - * Creates a new session for an agent endpoint. - * The endpoint resolves the backing agent version from `version_indicator` and - * enforces session ownership using the provided isolation key for session-mutating operations. - * - * @param agentName The name of the agent to create a session for. - * @param isolationKey Isolation key used by the agent endpoint to enforce session ownership for session-mutating - * operations. - * @param versionIndicator Determines which agent version backs the session. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - * @return an agent session providing a long-lived compute sandbox for hosted agent invocations. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public AgentSessionResource createSession(String agentName, String isolationKey, - VersionIndicator versionIndicator) { - // Generated convenience method for createSessionWithResponse - RequestOptions requestOptions = new RequestOptions(); - CreateSessionRequest createSessionRequestObj = new CreateSessionRequest(versionIndicator); - BinaryData createSessionRequest = BinaryData.fromObject(createSessionRequestObj); - return createSessionWithResponse(agentName, isolationKey, createSessionRequest, requestOptions).getValue() - .toObject(AgentSessionResource.class); - } - /** * Retrieves a session by ID. * @@ -2198,58 +2046,6 @@ public AgentSessionResource getSession(String agentName, String sessionId) { .toObject(AgentSessionResource.class); } - /** - * Deletes a session synchronously. - * Returns 204 No Content when the session is deleted or does not exist. - * - * @param agentName The name of the agent. - * @param sessionId The session identifier. - * @param isolationKey Isolation key used by the agent endpoint to enforce session ownership for session-mutating - * operations. - * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted - * preview resources. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public void deleteSession(String agentName, String sessionId, String isolationKey, - AgentDefinitionOptInKeys foundryFeatures) { - // Generated convenience method for deleteSessionWithResponse - RequestOptions requestOptions = new RequestOptions(); - if (foundryFeatures != null) { - requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); - } - deleteSessionWithResponse(agentName, sessionId, isolationKey, requestOptions).getValue(); - } - - /** - * Deletes a session synchronously. - * Returns 204 No Content when the session is deleted or does not exist. - * - * @param agentName The name of the agent. - * @param sessionId The session identifier. - * @param isolationKey Isolation key used by the agent endpoint to enforce session ownership for session-mutating - * operations. - * @throws IllegalArgumentException thrown if parameters fail the validation. - * @throws HttpResponseException thrown if the request is rejected by server. - * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. - * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. - * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. - * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. - */ - @Generated - @ServiceMethod(returns = ReturnType.SINGLE) - public void deleteSession(String agentName, String sessionId, String isolationKey) { - // Generated convenience method for deleteSessionWithResponse - RequestOptions requestOptions = new RequestOptions(); - deleteSessionWithResponse(agentName, sessionId, isolationKey, requestOptions).getValue(); - } - /** * Returns a list of sessions for the specified agent. * @@ -2389,7 +2185,8 @@ public IterableStreamgetSessionLogStream(String agentName, Str * * Name Type Required Description + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". * * You can add these to a request with {@link RequestOptions#addHeader} * Foundry-Features String No A feature flag opt-in required when using preview * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", - * "WorkflowAgents=V1Preview", "ContainerAgents=V1Preview", "AgentEndpoints=V1Preview". Response Body Schema
@@ -2431,7 +2228,8 @@ public ResponsegetSessionLogStreamWithResponse(String agentName, St * * Name Type Required Description + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". * * You can add these to a request with {@link RequestOptions#addHeader} * Foundry-Features String No A feature flag opt-in required when using preview * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", - * "WorkflowAgents=V1Preview", "ContainerAgents=V1Preview", "AgentEndpoints=V1Preview". Request Body Schema
@@ -2449,7 +2247,7 @@ public ResponsegetSessionLogStreamWithResponse(String agentName, St * ] * } * protocols (Optional): [ - * String(activity/responses/a2a/invocations) (Optional) + * String(activity/responses/a2a/mcp/invocations) (Optional) * ] * authorization_schemes (Optional): [ * (Optional){ @@ -2498,11 +2296,12 @@ public Response getSessionLogStreamWithResponse(String agentName, St * description: String (Optional) * created_at: long (Required) * definition (Required): { - * kind: String(prompt/hosted/workflow) (Required) + * kind: String(prompt/hosted/workflow/external) (Required) * rai_config (Optional): { * rai_policy_name: String (Required) * } * } + * status: String(creating/active/failed/deleting/deleted) (Optional) * instance_identity (Optional): { * principal_id: String (Required) * client_id: String (Required) @@ -2524,7 +2323,7 @@ public Response getSessionLogStreamWithResponse(String agentName, St * ] * } * protocols (Optional): [ - * String(activity/responses/a2a/invocations) (Optional) + * String(activity/responses/a2a/mcp/invocations) (Optional) * ] * authorization_schemes (Optional): [ * (Optional){ @@ -2706,4 +2505,2828 @@ public AgentDetails updateAgentDetails(String agentName, UpdateAgentDetailsOptio return updateAgentDetailsWithResponse(agentName, patchAgentObjectRequestInBinaryData, requestOptions).getValue() .toObject(AgentDetails.class); } + + /** + * Creates a new code-based agent. Uploads the code zip and creates the agent in a single call. + * The agent name is provided in the `x-ms-agent-name` header since POST /agents has no name in the URL path. + * The SHA-256 hex digest of the zip is provided in the `x-ms-code-zip-sha256` header for integrity and dedup. + * The request body is multipart/form-data with a JSON metadata part and a binary code part (part order is + * irrelevant). + * Maximum upload size is 250 MB. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". Response Body Schema
+ * + *+ * {@code + * { + * object: String(agent/agent.version/agent.deleted/agent.version.deleted/agent.container) (Required) + * id: String (Required) + * name: String (Required) + * versions (Required): { + * latest (Required): { + * metadata (Required): { + * String: String (Required) + * } + * object: String(agent/agent.version/agent.deleted/agent.version.deleted/agent.container) (Required) + * id: String (Required) + * name: String (Required) + * version: String (Required) + * description: String (Optional) + * created_at: long (Required) + * definition (Required): { + * kind: String(prompt/hosted/workflow/external) (Required) + * rai_config (Optional): { + * rai_policy_name: String (Required) + * } + * } + * status: String(creating/active/failed/deleting/deleted) (Optional) + * instance_identity (Optional): { + * principal_id: String (Required) + * client_id: String (Required) + * } + * blueprint (Optional): (recursive schema, see blueprint above) + * blueprint_reference (Optional): { + * type: String(ManagedAgentIdentityBlueprint) (Required) + * } + * agent_guid: String (Optional) + * } + * } + * agent_endpoint (Optional): { + * version_selector (Optional): { + * version_selection_rules (Optional, Required on create): [ + * (Optional, Required on create){ + * type: String(FixedRatio) (Required) + * agent_version: String (Optional, Required on create) + * } + * ] + * } + * protocols (Optional): [ + * String(activity/responses/a2a/mcp/invocations) (Optional) + * ] + * authorization_schemes (Optional): [ + * (Optional){ + * type: String(Entra/BotService/BotServiceRbac) (Required) + * } + * ] + * } + * instance_identity (Optional): (recursive schema, see instance_identity above) + * blueprint (Optional): (recursive schema, see blueprint above) + * blueprint_reference (Optional): (recursive schema, see blueprint_reference above) + * agent_card (Optional): { + * version: String (Optional, Required on create) + * description: String (Optional) + * skills (Optional, Required on create): [ + * (Optional, Required on create){ + * id: String (Optional, Required on create) + * name: String (Optional, Required on create) + * description: String (Optional) + * tags (Optional): [ + * String (Optional) + * ] + * examples (Optional): [ + * String (Optional) + * ] + * } + * ] + * } + * } + * } + *+ * + * @param agentName The unique name that identifies the agent. Max 63 chars, must start and end with alphanumeric, + * hyphens allowed in the middle. + * @param codeZipSha256 SHA-256 hex digest of the uploaded code zip. Used for change detection (dedup) and integrity + * verification. + * @param content The content parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + ResponsecreateAgentFromCodeWithResponse(String agentName, String codeZipSha256, BinaryData content, + RequestOptions requestOptions) { + // Operation 'createAgentFromCode' is of content-type 'multipart/form-data'. Protocol API is not usable and + // hence not generated. + return this.serviceClient.createAgentFromCodeWithResponse(agentName, codeZipSha256, content, requestOptions); + } + + /** + * Updates a code-based agent by uploading new code and creating a new version. + * If the code and definition are unchanged (matched by x-ms-code-zip-sha256 header), returns the existing version. + * The request body is multipart/form-data with a JSON metadata part and a binary code part (part order is + * irrelevant). + * Maximum upload size is 250 MB. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". Response Body Schema
+ * + *+ * {@code + * { + * object: String(agent/agent.version/agent.deleted/agent.version.deleted/agent.container) (Required) + * id: String (Required) + * name: String (Required) + * versions (Required): { + * latest (Required): { + * metadata (Required): { + * String: String (Required) + * } + * object: String(agent/agent.version/agent.deleted/agent.version.deleted/agent.container) (Required) + * id: String (Required) + * name: String (Required) + * version: String (Required) + * description: String (Optional) + * created_at: long (Required) + * definition (Required): { + * kind: String(prompt/hosted/workflow/external) (Required) + * rai_config (Optional): { + * rai_policy_name: String (Required) + * } + * } + * status: String(creating/active/failed/deleting/deleted) (Optional) + * instance_identity (Optional): { + * principal_id: String (Required) + * client_id: String (Required) + * } + * blueprint (Optional): (recursive schema, see blueprint above) + * blueprint_reference (Optional): { + * type: String(ManagedAgentIdentityBlueprint) (Required) + * } + * agent_guid: String (Optional) + * } + * } + * agent_endpoint (Optional): { + * version_selector (Optional): { + * version_selection_rules (Optional, Required on create): [ + * (Optional, Required on create){ + * type: String(FixedRatio) (Required) + * agent_version: String (Optional, Required on create) + * } + * ] + * } + * protocols (Optional): [ + * String(activity/responses/a2a/mcp/invocations) (Optional) + * ] + * authorization_schemes (Optional): [ + * (Optional){ + * type: String(Entra/BotService/BotServiceRbac) (Required) + * } + * ] + * } + * instance_identity (Optional): (recursive schema, see instance_identity above) + * blueprint (Optional): (recursive schema, see blueprint above) + * blueprint_reference (Optional): (recursive schema, see blueprint_reference above) + * agent_card (Optional): { + * version: String (Optional, Required on create) + * description: String (Optional) + * skills (Optional, Required on create): [ + * (Optional, Required on create){ + * id: String (Optional, Required on create) + * name: String (Optional, Required on create) + * description: String (Optional) + * tags (Optional): [ + * String (Optional) + * ] + * examples (Optional): [ + * String (Optional) + * ] + * } + * ] + * } + * } + * } + *+ * + * @param agentName The unique name that identifies the agent. Name can be used to retrieve/update/delete the agent. + * - Must start and end with alphanumeric characters, + * - Can contain hyphens in the middle + * - Must not exceed 63 characters. + * @param codeZipSha256 SHA-256 hex digest of the uploaded code zip. Used for change detection (dedup) and integrity + * verification. + * @param content The content parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + ResponseupdateAgentFromCodeWithResponse(String agentName, String codeZipSha256, BinaryData content, + RequestOptions requestOptions) { + // Operation 'updateAgentFromCode' is of content-type 'multipart/form-data'. Protocol API is not usable and + // hence not generated. + return this.serviceClient.updateAgentFromCodeWithResponse(agentName, codeZipSha256, content, requestOptions); + } + + /** + * The createAgentVersionFromCode operation. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". Response Body Schema
+ * + *+ * {@code + * { + * metadata (Required): { + * String: String (Required) + * } + * object: String(agent/agent.version/agent.deleted/agent.version.deleted/agent.container) (Required) + * id: String (Required) + * name: String (Required) + * version: String (Required) + * description: String (Optional) + * created_at: long (Required) + * definition (Required): { + * kind: String(prompt/hosted/workflow/external) (Required) + * rai_config (Optional): { + * rai_policy_name: String (Required) + * } + * } + * status: String(creating/active/failed/deleting/deleted) (Optional) + * instance_identity (Optional): { + * principal_id: String (Required) + * client_id: String (Required) + * } + * blueprint (Optional): (recursive schema, see blueprint above) + * blueprint_reference (Optional): { + * type: String(ManagedAgentIdentityBlueprint) (Required) + * } + * agent_guid: String (Optional) + * } + * } + *+ * + * @param agentName The unique name that identifies the agent. Name can be used to retrieve/update/delete the agent. + * - Must start and end with alphanumeric characters, + * - Can contain hyphens in the middle + * - Must not exceed 63 characters. + * @param codeZipSha256 SHA-256 hex digest of the uploaded code zip. Used for change detection (dedup) and integrity + * verification. + * @param content The content parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + ResponsecreateAgentVersionFromCodeWithResponse(String agentName, String codeZipSha256, + BinaryData content, RequestOptions requestOptions) { + // Operation 'createAgentVersionFromCode' is of content-type 'multipart/form-data'. Protocol API is not usable + // and hence not generated. + return this.serviceClient.createAgentVersionFromCodeWithResponse(agentName, codeZipSha256, content, + requestOptions); + } + + /** + * Download the code zip for a code-based hosted agent. + * Returns the previously-uploaded zip (`application/zip`). + * + * If `agent_version` is supplied, returns that version's code zip; otherwise + * returns the latest version's code zip. + * + * The SHA-256 digest of the returned bytes matches the `content_hash` on the + * resolved version's `code_configuration`. + * Query Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *Query Parameters + *+ * Name Type Required Description + * agent_version String No The version of the agent whose code zip should be + * downloaded. + * If omitted, the latest version's code zip is returned. Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". Response Body Schema
+ * + *+ * {@code + * BinaryData + * } + *+ * + * @param agentName The name of the agent. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response body along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponsedownloadAgentCodeWithResponse(String agentName, RequestOptions requestOptions) { + return this.serviceClient.downloadAgentCodeWithResponse(agentName, requestOptions); + } + + /** + * Creates a new session for an agent endpoint. + * The endpoint resolves the backing agent version from `version_indicator` and + * enforces session ownership using the provided isolation key for session-mutating operations. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". Request Body Schema
+ * + *+ * {@code + * { + * agent_session_id: String (Optional) + * version_indicator (Required): { + * type: String(version_ref) (Required) + * } + * } + * } + *+ * + *Response Body Schema
+ * + *+ * {@code + * { + * agent_session_id: String (Required) + * version_indicator (Required): { + * type: String(version_ref) (Required) + * } + * status: String(creating/active/idle/updating/failed/deleting/deleted/expired) (Required) + * created_at: long (Required) + * last_accessed_at: long (Required) + * expires_at: long (Required) + * } + * } + *+ * + * @param agentName The name of the agent to create a session for. + * @param createSessionRequest The createSessionRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return an agent session providing a long-lived compute sandbox for hosted agent invocations along with + * {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponsecreateSessionWithResponse(String agentName, BinaryData createSessionRequest, + RequestOptions requestOptions) { + return this.serviceClient.createSessionWithResponse(agentName, createSessionRequest, requestOptions); + } + + /** + * Deletes a session synchronously. + * Returns 204 No Content when the session is deleted or does not exist. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param agentName The name of the agent. + * @param sessionId The session identifier. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponseHeader Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "HostedAgents=V1Preview", + * "WorkflowAgents=V1Preview", "AgentEndpoints=V1Preview", "CodeAgents=V1Preview", + * "ExternalAgents=V1Preview". deleteSessionWithResponse(String agentName, String sessionId, RequestOptions requestOptions) { + return this.serviceClient.deleteSessionWithResponse(agentName, sessionId, requestOptions); + } + + /** + * Creates a new code-based agent. Uploads the code zip and creates the agent in a single call. + * The agent name is provided in the `x-ms-agent-name` header since POST /agents has no name in the URL path. + * The SHA-256 hex digest of the zip is provided in the `x-ms-code-zip-sha256` header for integrity and dedup. + * The request body is multipart/form-data with a JSON metadata part and a binary code part (part order is + * irrelevant). + * Maximum upload size is 250 MB. + * + * @param agentName The unique name that identifies the agent. Max 63 chars, must start and end with alphanumeric, + * hyphens allowed in the middle. + * @param codeZipSha256 SHA-256 hex digest of the uploaded code zip. Used for change detection (dedup) and integrity + * verification. + * @param content The content parameter. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + AgentDetails createAgentFromCode(String agentName, String codeZipSha256, CreateAgentFromCodeContent content, + AgentDefinitionOptInKeys foundryFeatures) { + // Generated convenience method for createAgentFromCodeWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + return createAgentFromCodeWithResponse(agentName, codeZipSha256, + new MultipartFormDataHelper(requestOptions).serializeJsonField("metadata", content.getMetadata()) + .serializeFileField("code", content.getCode().getContent(), content.getCode().getContentType(), + content.getCode().getFilename()) + .end() + .getRequestBody(), + requestOptions).getValue().toObject(AgentDetails.class); + } + + /** + * Creates a new code-based agent. Uploads the code zip and creates the agent in a single call. + * The agent name is provided in the `x-ms-agent-name` header since POST /agents has no name in the URL path. + * The SHA-256 hex digest of the zip is provided in the `x-ms-code-zip-sha256` header for integrity and dedup. + * The request body is multipart/form-data with a JSON metadata part and a binary code part (part order is + * irrelevant). + * Maximum upload size is 250 MB. + * + * @param agentName The unique name that identifies the agent. Max 63 chars, must start and end with alphanumeric, + * hyphens allowed in the middle. + * @param codeZipSha256 SHA-256 hex digest of the uploaded code zip. Used for change detection (dedup) and integrity + * verification. + * @param content The content parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + AgentDetails createAgentFromCode(String agentName, String codeZipSha256, CreateAgentFromCodeContent content) { + // Generated convenience method for createAgentFromCodeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createAgentFromCodeWithResponse(agentName, codeZipSha256, + new MultipartFormDataHelper(requestOptions).serializeJsonField("metadata", content.getMetadata()) + .serializeFileField("code", content.getCode().getContent(), content.getCode().getContentType(), + content.getCode().getFilename()) + .end() + .getRequestBody(), + requestOptions).getValue().toObject(AgentDetails.class); + } + + /** + * Updates a code-based agent by uploading new code and creating a new version. + * If the code and definition are unchanged (matched by x-ms-code-zip-sha256 header), returns the existing version. + * The request body is multipart/form-data with a JSON metadata part and a binary code part (part order is + * irrelevant). + * Maximum upload size is 250 MB. + * + * @param agentName The unique name that identifies the agent. Name can be used to retrieve/update/delete the agent. + * - Must start and end with alphanumeric characters, + * - Can contain hyphens in the middle + * - Must not exceed 63 characters. + * @param codeZipSha256 SHA-256 hex digest of the uploaded code zip. Used for change detection (dedup) and integrity + * verification. + * @param content The content parameter. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public AgentDetails updateAgentFromCode(String agentName, String codeZipSha256, + CreateAgentVersionFromCodeContent content, AgentDefinitionOptInKeys foundryFeatures) { + // Generated convenience method for updateAgentFromCodeWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + return updateAgentFromCodeWithResponse(agentName, codeZipSha256, + new MultipartFormDataHelper(requestOptions).serializeJsonField("metadata", content.getMetadata()) + .serializeFileField("code", content.getCode().getContent(), content.getCode().getContentType(), + content.getCode().getFilename()) + .end() + .getRequestBody(), + requestOptions).getValue().toObject(AgentDetails.class); + } + + /** + * Updates a code-based agent by uploading new code and creating a new version. + * If the code and definition are unchanged (matched by x-ms-code-zip-sha256 header), returns the existing version. + * The request body is multipart/form-data with a JSON metadata part and a binary code part (part order is + * irrelevant). + * Maximum upload size is 250 MB. + * + * @param agentName The unique name that identifies the agent. Name can be used to retrieve/update/delete the agent. + * - Must start and end with alphanumeric characters, + * - Can contain hyphens in the middle + * - Must not exceed 63 characters. + * @param codeZipSha256 SHA-256 hex digest of the uploaded code zip. Used for change detection (dedup) and integrity + * verification. + * @param content The content parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public AgentDetails updateAgentFromCode(String agentName, String codeZipSha256, + CreateAgentVersionFromCodeContent content) { + // Generated convenience method for updateAgentFromCodeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return updateAgentFromCodeWithResponse(agentName, codeZipSha256, + new MultipartFormDataHelper(requestOptions).serializeJsonField("metadata", content.getMetadata()) + .serializeFileField("code", content.getCode().getContent(), content.getCode().getContentType(), + content.getCode().getFilename()) + .end() + .getRequestBody(), + requestOptions).getValue().toObject(AgentDetails.class); + } + + /** + * The createAgentVersionFromCode operation. + * + * @param agentName The unique name that identifies the agent. Name can be used to retrieve/update/delete the agent. + * - Must start and end with alphanumeric characters, + * - Can contain hyphens in the middle + * - Must not exceed 63 characters. + * @param codeZipSha256 SHA-256 hex digest of the uploaded code zip. Used for change detection (dedup) and integrity + * verification. + * @param content The content parameter. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public AgentVersionDetails createAgentVersionFromCode(String agentName, String codeZipSha256, + CreateAgentVersionFromCodeContent content, AgentDefinitionOptInKeys foundryFeatures) { + // Generated convenience method for createAgentVersionFromCodeWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + return createAgentVersionFromCodeWithResponse(agentName, codeZipSha256, + new MultipartFormDataHelper(requestOptions).serializeJsonField("metadata", content.getMetadata()) + .serializeFileField("code", content.getCode().getContent(), content.getCode().getContentType(), + content.getCode().getFilename()) + .end() + .getRequestBody(), + requestOptions).getValue().toObject(AgentVersionDetails.class); + } + + /** + * The createAgentVersionFromCode operation. + * + * @param agentName The unique name that identifies the agent. Name can be used to retrieve/update/delete the agent. + * - Must start and end with alphanumeric characters, + * - Can contain hyphens in the middle + * - Must not exceed 63 characters. + * @param codeZipSha256 SHA-256 hex digest of the uploaded code zip. Used for change detection (dedup) and integrity + * verification. + * @param content The content parameter. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public AgentVersionDetails createAgentVersionFromCode(String agentName, String codeZipSha256, + CreateAgentVersionFromCodeContent content) { + // Generated convenience method for createAgentVersionFromCodeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createAgentVersionFromCodeWithResponse(agentName, codeZipSha256, + new MultipartFormDataHelper(requestOptions).serializeJsonField("metadata", content.getMetadata()) + .serializeFileField("code", content.getCode().getContent(), content.getCode().getContentType(), + content.getCode().getFilename()) + .end() + .getRequestBody(), + requestOptions).getValue().toObject(AgentVersionDetails.class); + } + + /** + * Download the code zip for a code-based hosted agent. + * Returns the previously-uploaded zip (`application/zip`). + * + * If `agent_version` is supplied, returns that version's code zip; otherwise + * returns the latest version's code zip. + * + * The SHA-256 digest of the returned bytes matches the `content_hash` on the + * resolved version's `code_configuration`. + * + * @param agentName The name of the agent. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BinaryData downloadAgentCode(String agentName) { + // Generated convenience method for downloadAgentCodeWithResponse + RequestOptions requestOptions = new RequestOptions(); + return downloadAgentCodeWithResponse(agentName, requestOptions).getValue(); + } + + /** + * Creates a new session for an agent endpoint. + * The endpoint resolves the backing agent version from `version_indicator` and + * enforces session ownership using the provided isolation key for session-mutating operations. + * + * @param agentName The name of the agent to create a session for. + * @param versionIndicator Determines which agent version backs the session. + * @param agentSessionId Optional caller-provided session ID. If specified, it must be unique within the agent + * endpoint. Auto-generated if omitted. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an agent session providing a long-lived compute sandbox for hosted agent invocations. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public AgentSessionResource createSession(String agentName, VersionIndicator versionIndicator, + String agentSessionId) { + // Generated convenience method for createSessionWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateSessionRequest createSessionRequestObj + = new CreateSessionRequest(versionIndicator).setAgentSessionId(agentSessionId); + BinaryData createSessionRequest = BinaryData.fromObject(createSessionRequestObj); + return createSessionWithResponse(agentName, createSessionRequest, requestOptions).getValue() + .toObject(AgentSessionResource.class); + } + + /** + * Creates a new session for an agent endpoint. + * The endpoint resolves the backing agent version from `version_indicator` and + * enforces session ownership using the provided isolation key for session-mutating operations. + * + * @param agentName The name of the agent to create a session for. + * @param versionIndicator Determines which agent version backs the session. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return an agent session providing a long-lived compute sandbox for hosted agent invocations. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public AgentSessionResource createSession(String agentName, VersionIndicator versionIndicator) { + // Generated convenience method for createSessionWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateSessionRequest createSessionRequestObj = new CreateSessionRequest(versionIndicator); + BinaryData createSessionRequest = BinaryData.fromObject(createSessionRequestObj); + return createSessionWithResponse(agentName, createSessionRequest, requestOptions).getValue() + .toObject(AgentSessionResource.class); + } + + /** + * Deletes a session synchronously. + * Returns 204 No Content when the session is deleted or does not exist. + * + * @param agentName The name of the agent. + * @param sessionId The session identifier. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void deleteSession(String agentName, String sessionId, AgentDefinitionOptInKeys foundryFeatures) { + // Generated convenience method for deleteSessionWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + deleteSessionWithResponse(agentName, sessionId, requestOptions).getValue(); + } + + /** + * Deletes a session synchronously. + * Returns 204 No Content when the session is deleted or does not exist. + * + * @param agentName The name of the agent. + * @param sessionId The session identifier. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void deleteSession(String agentName, String sessionId) { + // Generated convenience method for deleteSessionWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteSessionWithResponse(agentName, sessionId, requestOptions).getValue(); + } + + /** + * Download the code zip for a code-based hosted agent. + * Returns the previously-uploaded zip (`application/zip`). + * + * If `agent_version` is supplied, returns that version's code zip; otherwise + * returns the latest version's code zip. + * + * The SHA-256 digest of the returned bytes matches the `content_hash` on the + * resolved version's `code_configuration`. + * + * @param agentName The name of the agent. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @param agentVersion The version of the agent whose code zip should be downloaded. + * If omitted, the latest version's code zip is returned. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public BinaryData downloadAgentCode(String agentName, AgentDefinitionOptInKeys foundryFeatures, + String agentVersion) { + // Generated convenience method for downloadAgentCodeWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + if (agentVersion != null) { + requestOptions.addQueryParam("agent_version", agentVersion, false); + } + return downloadAgentCodeWithResponse(agentName, requestOptions).getValue(); + } + + /** + * Returns the list of all conversations. + * + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the + * default is 20. + * @param order Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` + * for descending order. + * @param after A cursor for use in pagination. `after` is an object ID that defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include after=obj_foo in order to fetch the next page of the list. + * @param before A cursor for use in pagination. `before` is an object ID that defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include before=obj_foo in order to fetch the previous page of the list. + * @param agentName Filter by agent name. If provided, only items associated with the specified agent will be + * returned. + * @param agentId Filter by agent ID in the format `name:version`. If provided, only items associated with the + * specified agent ID will be returned. + * @param userIsolationKey Opaque per-user isolation key used to scope endpoint-scoped data (responses, + * conversations, sessions) to a specific end user. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listAgentConversations(Integer limit, PageOrder order, String after, + String before, String agentName, String agentId, String userIsolationKey) { + // Generated convenience method for listAgentConversations + RequestOptions requestOptions = new RequestOptions(); + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + if (agentName != null) { + requestOptions.addQueryParam("agent_name", agentName, false); + } + if (agentId != null) { + requestOptions.addQueryParam("agent_id", agentId, false); + } + if (userIsolationKey != null) { + requestOptions.setHeader(HttpHeaderName.fromString("x-ms-user-isolation-key"), userIsolationKey); + } + return serviceClient.listAgentConversations(requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(Conversation.class)); + } + + /** + * Returns the list of all conversations. + * + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the + * default is 20. + * @param order Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` + * for descending order. + * @param after A cursor for use in pagination. `after` is an object ID that defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include after=obj_foo in order to fetch the next page of the list. + * @param before A cursor for use in pagination. `before` is an object ID that defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include before=obj_foo in order to fetch the previous page of the list. + * @param agentName Filter by agent name. If provided, only items associated with the specified agent will be + * returned. + * @param agentId Filter by agent ID in the format `name:version`. If provided, only items associated with the + * specified agent ID will be returned. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items as paginated response with {@link PagedIterable}. + */ + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listAgentConversations(Integer limit, PageOrder order, String after, + String before, String agentName, String agentId) { + // Generated convenience method for listAgentConversations + RequestOptions requestOptions = new RequestOptions(); + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + if (agentName != null) { + requestOptions.addQueryParam("agent_name", agentName, false); + } + if (agentId != null) { + requestOptions.addQueryParam("agent_id", agentId, false); + } + return serviceClient.listAgentConversations(requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(Conversation.class)); + } + + /** + * Creates an agent optimization job. + * + * Create an optimization job. Returns 201 with the queued job. Honours `Operation-Id` for idempotent retry. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "Evaluations=V1Preview", + * "Schedules=V1Preview", "RedTeams=V1Preview", "Insights=V1Preview", "MemoryStores=V1Preview", + * "Routines=V1Preview", "Skills=V1Preview", "DataGenerationJobs=V1Preview", "Models=V1Preview", + * "AgentsOptimization=V1Preview". + * Operation-Id String No Client-generated unique ID for idempotent retries. When + * absent, the server creates the job unconditionally. Request Body Schema
+ * + *+ * {@code + * { + * id: String (Required) + * inputs (Optional): { + * agent (Required): { + * agent_name: String (Required) + * agent_version: String (Optional) + * model: String (Optional) + * system_prompt: String (Optional) + * skills (Optional): [ + * (Optional){ + * name: String (Required) + * description: String (Optional) + * } + * ] + * } + * dataset (Optional): [ + * (Optional){ + * name: String (Required) + * query: String (Required) + * ground_truth: String (Optional) + * criteria (Optional): [ + * (Optional){ + * name: String (Required) + * instruction: String (Required) + * } + * ] + * eval_results (Optional): [ + * (Optional){ + * name: String (Required) + * type: String (Optional) + * score: double (Required) + * passed: boolean (Required) + * sample (Optional): { + * String: BinaryData (Required) + * } + * status: String(completed/errored/skipped) (Optional) + * metric: String (Optional) + * label: String (Optional) + * threshold: Double (Optional) + * reason: String (Optional) + * properties (Optional): { + * String: String (Required) + * } + * (Optional): { + * String: BinaryData (Required) + * } + * } + * ] + * response_items (Optional): [ + * BinaryData (Optional) + * ] + * } + * ] + * train_dataset_reference (Optional): { + * name: String (Required) + * version: String (Optional) + * } + * validation_dataset_reference (Optional): (recursive schema, see validation_dataset_reference above) + * evaluators (Optional): [ + * String (Optional) + * ] + * criteria (Optional): [ + * (recursive schema, see above) + * ] + * options (Optional): { + * strategies (Optional): [ + * String(instruction/model/skill) (Optional) + * ] + * budget: Integer (Optional) + * max_iterations: Integer (Optional) + * tasks_per_iteration: Integer (Optional) + * max_reflection_tasks: Integer (Optional) + * min_improvement: Double (Optional) + * pass_threshold: Double (Optional) + * improvement_threshold: Double (Optional) + * mode: String(optimize) (Optional) + * eval_model: String (Optional) + * reflection_model: String (Optional) + * task_timeout_seconds: Long (Optional) + * keep_versions: Boolean (Optional) + * } + * } + * result (Optional): { + * baseline (Optional): { + * candidate_id: String (Optional) + * name: String (Required) + * config (Required): (recursive schema, see config above) + * mutations (Required): { + * String: BinaryData (Required) + * } + * rationale: String (Required) + * avg_score: double (Required) + * avg_tokens: double (Required) + * pass_rate: double (Required) + * task_scores (Required): [ + * (Required){ + * task_name: String (Required) + * query: String (Optional) + * scores (Required): { + * String: double (Required) + * } + * composite_score: double (Required) + * tokens: int (Required) + * duration_seconds: double (Required) + * passed: boolean (Required) + * error_message: String (Optional) + * rationales (Optional): { + * String: String (Required) + * } + * response: String (Optional) + * run_id: String (Optional) + * } + * ] + * is_pareto_optimal: boolean (Required) + * sample_avg_score: Double (Optional) + * sample_size: Integer (Optional) + * evaluation_type: String (Optional) + * strategy: String(instruction/model/skill) (Optional) + * eval_id: String (Optional) + * eval_run_id: String (Optional) + * } + * best (Optional): (recursive schema, see best above) + * candidates (Optional): [ + * (recursive schema, see above) + * ] + * pareto_frontier (Optional): [ + * (recursive schema, see above) + * ] + * validation_score (Optional): (recursive schema, see validation_score above) + * options (Optional): (recursive schema, see options above) + * sample_size: Integer (Optional) + * warnings (Optional): [ + * String (Optional) + * ] + * all_strategies_failed: Boolean (Optional) + * } + * status: String(queued/in_progress/succeeded/failed/cancelled) (Required) + * error (Optional): { + * code: String (Required) + * message: String (Required) + * param: String (Optional) + * type: String (Optional) + * details (Optional): [ + * (recursive schema, see above) + * ] + * additionalInfo (Optional): { + * String: BinaryData (Required) + * } + * debugInfo (Optional): { + * String: BinaryData (Required) + * } + * } + * created_at: long (Required) + * updated_at: Long (Optional) + * progress (Optional): { + * current_strategy: String(instruction/model/skill) (Required) + * current_iteration: int (Required) + * tasks_completed: int (Required) + * tasks_total: int (Required) + * best_score: double (Required) + * elapsed_seconds: double (Required) + * } + * } + * } + *+ * + *Response Body Schema
+ * + *+ * {@code + * { + * id: String (Required) + * inputs (Optional): { + * agent (Required): { + * agent_name: String (Required) + * agent_version: String (Optional) + * model: String (Optional) + * system_prompt: String (Optional) + * skills (Optional): [ + * (Optional){ + * name: String (Required) + * description: String (Optional) + * } + * ] + * } + * dataset (Optional): [ + * (Optional){ + * name: String (Required) + * query: String (Required) + * ground_truth: String (Optional) + * criteria (Optional): [ + * (Optional){ + * name: String (Required) + * instruction: String (Required) + * } + * ] + * eval_results (Optional): [ + * (Optional){ + * name: String (Required) + * type: String (Optional) + * score: double (Required) + * passed: boolean (Required) + * sample (Optional): { + * String: BinaryData (Required) + * } + * status: String(completed/errored/skipped) (Optional) + * metric: String (Optional) + * label: String (Optional) + * threshold: Double (Optional) + * reason: String (Optional) + * properties (Optional): { + * String: String (Required) + * } + * (Optional): { + * String: BinaryData (Required) + * } + * } + * ] + * response_items (Optional): [ + * BinaryData (Optional) + * ] + * } + * ] + * train_dataset_reference (Optional): { + * name: String (Required) + * version: String (Optional) + * } + * validation_dataset_reference (Optional): (recursive schema, see validation_dataset_reference above) + * evaluators (Optional): [ + * String (Optional) + * ] + * criteria (Optional): [ + * (recursive schema, see above) + * ] + * options (Optional): { + * strategies (Optional): [ + * String(instruction/model/skill) (Optional) + * ] + * budget: Integer (Optional) + * max_iterations: Integer (Optional) + * tasks_per_iteration: Integer (Optional) + * max_reflection_tasks: Integer (Optional) + * min_improvement: Double (Optional) + * pass_threshold: Double (Optional) + * improvement_threshold: Double (Optional) + * mode: String(optimize) (Optional) + * eval_model: String (Optional) + * reflection_model: String (Optional) + * task_timeout_seconds: Long (Optional) + * keep_versions: Boolean (Optional) + * } + * } + * result (Optional): { + * baseline (Optional): { + * candidate_id: String (Optional) + * name: String (Required) + * config (Required): (recursive schema, see config above) + * mutations (Required): { + * String: BinaryData (Required) + * } + * rationale: String (Required) + * avg_score: double (Required) + * avg_tokens: double (Required) + * pass_rate: double (Required) + * task_scores (Required): [ + * (Required){ + * task_name: String (Required) + * query: String (Optional) + * scores (Required): { + * String: double (Required) + * } + * composite_score: double (Required) + * tokens: int (Required) + * duration_seconds: double (Required) + * passed: boolean (Required) + * error_message: String (Optional) + * rationales (Optional): { + * String: String (Required) + * } + * response: String (Optional) + * run_id: String (Optional) + * } + * ] + * is_pareto_optimal: boolean (Required) + * sample_avg_score: Double (Optional) + * sample_size: Integer (Optional) + * evaluation_type: String (Optional) + * strategy: String(instruction/model/skill) (Optional) + * eval_id: String (Optional) + * eval_run_id: String (Optional) + * } + * best (Optional): (recursive schema, see best above) + * candidates (Optional): [ + * (recursive schema, see above) + * ] + * pareto_frontier (Optional): [ + * (recursive schema, see above) + * ] + * validation_score (Optional): (recursive schema, see validation_score above) + * options (Optional): (recursive schema, see options above) + * sample_size: Integer (Optional) + * warnings (Optional): [ + * String (Optional) + * ] + * all_strategies_failed: Boolean (Optional) + * } + * status: String(queued/in_progress/succeeded/failed/cancelled) (Required) + * error (Optional): { + * code: String (Required) + * message: String (Required) + * param: String (Optional) + * type: String (Optional) + * details (Optional): [ + * (recursive schema, see above) + * ] + * additionalInfo (Optional): { + * String: BinaryData (Required) + * } + * debugInfo (Optional): { + * String: BinaryData (Required) + * } + * } + * created_at: long (Required) + * updated_at: Long (Optional) + * progress (Optional): { + * current_strategy: String(instruction/model/skill) (Required) + * current_iteration: int (Required) + * tasks_completed: int (Required) + * tasks_total: int (Required) + * best_score: double (Required) + * elapsed_seconds: double (Required) + * } + * } + * } + *+ * + * @param job The job to create. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return agent optimization job resource — a long-running job that optimizes an agent's configuration + * (instructions, model, skills) to maximize evaluation scores along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponsecreateOptimizationJobWithResponse(BinaryData job, RequestOptions requestOptions) { + return this.serviceClient.createOptimizationJobWithResponse(job, requestOptions); + } + + /** + * Get info about an agent optimization job. + * + * Get an optimization job by id. Emits `Retry-After` while the job is non-terminal. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "Evaluations=V1Preview", + * "Schedules=V1Preview", "RedTeams=V1Preview", "Insights=V1Preview", "MemoryStores=V1Preview", + * "Routines=V1Preview", "Skills=V1Preview", "DataGenerationJobs=V1Preview", "Models=V1Preview", + * "AgentsOptimization=V1Preview". Response Body Schema
+ * + *+ * {@code + * { + * id: String (Required) + * inputs (Optional): { + * agent (Required): { + * agent_name: String (Required) + * agent_version: String (Optional) + * model: String (Optional) + * system_prompt: String (Optional) + * skills (Optional): [ + * (Optional){ + * name: String (Required) + * description: String (Optional) + * } + * ] + * } + * dataset (Optional): [ + * (Optional){ + * name: String (Required) + * query: String (Required) + * ground_truth: String (Optional) + * criteria (Optional): [ + * (Optional){ + * name: String (Required) + * instruction: String (Required) + * } + * ] + * eval_results (Optional): [ + * (Optional){ + * name: String (Required) + * type: String (Optional) + * score: double (Required) + * passed: boolean (Required) + * sample (Optional): { + * String: BinaryData (Required) + * } + * status: String(completed/errored/skipped) (Optional) + * metric: String (Optional) + * label: String (Optional) + * threshold: Double (Optional) + * reason: String (Optional) + * properties (Optional): { + * String: String (Required) + * } + * (Optional): { + * String: BinaryData (Required) + * } + * } + * ] + * response_items (Optional): [ + * BinaryData (Optional) + * ] + * } + * ] + * train_dataset_reference (Optional): { + * name: String (Required) + * version: String (Optional) + * } + * validation_dataset_reference (Optional): (recursive schema, see validation_dataset_reference above) + * evaluators (Optional): [ + * String (Optional) + * ] + * criteria (Optional): [ + * (recursive schema, see above) + * ] + * options (Optional): { + * strategies (Optional): [ + * String(instruction/model/skill) (Optional) + * ] + * budget: Integer (Optional) + * max_iterations: Integer (Optional) + * tasks_per_iteration: Integer (Optional) + * max_reflection_tasks: Integer (Optional) + * min_improvement: Double (Optional) + * pass_threshold: Double (Optional) + * improvement_threshold: Double (Optional) + * mode: String(optimize) (Optional) + * eval_model: String (Optional) + * reflection_model: String (Optional) + * task_timeout_seconds: Long (Optional) + * keep_versions: Boolean (Optional) + * } + * } + * result (Optional): { + * baseline (Optional): { + * candidate_id: String (Optional) + * name: String (Required) + * config (Required): (recursive schema, see config above) + * mutations (Required): { + * String: BinaryData (Required) + * } + * rationale: String (Required) + * avg_score: double (Required) + * avg_tokens: double (Required) + * pass_rate: double (Required) + * task_scores (Required): [ + * (Required){ + * task_name: String (Required) + * query: String (Optional) + * scores (Required): { + * String: double (Required) + * } + * composite_score: double (Required) + * tokens: int (Required) + * duration_seconds: double (Required) + * passed: boolean (Required) + * error_message: String (Optional) + * rationales (Optional): { + * String: String (Required) + * } + * response: String (Optional) + * run_id: String (Optional) + * } + * ] + * is_pareto_optimal: boolean (Required) + * sample_avg_score: Double (Optional) + * sample_size: Integer (Optional) + * evaluation_type: String (Optional) + * strategy: String(instruction/model/skill) (Optional) + * eval_id: String (Optional) + * eval_run_id: String (Optional) + * } + * best (Optional): (recursive schema, see best above) + * candidates (Optional): [ + * (recursive schema, see above) + * ] + * pareto_frontier (Optional): [ + * (recursive schema, see above) + * ] + * validation_score (Optional): (recursive schema, see validation_score above) + * options (Optional): (recursive schema, see options above) + * sample_size: Integer (Optional) + * warnings (Optional): [ + * String (Optional) + * ] + * all_strategies_failed: Boolean (Optional) + * } + * status: String(queued/in_progress/succeeded/failed/cancelled) (Required) + * error (Optional): { + * code: String (Required) + * message: String (Required) + * param: String (Optional) + * type: String (Optional) + * details (Optional): [ + * (recursive schema, see above) + * ] + * additionalInfo (Optional): { + * String: BinaryData (Required) + * } + * debugInfo (Optional): { + * String: BinaryData (Required) + * } + * } + * created_at: long (Required) + * updated_at: Long (Optional) + * progress (Optional): { + * current_strategy: String(instruction/model/skill) (Required) + * current_iteration: int (Required) + * tasks_completed: int (Required) + * tasks_total: int (Required) + * best_score: double (Required) + * elapsed_seconds: double (Required) + * } + * } + * } + *+ * + * @param jobId The ID of the job. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return info about an agent optimization job. + * + * Get an optimization job by id along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponsegetOptimizationJobWithResponse(String jobId, RequestOptions requestOptions) { + return this.serviceClient.getOptimizationJobWithResponse(jobId, requestOptions); + } + + /** + * Returns a list of agent optimization jobs. + * + * List optimization jobs. Supports cursor pagination and optional `status` / `agent_name` filters. + * Query Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *Query Parameters + *+ * Name Type Required Description + * limit Integer No A limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the + * default is 20. + * order String No Sort order by the `created_at` timestamp of the objects. `asc` + * for ascending order and`desc` + * for descending order. Allowed values: "asc", "desc". + * after String No A cursor for use in pagination. `after` is an object ID that + * defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include after=obj_foo in order to fetch the next page of the list. + * before String No A cursor for use in pagination. `before` is an object ID that + * defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include before=obj_foo in order to fetch the previous page of the list. + * status String No Filter to jobs in this lifecycle state. Allowed values: + * "queued", "in_progress", "succeeded", "failed", "cancelled". + * agent_name String No Filter to jobs targeting this agent name. Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "Evaluations=V1Preview", + * "Schedules=V1Preview", "RedTeams=V1Preview", "Insights=V1Preview", "MemoryStores=V1Preview", + * "Routines=V1Preview", "Skills=V1Preview", "DataGenerationJobs=V1Preview", "Models=V1Preview", + * "AgentsOptimization=V1Preview". Response Body Schema
+ * + *+ * {@code + * { + * id: String (Required) + * inputs (Optional): { + * agent (Required): { + * agent_name: String (Required) + * agent_version: String (Optional) + * model: String (Optional) + * system_prompt: String (Optional) + * skills (Optional): [ + * (Optional){ + * name: String (Required) + * description: String (Optional) + * } + * ] + * } + * dataset (Optional): [ + * (Optional){ + * name: String (Required) + * query: String (Required) + * ground_truth: String (Optional) + * criteria (Optional): [ + * (Optional){ + * name: String (Required) + * instruction: String (Required) + * } + * ] + * eval_results (Optional): [ + * (Optional){ + * name: String (Required) + * type: String (Optional) + * score: double (Required) + * passed: boolean (Required) + * sample (Optional): { + * String: BinaryData (Required) + * } + * status: String(completed/errored/skipped) (Optional) + * metric: String (Optional) + * label: String (Optional) + * threshold: Double (Optional) + * reason: String (Optional) + * properties (Optional): { + * String: String (Required) + * } + * (Optional): { + * String: BinaryData (Required) + * } + * } + * ] + * response_items (Optional): [ + * BinaryData (Optional) + * ] + * } + * ] + * train_dataset_reference (Optional): { + * name: String (Required) + * version: String (Optional) + * } + * validation_dataset_reference (Optional): (recursive schema, see validation_dataset_reference above) + * evaluators (Optional): [ + * String (Optional) + * ] + * criteria (Optional): [ + * (recursive schema, see above) + * ] + * options (Optional): { + * strategies (Optional): [ + * String(instruction/model/skill) (Optional) + * ] + * budget: Integer (Optional) + * max_iterations: Integer (Optional) + * tasks_per_iteration: Integer (Optional) + * max_reflection_tasks: Integer (Optional) + * min_improvement: Double (Optional) + * pass_threshold: Double (Optional) + * improvement_threshold: Double (Optional) + * mode: String(optimize) (Optional) + * eval_model: String (Optional) + * reflection_model: String (Optional) + * task_timeout_seconds: Long (Optional) + * keep_versions: Boolean (Optional) + * } + * } + * result (Optional): { + * baseline (Optional): { + * candidate_id: String (Optional) + * name: String (Required) + * config (Required): (recursive schema, see config above) + * mutations (Required): { + * String: BinaryData (Required) + * } + * rationale: String (Required) + * avg_score: double (Required) + * avg_tokens: double (Required) + * pass_rate: double (Required) + * task_scores (Required): [ + * (Required){ + * task_name: String (Required) + * query: String (Optional) + * scores (Required): { + * String: double (Required) + * } + * composite_score: double (Required) + * tokens: int (Required) + * duration_seconds: double (Required) + * passed: boolean (Required) + * error_message: String (Optional) + * rationales (Optional): { + * String: String (Required) + * } + * response: String (Optional) + * run_id: String (Optional) + * } + * ] + * is_pareto_optimal: boolean (Required) + * sample_avg_score: Double (Optional) + * sample_size: Integer (Optional) + * evaluation_type: String (Optional) + * strategy: String(instruction/model/skill) (Optional) + * eval_id: String (Optional) + * eval_run_id: String (Optional) + * } + * best (Optional): (recursive schema, see best above) + * candidates (Optional): [ + * (recursive schema, see above) + * ] + * pareto_frontier (Optional): [ + * (recursive schema, see above) + * ] + * validation_score (Optional): (recursive schema, see validation_score above) + * options (Optional): (recursive schema, see options above) + * sample_size: Integer (Optional) + * warnings (Optional): [ + * String (Optional) + * ] + * all_strategies_failed: Boolean (Optional) + * } + * status: String(queued/in_progress/succeeded/failed/cancelled) (Required) + * error (Optional): { + * code: String (Required) + * message: String (Required) + * param: String (Optional) + * type: String (Optional) + * details (Optional): [ + * (recursive schema, see above) + * ] + * additionalInfo (Optional): { + * String: BinaryData (Required) + * } + * debugInfo (Optional): { + * String: BinaryData (Required) + * } + * } + * created_at: long (Required) + * updated_at: Long (Optional) + * progress (Optional): { + * current_strategy: String(instruction/model/skill) (Required) + * current_iteration: int (Required) + * tasks_completed: int (Required) + * tasks_total: int (Required) + * best_score: double (Required) + * elapsed_seconds: double (Required) + * } + * } + * } + *+ * + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterablelistOptimizationJobs(RequestOptions requestOptions) { + return this.serviceClient.listOptimizationJobs(requestOptions); + } + + /** + * Cancels an agent optimization job. + * + * Request cancellation. Idempotent on terminal states. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "Evaluations=V1Preview", + * "Schedules=V1Preview", "RedTeams=V1Preview", "Insights=V1Preview", "MemoryStores=V1Preview", + * "Routines=V1Preview", "Skills=V1Preview", "DataGenerationJobs=V1Preview", "Models=V1Preview", + * "AgentsOptimization=V1Preview". Response Body Schema
+ * + *+ * {@code + * { + * id: String (Required) + * inputs (Optional): { + * agent (Required): { + * agent_name: String (Required) + * agent_version: String (Optional) + * model: String (Optional) + * system_prompt: String (Optional) + * skills (Optional): [ + * (Optional){ + * name: String (Required) + * description: String (Optional) + * } + * ] + * } + * dataset (Optional): [ + * (Optional){ + * name: String (Required) + * query: String (Required) + * ground_truth: String (Optional) + * criteria (Optional): [ + * (Optional){ + * name: String (Required) + * instruction: String (Required) + * } + * ] + * eval_results (Optional): [ + * (Optional){ + * name: String (Required) + * type: String (Optional) + * score: double (Required) + * passed: boolean (Required) + * sample (Optional): { + * String: BinaryData (Required) + * } + * status: String(completed/errored/skipped) (Optional) + * metric: String (Optional) + * label: String (Optional) + * threshold: Double (Optional) + * reason: String (Optional) + * properties (Optional): { + * String: String (Required) + * } + * (Optional): { + * String: BinaryData (Required) + * } + * } + * ] + * response_items (Optional): [ + * BinaryData (Optional) + * ] + * } + * ] + * train_dataset_reference (Optional): { + * name: String (Required) + * version: String (Optional) + * } + * validation_dataset_reference (Optional): (recursive schema, see validation_dataset_reference above) + * evaluators (Optional): [ + * String (Optional) + * ] + * criteria (Optional): [ + * (recursive schema, see above) + * ] + * options (Optional): { + * strategies (Optional): [ + * String(instruction/model/skill) (Optional) + * ] + * budget: Integer (Optional) + * max_iterations: Integer (Optional) + * tasks_per_iteration: Integer (Optional) + * max_reflection_tasks: Integer (Optional) + * min_improvement: Double (Optional) + * pass_threshold: Double (Optional) + * improvement_threshold: Double (Optional) + * mode: String(optimize) (Optional) + * eval_model: String (Optional) + * reflection_model: String (Optional) + * task_timeout_seconds: Long (Optional) + * keep_versions: Boolean (Optional) + * } + * } + * result (Optional): { + * baseline (Optional): { + * candidate_id: String (Optional) + * name: String (Required) + * config (Required): (recursive schema, see config above) + * mutations (Required): { + * String: BinaryData (Required) + * } + * rationale: String (Required) + * avg_score: double (Required) + * avg_tokens: double (Required) + * pass_rate: double (Required) + * task_scores (Required): [ + * (Required){ + * task_name: String (Required) + * query: String (Optional) + * scores (Required): { + * String: double (Required) + * } + * composite_score: double (Required) + * tokens: int (Required) + * duration_seconds: double (Required) + * passed: boolean (Required) + * error_message: String (Optional) + * rationales (Optional): { + * String: String (Required) + * } + * response: String (Optional) + * run_id: String (Optional) + * } + * ] + * is_pareto_optimal: boolean (Required) + * sample_avg_score: Double (Optional) + * sample_size: Integer (Optional) + * evaluation_type: String (Optional) + * strategy: String(instruction/model/skill) (Optional) + * eval_id: String (Optional) + * eval_run_id: String (Optional) + * } + * best (Optional): (recursive schema, see best above) + * candidates (Optional): [ + * (recursive schema, see above) + * ] + * pareto_frontier (Optional): [ + * (recursive schema, see above) + * ] + * validation_score (Optional): (recursive schema, see validation_score above) + * options (Optional): (recursive schema, see options above) + * sample_size: Integer (Optional) + * warnings (Optional): [ + * String (Optional) + * ] + * all_strategies_failed: Boolean (Optional) + * } + * status: String(queued/in_progress/succeeded/failed/cancelled) (Required) + * error (Optional): { + * code: String (Required) + * message: String (Required) + * param: String (Optional) + * type: String (Optional) + * details (Optional): [ + * (recursive schema, see above) + * ] + * additionalInfo (Optional): { + * String: BinaryData (Required) + * } + * debugInfo (Optional): { + * String: BinaryData (Required) + * } + * } + * created_at: long (Required) + * updated_at: Long (Optional) + * progress (Optional): { + * current_strategy: String(instruction/model/skill) (Required) + * current_iteration: int (Required) + * tasks_completed: int (Required) + * tasks_total: int (Required) + * best_score: double (Required) + * elapsed_seconds: double (Required) + * } + * } + * } + *+ * + * @param jobId The ID of the job to cancel. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return agent optimization job resource — a long-running job that optimizes an agent's configuration + * (instructions, model, skills) to maximize evaluation scores along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponsecancelOptimizationJobWithResponse(String jobId, RequestOptions requestOptions) { + return this.serviceClient.cancelOptimizationJobWithResponse(jobId, requestOptions); + } + + /** + * Deletes an agent optimization job. + * + * Delete the job and its candidate artifacts. Cancels first if non-terminal. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + * + * @param jobId The ID of the job to delete. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponseHeader Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "Evaluations=V1Preview", + * "Schedules=V1Preview", "RedTeams=V1Preview", "Insights=V1Preview", "MemoryStores=V1Preview", + * "Routines=V1Preview", "Skills=V1Preview", "DataGenerationJobs=V1Preview", "Models=V1Preview", + * "AgentsOptimization=V1Preview". deleteOptimizationJobWithResponse(String jobId, RequestOptions requestOptions) { + return this.serviceClient.deleteOptimizationJobWithResponse(jobId, requestOptions); + } + + /** + * Returns a list of candidates for an optimization job. + * + * List candidates produced by a job. + * Query Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *Query Parameters + *+ * Name Type Required Description + * limit Integer No A limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the + * default is 20. + * order String No Sort order by the `created_at` timestamp of the objects. `asc` + * for ascending order and`desc` + * for descending order. Allowed values: "asc", "desc". + * after String No A cursor for use in pagination. `after` is an object ID that + * defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include after=obj_foo in order to fetch the next page of the list. + * before String No A cursor for use in pagination. `before` is an object ID that + * defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include before=obj_foo in order to fetch the previous page of the list. Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "Evaluations=V1Preview", + * "Schedules=V1Preview", "RedTeams=V1Preview", "Insights=V1Preview", "MemoryStores=V1Preview", + * "Routines=V1Preview", "Skills=V1Preview", "DataGenerationJobs=V1Preview", "Models=V1Preview", + * "AgentsOptimization=V1Preview". Response Body Schema
+ * + *+ * {@code + * { + * data (Required): [ + * (Required){ + * candidate_id: String (Optional) + * name: String (Required) + * config (Required): { + * agent_name: String (Required) + * agent_version: String (Optional) + * model: String (Optional) + * system_prompt: String (Optional) + * skills (Optional): [ + * (Optional){ + * name: String (Required) + * description: String (Optional) + * } + * ] + * } + * mutations (Required): { + * String: BinaryData (Required) + * } + * rationale: String (Required) + * avg_score: double (Required) + * avg_tokens: double (Required) + * pass_rate: double (Required) + * task_scores (Required): [ + * (Required){ + * task_name: String (Required) + * query: String (Optional) + * scores (Required): { + * String: double (Required) + * } + * composite_score: double (Required) + * tokens: int (Required) + * duration_seconds: double (Required) + * passed: boolean (Required) + * error_message: String (Optional) + * rationales (Optional): { + * String: String (Required) + * } + * response: String (Optional) + * run_id: String (Optional) + * } + * ] + * is_pareto_optimal: boolean (Required) + * sample_avg_score: Double (Optional) + * sample_size: Integer (Optional) + * evaluation_type: String (Optional) + * strategy: String(instruction/model/skill) (Optional) + * eval_id: String (Optional) + * eval_run_id: String (Optional) + * } + * ] + * first_id: String (Optional) + * last_id: String (Optional) + * has_more: boolean (Required) + * } + * } + *+ * + * @param jobId The optimization job id. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponselistOptimizationCandidatesWithResponse(String jobId, RequestOptions requestOptions) { + return this.serviceClient.listOptimizationCandidatesWithResponse(jobId, requestOptions); + } + + /** + * Get a candidate by id. + * + * Get a single candidate manifest and aggregated evaluation summary. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "Evaluations=V1Preview", + * "Schedules=V1Preview", "RedTeams=V1Preview", "Insights=V1Preview", "MemoryStores=V1Preview", + * "Routines=V1Preview", "Skills=V1Preview", "DataGenerationJobs=V1Preview", "Models=V1Preview", + * "AgentsOptimization=V1Preview". Response Body Schema
+ * + *+ * {@code + * { + * candidate_id: String (Optional) + * name: String (Required) + * config (Required): { + * agent_name: String (Required) + * agent_version: String (Optional) + * model: String (Optional) + * system_prompt: String (Optional) + * skills (Optional): [ + * (Optional){ + * name: String (Required) + * description: String (Optional) + * } + * ] + * } + * mutations (Required): { + * String: BinaryData (Required) + * } + * rationale: String (Required) + * avg_score: double (Required) + * avg_tokens: double (Required) + * pass_rate: double (Required) + * task_scores (Required): [ + * (Required){ + * task_name: String (Required) + * query: String (Optional) + * scores (Required): { + * String: double (Required) + * } + * composite_score: double (Required) + * tokens: int (Required) + * duration_seconds: double (Required) + * passed: boolean (Required) + * error_message: String (Optional) + * rationales (Optional): { + * String: String (Required) + * } + * response: String (Optional) + * run_id: String (Optional) + * } + * ] + * is_pareto_optimal: boolean (Required) + * sample_avg_score: Double (Optional) + * sample_size: Integer (Optional) + * evaluation_type: String (Optional) + * strategy: String(instruction/model/skill) (Optional) + * eval_id: String (Optional) + * eval_run_id: String (Optional) + * } + * } + *+ * + * @param jobId The optimization job id. + * @param candidateId The candidate id. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a candidate by id. + * + * Get a single candidate manifest and aggregated evaluation summary along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponsegetOptimizationCandidateWithResponse(String jobId, String candidateId, + RequestOptions requestOptions) { + return this.serviceClient.getOptimizationCandidateWithResponse(jobId, candidateId, requestOptions); + } + + /** + * Get candidate deploy config. + * + * Get the candidate's deploy config JSON. Used to compose `agents.create_version(...)` from a candidate. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "Evaluations=V1Preview", + * "Schedules=V1Preview", "RedTeams=V1Preview", "Insights=V1Preview", "MemoryStores=V1Preview", + * "Routines=V1Preview", "Skills=V1Preview", "DataGenerationJobs=V1Preview", "Models=V1Preview", + * "AgentsOptimization=V1Preview". Response Body Schema
+ * + *+ * {@code + * { + * instructions: String (Optional) + * model: String (Optional) + * temperature: Double (Optional) + * skills (Optional): [ + * (Optional){ + * name: String (Required) + * description: String (Optional) + * } + * ] + * } + * } + *+ * + * @param jobId The optimization job id. + * @param candidateId The candidate id. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return candidate deploy config. + * + * Get the candidate's deploy config JSON along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponsegetOptimizationCandidateConfigWithResponse(String jobId, String candidateId, + RequestOptions requestOptions) { + return this.serviceClient.getOptimizationCandidateConfigWithResponse(jobId, candidateId, requestOptions); + } + + /** + * Get candidate evaluation results. + * + * Get full per-task evaluation results for a candidate. + * Header Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addHeader} + *Header Parameters + *+ * Name Type Required Description + * Foundry-Features String No A feature flag opt-in required when using preview + * operations or modifying persisted preview resources. Allowed values: "Evaluations=V1Preview", + * "Schedules=V1Preview", "RedTeams=V1Preview", "Insights=V1Preview", "MemoryStores=V1Preview", + * "Routines=V1Preview", "Skills=V1Preview", "DataGenerationJobs=V1Preview", "Models=V1Preview", + * "AgentsOptimization=V1Preview". Response Body Schema
+ * + *+ * {@code + * { + * candidate_id: String (Required) + * results (Required): [ + * (Required){ + * task_name: String (Required) + * query: String (Optional) + * scores (Required): { + * String: double (Required) + * } + * composite_score: double (Required) + * tokens: int (Required) + * duration_seconds: double (Required) + * passed: boolean (Required) + * error_message: String (Optional) + * rationales (Optional): { + * String: String (Required) + * } + * response: String (Optional) + * run_id: String (Optional) + * } + * ] + * } + * } + *+ * + * @param jobId The optimization job id. + * @param candidateId The candidate id. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return candidate evaluation results. + * + * Get full per-task evaluation results for a candidate along with {@link Response}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public ResponsegetOptimizationCandidateResultsWithResponse(String jobId, String candidateId, + RequestOptions requestOptions) { + return this.serviceClient.getOptimizationCandidateResultsWithResponse(jobId, candidateId, requestOptions); + } + + /** + * Creates an agent optimization job. + * + * Create an optimization job. Returns 201 with the queued job. Honours `Operation-Id` for idempotent retry. + * + * @param job The job to create. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @param operationId Client-generated unique ID for idempotent retries. When absent, the server creates the job + * unconditionally. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return agent optimization job resource — a long-running job that optimizes an agent's configuration + * (instructions, model, skills) to maximize evaluation scores. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public OptimizationJob createOptimizationJob(OptimizationJob job, FoundryFeaturesOptInKeys foundryFeatures, + String operationId) { + // Generated convenience method for createOptimizationJobWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + if (operationId != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Operation-Id"), operationId); + } + return createOptimizationJobWithResponse(BinaryData.fromObject(job), requestOptions).getValue() + .toObject(OptimizationJob.class); + } + + /** + * Creates an agent optimization job. + * + * Create an optimization job. Returns 201 with the queued job. Honours `Operation-Id` for idempotent retry. + * + * @param job The job to create. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return agent optimization job resource — a long-running job that optimizes an agent's configuration + * (instructions, model, skills) to maximize evaluation scores. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public OptimizationJob createOptimizationJob(OptimizationJob job) { + // Generated convenience method for createOptimizationJobWithResponse + RequestOptions requestOptions = new RequestOptions(); + return createOptimizationJobWithResponse(BinaryData.fromObject(job), requestOptions).getValue() + .toObject(OptimizationJob.class); + } + + /** + * Get info about an agent optimization job. + * + * Get an optimization job by id. Emits `Retry-After` while the job is non-terminal. + * + * @param jobId The ID of the job. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return info about an agent optimization job. + * + * Get an optimization job by id. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public OptimizationJob getOptimizationJob(String jobId, FoundryFeaturesOptInKeys foundryFeatures) { + // Generated convenience method for getOptimizationJobWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + return getOptimizationJobWithResponse(jobId, requestOptions).getValue().toObject(OptimizationJob.class); + } + + /** + * Get info about an agent optimization job. + * + * Get an optimization job by id. Emits `Retry-After` while the job is non-terminal. + * + * @param jobId The ID of the job. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return info about an agent optimization job. + * + * Get an optimization job by id. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public OptimizationJob getOptimizationJob(String jobId) { + // Generated convenience method for getOptimizationJobWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getOptimizationJobWithResponse(jobId, requestOptions).getValue().toObject(OptimizationJob.class); + } + + /** + * Returns a list of agent optimization jobs. + * + * List optimization jobs. Supports cursor pagination and optional `status` / `agent_name` filters. + * + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the + * default is 20. + * @param order Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` + * for descending order. + * @param after A cursor for use in pagination. `after` is an object ID that defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include after=obj_foo in order to fetch the next page of the list. + * @param before A cursor for use in pagination. `before` is an object ID that defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include before=obj_foo in order to fetch the previous page of the list. + * @param status Filter to jobs in this lifecycle state. + * @param agentName Filter to jobs targeting this agent name. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listOptimizationJobs(FoundryFeaturesOptInKeys foundryFeatures, Integer limit, + PageOrder order, String after, String before, JobStatus status, String agentName) { + // Generated convenience method for listOptimizationJobs + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + if (status != null) { + requestOptions.addQueryParam("status", status.toString(), false); + } + if (agentName != null) { + requestOptions.addQueryParam("agent_name", agentName, false); + } + return serviceClient.listOptimizationJobs(requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(OptimizationJob.class)); + } + + /** + * Returns a list of agent optimization jobs. + * + * List optimization jobs. Supports cursor pagination and optional `status` / `agent_name` filters. + * + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items as paginated response with {@link PagedIterable}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedIterable listOptimizationJobs() { + // Generated convenience method for listOptimizationJobs + RequestOptions requestOptions = new RequestOptions(); + return serviceClient.listOptimizationJobs(requestOptions) + .mapPage(bodyItemValue -> bodyItemValue.toObject(OptimizationJob.class)); + } + + /** + * Cancels an agent optimization job. + * + * Request cancellation. Idempotent on terminal states. + * + * @param jobId The ID of the job to cancel. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return agent optimization job resource — a long-running job that optimizes an agent's configuration + * (instructions, model, skills) to maximize evaluation scores. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public OptimizationJob cancelOptimizationJob(String jobId, FoundryFeaturesOptInKeys foundryFeatures) { + // Generated convenience method for cancelOptimizationJobWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + return cancelOptimizationJobWithResponse(jobId, requestOptions).getValue().toObject(OptimizationJob.class); + } + + /** + * Cancels an agent optimization job. + * + * Request cancellation. Idempotent on terminal states. + * + * @param jobId The ID of the job to cancel. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return agent optimization job resource — a long-running job that optimizes an agent's configuration + * (instructions, model, skills) to maximize evaluation scores. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public OptimizationJob cancelOptimizationJob(String jobId) { + // Generated convenience method for cancelOptimizationJobWithResponse + RequestOptions requestOptions = new RequestOptions(); + return cancelOptimizationJobWithResponse(jobId, requestOptions).getValue().toObject(OptimizationJob.class); + } + + /** + * Deletes an agent optimization job. + * + * Delete the job and its candidate artifacts. Cancels first if non-terminal. + * + * @param jobId The ID of the job to delete. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void deleteOptimizationJob(String jobId, FoundryFeaturesOptInKeys foundryFeatures) { + // Generated convenience method for deleteOptimizationJobWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + deleteOptimizationJobWithResponse(jobId, requestOptions).getValue(); + } + + /** + * Deletes an agent optimization job. + * + * Delete the job and its candidate artifacts. Cancels first if non-terminal. + * + * @param jobId The ID of the job to delete. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public void deleteOptimizationJob(String jobId) { + // Generated convenience method for deleteOptimizationJobWithResponse + RequestOptions requestOptions = new RequestOptions(); + deleteOptimizationJobWithResponse(jobId, requestOptions).getValue(); + } + + /** + * Returns a list of candidates for an optimization job. + * + * List candidates produced by a job. + * + * @param jobId The optimization job id. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @param limit A limit on the number of objects to be returned. Limit can range between 1 and 100, and the + * default is 20. + * @param order Sort order by the `created_at` timestamp of the objects. `asc` for ascending order and`desc` + * for descending order. + * @param after A cursor for use in pagination. `after` is an object ID that defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include after=obj_foo in order to fetch the next page of the list. + * @param before A cursor for use in pagination. `before` is an object ID that defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include before=obj_foo in order to fetch the previous page of the list. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public AgentsPagedResultOptimizationCandidate listOptimizationCandidates(String jobId, + FoundryFeaturesOptInKeys foundryFeatures, Integer limit, PageOrder order, String after, String before) { + // Generated convenience method for listOptimizationCandidatesWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + return listOptimizationCandidatesWithResponse(jobId, requestOptions).getValue() + .toObject(AgentsPagedResultOptimizationCandidate.class); + } + + /** + * Returns a list of candidates for an optimization job. + * + * List candidates produced by a job. + * + * @param jobId The optimization job id. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public AgentsPagedResultOptimizationCandidate listOptimizationCandidates(String jobId) { + // Generated convenience method for listOptimizationCandidatesWithResponse + RequestOptions requestOptions = new RequestOptions(); + return listOptimizationCandidatesWithResponse(jobId, requestOptions).getValue() + .toObject(AgentsPagedResultOptimizationCandidate.class); + } + + /** + * Get a candidate by id. + * + * Get a single candidate manifest and aggregated evaluation summary. + * + * @param jobId The optimization job id. + * @param candidateId The candidate id. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a candidate by id. + * + * Get a single candidate manifest and aggregated evaluation summary. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public OptimizationCandidate getOptimizationCandidate(String jobId, String candidateId, + FoundryFeaturesOptInKeys foundryFeatures) { + // Generated convenience method for getOptimizationCandidateWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + return getOptimizationCandidateWithResponse(jobId, candidateId, requestOptions).getValue() + .toObject(OptimizationCandidate.class); + } + + /** + * Get a candidate by id. + * + * Get a single candidate manifest and aggregated evaluation summary. + * + * @param jobId The optimization job id. + * @param candidateId The candidate id. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a candidate by id. + * + * Get a single candidate manifest and aggregated evaluation summary. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public OptimizationCandidate getOptimizationCandidate(String jobId, String candidateId) { + // Generated convenience method for getOptimizationCandidateWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getOptimizationCandidateWithResponse(jobId, candidateId, requestOptions).getValue() + .toObject(OptimizationCandidate.class); + } + + /** + * Get candidate deploy config. + * + * Get the candidate's deploy config JSON. Used to compose `agents.create_version(...)` from a candidate. + * + * @param jobId The optimization job id. + * @param candidateId The candidate id. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return candidate deploy config. + * + * Get the candidate's deploy config JSON. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CandidateDeployConfig getOptimizationCandidateConfig(String jobId, String candidateId, + FoundryFeaturesOptInKeys foundryFeatures) { + // Generated convenience method for getOptimizationCandidateConfigWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + return getOptimizationCandidateConfigWithResponse(jobId, candidateId, requestOptions).getValue() + .toObject(CandidateDeployConfig.class); + } + + /** + * Get candidate deploy config. + * + * Get the candidate's deploy config JSON. Used to compose `agents.create_version(...)` from a candidate. + * + * @param jobId The optimization job id. + * @param candidateId The candidate id. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return candidate deploy config. + * + * Get the candidate's deploy config JSON. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CandidateDeployConfig getOptimizationCandidateConfig(String jobId, String candidateId) { + // Generated convenience method for getOptimizationCandidateConfigWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getOptimizationCandidateConfigWithResponse(jobId, candidateId, requestOptions).getValue() + .toObject(CandidateDeployConfig.class); + } + + /** + * Get candidate evaluation results. + * + * Get full per-task evaluation results for a candidate. + * + * @param jobId The optimization job id. + * @param candidateId The candidate id. + * @param foundryFeatures A feature flag opt-in required when using preview operations or modifying persisted + * preview resources. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return candidate evaluation results. + * + * Get full per-task evaluation results for a candidate. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CandidateResults getOptimizationCandidateResults(String jobId, String candidateId, + FoundryFeaturesOptInKeys foundryFeatures) { + // Generated convenience method for getOptimizationCandidateResultsWithResponse + RequestOptions requestOptions = new RequestOptions(); + if (foundryFeatures != null) { + requestOptions.setHeader(HttpHeaderName.fromString("Foundry-Features"), foundryFeatures.toString()); + } + return getOptimizationCandidateResultsWithResponse(jobId, candidateId, requestOptions).getValue() + .toObject(CandidateResults.class); + } + + /** + * Get candidate evaluation results. + * + * Get full per-task evaluation results for a candidate. + * + * @param jobId The optimization job id. + * @param candidateId The candidate id. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return candidate evaluation results. + * + * Get full per-task evaluation results for a candidate. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public CandidateResults getOptimizationCandidateResults(String jobId, String candidateId) { + // Generated convenience method for getOptimizationCandidateResultsWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getOptimizationCandidateResultsWithResponse(jobId, candidateId, requestOptions).getValue() + .toObject(CandidateResults.class); + } } diff --git a/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/MemoryStoresAsyncClient.java b/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/MemoryStoresAsyncClient.java index 714f31b8f084..f9de3714e4f4 100644 --- a/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/MemoryStoresAsyncClient.java +++ b/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/MemoryStoresAsyncClient.java @@ -5,11 +5,18 @@ import com.azure.ai.agents.implementation.MemoryStoresImpl; import com.azure.ai.agents.implementation.OpenAIJsonHelper; +import com.azure.ai.agents.implementation.models.CreateMemoryRequest; import com.azure.ai.agents.implementation.models.CreateMemoryStoreRequest; import com.azure.ai.agents.implementation.models.InputItem; +import com.azure.ai.agents.implementation.models.ListMemoriesRequest; import com.azure.ai.agents.implementation.models.SearchMemoriesRequest; import com.azure.ai.agents.implementation.models.UpdateMemoriesRequest; +import com.azure.ai.agents.implementation.models.UpdateMemoryRequest; import com.azure.ai.agents.implementation.models.UpdateMemoryStoreRequest; +import com.azure.ai.agents.models.DeleteMemoryResponse; +import com.azure.ai.agents.models.ListMemoriesOptions; +import com.azure.ai.agents.models.MemoryItem; +import com.azure.ai.agents.models.MemoryItemKind; import com.azure.ai.agents.models.MemorySearchOptions; import com.azure.ai.agents.models.MemoryStoreDefinition; import com.azure.ai.agents.models.MemoryStoreDetails; @@ -85,7 +92,7 @@ public final class MemoryStoresAsyncClient { * * {@code * { - * object: String(memory_store/memory_store.deleted/memory_store.scope.deleted) (Required) + * object: String(memory_store/memory_store.deleted/memory_store.scope.deleted/memory_store.item.deleted) (Required) * id: String (Required) * created_at: long (Required) * updated_at: long (Required) @@ -137,7 +144,7 @@ public Mono> createMemoryStoreWithResponse(BinaryData creat * * {@code * { - * object: String(memory_store/memory_store.deleted/memory_store.scope.deleted) (Required) + * object: String(memory_store/memory_store.deleted/memory_store.scope.deleted/memory_store.item.deleted) (Required) * id: String (Required) * created_at: long (Required) * updated_at: long (Required) @@ -177,7 +184,7 @@ public Mono> updateMemoryStoreWithResponse(String name, Bin * * {@code * { - * object: String(memory_store/memory_store.deleted/memory_store.scope.deleted) (Required) + * object: String(memory_store/memory_store.deleted/memory_store.scope.deleted/memory_store.item.deleted) (Required) * id: String (Required) * created_at: long (Required) * updated_at: long (Required) @@ -235,7 +242,7 @@ public Mono> getMemoryStoreWithResponse(String name, Reques * * {@code * { - * object: String(memory_store/memory_store.deleted/memory_store.scope.deleted) (Required) + * object: String(memory_store/memory_store.deleted/memory_store.scope.deleted/memory_store.item.deleted) (Required) * id: String (Required) * created_at: long (Required) * updated_at: long (Required) @@ -307,7 +314,7 @@ public Mono> deleteMemoryStoreWithResponse(String name, RequestOp * (Required){ * kind: String(create/update/delete) (Required) * memory_item (Required): { - * kind: String(user_profile/chat_summary) (Required) + * kind: String(user_profile/chat_summary/procedural) (Required) * memory_id: String (Required) * updated_at: long (Required) * scope: String (Required) @@ -699,7 +706,7 @@ public PagedFlux listMemoryStores(Integer limit, PageOrder o * memories (Required): [ * (Required){ * memory_item (Required): { - * kind: String(user_profile/chat_summary) (Required) + * kind: String(user_profile/chat_summary/procedural) (Required) * memory_id: String (Required) * updated_at: long (Required) * scope: String (Required) @@ -771,7 +778,7 @@ Mono > internalSearchMemoriesWithResponse(String name, Binar * (Required){ * kind: String(create/update/delete) (Required) * memory_item (Required): { - * kind: String(user_profile/chat_summary) (Required) + * kind: String(user_profile/chat_summary/procedural) (Required) * memory_id: String (Required) * updated_at: long (Required) * scope: String (Required) @@ -1018,7 +1025,7 @@ public PollerFlux b * * {@code * { - * object: String(memory_store/memory_store.deleted/memory_store.scope.deleted) (Required) + * object: String(memory_store/memory_store.deleted/memory_store.scope.deleted/memory_store.item.deleted) (Required) * name: String (Required) * deleted: boolean (Required) * } @@ -1056,7 +1063,7 @@ Mono> internalDeleteMemoryStoreWithResponse(String name, Re * * {@code * { - * object: String(memory_store/memory_store.deleted/memory_store.scope.deleted) (Required) + * object: String(memory_store/memory_store.deleted/memory_store.scope.deleted/memory_store.item.deleted) (Required) * name: String (Required) * scope: String (Required) * deleted: boolean (Required) @@ -1080,4 +1087,374 @@ Mono> internalDeleteScopeWithResponse(String name, BinaryDa RequestOptions requestOptions) { return this.serviceClient.internalDeleteScopeWithResponseAsync(name, deleteScopeRequest, requestOptions); } + + /** + * Create a memory item in a memory store. + * Request Body Schema
+ * + *+ * {@code + * { + * scope: String (Required) + * content: String (Required) + * kind: String(user_profile/chat_summary/procedural) (Required) + * } + * } + *+ * + *Response Body Schema
+ * + *+ * {@code + * { + * kind: String(user_profile/chat_summary/procedural) (Required) + * memory_id: String (Required) + * updated_at: long (Required) + * scope: String (Required) + * content: String (Required) + * } + * } + *+ * + * @param name The name of the memory store. + * @param createMemoryRequest The createMemoryRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a single memory item stored in the memory store, containing content and metadata along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> createMemoryWithResponse(String name, BinaryData createMemoryRequest, + RequestOptions requestOptions) { + return this.serviceClient.createMemoryWithResponseAsync(name, createMemoryRequest, requestOptions); + } + + /** + * Update a memory item in a memory store. + * Request Body Schema
+ * + *+ * {@code + * { + * content: String (Required) + * } + * } + *+ * + *Response Body Schema
+ * + *+ * {@code + * { + * kind: String(user_profile/chat_summary/procedural) (Required) + * memory_id: String (Required) + * updated_at: long (Required) + * scope: String (Required) + * content: String (Required) + * } + * } + *+ * + * @param name The name of the memory store. + * @param memoryId The ID of the memory item to update. + * @param updateMemoryRequest The updateMemoryRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a single memory item stored in the memory store, containing content and metadata along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> updateMemoryWithResponse(String name, String memoryId, + BinaryData updateMemoryRequest, RequestOptions requestOptions) { + return this.serviceClient.updateMemoryWithResponseAsync(name, memoryId, updateMemoryRequest, requestOptions); + } + + /** + * Retrieve a memory item from a memory store. + * Response Body Schema
+ * + *+ * {@code + * { + * kind: String(user_profile/chat_summary/procedural) (Required) + * memory_id: String (Required) + * updated_at: long (Required) + * scope: String (Required) + * content: String (Required) + * } + * } + *+ * + * @param name The name of the memory store. + * @param memoryId The ID of the memory item to retrieve. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return a single memory item stored in the memory store, containing content and metadata along with + * {@link Response} on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> getMemoryWithResponse(String name, String memoryId, + RequestOptions requestOptions) { + return this.serviceClient.getMemoryWithResponseAsync(name, memoryId, requestOptions); + } + + /** + * Delete a memory item from a memory store. + * Response Body Schema
+ * + *+ * {@code + * { + * object: String(memory_store/memory_store.deleted/memory_store.scope.deleted/memory_store.item.deleted) (Required) + * memory_id: String (Required) + * deleted: boolean (Required) + * } + * } + *+ * + * @param name The name of the memory store. + * @param memoryId The ID of the memory item to delete. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return response for deleting a memory item from a memory store along with {@link Response} on successful + * completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono> deleteMemoryWithResponse(String name, String memoryId, + RequestOptions requestOptions) { + return this.serviceClient.deleteMemoryWithResponseAsync(name, memoryId, requestOptions); + } + + /** + * Create a memory item in a memory store. + * + * @param name The name of the memory store. + * @param scope The namespace that logically groups and isolates memories, such as a user ID. + * @param content The content of the memory. + * @param kind The kind of the memory item. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a single memory item stored in the memory store, containing content and metadata on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono createMemory(String name, String scope, String content, MemoryItemKind kind) { + // Generated convenience method for createMemoryWithResponse + RequestOptions requestOptions = new RequestOptions(); + CreateMemoryRequest createMemoryRequestObj = new CreateMemoryRequest(scope, content, kind); + BinaryData createMemoryRequest = BinaryData.fromObject(createMemoryRequestObj); + return createMemoryWithResponse(name, createMemoryRequest, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(MemoryItem.class)); + } + + /** + * Update a memory item in a memory store. + * + * @param name The name of the memory store. + * @param memoryId The ID of the memory item to update. + * @param content The updated content of the memory. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a single memory item stored in the memory store, containing content and metadata on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono updateMemory(String name, String memoryId, String content) { + // Generated convenience method for updateMemoryWithResponse + RequestOptions requestOptions = new RequestOptions(); + UpdateMemoryRequest updateMemoryRequestObj = new UpdateMemoryRequest(content); + BinaryData updateMemoryRequest = BinaryData.fromObject(updateMemoryRequestObj); + return updateMemoryWithResponse(name, memoryId, updateMemoryRequest, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(MemoryItem.class)); + } + + /** + * Retrieve a memory item from a memory store. + * + * @param name The name of the memory store. + * @param memoryId The ID of the memory item to retrieve. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return a single memory item stored in the memory store, containing content and metadata on successful completion + * of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono getMemory(String name, String memoryId) { + // Generated convenience method for getMemoryWithResponse + RequestOptions requestOptions = new RequestOptions(); + return getMemoryWithResponse(name, memoryId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(MemoryItem.class)); + } + + /** + * Delete a memory item from a memory store. + * + * @param name The name of the memory store. + * @param memoryId The ID of the memory item to delete. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return response for deleting a memory item from a memory store on successful completion of {@link Mono}. + */ + @Generated + @ServiceMethod(returns = ReturnType.SINGLE) + public Mono deleteMemory(String name, String memoryId) { + // Generated convenience method for deleteMemoryWithResponse + RequestOptions requestOptions = new RequestOptions(); + return deleteMemoryWithResponse(name, memoryId, requestOptions).flatMap(FluxUtil::toMono) + .map(protocolMethodData -> protocolMethodData.toObject(DeleteMemoryResponse.class)); + } + + /** + * List all memory items in a memory store. + * Query Parameters
+ *+ *
+ * You can add these to a request with {@link RequestOptions#addQueryParam} + *Query Parameters + *+ * Name Type Required Description + * kind String No The kind of the memory item. Allowed values: "user_profile", + * "chat_summary", "procedural". + * limit Integer No A limit on the number of objects to be returned. Limit can range + * between 1 and 100, and the + * default is 20. + * order String No Sort order by the `created_at` timestamp of the objects. `asc` + * for ascending order and`desc` + * for descending order. Allowed values: "asc", "desc". + * after String No A cursor for use in pagination. `after` is an object ID that + * defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include after=obj_foo in order to fetch the next page of the list. + * before String No A cursor for use in pagination. `before` is an object ID that + * defines your place in the list. + * For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + * subsequent call can include before=obj_foo in order to fetch the previous page of the list. Request Body Schema
+ * + *+ * {@code + * { + * scope: String (Required) + * } + * } + *+ * + *Response Body Schema
+ * + *+ * {@code + * { + * kind: String(user_profile/chat_summary/procedural) (Required) + * memory_id: String (Required) + * updated_at: long (Required) + * scope: String (Required) + * content: String (Required) + * } + * } + *+ * + * @param name The name of the memory store. + * @param listMemoriesRequest The listMemoriesRequest parameter. + * @param requestOptions The options to configure the HTTP request before HTTP client sends it. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFluxlistMemories(String name, BinaryData listMemoriesRequest, + RequestOptions requestOptions) { + return this.serviceClient.listMemoriesAsync(name, listMemoriesRequest, requestOptions); + } + + /** + * List all memory items in a memory store. + * + * @param options Options for listMemories API. + * @throws IllegalArgumentException thrown if parameters fail the validation. + * @throws HttpResponseException thrown if the request is rejected by server. + * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401. + * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404. + * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409. + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent. + * @return the response data for a requested list of items as paginated response with {@link PagedFlux}. + */ + @Generated + @ServiceMethod(returns = ReturnType.COLLECTION) + public PagedFlux listMemories(ListMemoriesOptions options) { + // Generated convenience method for listMemories + RequestOptions requestOptions = new RequestOptions(); + String name = options.getName(); + MemoryItemKind kind = options.getKind(); + Integer limit = options.getLimit(); + PageOrder order = options.getOrder(); + String after = options.getAfter(); + String before = options.getBefore(); + ListMemoriesRequest listMemoriesRequestObj = new ListMemoriesRequest(options.getScope()); + BinaryData listMemoriesRequest = BinaryData.fromObject(listMemoriesRequestObj); + if (kind != null) { + requestOptions.addQueryParam("kind", kind.toString(), false); + } + if (limit != null) { + requestOptions.addQueryParam("limit", String.valueOf(limit), false); + } + if (order != null) { + requestOptions.addQueryParam("order", order.toString(), false); + } + if (after != null) { + requestOptions.addQueryParam("after", after, false); + } + if (before != null) { + requestOptions.addQueryParam("before", before, false); + } + PagedFlux pagedFluxResponse = listMemories(name, listMemoriesRequest, requestOptions); + return PagedFlux.create(() -> (continuationTokenParam, pageSizeParam) -> { + Flux > flux = (continuationTokenParam == null) + ? pagedFluxResponse.byPage().take(1) + : pagedFluxResponse.byPage(continuationTokenParam).take(1); + return flux.map(pagedResponse -> new PagedResponseBase (pagedResponse.getRequest(), + pagedResponse.getStatusCode(), pagedResponse.getHeaders(), + pagedResponse.getValue() + .stream() + .map(protocolMethodData -> protocolMethodData.toObject(MemoryItem.class)) + .collect(Collectors.toList()), + pagedResponse.getContinuationToken(), null)); + }); + } } diff --git a/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/MemoryStoresClient.java b/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/MemoryStoresClient.java index ed14d4fccbc8..2360080e6a05 100644 --- a/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/MemoryStoresClient.java +++ b/sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/MemoryStoresClient.java @@ -5,11 +5,18 @@ import com.azure.ai.agents.implementation.MemoryStoresImpl; import com.azure.ai.agents.implementation.OpenAIJsonHelper; +import com.azure.ai.agents.implementation.models.CreateMemoryRequest; import com.azure.ai.agents.implementation.models.CreateMemoryStoreRequest; import com.azure.ai.agents.implementation.models.InputItem; +import com.azure.ai.agents.implementation.models.ListMemoriesRequest; import com.azure.ai.agents.implementation.models.SearchMemoriesRequest; import com.azure.ai.agents.implementation.models.UpdateMemoriesRequest; +import com.azure.ai.agents.implementation.models.UpdateMemoryRequest; import com.azure.ai.agents.implementation.models.UpdateMemoryStoreRequest; +import com.azure.ai.agents.models.DeleteMemoryResponse; +import com.azure.ai.agents.models.ListMemoriesOptions; +import com.azure.ai.agents.models.MemoryItem; +import com.azure.ai.agents.models.MemoryItemKind; import com.azure.ai.agents.models.MemorySearchOptions; import com.azure.ai.agents.models.MemoryStoreDefinition; import com.azure.ai.agents.models.MemoryStoreDetails; @@ -79,7 +86,7 @@ public final class MemoryStoresClient { * * {@code * { - * object: String(memory_store/memory_store.deleted/memory_store.scope.deleted) (Required) + * object: String(memory_store/memory_store.deleted/memory_store.scope.deleted/memory_store.item.deleted) (Required) * id: String (Required) * created_at: long (Required) * updated_at: long (Required) @@ -130,7 +137,7 @@ public ResponsecreateMemoryStoreWithResponse(BinaryData createMemor * * {@code * { - * object: String(memory_store/memory_store.deleted/memory_store.scope.deleted) (Required) + * object: String(memory_store/memory_store.deleted/memory_store.scope.deleted/memory_store.item.deleted) (Required) * id: String (Required) * created_at: long (Required) * updated_at: long (Required) @@ -169,7 +176,7 @@ public ResponseupdateMemoryStoreWithResponse(String name, BinaryDat * * {@code * { - * object: String(memory_store/memory_store.deleted/memory_store.scope.deleted) (Required) + * object: String(memory_store/memory_store.deleted/memory_store.scope.deleted/memory_store.item.deleted) (Required) * id: String (Required) * created_at: long (Required) * updated_at: long (Required) @@ -226,7 +233,7 @@ public ResponsegetMemoryStoreWithResponse(String name, RequestOptio *