Skip to content

fix(openai): merge custom-provider system prompts#2382

Open
pandego wants to merge 1 commit intodocker:mainfrom
pandego:fix/2327-merge-system-messages
Open

fix(openai): merge custom-provider system prompts#2382
pandego wants to merge 1 commit intodocker:mainfrom
pandego:fix/2327-merge-system-messages

Conversation

@pandego
Copy link
Copy Markdown
Contributor

@pandego pandego commented Apr 11, 2026

Summary

  • merge consecutive system and user messages for custom openai_chatcompletions providers
  • align custom OpenAI-compatible providers with the existing DMR prompt-normalization behavior
  • add regression coverage so custom providers collapse multiple system prompts while the native OpenAI path stays unchanged

Testing

  • docker run --rm -v "$PWD":/src -w /src golang:1.26 sh -lc '/usr/local/go/bin/gofmt -w pkg/model/provider/openai/client.go pkg/model/provider/openai/client_test.go && /usr/local/go/bin/go test ./pkg/model/provider/openai ./pkg/model/provider/oaistream -run "TestConvertMessages_MergesConsecutiveSystemMessagesForCustomProviders|TestConvertMessages_PreservesConsecutiveSystemMessagesForOpenAIProvider|TestConvertMessages|TestMergeConsecutiveMessages" -count=1'

Closes #2327

@pandego pandego requested a review from a team as a code owner April 11, 2026 16:23
aheritier
aheritier previously approved these changes May 6, 2026
Copy link
Copy Markdown
Contributor

@aheritier aheritier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Clean, minimal fix that reuses existing infrastructure (isCustomProvider, MergeConsecutiveMessages). Both paths are well-tested and CI passes.

One nit: the em dash → hyphen change on line 51 of the test file is unrelated noise — consider keeping commits atomic in the future.

@aheritier aheritier added kind/fix PR fixes a bug (maps to fix: commit prefix) area/providers/openai For features/issues/fixes related to the usage of OpenAI models priority:medium Normal priority, standard sprint work labels May 6, 2026
Signed-off-by: pandego <7780875+pandego@users.noreply.github.com>
@pandego pandego force-pushed the fix/2327-merge-system-messages branch from 23681e3 to 578a48d Compare May 7, 2026 11:23
@aheritier aheritier added effort:small Isolated change, clear solution, single area go Pull requests that update go code and removed priority:medium Normal priority, standard sprint work labels May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/providers/openai For features/issues/fixes related to the usage of OpenAI models effort:small Isolated change, clear solution, single area go Pull requests that update go code kind/fix PR fixes a bug (maps to fix: commit prefix)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Jinja Exception: System message must be at the beginning with custom provider, docker model runner and qwen 3.5 family models

2 participants