Skip to content

WIP - #157

Closed
perk11 wants to merge 2 commits into
mainfrom
20260902
Closed

WIP#157
perk11 wants to merge 2 commits into
mainfrom
20260902

Conversation

@perk11

@perk11 perk11 commented Sep 3, 2026

Copy link
Copy Markdown
Owner

No description provided.

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.
@perk11

perk11 commented Sep 3, 2026

Copy link
Copy Markdown
Owner Author

Too much vibe code here, going to do this in smaller parts

@perk11 perk11 closed this Sep 3, 2026
@perk11
perk11 deleted the 20260902 branch September 3, 2026 03:55
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