Skip to content

Investigate structural changes to tool sampling #2853

@alzimmermsft

Description

@alzimmermsft

Right now, in --mode single, --mode namespace, and --mode consolidated we leverage sampling to determine which tool should be used based on the intent of the prompt. --mode single has two phases of sampling and --mode namespace and --mode consolidated have one phase. --mode single has a first phase where it determines which tool area to use based on the prompt intent, from there all three have the same phase next where the tool and parameters are determined based on the prompt.

We should investigate whether the tool selection and parameter binding should be split into two phases. This would allow the tool selection phase to remove all overhead of parameter information, making the sampling request much smaller, allowing less context to be used and prioritizing the presentation of tool names and descriptions. The parameter binding phase would then happen, and it would allow for the parameter description and whether their required to have higher visibility.

For example, currently, this is the prompt for tool selection and parameter binding:

This is a list of available commands for the storage server.

Your task:
- Select the single command that best matches the user's intent.
- Return a valid JSON object that matches the provided result schema.
- Map the user's intent and known parameters to the command's input schema, ensuring parameter names and types match the schema exactly (no extra or missing parameters).
- Only include parameters that are defined in the selected command's input schema.
- Do not guess or invent parameters.
- If no command matches, return JSON schema with "Unknown" tool name.

Result Schema:
{
  "type": "object",
  "properties": {
    "tool": {
      "type": "string",
      "description": "The name of the tool to call."
    },
    "parameters": {
      "type": "object",
      "description": "A key/value pair of parameters names and values to pass to the tool call command."
    }
  },
  "additionalProperties": false
}

Intent:
List blobs in container

Known Parameters:
{"subscription":"redacted","storage-account":"redacted","container":"redacted"}

