Skip to content

Add max_output_tokens to ModelCapabilities limits - #2569

Merged
SteveSandersonMS merged 3 commits into
github:mainfrom
1fanwang:1fannnw/model-capabilities-max-output-tokens
Sep 10, 2026
Merged

SteveSandersonMS merged 3 commits into
github:mainfrom
1fanwang:1fannnw/model-capabilities-max-output-tokens

Conversation

@1fanwang

@1fanwang 1fanwang commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Summary

TypeScript callers cannot set an output token limit through the session config, even though the wire protocol accepts one. Setting a value fails to compile with TS2561, so the only way to reach the field is to cast away the type.

Problem

The generated RPC schema declares an optional output token limit on the model capabilities override. The hand-written public model capabilities type omits it. The session config override is a deep partial of that public type, so the compiler rejects the field for a value the protocol already accepts.

Solution

Add the optional field to the public limits type, next to the existing prompt token limit, so the public surface matches the generated schema.

Testing Done

Compiled a probe that sets the field on a session config against the base branch and this branch, and ran the repository typecheck gate.

Raw logs
$ printf 'import type { SessionConfig } from "./src/types";\nconst c: SessionConfig = { modelCapabilities: { limits: { max_output_tokens: 8192 } } };\nvoid c;\n' > probe-mot.ts
$ npx tsc --noEmit --skipLibCheck --target es2020 --moduleResolution node probe-mot.ts

# base branch:
probe-mot.ts(2,59): error TS2561: Object literal may only specify known properties, but
'max_output_tokens' does not exist in type '{ max_prompt_tokens?: number; ... }'.
Did you mean to write 'max_prompt_tokens'?

# this branch:
(no output, compiles cleanly)

$ npm run typecheck
> tsc --noEmit && tsc --noEmit -p tsconfig.test.json
(no output, both configs pass)

The generated RPC schema ModelCapabilitiesOverrideLimits declares
max_output_tokens, but the hand-written public ModelCapabilities type
omits it. Because ModelCapabilitiesOverride is DeepPartial of
ModelCapabilities, callers setting modelCapabilities.limits on a session
config are rejected by the compiler for a field the protocol accepts.

Signed-off-by: 1fanwang <1fannnw@gmail.com>
Copilot AI balanced review requested due to automatic review settings September 8, 2026 09:15
@1fanwang
1fanwang requested a review from a team as a code owner September 8, 2026 09:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused type change resolves the schema mismatch with no unresolved issues.

Pull request overview

Aligns the public TypeScript model-capabilities type with the generated RPC schema.

Changes:

  • Adds optional max_output_tokens support to model capability limits.
File summaries
File Description
nodejs/src/types.ts Exposes the existing wire-protocol output-token limit in the public type.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@SteveSandersonMS SteveSandersonMS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed: the generated RPC schema (ModelCapabilitiesOverrideLimits) already declares max_output_tokens, and this field is already present in the hand-written public wrapper types for Python, Rust, Java, Go, and .NET — Node's ModelCapabilities was the only one missing it. I reproduced the reported TS2561 compile error locally by reverting this change and confirmed the fix resolves it cleanly. Minimal, correctly-scoped, no further test/doc changes needed. Approving.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants