Skip to content

Commit d11df24

Browse files
authored
Add DeepSeek V4 provider (#574)
1 parent 7f1131a commit d11df24

17 files changed

Lines changed: 1122 additions & 41 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { createBase2 } from './base2'
2+
3+
const definition = {
4+
...createBase2('free', {
5+
noAskUser: true,
6+
model: 'deepseek/deepseek-v4-pro',
7+
}),
8+
id: 'base2-free-deepseek-v4',
9+
displayName: 'Buffy the DeepSeek V4 Free Orchestrator',
10+
}
11+
export default definition

agents/types/agent-definition.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,8 @@ export type ModelName =
415415
| 'qwen/qwen3-30b-a3b:nitro'
416416

417417
// DeepSeek
418+
| 'deepseek/deepseek-v4-pro'
419+
| 'deepseek-v4-pro'
418420
| 'deepseek/deepseek-chat-v3-0324'
419421
| 'deepseek/deepseek-chat-v3-0324:nitro'
420422
| 'deepseek/deepseek-r1-0528'

common/src/constants/free-agents.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { parseAgentId } from '../util/agent-id-parsing'
22

33
import { FREEBUFF_GEMINI_THINKER_AGENT_ID } from './freebuff-gemini-thinker'
44
import {
5+
FREEBUFF_DEEPSEEK_V4_PRO_MODEL_ID,
56
FREEBUFF_GEMINI_PRO_MODEL_ID,
67
SUPPORTED_FREEBUFF_MODELS,
78
} from './freebuff-models'
@@ -20,7 +21,10 @@ export const FREE_COST_MODE = 'free' as const
2021
* excluded — they're spawned by the root, so counting them would inflate
2122
* every user's apparent activity.
2223
*/
23-
export const FREEBUFF_ROOT_AGENT_IDS = ['base2-free'] as const
24+
export const FREEBUFF_ROOT_AGENT_IDS = [
25+
'base2-free',
26+
'base2-free-deepseek-v4',
27+
] as const
2428
const FREEBUFF_ROOT_AGENT_ID_SET: ReadonlySet<string> = new Set(
2529
FREEBUFF_ROOT_AGENT_IDS,
2630
)
@@ -39,6 +43,7 @@ const FREEBUFF_ALLOWED_MODEL_IDS = SUPPORTED_FREEBUFF_MODELS.map(
3943
export const FREE_MODE_AGENT_MODELS: Record<string, Set<string>> = {
4044
// Root orchestrator
4145
'base2-free': new Set(FREEBUFF_ALLOWED_MODEL_IDS),
46+
'base2-free-deepseek-v4': new Set([FREEBUFF_DEEPSEEK_V4_PRO_MODEL_ID]),
4247

4348
// File exploration agents
4449
'file-picker': new Set(['google/gemini-2.5-flash-lite']),

common/src/constants/freebuff-models.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface FreebuffModelOption {
2222
* `getFreebuffDeploymentAvailabilityLabel()` instead. */
2323
export const FREEBUFF_DEPLOYMENT_HOURS_LABEL = '9am ET-5pm PT every day'
2424
export const FREEBUFF_GEMINI_PRO_MODEL_ID = 'google/gemini-3.1-pro-preview'
25+
export const FREEBUFF_DEEPSEEK_V4_PRO_MODEL_ID = 'deepseek/deepseek-v4-pro'
2526
export const FREEBUFF_GLM_MODEL_ID = 'z-ai/glm-5.1'
2627
export const FREEBUFF_KIMI_MODEL_ID = 'moonshotai/kimi-k2.6'
2728
export const FREEBUFF_MINIMAX_MODEL_ID = 'minimax/minimax-m2.7'

common/src/constants/model-config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const ALLOWED_MODEL_PREFIXES = [
66
'openai',
77
'google',
88
'x-ai',
9+
'deepseek',
910
] as const
1011

1112
export const costModes = [
@@ -55,6 +56,8 @@ export type openrouterModel =
5556
export const deepseekModels = {
5657
deepseekChat: 'deepseek-chat',
5758
deepseekReasoner: 'deepseek-reasoner',
59+
deepseekV4ProDirect: 'deepseek-v4-pro',
60+
deepseekV4Pro: 'deepseek/deepseek-v4-pro',
5861
} as const
5962
export type DeepseekModel = (typeof deepseekModels)[keyof typeof deepseekModels]
6063

common/src/templates/initial-agents-dir/types/agent-definition.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,8 @@ export type ModelName =
415415
| 'qwen/qwen3-30b-a3b:nitro'
416416

417417
// DeepSeek
418+
| 'deepseek/deepseek-v4-pro'
419+
| 'deepseek-v4-pro'
418420
| 'deepseek/deepseek-chat-v3-0324'
419421
| 'deepseek/deepseek-chat-v3-0324:nitro'
420422
| 'deepseek/deepseek-r1-0528'

evals/buffbench/main-single-eval.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ async function main() {
77

88
await runBuffBench({
99
evalDataPaths: [path.join(__dirname, 'eval-codebuff.json')],
10-
agents: ['base2-free-evals'],
10+
agents: ['base2-free-deepseek-v4'],
1111
taskIds: ['server-agent-validation'],
1212
saveTraces,
1313
})

packages/agent-runtime/src/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ export const globalStopSequence = `${JSON.stringify(endsAgentStepParam)}`
99
* to diff sequential requests and find what's breaking prompt caching.
1010
*/
1111
export const CACHE_DEBUG_FULL_LOGGING = false
12+
13+
// Keep disabled by default to preserve mainline behavior until reasoning-token
14+
// replay has been tested more thoroughly.
15+
export const INCLUDE_REASONING_IN_MESSAGE_HISTORY = false

packages/agent-runtime/src/tools/stream-parser.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
import { generateCompactId } from '@codebuff/common/util/string'
99

1010
import { processStreamWithTools } from '../tool-stream-parser'
11+
import { INCLUDE_REASONING_IN_MESSAGE_HISTORY } from '../constants'
1112
import {
1213
executeCustomToolCall,
1314
executeToolCall,
@@ -276,6 +277,11 @@ export async function processStream(
276277
}
277278

278279
if (chunk.type === 'reasoning') {
280+
if (INCLUDE_REASONING_IN_MESSAGE_HISTORY && chunk.text) {
281+
assistantMessages.push(
282+
assistantMessage({ type: 'reasoning', text: chunk.text }),
283+
)
284+
}
279285
onResponseChunk({
280286
type: 'reasoning_delta',
281287
text: chunk.text,

packages/internal/src/env-schema.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const serverEnvSchema = clientEnvSchema.extend({
88
ANTHROPIC_API_KEY: z.string().min(1),
99
FIREWORKS_API_KEY: z.string().min(1),
1010
CANOPYWAVE_API_KEY: z.string().min(1).optional(),
11+
DEEPSEEK_API_KEY: z.string().min(1).optional(),
1112
SILICONFLOW_API_KEY: z.string().min(1).optional(),
1213
LINKUP_API_KEY: z.string().min(1),
1314
CONTEXT7_API_KEY: z.string().optional(),
@@ -87,6 +88,7 @@ export const serverProcessEnv: ServerInput = {
8788
ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY,
8889
FIREWORKS_API_KEY: process.env.FIREWORKS_API_KEY,
8990
CANOPYWAVE_API_KEY: process.env.CANOPYWAVE_API_KEY,
91+
DEEPSEEK_API_KEY: process.env.DEEPSEEK_API_KEY,
9092
SILICONFLOW_API_KEY: process.env.SILICONFLOW_API_KEY,
9193
LINKUP_API_KEY: process.env.LINKUP_API_KEY,
9294
CONTEXT7_API_KEY: process.env.CONTEXT7_API_KEY,

0 commit comments

Comments
 (0)