Skip to content

Strip [1m] model hints before provider dispatch#50

Merged
raine merged 1 commit into
raine:mainfrom
mulfyx:fix/strip-context-window-hint
Jul 13, 2026
Merged

Strip [1m] model hints before provider dispatch#50
raine merged 1 commit into
raine:mainfrom
mulfyx:fix/strip-context-window-hint

Conversation

@mulfyx

@mulfyx mulfyx commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • write the normalized incoming model back into the request before provider dispatch
  • keep [1m] as a Claude Code-only context hint, matching the documented behavior
  • add an integration regression test through /v1/messages/count_tokens

Problem

Provider selection already strips a trailing [1m], but the selected provider still receives the original model string. For example, gpt-5.6-luna[1m] reaches the Codex provider and is then rejected as an unsupported model with HTTP 400.

Verification

  • regression test failed before the fix with 400 instead of 200
  • cargo test --locked (541 passed)
  • targeted regression test passed again after rebasing onto the latest main
  • git diff --check

@raine

raine commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Not sure why this is needed

@mulfyx

mulfyx commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

This restores behavior from the original TypeScript implementation. Commit 66f957a normalized body.model before provider dispatch as a defense-in-depth fallback.

During the Rust port, normalization remained in Registry::provider_for_model, so provider selection accepts gpt-5.6-luna[1m], but the selected provider still receives the original value and rejects it with HTTP 400. The regression test demonstrates that path.

You’re right that this is not needed for Claude Code itself if it strips [1m] before sending the request. The intent is parity with the previous implementation, support for other Anthropic-compatible clients, and matching the current README statement that the proxy strips the suffix. If that fallback is no longer desired, the PR can be closed and the README wording should be adjusted instead.

@raine raine merged commit e7add44 into raine:main Jul 13, 2026
1 check passed
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.

2 participants