Available Commands:
[{"name":"storage_account_create","description":"Creates an Azure Storage account in the specified resource group and location and returns the created storage account\r\ninformation including name, location, SKU, access settings, and configuration details.","inputSchema":{"type":"object","properties":{"account":{"type":"string","description":"The name of the Azure Storage account to create. Must be globally unique, 3-24 characters, lowercase letters and numbers only."},"location":{"type":"string","description":"The Azure region where the storage account will be created (e.g., \u0027eastus\u0027, \u0027westus2\u0027)."},"sku":{"type":"string","description":"The storage account SKU. Valid values: Standard_LRS, Standard_GRS, Standard_RAGRS, Standard_ZRS, Premium_LRS, Premium_ZRS, Standard_GZRS, Standard_RAGZRS."},"access-tier":{"type":"string","description":"The default access tier for blob storage. Valid values: Hot, Cool."},"enable-hierarchical-namespace":{"type":"boolean","description":"Whether to enable hierarchical namespace (Data Lake Storage Gen2) for the storage account."},"resource-group":{"type":"string","description":"The name of the Azure resource group. This is a logical container for Azure resources."},"subscription":{"type":"string","description":"Specifies the Azure subscription to use. Accepts either a subscription ID (GUID) or display name. If not specified, the AZURE_SUBSCRIPTION_ID environment variable will be used instead."},"tenant":{"type":"string","description":"The Microsoft Entra ID tenant ID or name. This can be either the GUID identifier or the display name of your Entra ID tenant."},"auth-method":{"type":"string","description":"Authentication method to use. Options: \u0027credential\u0027 (Azure CLI/managed identity), \u0027key\u0027 (access key), or \u0027connectionString\u0027."},"retry-delay":{"type":"number","description":"Initial delay in seconds between retry attempts. For exponential backoff, this value is used as the base."},"retry-max-delay":{"type":"number","description":"Maximum delay in seconds between retries, regardless of the retry strategy."},"retry-max-retries":{"type":"integer","description":"Maximum number of retry attempts for failed operations before giving up."},"retry-mode":{"type":"string","description":"Retry strategy to use. \u0027fixed\u0027 uses consistent delays, \u0027exponential\u0027 increases delay between attempts."},"retry-network-timeout":{"type":"number","description":"Network operation timeout in seconds. Operations taking longer than this will be cancelled."}},"required":["account","location","resource-group"],"additionalProperties":false},"annotations":{"title":"Create Storage Account","destructiveHint":true,"idempotentHint":false,"openWorldHint":false,"readOnlyHint":false},"_meta":{"MicrosoftMcpToolId":"a2cf843a-57f2-45ea-8078-59b0be0805e6"}},{"name":"storage_account_get","description":"Retrieves detailed information about Azure Storage accounts, including account name, location, SKU, kind, hierarchical namespace status, HTTPS-only settings, and blob public access configuration. If a specific account name is not provided, the command will return details for all accounts in a subscription.","inputSchema":{"type":"object","properties":{"account":{"type":"string","description":"The name of the Azure Storage account. This is the unique name you chose for your storage account (e.g., \u0027mystorageaccount\u0027)."},"resource-group":{"type":"string","description":"The name of the Azure resource group. This is a logical container for Azure resources."},"subscription":{"type":"string","description":"Specifies the Azure subscription to use. Accepts either a subscription ID (GUID) or display name. If not specified, the AZURE_SUBSCRIPTION_ID environment variable will be used instead."},"tenant":{"type":"string","description":"The Microsoft Entra ID tenant ID or name. This can be either the GUID identifier or the display name of your Entra ID tenant."},"auth-method":{"type":"string","description":"Authentication method to use. Options: \u0027credential\u0027 (Azure CLI/managed identity), \u0027key\u0027 (access key), or \u0027connectionString\u0027."},"retry-delay":{"type":"number","description":"Initial delay in seconds between retry attempts. For exponential backoff, this value is used as the base."},"retry-max-delay":{"type":"number","description":"Maximum delay in seconds between retries, regardless of the retry strategy."},"retry-max-retries":{"type":"integer","description":"Maximum number of retry attempts for failed operations before giving up."},"retry-mode":{"type":"string","description":"Retry strategy to use. \u0027fixed\u0027 uses consistent delays, \u0027exponential\u0027 increases delay between attempts."},"retry-network-timeout":{"type":"number","description":"Network operation timeout in seconds. Operations taking longer than this will be cancelled."}},"required":[],"additionalProperties":false},"annotations":{"title":"Get Storage Account Details","destructiveHint":false,"idempotentHint":true,"openWorldHint":false,"readOnlyHint":true},"_meta":{"MicrosoftMcpToolId":"eb2363f1-f21f-45fc-ad63-bacfbae8c45c"}},{"name":"storage_blob_get","description":"List/get/show blobs in a blob container in Storage account. Use this tool to list the blobs in a container or\r\nget details for a specific blob. If no blob specified, lists all blobs present in the container, optionally\r\nfiltering on a prefix. The prefix is ignored if a blob is specified.\r\n\r\nRequired: --account, --container, --subscription\r\nOptional: --blob, --tenant, --prefix\r\n\r\nReturns: blob name, size, lastModified, contentType, contentHash, metadata, and blob properties.\r\nDo not use this tool to list containers in the storage account.","inputSchema":{"type":"object","properties":{"blob":{"type":"string","description":"The name of the blob to access within the container. This should be the full path within the container (e.g., \u0027file.txt\u0027 or \u0027folder/file.txt\u0027)."},"prefix":{"type":"string","description":"The prefix to filter blobs when listing blobs in a container. Only blobs whose names start with the specified prefix will be listed."},"account":{"type":"string","description":"The name of the Azure Storage account. This is the unique name you chose for your storage account (e.g., \u0027mystorageaccount\u0027)."},"container":{"type":"string","description":"The name of the container to access within the storage account."},"subscription":{"type":"string","description":"Specifies the Azure subscription to use. Accepts either a subscription ID (GUID) or display name. If not specified, the AZURE_SUBSCRIPTION_ID environment variable will be used instead."},"tenant":{"type":"string","description":"The Microsoft Entra ID tenant ID or name. This can be either the GUID identifier or the display name of your Entra ID tenant."},"auth-method":{"type":"string","description":"Authentication method to use. Options: \u0027credential\u0027 (Azure CLI/managed identity), \u0027key\u0027 (access key), or \u0027connectionString\u0027."},"retry-delay":{"type":"number","description":"Initial delay in seconds between retry attempts. For exponential backoff, this value is used as the base."},"retry-max-delay":{"type":"number","description":"Maximum delay in seconds between retries, regardless of the retry strategy."},"retry-max-retries":{"type":"integer","description":"Maximum number of retry attempts for failed operations before giving up."},"retry-mode":{"type":"string","description":"Retry strategy to use. \u0027fixed\u0027 uses consistent delays, \u0027exponential\u0027 increases delay between attempts."},"retry-network-timeout":{"type":"number","description":"Network operation timeout in seconds. Operations taking longer than this will be cancelled."}},"required":["account","container"],"additionalProperties":false},"annotations":{"title":"Get Storage Blob Details","destructiveHint":false,"idempotentHint":true,"openWorldHint":false,"readOnlyHint":true},"_meta":{"MicrosoftMcpToolId":"d6bdc190-e68f-49af-82e7-9cf6ec9b8183"}},{"name":"storage_blob_upload","description":"Uploads a local file to an Azure Storage blob, only if the blob does not exist, returning the last modified time,\r\nETag, and content hash of the uploaded blob.","inputSchema":{"type":"object","properties":{"local-file-path":{"type":"string","description":"The local file path to read content from or to write content to. This should be the full path to the file on your local system."},"account":{"type":"string","description":"The name of the Azure Storage account. This is the unique name you chose for your storage account (e.g., \u0027mystorageaccount\u0027)."},"container":{"type":"string","description":"The name of the container to access within the storage account."},"blob":{"type":"string","description":"The name of the blob to access within the container. This should be the full path within the container (e.g., \u0027file.txt\u0027 or \u0027folder/file.txt\u0027)."},"subscription":{"type":"string","description":"Specifies the Azure subscription to use. Accepts either a subscription ID (GUID) or display name. If not specified, the AZURE_SUBSCRIPTION_ID environment variable will be used instead."},"tenant":{"type":"string","description":"The Microsoft Entra ID tenant ID or name. This can be either the GUID identifier or the display name of your Entra ID tenant."},"auth-method":{"type":"string","description":"Authentication method to use. Options: \u0027credential\u0027 (Azure CLI/managed identity), \u0027key\u0027 (access key), or \u0027connectionString\u0027."},"retry-delay":{"type":"number","description":"Initial delay in seconds between retry attempts. For exponential backoff, this value is used as the base."},"retry-max-delay":{"type":"number","description":"Maximum delay in seconds between retries, regardless of the retry strategy."},"retry-max-retries":{"type":"integer","description":"Maximum number of retry attempts for failed operations before giving up."},"retry-mode":{"type":"string","description":"Retry strategy to use. \u0027fixed\u0027 uses consistent delays, \u0027exponential\u0027 increases delay between attempts."},"retry-network-timeout":{"type":"number","description":"Network operation timeout in seconds. Operations taking longer than this will be cancelled."}},"required":["local-file-path","account","container","blob"],"additionalProperties":false},"annotations":{"title":"Upload Local File to Blob","destructiveHint":false,"idempotentHint":false,"openWorldHint":false,"readOnlyHint":false},"_meta":{"MicrosoftMcpToolId":"aafb82ac-e35a-4800-b362-c642a3ac1e17","LocalRequiredHint":true}},{"name":"storage_blob_container_create","description":"Create/provision a new Azure Storage blob container in a storage account.\r\n\r\nRequired: --account, --container, --subscription\r\nOptional: --tenant\r\n\r\nReturns: container name, lastModified, eTag, leaseStatus, publicAccessLevel, hasImmutabilityPolicy, hasLegalHold.\r\nCreates a logical container for organizing blobs within a storage account.","inputSchema":{"type":"object","properties":{"account":{"type":"string","description":"The name of the Azure Storage account. This is the unique name you chose for your storage account (e.g., \u0027mystorageaccount\u0027)."},"container":{"type":"string","description":"The name of the container to access within the storage account."},"subscription":{"type":"string","description":"Specifies the Azure subscription to use. Accepts either a subscription ID (GUID) or display name. If not specified, the AZURE_SUBSCRIPTION_ID environment variable will be used instead."},"tenant":{"type":"string","description":"The Microsoft Entra ID tenant ID or name. This can be either the GUID identifier or the display name of your Entra ID tenant."},"auth-method":{"type":"string","description":"Authentication method to use. Options: \u0027credential\u0027 (Azure CLI/managed identity), \u0027key\u0027 (access key), or \u0027connectionString\u0027."},"retry-delay":{"type":"number","description":"Initial delay in seconds between retry attempts. For exponential backoff, this value is used as the base."},"retry-max-delay":{"type":"number","description":"Maximum delay in seconds between retries, regardless of the retry strategy."},"retry-max-retries":{"type":"integer","description":"Maximum number of retry attempts for failed operations before giving up."},"retry-mode":{"type":"string","description":"Retry strategy to use. \u0027fixed\u0027 uses consistent delays, \u0027exponential\u0027 increases delay between attempts."},"retry-network-timeout":{"type":"number","description":"Network operation timeout in seconds. Operations taking longer than this will be cancelled."}},"required":["account","container"],"additionalProperties":false},"annotations":{"title":"Create Storage Blob Container","destructiveHint":true,"idempotentHint":false,"openWorldHint":false,"readOnlyHint":false},"_meta":{"MicrosoftMcpToolId":"f5088334-e630-4df0-a5be-ac87787acad0"}},{"name":"storage_blob_container_get","description":"Show/list containers in a storage account. Use this tool to list all blob containers in the storage account or\r\nshow details for a specific Storage container. If no container specified, shows all containers in the storage\r\naccount, optionally filtering on a prefix. The prefix is ignored if a container is specified.\r\n\r\nRequired: --account, --subscription\r\nOptional: --container, --tenant, --prefix\r\n\r\nReturns: container name, lastModified, leaseStatus, publicAccess, metadata, and container properties.\r\nDo not use this tool to list blobs in a container.","inputSchema":{"type":"object","properties":{"account":{"type":"string","description":"The name of the Azure Storage account. This is the unique name you chose for your storage account (e.g., \u0027mystorageaccount\u0027)."},"container":{"type":"string","description":"The name of the container to access within the storage account."},"prefix":{"type":"string","description":"The prefix to filter containers when listing containers in a storage account. Only containers whose names start with the specified prefix will be listed."},"subscription":{"type":"string","description":"Specifies the Azure subscription to use. Accepts either a subscription ID (GUID) or display name. If not specified, the AZURE_SUBSCRIPTION_ID environment variable will be used instead."},"tenant":{"type":"string","description":"The Microsoft Entra ID tenant ID or name. This can be either the GUID identifier or the display name of your Entra ID tenant."},"auth-method":{"type":"string","description":"Authentication method to use. Options: \u0027credential\u0027 (Azure CLI/managed identity), \u0027key\u0027 (access key), or \u0027connectionString\u0027."},"retry-delay":{"type":"number","description":"Initial delay in seconds between retry attempts. For exponential backoff, this value is used as the base."},"retry-max-delay":{"type":"number","description":"Maximum delay in seconds between retries, regardless of the retry strategy."},"retry-max-retries":{"type":"integer","description":"Maximum number of retry attempts for failed operations before giving up."},"retry-mode":{"type":"string","description":"Retry strategy to use. \u0027fixed\u0027 uses consistent delays, \u0027exponential\u0027 increases delay between attempts."},"retry-network-timeout":{"type":"number","description":"Network operation timeout in seconds. Operations taking longer than this will be cancelled."}},"required":["account"],"additionalProperties":false},"annotations":{"title":"Get Storage Container Details","destructiveHint":false,"idempotentHint":true,"openWorldHint":false,"readOnlyHint":true},"_meta":{"MicrosoftMcpToolId":"e96eb850-abb8-431d-bdc6-7ccd0a24838e"}},{"name":"storage_table_list","description":"List all tables in an Azure Storage account. Shows table names for the specified storage account. Required: account, subscription. Optional: tenant. Returns: table names. Do not use this tool for Cosmos DB tables or Kusto/Data Explorer tables.","inputSchema":{"type":"object","properties":{"account":{"type":"string","description":"The name of the Azure Storage account. This is the unique name you chose for your storage account (e.g., \u0027mystorageaccount\u0027)."},"subscription":{"type":"string","description":"Specifies the Azure subscription to use. Accepts either a subscription ID (GUID) or display name. If not specified, the AZURE_SUBSCRIPTION_ID environment variable will be used instead."},"tenant":{"type":"string","description":"The Microsoft Entra ID tenant ID or name. This can be either the GUID identifier or the display name of your Entra ID tenant."},"auth-method":{"type":"string","description":"Authentication method to use. Options: \u0027credential\u0027 (Azure CLI/managed identity), \u0027key\u0027 (access key), or \u0027connectionString\u0027."},"retry-delay":{"type":"number","description":"Initial delay in seconds between retry attempts. For exponential backoff, this value is used as the base."},"retry-max-delay":{"type":"number","description":"Maximum delay in seconds between retries, regardless of the retry strategy."},"retry-max-retries":{"type":"integer","description":"Maximum number of retry attempts for failed operations before giving up."},"retry-mode":{"type":"string","description":"Retry strategy to use. \u0027fixed\u0027 uses consistent delays, \u0027exponential\u0027 increases delay between attempts."},"retry-network-timeout":{"type":"number","description":"Network operation timeout in seconds. Operations taking longer than this will be cancelled."}},"required":["account"],"additionalProperties":false},"annotations":{"title":"List Tables in Azure Storage","destructiveHint":false,"idempotentHint":true,"openWorldHint":false,"readOnlyHint":true},"_meta":{"MicrosoftMcpToolId":"1236ad1d-baf1-4b95-8c1d-420637ce08da"}}]

