Feat: runtime reduction mode API (on/off/deterministic)#3
Merged
Conversation
Add a process-wide reduction mode settable at runtime via POST /labcx/mode, so an
external signal (e.g. a vLLM KV-cache-pressure monitor) can activate/deactivate
context engineering live — without restarting the proxy.
- Mode enum on|off|deterministic; ParseMode validates (unknown -> HTTP 400).
off = transparent passthrough; on = reduce with the configured method;
deterministic is reserved and currently behaves like on.
- GET /labcx/mode reports the current mode; POST/PUT sets it from {"mode":"..."}
or ?mode=. Held in an atomic.Value.
- Reduce gate becomes: !bypassed(r) && mode != off. The per-request
x-labcx-bypass header still forces passthrough. Default mode = on, so existing
behavior is unchanged. Fail-open preserved.
- --mode initial-state flag on `lab-cx proxy`.
- TestRuntimeModeToggle: on/off/deterministic flips reduce<->passthrough, bad
value -> 400, GET reports state.
Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Itay-Nakash <itay.nakash@ibm.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
Add a process-wide reduction mode settable at runtime via POST /labcx/mode, so an external signal (e.g. a vLLM KV-cache-pressure monitor) can activate/deactivate context engineering live — without restarting the proxy.
lab-cx proxy.Related issue(s)
(Optional) Testing Instructions
make test(full suite, with the race detector) is green;go vetandgofmtare clean.lab-cx proxy, thencurl -XPOST localhost:8080/labcx/mode -d '{"mode":"off"}'-> next reduce-eligible request is forwarded verbatim;curl -XPOST localhost:8080/labcx/mode -d '{"mode":"on"}'-> reduction resumes;curl -XPOST localhost:8080/labcx/mode -d '{"mode":"bogus"}'-> HTTP 400;curl localhost:8080/labcx/mode->{"mode":"..."};/readyunaffected.Fixes #