Skip to content

feat(gitlab): send context-1m-2025-08-07 beta header to enable 1M context window#16153

Open
Krule wants to merge 1 commit intoanomalyco:devfrom
Krule:krule/gitlab-1m-context
Open

feat(gitlab): send context-1m-2025-08-07 beta header to enable 1M context window#16153
Krule wants to merge 1 commit intoanomalyco:devfrom
Krule:krule/gitlab-1m-context

Conversation

@Krule
Copy link

@Krule Krule commented Mar 5, 2026

Issue for this PR

Related to #12338

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds anthropic-beta: context-1m-2025-08-07 to the aiGatewayHeaders sent with every GitLab Duo request. This unlocks the 1M token context window for Claude Sonnet 4.6 and Claude Opus 4.6 via the GitLab Duo provider.

The GitLab AI Gateway already supports this: it lists duo-chat-opus-4-6 with max_context_tokens: 1_000_000 in its model config, and anthropic-beta is explicitly in its _ALLOWED_HEADERS_TO_DOWNSTREAM list, meaning it forwards the header to Anthropic.

A companion PR to update the context limit in models.dev is at anomalyco/models.dev#1089.

How did you verify your code works?

Tested locally by building from source and running a session with gitlab/duo-chat-opus-4-6 that exceeded 200k tokens. Without this change the gateway returns a 400 context overflow error. With this change the session continues past 200k.

Also verified by reading the GitLab AI Gateway source:

  • models.ymlmax_context_tokens: 1_000_000 for claude_opus_4_6_20260205
  • anthropic.pyanthropic-beta is in _ALLOWED_HEADERS_TO_DOWNSTREAM

Screenshots / recordings

N/A — not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 5, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

The following comment was made by an LLM, it may be inaccurate:

Based on the search results, here are potential related PRs:

Potentially Related PRs

  1. feat(provider): add 1M context window support for Anthropic models (feat(provider): add 1M context window support for Anthropic models #14375)

  2. fix(provider): enable 1M context for Vertex AI Anthropic models (fix(provider): enable 1M context for Vertex AI Anthropic models #14055)

  3. feat(provider): add adaptive thinking and 1M context support for Claude Opus 4.6 (feat(provider): add adaptive thinking and 1M context support for Claude Opus 4.6 #12342)

These PRs address similar functionality (1M context support for Anthropic/Claude models) but on different providers/platforms. The current PR (#16153) is specifically for GitLab AI Gateway, so these are likely complementary rather than duplicates.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 5, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@Krule Krule force-pushed the krule/gitlab-1m-context branch from d38f331 to ca0a3d1 Compare March 5, 2026 11:02
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.

1 participant