This could then become something like the following with this being split into two sampling requests:

This is a list of available commands for the storage server.

Your task:
- Select the single command that best matches the user's intent.
- If no command matches, return JSON schema with "Unknown" tool name.

Intent:
List blobs in container

Available Commands:
[{"name":"storage_account_create","description":"Creates an Azure Storage account in the specified resource group and location and returns the created storage account\r\ninformation including name, location, SKU, access settings, and configuration details."},{"name":"storage_account_get","description":"Retrieves detailed information about Azure Storage accounts, including account name, location, SKU, kind, hierarchical namespace status, HTTPS-only settings, and blob public access configuration. If a specific account name is not provided, the command will return details for all accounts in a subscription."},{"name":"storage_blob_get","description":"List/get/show blobs in a blob container in Storage account. Use this tool to list the blobs in a container or\r\nget details for a specific blob. If no blob specified, lists all blobs present in the container, optionally\r\nfiltering on a prefix. The prefix is ignored if a blob is specified.\r\n\r\nRequired: --account, --container, --subscription\r\nOptional: --blob, --tenant, --prefix\r\n\r\nReturns: blob name, size, lastModified, contentType, contentHash, metadata, and blob properties.\r\nDo not use this tool to list containers in the storage account."},{"name":"storage_blob_upload","description":"Uploads a local file to an Azure Storage blob, only if the blob does not exist, returning the last modified time,\r\nETag, and content hash of the uploaded blob."},{"name":"storage_blob_container_create","description":"Create/provision a new Azure Storage blob container in a storage account.\r\n\r\nRequired: --account, --container, --subscription\r\nOptional: --tenant\r\n\r\nReturns: container name, lastModified, eTag, leaseStatus, publicAccessLevel, hasImmutabilityPolicy, hasLegalHold.\r\nCreates a logical container for organizing blobs within a storage account."},{"name":"storage_blob_container_get","description":"Show/list containers in a storage account. Use this tool to list all blob containers in the storage account or\r\nshow details for a specific Storage container. If no container specified, shows all containers in the storage\r\naccount, optionally filtering on a prefix. The prefix is ignored if a container is specified.\r\n\r\nRequired: --account, --subscription\r\nOptional: --container, --tenant, --prefix\r\n\r\nReturns: container name, lastModified, leaseStatus, publicAccess, metadata, and container properties.\r\nDo not use this tool to list blobs in a container."},{"name":"storage_table_list","description":"List all tables in an Azure Storage account. Shows table names for the specified storage account. Required: account, subscription. Optional: tenant. Returns: table names. Do not use this tool for Cosmos DB tables or Kusto/Data Explorer tables."}]

