Skip to content

Fix/ollama system prompt#568

Open
wiizzl wants to merge 2 commits into
TanStack:mainfrom
wiizzl:fix/ollama-system-prompt
Open

Fix/ollama system prompt#568
wiizzl wants to merge 2 commits into
TanStack:mainfrom
wiizzl:fix/ollama-system-prompt

Conversation

@wiizzl
Copy link
Copy Markdown

@wiizzl wiizzl commented May 16, 2026

🎯 Changes

Fixes #567

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

Bug Fixes

  • System prompt handling in the Ollama chat adapter has been refined to ensure proper integration with chat requests. System prompts are now consistently processed within the chat API workflow, improving message handling, consistency, and overall chat operation reliability.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 16, 2026

📝 Walkthrough

Walkthrough

This PR fixes the Ollama adapter's handling of global system prompts by moving them from a dedicated request field into the messages array as a leading system message, aligning with Ollama's chat endpoint expectations. A changeset entry documents the patch release.

Changes

System Prompts in Ollama Chat API

Layer / File(s) Summary
System prompts prepended to messages array
packages/typescript/ai-ollama/src/adapters/text.ts, .changeset/strong-heads-hang.md
mapCommonOptionsToOllama now stores formatted messages, prepends a role: 'system' message with joined systemPrompts when present, and returns the request with the updated messages list instead of a separate system field. Changeset documents the patch-level chat API behavior change.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A whisper in the messages flow,
System prompts now lead the way,
No longer lost in fields below,
Ollama listens what we say! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix/ollama system prompt' clearly and concisely summarizes the main change: fixing how the Ollama adapter handles system prompts.
Linked Issues check ✅ Passed The code changes fully implement the proposed fix from issue #567: system prompts are now prepended as a system message to the messages array instead of placed at root level, matching Ollama's chat API expectations.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the reported issue: the text adapter is modified to fix system prompt handling, and a changeset is added for the release, with no unrelated modifications present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The PR description includes the required template sections with checked boxes indicating contributor completed the contributing guide and generated a changeset for release impact.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ollama adapter ignores global systemPrompts

1 participant