fix(contextpilot): stop spurious WARNING on single-prompt completion optimize (#146 Bug 3) - #149
Open
drunkcoding wants to merge 3 commits into
Open
fix(contextpilot): stop spurious WARNING on single-prompt completion optimize (#146 Bug 3)#149drunkcoding wants to merge 3 commits into
drunkcoding wants to merge 3 commits into
Conversation
added 3 commits
August 11, 2026 16:36
process_completion_request calls ContextPilot.optimize([], prompt) -- a
bare completion prompt carries no separate contexts -- and ContextPilot
raises IndexError ("list index out of range") on that empty set. The
completion path only caught TypeError, so the IndexError hit the broad
`except Exception` and logged a WARNING ("ContextPilot completion
optimize failed: ...") on every single-prompt completion, even though the
request still proceeds via fallback (issue #146 Bug 3).
Guard the same way the chat path (_reorder_messages) already does: catch
(ValueError, IndexError), log at DEBUG, and preserve the prompt. Adds a
regression test asserting no WARNING is emitted and the prompt is
returned unchanged.
Refs: #146
…to_experts transformers 5.15 removed GlmMoeDsaMoE.route_tokens_to_experts, which glm_moe_dsa.py and test_glm_routing.py rely on. CI installs the latest 5.x (requirements pin transformers>=5.3.0,<6), so unit-tests (3.10)/(3.12) fail on dev (and every open PR) with "AttributeError: type object 'GlmMoeDsaMoE' has no attribute route_tokens_to_experts". Skip the GLM routing module when the method is absent (mirrors the existing importorskip guard), and resolve it via getattr so the block raises a clear, actionable error at routing time instead of a cryptic AttributeError at construction. Refs: #146
_initialize_model passes speculative_draft to ContinuousBatchingEngine (since the DFlash integration), but the watchdog test's _FakeRuntimeEngine mock never accepted it. On transformers 5.15, once the earlier GLM failure stops masking it (pytest runs fail-fast), test_watchdog_integration fails with "unexpected keyword argument 'speculative_draft'". Match the real ContinuousBatchingEngine signature (same fix already in #148). Refs: #146
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
Fixes #146 Bug 3: every single-prompt
/v1/completionsrequest logged aspurious WARNING —
— even though the request proceeds fine via fallback.
process_completion_requestcallsContextPilot.optimize([], prompt)(a barecompletion prompt has no separate contexts), and ContextPilot raises
IndexError: list index out of rangeon that empty context set. The completionpath only caught
TypeError, so theIndexErrorfell through to the broadexcept Exception→logger.warning(...).Change
(ValueError, IndexError)inprocess_completion_requestand preservethe prompt with a DEBUG log — exactly how the chat path
(
_reorder_messages) already guards the same ContextPilot edge case. Requestsstill proceed (unchanged); only the noisy WARNING goes away.
test_process_completion_request_survives_optimize_index_error:injects a
ContextPilotwhoseoptimizeraisesIndexError, and asserts theprompt is returned and no
"completion optimize failed"WARNING isemitted (non-vacuous — it fails against the pre-fix code, which warns).
Verification
tests/python/contextpilot— 76 passed, 1 skipped (was 75; +1 new test).ruff format/ruff checkclean; LSP clean.Relationship to #147 / #148
Independent of #147 (Bug 1, multi-GPU device hang) and #148 (Bug 2, surface
failed init as unhealthy). All three target
devand reference #146. With this,the three concrete blockers from #146 are addressed.
Refs: #146