Skip to content

Send system role, not developer, to Ollama-compatible endpoints - #71

Open
map-c wants to merge 1 commit into
cloudflare:mainfrom
map-c:fix-ollama-developer-role
Open

Send system role, not developer, to Ollama-compatible endpoints#71
map-c wants to merge 1 commit into
cloudflare:mainfrom
map-c:fix-ollama-developer-role

Conversation

@map-c

@map-c map-c commented Aug 7, 2026

Copy link
Copy Markdown

Fixes #36.

Problem

A model added through the Ollama provider slot pointing at a self-hosted OpenAI-compatible endpoint fails on the first message with HTTP 400: the system prompt goes out with role: "developer", which strictly-validating endpoints (vLLM, LM Studio, llama.cpp, self-hosted gateways) reject.

pi's openai-completions API picks the system-prompt role from model.reasoning && compat.supportsDeveloperRole. detectCompat() doesn't recognize the ollama provider or an arbitrary self-hosted hostname, so the flag defaults on — and the ollama branch hardcodes reasoning: true, supplying the other half of the condition.

Fix

Pin compat: { supportsDeveloperRole: false } on the ollama branch in getModelDirect(), mirroring what workersAiCompat() already does for the sibling Workers AI branch.

Tests

Two regression tests in __tests__/ai-models.test.ts (which drives the real pi-ai stack with an injected fetch stub):

  • the ollama model descriptor carries supportsDeveloperRole: false;
  • the captured request body sends the system prompt as role: "system" — red before the fix (it captured "developer", exactly the issue's repro), green after.

pnpm exec vitest run (workshop-backend, 281 tests), pnpm lint:check, and tsc --noEmit all pass.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

The Ollama provider slot is what users point at arbitrary OpenAI-compatible
endpoints (vLLM, LM Studio, self-hosted gateways). pi defaults
supportsDeveloperRole on for providers it doesn't recognize, and with
reasoning: true that sends the system prompt as role "developer", which
strictly-validating endpoints reject with a 400 on the first message.

Pin supportsDeveloperRole: false on the ollama branch, mirroring
workersAiCompat(). Regression tests assert the compat flag and the role on
the wire.

Fixes cloudflare#36
@map-c
map-c force-pushed the fix-ollama-developer-role branch from d44e727 to 164bb4c Compare August 7, 2026 09:51
@map-c

map-c commented Aug 7, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Aug 7, 2026
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-slot models send role: "developer", which most OpenAI-compatible endpoints reject

1 participant