feat(headroom): make the compression request timeout configurable
The 3000 ms timeout on /v1/compress was fixed, so busy or slow machines timed out often and sent the LLM an inconsistently compressed body, hurting prompt caching. Add a headroomTimeoutMs setting, thread it from the chat handler down to compressWithHeadroom, expose it in the Token Saver dashboard, and normalize invalid values back to the 3000 ms default.
This commit is contained in:
@@ -14,6 +14,7 @@ export default function TokenSaverClient() {
|
||||
const [rtkEnabled, setRtkEnabledState] = useState(true);
|
||||
const [headroomEnabled, setHeadroomEnabled] = useState(false);
|
||||
const [headroomUrl, setHeadroomUrl] = useState("http://localhost:8787");
|
||||
const [headroomTimeoutMs, setHeadroomTimeoutMs] = useState(3000);
|
||||
const [headroomStatus, setHeadroomStatus] = useState({
|
||||
installed: false,
|
||||
running: false,
|
||||
@@ -406,6 +407,13 @@ export default function TokenSaverClient() {
|
||||
patchSetting({ pxpipeMinChars: next });
|
||||
};
|
||||
|
||||
const handleHeadroomTimeoutBlur = () => {
|
||||
const raw = Math.round(Number(headroomTimeoutMs));
|
||||
const next = Number.isFinite(raw) && raw > 0 ? raw : 3000;
|
||||
setHeadroomTimeoutMs(next);
|
||||
patchSetting({ headroomTimeoutMs: next });
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const loadSettings = async () => {
|
||||
try {
|
||||
@@ -415,6 +423,7 @@ export default function TokenSaverClient() {
|
||||
setRtkEnabledState(data.rtkEnabled !== false);
|
||||
setHeadroomEnabled(!!data.headroomEnabled);
|
||||
setHeadroomUrl(data.headroomUrl || "http://localhost:8787");
|
||||
if (typeof data.headroomTimeoutMs === "number") setHeadroomTimeoutMs(data.headroomTimeoutMs);
|
||||
setCodeAware(data.headroomCodeAware === true);
|
||||
setKompress(data.headroomKompress !== false);
|
||||
setCavemanEnabled(!!data.cavemanEnabled);
|
||||
@@ -818,6 +827,19 @@ export default function TokenSaverClient() {
|
||||
like http://headroom:8787.
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex flex-col gap-1">
|
||||
<p className="text-sm font-medium">Timeout (ms)</p>
|
||||
<Input
|
||||
value={String(headroomTimeoutMs)}
|
||||
onChange={(e) => setHeadroomTimeoutMs(e.target.value)}
|
||||
onBlur={handleHeadroomTimeoutBlur}
|
||||
placeholder="3000"
|
||||
className="font-mono text-sm"
|
||||
/>
|
||||
<p className="text-xs text-text-muted">
|
||||
Request timeout in milliseconds. Defaults to 3000 ms.
|
||||
</p>
|
||||
</div>
|
||||
{headroomManaged ? (
|
||||
<Button
|
||||
onClick={handleHeadroomStop}
|
||||
|
||||
@@ -53,6 +53,7 @@ const DEFAULT_SETTINGS = {
|
||||
headroomEnabled: false,
|
||||
headroomUrl: DEFAULT_HEADROOM_URL,
|
||||
headroomCompressUserMessages: false,
|
||||
headroomTimeoutMs: 3000,
|
||||
cavemanEnabled: false,
|
||||
cavemanLevel: "full",
|
||||
ponytailEnabled: false,
|
||||
|
||||
@@ -274,6 +274,7 @@ async function handleSingleModelChat(body, modelStr, clientRawRequest = null, re
|
||||
headroomEnabled: !!chatSettings.headroomEnabled,
|
||||
headroomUrl: chatSettings.headroomUrl || DEFAULT_HEADROOM_URL,
|
||||
headroomCompressUserMessages: !!chatSettings.headroomCompressUserMessages,
|
||||
headroomTimeoutMs: chatSettings.headroomTimeoutMs,
|
||||
cavemanEnabled: !!chatSettings.cavemanEnabled,
|
||||
cavemanLevel: chatSettings.cavemanLevel || "full",
|
||||
ponytailEnabled: !!chatSettings.ponytailEnabled,
|
||||
|
||||
Reference in New Issue
Block a user