Don't send the developer role from the Ollama provider slot - #37
Closed
warmwind wants to merge 1 commit into
Closed
Conversation
pi picks the system-prompt role from `model.reasoning && compat.supportsDeveloperRole`, and its detectCompat() infers supportsDeveloperRole from the provider id and base URL. ollama is absent from the isNonStandard list and a self-hosted base URL matches none of the hostname checks, so an arbitrary OpenAI-compatible gateway is assumed to accept `role: "developer"`. Together with the hardcoded reasoning: true above, that sent the developer role on every request, and endpoints which validate message roles strictly rejected the very first message with a 400. This slot is the only one pairing a user-supplied base URL with the chat-completions API, so it is what vLLM, LM Studio, llama.cpp and self-hosted gateways are added through -- not just Ollama itself. workersAiCompat() already pins the same flag. Fixes cloudflare#36 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
All contributors have signed the CLA ✍️ ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
Member
|
Hi @warmwind, Apologies but, per our contributing guide, we prefer not to receive external pull requests. We'd rather receive issue reports, which we can then prompt our own agents to solve. Could you please file an issue instead? I realize this one may seem trivial, but I think it's not really -- presumably Pi is using the developer role for a reason here, and by accepting this change we might lose somtehing. The ollama provider is not intended to be a general "OpenAI compatible" provider; it is specifically intended for ollama, and in my testing it does in fact work correctly against ollama. |
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.
Fixes #36.
A model added through the Ollama provider slot against a self-hosted OpenAI-compatible endpoint fails on the very first message:
pi chooses the system-prompt role with
and
detectCompat()inferssupportsDeveloperRolefrom the provider id and base URL.ollamais not in itsisNonStandardlist, and a self-hosted base URL matches none of its hostname checks, so the endpoint is assumed to acceptrole: "developer". The branch also hardcodesreasoning: true, which supplies the other half of the condition — so the developer role went out on every request.This slot is the only one in
AddModelModalthat pairs a user-supplied base URL with the chat-completions API (openaiusesopenai-responses,googleusesgoogle-generative-ai,cloudflareis account-scoped), so it is what vLLM, LM Studio, llama.cpp and self-hosted gateways get added through, not just Ollama itself. Any of them that validates message roles strictly was unusable.workersAiCompat()in the same file already pins this flag; this brings the ollama branch in line.Verification
Against an internal OpenAI-compatible gateway serving a DeepSeek model, before the change every chat failed with the 400 above. After it:
reasoning_contentdeltas rendered as thinking ✅executeCodetool calls ✅executeCodeand returned 338350)pnpm --filter @gadgets/workshop-backend types:checkpasses.I also checked with
curlthat the endpoint itself accepts everything else pi sends — non-streaming, streaming, assistant-message replay with and withoutreasoning_content, and function calling all return 200. Thedeveloperrole was the only rejected part.🤖 Generated with Claude Code