Skip to content

Commit 1f9be44

Browse files
Add token limit fields to ProviderConfig across all SDKs
Add maxOutputTokens, maxPromptTokens, maxContextWindowTokens, and modelLimitsId to ProviderConfig in Node.js, Python, .NET, and Go SDKs. These optional fields allow BYOK users to configure token limits for custom providers, matching the runtime's ProviderConfig (PR #5311). Also update the Python wire format conversion to map the new snake_case fields to camelCase for the JSON-RPC wire protocol. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 4d26e30 commit 1f9be44

5 files changed

Lines changed: 90 additions & 0 deletions

File tree

dotnet/src/Types.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,6 +1115,35 @@ public class ProviderConfig
11151115
/// </summary>
11161116
[JsonPropertyName("azure")]
11171117
public AzureOptions? Azure { get; set; }
1118+
1119+
/// <summary>
1120+
/// Overrides the maximum number of output tokens the model can generate.
1121+
/// When set, takes precedence over the default limit resolved from the model's capability catalog entry.
1122+
/// </summary>
1123+
[JsonPropertyName("maxOutputTokens")]
1124+
public int? MaxOutputTokens { get; set; }
1125+
1126+
/// <summary>
1127+
/// Overrides the maximum number of prompt/input tokens.
1128+
/// When set, takes precedence over the default limit resolved from the model's capability catalog entry.
1129+
/// </summary>
1130+
[JsonPropertyName("maxPromptTokens")]
1131+
public int? MaxPromptTokens { get; set; }
1132+
1133+
/// <summary>
1134+
/// Overrides the maximum context window size in tokens.
1135+
/// When set, takes precedence over the default limit resolved from the model's capability catalog entry.
1136+
/// </summary>
1137+
[JsonPropertyName("maxContextWindowTokens")]
1138+
public int? MaxContextWindowTokens { get; set; }
1139+
1140+
/// <summary>
1141+
/// Specifies the model ID used to look up default token limits from the capability catalog.
1142+
/// When unset, the session's configured model ID (see <see cref="SessionConfig.Model"/>) is used.
1143+
/// This is useful for fine-tuned models that share the same limits as a base model.
1144+
/// </summary>
1145+
[JsonPropertyName("modelLimitsId")]
1146+
public string? ModelLimitsId { get; set; }
11181147
}
11191148

11201149
/// <summary>

go/types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,19 @@ type ProviderConfig struct {
601601
BearerToken string `json:"bearerToken,omitempty"`
602602
// Azure contains Azure-specific options
603603
Azure *AzureProviderOptions `json:"azure,omitempty"`
604+
// MaxOutputTokens overrides the maximum number of output tokens the model can generate.
605+
// When set, takes precedence over the default limit from the model's capability catalog entry.
606+
MaxOutputTokens int `json:"maxOutputTokens,omitempty"`
607+
// MaxPromptTokens overrides the maximum number of prompt/input tokens.
608+
// When set, takes precedence over the default limit from the model's capability catalog entry.
609+
MaxPromptTokens int `json:"maxPromptTokens,omitempty"`
610+
// MaxContextWindowTokens overrides the maximum context window size in tokens.
611+
// When set, takes precedence over the default limit from the model's capability catalog entry.
612+
MaxContextWindowTokens int `json:"maxContextWindowTokens,omitempty"`
613+
// ModelLimitsId specifies the model ID used to look up default token limits from the capability catalog.
614+
// When unset, the session's configured model ID is used.
615+
// Useful for fine-tuned models that share the same limits as a base model.
616+
ModelLimitsId string `json:"modelLimitsId,omitempty"`
604617
}
605618

606619
// AzureProviderOptions contains Azure-specific provider configuration

nodejs/src/types.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,6 +1260,31 @@ export interface ProviderConfig {
12601260
*/
12611261
apiVersion?: string;
12621262
};
1263+
1264+
/**
1265+
* Overrides the maximum number of output tokens the model can generate.
1266+
* When set, takes precedence over the default limit resolved from the model's capability catalog entry.
1267+
*/
1268+
maxOutputTokens?: number;
1269+
1270+
/**
1271+
* Overrides the maximum number of prompt/input tokens.
1272+
* When set, takes precedence over the default limit resolved from the model's capability catalog entry.
1273+
*/
1274+
maxPromptTokens?: number;
1275+
1276+
/**
1277+
* Overrides the maximum context window size in tokens.
1278+
* When set, takes precedence over the default limit resolved from the model's capability catalog entry.
1279+
*/
1280+
maxContextWindowTokens?: number;
1281+
1282+
/**
1283+
* Specifies the model ID used to look up default token limits from the capability catalog.
1284+
* When unset, the session's configured model ID is used.
1285+
* This is useful for fine-tuned models that share the same limits as a base model.
1286+
*/
1287+
modelLimitsId?: string;
12631288
}
12641289

12651290
/**

python/copilot/client.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,6 +1962,16 @@ def _convert_provider_to_wire_format(
19621962
wire_azure["apiVersion"] = azure["api_version"]
19631963
if wire_azure:
19641964
wire_provider["azure"] = wire_azure
1965+
if "max_output_tokens" in provider:
1966+
wire_provider["maxOutputTokens"] = provider["max_output_tokens"]
1967+
if "max_prompt_tokens" in provider:
1968+
wire_provider["maxPromptTokens"] = provider["max_prompt_tokens"]
1969+
if "max_context_window_tokens" in provider:
1970+
wire_provider["maxContextWindowTokens"] = provider[
1971+
"max_context_window_tokens"
1972+
]
1973+
if "model_limits_id" in provider:
1974+
wire_provider["modelLimitsId"] = provider["model_limits_id"]
19651975
return wire_provider
19661976

19671977
def _convert_custom_agent_to_wire_format(

python/copilot/session.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,19 @@ class ProviderConfig(TypedDict, total=False):
507507
# Takes precedence over api_key when both are set.
508508
bearer_token: str
509509
azure: AzureProviderOptions # Azure-specific options
510+
# Overrides the maximum number of output tokens the model can generate.
511+
# Takes precedence over the default limit from the model's capability catalog entry.
512+
max_output_tokens: int
513+
# Overrides the maximum number of prompt/input tokens.
514+
# Takes precedence over the default limit from the model's capability catalog entry.
515+
max_prompt_tokens: int
516+
# Overrides the maximum context window size in tokens.
517+
# Takes precedence over the default limit from the model's capability catalog entry.
518+
max_context_window_tokens: int
519+
# Model ID used to look up default token limits from the capability catalog.
520+
# When unset, the session's configured model ID is used.
521+
# Useful for fine-tuned models that share the same limits as a base model.
522+
model_limits_id: str
510523

511524

512525
class SessionConfig(TypedDict, total=False):

0 commit comments

Comments
 (0)