GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat(muse-proxy): warm sessions on a persistent muse serve (MSP) host (#480) by dezren39 · Pull Request #769 · developing-today/code Conversation
|
|
Caution Review failedThe pull request is closed. Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Here are some automated review suggestions for this pull request.
Reviewed commit: a61e39bb23
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const midUsers = suffix.slice(0, -1).filter(m => m.role === 'user').length; | ||
| if (prefixOk && suffix.length > 0 && last.role === 'user' && midUsers === 0) { | ||
| turnText = messageText(last); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Validate the assistant history before reusing a warm session
When a client edits an assistant reply or forks a conversation after the same opening user message, this condition still reuses the original session: entry.hashes covers only the previous request's inputs, so the newly supplied assistant reply is outside the checked prefix. Sending only messageText(last) then silently discards that reply and answers against the original session's history instead. The same condition also discards intervening tool results. Store and validate the generated assistant response, and re-bootstrap whenever the supplied suffix contains history that is not already represented in the session.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| let fullContent = result.deltasText; | ||
| let unstreamedSuffix = ''; | ||
| if (typeof result.fullText === 'string' && result.fullText.length >= fullContent.length) { | ||
| if (result.fullText.startsWith(fullContent)) unstreamedSuffix = result.fullText.slice(fullContent.length); | ||
| fullContent = result.fullText; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Use the authoritative final answer regardless of its length
When a warm turn emits intermediate agent-message commentary followed by a shorter final answer, deltasText contains the accumulated commentary while fullText contains the selected finalAnswer. This length check rejects the authoritative answer, so even a non-streaming response returns commentary concatenated with the answer instead of the final answer alone. A stub turn with accumulated deltas Long intermediate commentary. Done and final text Done reproduces this. Select the authoritative text unconditionally for non-streaming responses; keep prefix checks only for deciding what can safely be appended to an already-started stream.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| let result; | ||
| try { | ||
| result = await enqueueWarm(key, job); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Cancel warm work when the HTTP client disconnects
When a client aborts a request, the warm path neither cancels its active turn nor prevents its queued job from starting, unlike the exec path's response-close handler. This is reproducible by delaying one warm turn, queuing another request for the same conversation, and aborting the second request before the first finishes: the canceled request still starts another turn. Abandoned requests therefore continue consuming inference and holding the per-conversation queue, potentially delaying subsequent live requests for the full turn timeout. Observe response closure, skip canceled queued jobs, and cancel active work without terminating unrelated sessions.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| child.on('error', err => this._onExit(`spawn error: ${err.message}`)); | ||
| child.on('close', (code, signal) => this._onExit(`serve host exited (code ${code}, signal ${signal})`)); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Ignore exit callbacks from replaced serve children
If initialization fails while another request is queued, _start() kills the failed child and clears its reference before that child's asynchronous close event arrives. The queued request can start a replacement host in that interval, but the old child's callback then invokes _onExit(), which unconditionally clears the replacement's state and rejects its pending RPCs. This makes the replacement initialization fail because of the previous process's exit. Bind these callbacks to their originating child and ignore them when that child is no longer the active host.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const enqueueWarm = (key, job) => { | ||
| const prev = warmChains.get(key) || Promise.resolve(); | ||
| const run = prev.then(job, job); | ||
| warmChains.set(key, run.catch(() => {})); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Release completed per-conversation chains
For a long-lived proxy serving distinct conversations, warmChains permanently retains one promise per conversation key. Because run.catch(() => {}) preserves successful fulfillment values, those promises also retain each completed turn's entire result, including fullText and deltasText; the 64-session LRU never removes these entries. Extracting this implementation and completing 256 unique conversations left all 256 result objects alive after repeated garbage collection, whereas clearing the map released them. Remove settled chains when they are still the latest chain for their key so response data does not accumulate without bound.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| _write(obj) { | ||
| if (!this.child || !this.child.stdin.writable) throw new Error('serve host stdin is not writable'); | ||
| this.child.stdin.write(JSON.stringify(obj) + '\n'); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Handle asynchronous errors on the serve host's stdin
If the serve host exits while a buffered RPC write is pending, child.stdin emits an asynchronous error event that neither the surrounding write try/catch nor child.on('error') handles. This terminates the entire proxy instead of falling back to exec, dropping unrelated requests as well. A stub host that exits after reading the beginning of a 4 MiB turn/start request reproduces an uncaught Error: write EPIPE and proxy process exit. Register an error handler on the stdin stream and route the failure through the host/RPC rejection path.
Useful? React with 👍 / 👎.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.