and

This is the storage_blob_get command.

Your task:
- Return a valid JSON object that matches the provided result schema.
- Map the user's intent and known parameters to the command's input schema, ensuring parameter names and types match the schema exactly (no extra or missing parameters).
- Only include parameters that are defined in the selected command's input schema.
- Do not guess or invent parameters.

Result Schema:
{
  "type": "object",
  "properties": {
    "tool": {
      "type": "string",
      "description": "The name of the tool to call."
    },
    "parameters": {
      "type": "object",
      "description": "A key/value pair of parameters names and values to pass to the tool call command."
    }
  },
  "additionalProperties": false
}

Known Parameters:
{"subscription":"redacted","storage-account":"redacted","container":"redacted"}

Command Information:
{"name":"storage_blob_get","description":"List/get/show blobs in a blob container in Storage account. Use this tool to list the blobs in a container or\r\nget details for a specific blob. If no blob specified, lists all blobs present in the container, optionally\r\nfiltering on a prefix. The prefix is ignored if a blob is specified.\r\n\r\nRequired: --account, --container, --subscription\r\nOptional: --blob, --tenant, --prefix\r\n\r\nReturns: blob name, size, lastModified, contentType, contentHash, metadata, and blob properties.\r\nDo not use this tool to list containers in the storage account.","inputSchema":{"type":"object","properties":{"blob":{"type":"string","description":"The name of the blob to access within the container. This should be the full path within the container (e.g., \u0027file.txt\u0027 or \u0027folder/file.txt\u0027)."},"prefix":{"type":"string","description":"The prefix to filter blobs when listing blobs in a container. Only blobs whose names start with the specified prefix will be listed."},"account":{"type":"string","description":"The name of the Azure Storage account. This is the unique name you chose for your storage account (e.g., \u0027mystorageaccount\u0027)."},"container":{"type":"string","description":"The name of the container to access within the storage account."},"subscription":{"type":"string","description":"Specifies the Azure subscription to use. Accepts either a subscription ID (GUID) or display name. If not specified, the AZURE_SUBSCRIPTION_ID environment variable will be used instead."},"tenant":{"type":"string","description":"The Microsoft Entra ID tenant ID or name. This can be either the GUID identifier or the display name of your Entra ID tenant."},"auth-method":{"type":"string","description":"Authentication method to use. Options: \u0027credential\u0027 (Azure CLI/managed identity), \u0027key\u0027 (access key), or \u0027connectionString\u0027."},"retry-delay":{"type":"number","description":"Initial delay in seconds between retry attempts. For exponential backoff, this value is used as the base."},"retry-max-delay":{"type":"number","description":"Maximum delay in seconds between retries, regardless of the retry strategy."},"retry-max-retries":{"type":"integer","description":"Maximum number of retry attempts for failed operations before giving up."},"retry-mode":{"type":"string","description":"Retry strategy to use. \u0027fixed\u0027 uses consistent delays, \u0027exponential\u0027 increases delay between attempts."},"retry-network-timeout":{"type":"number","description":"Network operation timeout in seconds. Operations taking longer than this will be cancelled."}},"required":["account","container"],"additionalProperties":false},"annotations":{"title":"Get Storage Blob Details","destructiveHint":false,"idempotentHint":true,"openWorldHint":false,"readOnlyHint":true},"_meta":{"MicrosoftMcpToolId":"d6bdc190-e68f-49af-82e7-9cf6ec9b8183"}}

Using characters as a really rough estimate for tokens, you get the following:

Case Characters
Combined tool selection and parameter binding 19004
Tool selection with name and description 3013
Parameter binding with selected tool information 3809
Combined investigation example 6822

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Untriaged

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions