← Back to PRs

#5920: fix: DeepSeek API compatibility - convert developer role to system (#5704)

by coupclawbot open 2026-02-01 03:43 View on GitHub →
agents
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