Skip to content

fix: add system-message guard for ollama-cloud (#29871) - #29935

Closed
zombi3butt wants to merge 4 commits into
NousResearch:mainfrom
zombi3butt:fix/ollama-cloud-system-message-injection
Closed

fix: add system-message guard for ollama-cloud (#29871)#29935
zombi3butt wants to merge 4 commits into
NousResearch:mainfrom
zombi3butt:fix/ollama-cloud-system-message-injection

Conversation

@zombi3butt

Copy link
Copy Markdown

fix: add system-message guard for ollama-cloud (#29871)

When provider hooks silently strip the role="system" message (known with
some Ollama Cloud variants), re-inject from original input so SOUL.md is
never lost mid-flight.

The bug: The ollama-cloud provider does not inject SOUL.md into outgoing
requests — load_soul_md() fires correctly but content drops downstream.

The fix: Added a defensive verification step at the end of
_build_kwargs_from_profile() in agent/transports/chat_completions.py. If
the input messages contained a system role that doesn't appear in the final
kwargs, we re-inject it from the original input content.

This guard:

  • Checks if input had role=\"system\" at index 0
  • Verifies output kwargs also have it at index 0
  • If missing: re-prepends the system message from original input

Impact: Zero breaking changes. This is a pure defensive addition that
only triggers when messages are unexpectedly stripped. Works with ALL
providers through the profile path — not just ollama-cloud.

Resolves #29871

3ighty2O and others added 4 commits May 21, 2026 21:17
…me dict (issue NousResearch#29872)

When resolving named custom providers (custom:<name>), the returned
runtime dict previously collapsed provider to bare 'custom', losing
the specific sub-provider identity. This caused TUI display and
credential pool lookups to show only 'custom' instead of
'custom:bobapi-deepseek' etc.

Changes:
- _try_resolve_from_custom_pool: preserve sub-provider name in
  returned provider field as 'custom:<name>'
- _resolve_named_custom_runtime: non-pool return path uses
  'custom:<name>' for the provider field
- Bare 'custom' with explicit base_url remains unchanged

Updated tests to reflect new expected provider values.
When provider hooks silently strip the role="system" message (known with
some Ollama Cloud variants), re-inject from original input so SOUL.md is
never lost mid-flight. Adds defensive verification in _build_kwargs_from_profile.
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/ollama Ollama / local models P3 Low — cosmetic, nice to have labels May 21, 2026
@zombi3butt

Copy link
Copy Markdown
Author

Closing this PR as it bundles 4 unrelated changes alongside the actual #29871 fix. Only agent/transports/chat_completions.py is relevant to the system-message guard. The other changed files (agent/model_metadata.py llama.cpp context, hermes_cli/runtime_provider.py custom provider identity from closed #30107, tests/hermes_cli/test_runtime_provider_resolution.py, tools/skills_sync.py skills CLI fix) should be in separate focused PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have provider/ollama Ollama / local models type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: ollama-cloud provider does not inject SOUL.md into outgoing request (loader fires correctly; content drops downstream)

3 participants