Skip to content

feat(agents): add DeepSeek-V4 native support#3651

Open
gutierrezx7 wants to merge 1 commit intocode-yeongyu:devfrom
gutierrezx7:feat/deepseek-v4-support
Open

feat(agents): add DeepSeek-V4 native support#3651
gutierrezx7 wants to merge 1 commit intocode-yeongyu:devfrom
gutierrezx7:feat/deepseek-v4-support

Conversation

@gutierrezx7
Copy link
Copy Markdown

@gutierrezx7 gutierrezx7 commented Apr 26, 2026

DeepSeek-V4 Support Implementation

Summary

This PR adds native support for DeepSeek-V4 models to oh-my-openagent, enabling users to leverage DeepSeek's advanced agent capabilities within the OMO orchestration framework.

Problem Statement

Users of oh-my-openagent (OMO) who wanted to use DeepSeek-V4 faced compatibility issues:

  1. No model detection: DeepSeek-V4 models were not recognized, falling back to generic handling
  2. Suboptimal prompts: The default Claude-style prompt (~540 LOC) was too verbose for DeepSeek's attention patterns, causing "lost in the middle" issues
  3. Missing fallback chains: DeepSeek-V4 wasn't available in agent fallback chains
  4. Incorrect configuration: No proper support for V4-Pro's native thinking mode vs V4-Flash's fast inference

Solution

1. Model Detection (src/agents/types.ts)

Added four detection functions to properly identify DeepSeek model variants:

isDeepSeekV4Model()       // Detects any V4 variant
isDeepSeekV4ProModel()    // Detects Pro variant with thinking support
isDeepSeekV4FlashModel()  // Detects Flash variant for fast inference
isDeepSeekR1Model()       // Detects R1 reasoning model (future use)

Design rationale: Separate detection functions allow granular control over model-specific features (e.g., thinking mode for Pro only).

2. Native Prompt (src/agents/sisyphus/deepseek-v4.ts)

Created a purpose-built prompt for DeepSeek-V4 with the following optimizations:

  • Compact structure: ~330 LOC vs ~540 LOC default prompt, reducing "lost in the middle" issues
  • High-attention placement: Critical instructions at start and end of prompt
  • XML-tagged sections: Clear structure for better parsing
  • No corrective overlays: Unlike Gemini, V4 doesn't require behavioral corrections

Key sections:

  • Phase 0: Intent Classification (mandatory first step)
  • Phase 1: Tool Usage Rules with parallel execution guidelines
  • Phase 2: Implementation Rules with delegation structure
  • Phase 3: Failure Recovery procedures
  • Phase 4: Completion criteria

3. Routing Logic (src/agents/sisyphus.ts)

Added V4-specific routing in createSisyphusAgent():

if (isDeepSeekV4Model(model)) {
  // Use native V4 prompt
  // Enable thinking for Pro variant (32k budget)
  // No reasoningEffort (V4 uses thinking, not OpenAI-style reasoning)
}

Configuration:

  • V4-Pro: thinking: { type: "enabled", budgetTokens: 32000 }
  • V4-Flash: No thinking config (optimized for speed)

4. Fallback Chains (src/shared/model-requirements.ts)

Added DeepSeek-V4-Pro to agent fallback chains:

Sisyphus:

claude-opus-4-7 (max) → kimi-k2.5 → gpt-5.5 (medium) → deepseek-v4-pro (max) → glm-5 → big-pickle

Oracle:

gpt-5.5 (high) → gemini-3.1-pro (high) → claude-opus-4-7 (max) → deepseek-v4-pro (high) → glm-5

5. Test Coverage (src/agents/types.test.ts)

Added comprehensive tests (42 test cases):

  • Provider-prefixed models: llmgateway/deepseek-v4-pro
  • Providerless models: deepseek-v4-pro
  • Negative cases: V3, R1, other models correctly rejected
  • Variant separation: Pro vs Flash detection

Technical Decisions

Why Native Prompt Instead of Overlays?

DeepSeek-V4 differs from Gemini in key ways:

  • ✅ Follows system prompts correctly (unlike R1)
  • ✅ Has native tool calling with strict mode
  • ✅ Doesn't hallucinate tool calls (unlike Gemini)
  • ✅ Has larger context window (1M tokens)

A native prompt allows better optimization for V4's architecture than injecting overlays into a generic prompt.

Why Not Support R1 in This PR?

DeepSeek-R1 has fundamentally different requirements:

  • Official docs recommend avoiding system prompts
  • Requires instructions in user messages instead
  • Needs different temperature settings (0.5-0.7)
  • Has unique reasoning behavior

Supporting R1 requires architectural changes beyond this PR's scope.

Why Thinking Instead of reasoningEffort?

  • reasoningEffort is OpenAI-specific
  • DeepSeek-V4 uses Claude-style thinking with budget tokens
  • Consistent with existing Claude handling in codebase

Usage

Configuration

Add to oh-my-opencode.jsonc:

{
  "agents": {
    "sisyphus": {
      "model": "llmgateway/deepseek-v4-pro"
    }
  }
}

Or use via LLM Gateway:

