#5920: fix: DeepSeek API compatibility - convert developer role to system (#5704)
agents
Cluster:
Provider Support Enhancements
This PR fixes Issue #5704 where DeepSeek and other non-OpenAI providers don't support the 'developer' role introduced by OpenAI.
## Problem
When using DeepSeek models, the API returns:
```
400 Failed to deserialize: messages[0].role: unknown variant `developer`
```
## Solution
Transform 'developer' role messages to 'system' role for non-OpenAI providers.
## Changes
- Added `needsRoleTransformation()` to detect DeepSeek/non-OpenAI providers
- Added `transformDeveloperRole()` to convert developer → system role
- Modified `createStreamFnWithExtraParams()` to apply transformation
- Added 13 comprehensive unit tests
## Testing
All tests passing (4ms).
## Compatibility
- ✅ Non-breaking for OpenAI users
- ✅ Only transforms when necessary
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This change adds provider/model-based logic in `src/agents/pi-embedded-runner/extra-params.ts` to transform any `developer` role messages into `system` for providers deemed incompatible (notably DeepSeek), and wires that transformation into the stream wrapper created by `createStreamFnWithExtraParams`. It also adds a new Vitest suite (`src/agents/pi-embedded-runner/extra-params.test.ts`) covering transformation behavior and the provider/model decision function.
Overall the implementation is straightforward and well-tested, but the current `needsRoleTransformation` default (`true` for all non-OpenAI providers) is broader than the PR description implies and may cause unintended prompt semantics changes for providers that already accept `developer` (or treat roles differently).
<h3>Confidence Score: 3/5</h3>
- Reasonably safe to merge, but role transformation scope may be broader than intended.
- The change is small and has good unit test coverage, and it only rewrites message roles in the wrapper. However, `needsRoleTransformation` defaults to transforming for all non-OpenAI providers, which could change behavior for providers/models that already support `developer` or have different role semantics.
- src/agents/pi-embedded-runner/extra-params.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#14393: feat: add standalone DeepSeek provider support
by osoulmate · 2026-02-12
76.9%
#14187: fix: add Moonshot AI to non-standard provider detection
by shad0wca7 · 2026-02-11
76.5%
#23655: fix(model): map developer role to system for Aliyun/Dashscope/Qianf...
by SleuthCo · 2026-02-22
75.9%
#6673: fix: preserve allowAny flag in createModelSelectionState for custom...
by tenor0 · 2026-02-01
75.0%
#12503: feat: add DeepSeek provider suppor
by MackDing · 2026-02-09
75.0%
#7767: fix: enable turn validation for all non-OpenAI providers to prevent...
by sohail22dec · 2026-02-03
74.5%
#7163: fix #7151
by vivganes · 2026-02-02
74.4%
#22194: fix(agent) Moonshot/Kimi kimi-k2.5 returns ROLE_UNSPECIFIED
by ShengFuC · 2026-02-20
74.4%
#22741: fix(models): add DashScope/Qwen to normalizeModelCompat developer r...
by lailoo · 2026-02-21
74.2%
#12812: fix(transcript-policy): sanitize tool call IDs for all non-OpenAI p...
by justin-nevins · 2026-02-09
73.5%