You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SimpleContext.add() content is silently discarded from generation — add a safety net #1597
area/stdlibCore abstractions: Context, MOT, SamplingStrategy, formatters, serializationbugSomething isn't workingp1High: important bugs (workaround exists) or high-value core features. Do soon, not on fire.
SimpleContext.view_for_generation() always returns [] by design (mellea/stdlib/context/simple.py) — it's a stateless context and never forwards history to the model. But .add() still exists and returns a chainable context, which reads like it records the turn for the next call. A caller who .add()s a message and then separately passes an unrelated (or empty) action to generate_from_context ends up sending a request with no real user content at all — and nothing errors. The model just receives an empty conversation.
Concrete instance
This is exactly what happened in #1587's live Ollama telemetry tests, before it was caught:
The .add()ed message never reaches the model — the actual generation input is the empty assistant message. Granite 4.2 rambles for 2000+ tokens on the resulting empty prompt, which was one of two root causes behind sustained CI stalls on that PR (see its "CI stability fixes" section).
Proposed fix
Docs: SimpleContext.add()'s own docstring should state that content added here is not forwarded to generation — today only view_for_generation() mentions the discard, and it's easy to read .add() in isolation and assume otherwise.
Code: add a guard in the shared message-assembly path (each backend's _generate_from_chat_context_standard or equivalent) that raises or logs a warning when the fully-assembled messages list sent to the model has no non-empty user-role content. This is a universal invariant, not SimpleContext-specific, and would have caught this exact bug at test-authoring time instead of during a multi-hour CI stall investigation.
Status: mostly covered by open PR #1632 — remainder is the HF path (tracked in #1705)
Verified against main at 4c53add4e. PR #1632 (open, simonyang08) already implements both of this issue's proposed items, except the Hugging Face backend:
Guard (item 2): 3 of 4 backends in fix(backends): reject empty user content before sending chat request #1632 — OpenAI, LiteLLM, Ollama, via the new shared has_user_content helper in mellea/helpers/openai_compatible_helpers.py. LocalHFBackend is not in the PR's file list, and its path (to_chat() in mellea/backends/utils.py → apply_chat_template) does not go through the helper.
So once #1632 merges, this issue reduces to the HF half, which #1705 already tracks. Proposal: leave #1705 as the remaining vehicle and close this one then, with a cross-reference — rather than opening a third issue or duplicating the guard work. Flagging here rather than on #1632 so the PR's author sees the intended division before merge.
area/stdlibCore abstractions: Context, MOT, SamplingStrategy, formatters, serializationbugSomething isn't workingp1High: important bugs (workaround exists) or high-value core features. Do soon, not on fire.
Activity
fix(backends): reject empty user content before sending chat request
planetf1 commentedon Oct 5, 2026
Status: mostly covered by open PR #1632 — remainder is the HF path (tracked in #1705)
Verified against
mainat4c53add4e. PR #1632 (open, simonyang08) already implements both of this issue's proposed items, except the Hugging Face backend:SimpleContextclass docstring,add(), andview_for_generation()all carry the "content is never forwarded to the model" wording.has_user_contenthelper inmellea/helpers/openai_compatible_helpers.py.LocalHFBackendis not in the PR's file list, and its path (to_chat()inmellea/backends/utils.py→apply_chat_template) does not go through the helper.So once #1632 merges, this issue reduces to the HF half, which #1705 already tracks. Proposal: leave #1705 as the remaining vehicle and close this one then, with a cross-reference — rather than opening a third issue or duplicating the guard work. Flagging here rather than on #1632 so the PR's author sees the intended division before merge.
test(telemetry): keep the user turn visible to generation in streamin…
fix(backends): reject empty user content before sending chat request (g…
fix(backends): guard LocalHFBackend against empty user content (gener…