fix: add configurable maxInputTokens to OpenAI and Anthropic adapters (#2405) by jpr5 · Pull Request #3823 · CopilotKit/CopilotKit · GitHub
Skip to content

fix: add configurable maxInputTokens to OpenAI and Anthropic adapters (#2405) - #3823

Merged
AlemTuzlak merged 1 commit into
mainfrom
fix/max-input-tokens-configurable-2405
Apr 16, 2026
Merged

AlemTuzlak merged 1 commit into
mainfrom
fix/max-input-tokens-configurable-2405

Conversation

@jpr5

@jpr5 jpr5 commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #2405

Both OpenAI and Anthropic adapters used a hardcoded token limit for message trimming. This adds an optional maxInputTokens constructor parameter to both adapter classes, allowing consumers to override the default context window limit.

Test plan

  • Verify default behavior unchanged when maxInputTokens not provided
  • Verify custom maxInputTokens is passed through to limitMessagesToTokenCount

@vercel

vercel Bot commented Apr 12, 2026 •

Copy link
Copy Markdown
Contributor

@changeset-bot

changeset-bot Bot commented Apr 12, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5875c58

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

Copy link
Copy Markdown
Contributor

📣 Social Copy Generator

Generate social media copies (Twitter/X, LinkedIn, Blog Post) for this PR using Claude.

  • Generate social media copies

@pkg-pr-new

pkg-pr-new Bot commented Apr 12, 2026 •

Copy link
Copy Markdown

@AlemTuzlak
AlemTuzlak merged commit 2b8a426 into main Apr 16, 2026
35 checks passed
@AlemTuzlak
AlemTuzlak deleted the fix/max-input-tokens-configurable-2405 branch April 16, 2026 09:52
zeekay pushed a commit to Dream-AI-4444/CopilotKit that referenced this pull request Sep 11, 2026
…CopilotKit#2405) (CopilotKit#3823)

## Summary

Fixes CopilotKit#2405

Both OpenAI and Anthropic adapters used a hardcoded token limit for
message trimming. This adds an optional `maxInputTokens` constructor
parameter to both adapter classes, allowing consumers to override the
default context window limit.

## Test plan

- [ ] Verify default behavior unchanged when `maxInputTokens` not
provided
- [ ] Verify custom `maxInputTokens` is passed through to
`limitMessagesToTokenCount`

This branch was successfully deployed

5 active deployments
Preview – research-canvas — a7cf3821 Deployed Apr 14, 2026 by vercel[bot]
Preview – travel — a7cf3821 Deployed Apr 14, 2026 by vercel[bot]
Preview – form-filling — a7cf3821 Deployed Apr 14, 2026 by vercel[bot]
Preview – docs — a7cf3821 Deployed Apr 14, 2026 by vercel[bot]
Preview – chat-with-your-data — a7cf3821 Deployed Apr 14, 2026 by vercel[bot]
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.

🚀 Feature Request: Make the LLM input token limits configurable

2 participants