Skip to content

feature[anthropic]: dynamically set max_tokens #31605

@ccurme

Description

@ccurme

Privileged issue

  • I am a LangChain maintainer, or was asked directly by a LangChain maintainer to create an issue here.

Issue Content

Anthropic's messages API requires an integer max_tokens parameter, which is currently set at 1024 (also the example value in their reference doc for that parameter).

This is a bad fit for Anthropic's more recent models, which may generate reasoning, server-side tool invocations, and other varieties of content and have commensurately higher token limits (64,000 for Claude 3.7 and 4). ctrl+F for "max output" here to see limits for each model.

It would be nice to set this attribute to Optional[int] and, if None, set the value according to the model's documented maximum.

This is technically a breaking change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    investigateFlagged for investigation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions