feat: LUNAROUTE marker-based provider routing#34
Merged
Conversation
Describes the feature for dynamically overriding which provider handles a request via [LUNAROUTE:provider] markers in request bodies, enabling Claude Code users to switch providers on-the-fly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix critical and major issues from spec review: - Add provider_type field for extra providers (connector type inference) - Document serde flatten caveats and validation requirements - Add extra providers connector construction note - Clarify streaming + non-streaming connector swap paths - Use MarkerResult enum instead of Option for clear/provider/none - Add stripping regexes for system-reminder blocks - Document req mutability requirement - Add /v1/responses and /v1/models to Out of Scope Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
10 tasks covering: marker extraction/stripping module, config changes, provider registry type, startup construction, handler integration (both Anthropic and OpenAI), config example, and integration tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
After reviewing the client-side Claude Code plugin, updated both spec and plan to match actual plugin behavior: - extract_marker scans only the last user message (not all messages), since old markers persist in conversation history - strip_marker operates on last user message only - Added tests for old-marker-ignored and last-message-wins scenarios - Documented subagent routing (plain text marker, no system-reminder) - Noted that [LUNAROUTE:clear] is handled client-side only Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add `provider_type` and `model` fields to `ProviderSettings`, an `extra` HashMap to `ProvidersConfig` for marker-based routing of named providers, and a `validate_extra_providers()` method with full test coverage. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix pre-existing build failures: add missing provider_registry argument to passthrough_router calls in integration test files, and suppress clippy::too_many_arguments on multi_dialect::passthrough_router. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…andler Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove stale #[allow(dead_code)] from validate_extra_providers (it IS called) - Add debug log when marker found but no provider registry available Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
[LUNAROUTE:provider_name]marker detection in passthrough request bodies to dynamically route requests to named providersserde(flatten)with optional model overridelunaroute:<provider>,model_override:<model>)This enables Claude Code users to switch providers on-the-fly via a
#!providercommand (e.g.,#!sonnet) without restarting sessions or changing configuration. The client-side plugin injects the marker; the proxy handles routing.Changes
marker.rs(new, 433 lines)extract_marker(),strip_marker(), 19 unit testsprovider_registry.rs(new)ProviderType,ProviderEntry,ProviderRegistrytypesconfig.rsprovider_type,modelfields +extraproviders via serde flattenmain.rsProviderRegistryfrom config at startupanthropic.rsmessages_passthroughopenai.rschat_completions_passthroughmulti_dialect.rsconfig.example.yamlCargo.tomlError handling
Test plan
cargo testpasses (0 failures)🤖 Generated with Claude Code