{
  "agents": {
    "sisyphus": {
      "model": "llmgateway/deepseek-v4-pro"
    }
  }
}

Available Models

Model Variant Context Features
deepseek-v4-pro High quality 1M tokens Thinking mode, strict tool calling
deepseek-v4-flash Fast inference 1M tokens Optimized for speed

Testing

All tests pass:

$ bun test src/agents/types.test.ts
42 pass
0 fail

Build succeeds:

$ bun run build
✓ Bundled 1295 modules
✓ TypeScript declarations emitted
✓ JSON Schema generated

Checklist

  • Added model detection functions with provider support
  • Created native V4 prompt optimized for agent orchestration
  • Implemented proper routing with thinking configuration
  • Added to fallback chains for Sisyphus and Oracle
  • Comprehensive test coverage (42 tests)
  • Build passes without errors
  • TypeScript type checking passes
  • Schema JSON regenerated

References

Related

Closes #2072 (partially - V4 support, R1 deferred to future PR)


View in Codesmith
Codesmith can help with this PR, just tag @codesmith or enable autofix. Settings.

  • Autofix CI and bot reviews

Summary by cubic

Adds native DeepSeek-V4 support to Sisyphus with a compact, V4-optimized prompt and model-aware routing. Improves orchestration quality and adds deepseek-v4-pro to Sisyphus and Oracle fallback chains.

  • New Features

    • Detects deepseek-v4 variants (pro, flash) and adds an r1 detector for future use.
    • Adds a native DeepSeek-V4 Sisyphus prompt (~330 LOC) with clear, XML-tagged phases. No corrective overlays.
    • Routes V4 models to the native prompt; enables thinking for deepseek-v4-pro (32k budget). No reasoningEffort.
    • Updates fallback chains to include deepseek-v4-pro.
    • Adds 42 tests covering provider-prefixed/providerless names, variant separation, and negatives.
  • Migration

    • To use: set agents.sisyphus.model to llmgateway/deepseek-v4-pro (quality) or deepseek-v4-flash (speed).

Written for commit b12bab0. Summary will update on new commits.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 26, 2026

All contributors have signed the CLA. Thank you! ✅
Posted by the CLA Assistant Lite bot.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 6 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Native support for DeepSeek-V4 is implemented as a new, isolated code path with specific model detection and comprehensive tests. No existing model logic is modified.

@gutierrezx7
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@gutierrezx7
Copy link
Copy Markdown
Author

recheck

@gutierrezx7
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

recheck

Add comprehensive support for DeepSeek-V4 models to enable users to leverage
DeepSeek's advanced agent capabilities within the OMO orchestration framework.

## Changes

### Model Detection (src/agents/types.ts)
- Add isDeepSeekV4Model() - detect any V4 variant
- Add isDeepSeekV4ProModel() - detect Pro with thinking support
- Add isDeepSeekV4FlashModel() - detect Flash for fast inference
- Add isDeepSeekR1Model() - detect R1 reasoning model (future use)

### Native Prompt (src/agents/sisyphus/deepseek-v4.ts)
- Create optimized prompt (~330 LOC vs ~540 default)
- Compact structure to avoid "lost in the middle" issues
- XML-tagged sections for clear parsing
- Phases: Intent → Tools → Implementation → Recovery → Completion

### Routing (src/agents/sisyphus.ts)
- Add V4-specific routing branch before default prompt
- V4-Pro: thinking enabled with 32k budget
- V4-Flash: optimized for speed without thinking

### Fallback Chains (src/shared/model-requirements.ts)
- Add deepseek-v4-pro to Sisyphus fallback chain
- Add deepseek-v4-pro to Oracle fallback chain

### Tests (src/agents/types.test.ts)
- Add 42 comprehensive test cases
- Cover provider-prefixed and providerless models
- Test variant separation (Pro vs Flash)
- Test negative cases (V3, R1, other models)

## Why Native Prompt?

Unlike Gemini which requires corrective overlays, DeepSeek-V4:
- Follows system prompts correctly (unlike R1)
- Has native tool calling with strict mode support
- Doesn't hallucinate tool calls
- Benefits from compact, well-structured prompts

## Usage

Configure in oh-my-opencode.jsonc:
{
  "agents": {
    "sisyphus": {
      "model": "llmgateway/deepseek-v4-pro"
    }
  }
}

## Testing

- All 42 new tests pass
- Build succeeds (1295 modules)
- TypeScript type checking passes
- Schema JSON regenerated

Refs: code-yeongyu#2072
Related: code-yeongyu#3517 (follows same GLM overlay pattern)
@gutierrezx7 gutierrezx7 force-pushed the feat/deepseek-v4-support branch from 0232836 to b12bab0 Compare April 26, 2026 11:58
@gutierrezx7
Copy link
Copy Markdown
Author

recheck

github-actions Bot added a commit that referenced this pull request Apr 26, 2026
rustybret pushed a commit to rustybret/agent-harness that referenced this pull request Apr 27, 2026
@jtoronto
Copy link
Copy Markdown

jtoronto commented May 3, 2026

Waiting for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Enhancing Support For Other Models

2 participants