Skip to content

Conversation

@mostlygeek
Copy link
Owner

@mostlygeek mostlygeek commented Aug 8, 2025

Model alias values are not properly resolved and work in upstream/ path.

Related to #229.

Summary by CodeRabbit

  • Bug Fixes

    • Ensured that requests to proxied models use the resolved real model name instead of any alias, improving accuracy when handling model aliases.
  • Tests

    • Updated and expanded tests to verify correct behavior when accessing models by both their main name and alias, ensuring consistent responses.

Model alias values are not properly resolved and work in upstream/ path.

Related to #229.
@mostlygeek mostlygeek added the bug Something isn't working label Aug 8, 2025
@coderabbitai
Copy link

coderabbitai bot commented Aug 8, 2025

Walkthrough

The proxyToUpstream method in ProxyManager was updated to use the resolved real model name from swapProcessGroup when proxying requests, instead of the originally requested model name. Corresponding tests were updated to use YAML-based configuration with model aliases and to verify correct behavior for both main model names and aliases.

Changes

Cohort / File(s) Change Summary
Proxy Logic Update
proxy/proxymanager.go
Modified proxyToUpstream to use the real model name returned by swapProcessGroup when proxying requests.
Test Enhancements and Refactor
proxy/proxymanager_test.go
Refactored tests to use YAML config with model aliases, added subtests for alias handling, and reformatted tests.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Note

🔌 MCP (Model Context Protocol) integration is now available in Early Access!

Pro users can now connect to remote MCP servers under the Integrations page to get reviews and chat conversations that understand additional development context.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5b10b3c and 9134005.

📒 Files selected for processing (2)
  • proxy/proxymanager.go (1 hunks)
  • proxy/proxymanager_test.go (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
proxy/proxymanager.go (1)
proxy/processgroup_test.go (2)
  • TestProcessGroup_ProxyRequestSwapIsFalse (75-96)
  • TestProcessGroup_ProxyRequestSwapIsTrue (47-73)
🔇 Additional comments (5)
proxy/proxymanager.go (2)

364-364: LGTM! Correctly captures the resolved model name.

This change properly captures the realModelName returned by swapProcessGroup, which is essential for using the de-aliased model name in the subsequent proxy request.


372-372: LGTM! Fixes model alias resolution for upstream requests.

This change ensures that the upstream process receives the resolved real model name instead of the potentially aliased requestedModel. This is the core fix that allows model aliases to work properly in the /upstream/:model_id/* path.

proxy/proxymanager_test.go (3)

12-12: LGTM! Required import for test changes.

The strings import is needed for strings.NewReader() usage in the updated test.


284-326: LGTM! Clean formatting improvements.

The formatting changes improve readability while maintaining the same test logic for verifying model sorting and unlisted model exclusion.


659-688: Excellent test coverage for model alias functionality!

This test improvement effectively validates the model alias fix by:

  • Using YAML configuration with model aliases (aliases: [model-alias])
  • Testing both the main model name and alias in separate subtests
  • Verifying that both requests return the real model name ("model1") in the response

The test structure perfectly validates the changes in proxyToUpstream where realModelName is now used instead of requestedModel.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch upstream-alias

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

}

func TestProxyManager_ListModelsHandler_SortedByID(t *testing.T) {
// Intentionally add models in non-sorted order and with an unlisted model
Copy link
Owner Author

Choose a reason for hiding this comment

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

These spaces were fixed with gofmt.

@mostlygeek mostlygeek merged commit 10569ed into main Aug 8, 2025
3 checks passed
@mostlygeek mostlygeek deleted the upstream-alias branch August 8, 2025 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants