Conversation
Multiple services can now share one ListenPort as a set of context-size tiers. Requests are routed to the service with the smallest context size that fits, and the proxy transparently switches to the next larger service mid-connection once a request outgrows the current one. - New per-service config: ContextSize (tokens) + Tokenizer, or ContextSizeBytes (raw bytes), with validation for shared-port groups (uniform units, unique sizes, known tokenizer). - Token counting via a named registry (qwen3.8/qwen3, gemma4/gemma3) of heuristic per-family counters; adding a model is one RegisterTokenCounter call. - Incremental HTTP request framing (Content-Length, chunked, bodyless methods) with passthrough fallback for unframmable traffic. - Requests are measured from messages/prompt/input text; oversized requests go to the largest tier; unframmable traffic falls back to the smallest tier; switching is upward-only per connection. - test-server: new -openai-api-keep-alive flag for e2e switching tests. - tests: fixed pre-existing flake where TestEvictionOfAlreadyDeadProcessDoesNotLoop counted log lines accumulated across runs (append-mode log never truncated).
A service can now set ListenPort to "auto" and get a free port picked
automatically. The last port selected for each service is persisted in
a small SQLite database (AutoListenPortDatabasePath, default
auto-listen-ports.db, keyed by service name), and on startup the proxy
first tries to reuse the service's last used port, so clients keep
working across restarts. When that port is no longer free, a new one is
requested from the OS, avoiding every port already used in the same
configuration (including OpenAI API and management ports).
Chosen ports are bound immediately at selection and the live listener
is handed to the proxy, so a selected port can never be lost to another
process between allocation and use. Resolved ports are written back
into the config, so the startup logs, the management API listen_port
field and ServiceUrl {{.PORT}} templates all report the real port.
Each "auto" service gets a port of its own; context-routing groups
still require explicit numeric ports. Persistence uses the pure-Go
modernc.org/sqlite driver, keeping cross-compilation cgo-free.
Owner
Author
|
Too much vibe code here, going to do this in smaller parts |
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.
No description provided.