DeepSeek-TUI
Terminal-native coding agent built around DeepSeek V4's 1M-token context and prefix cache. Single binary (Rust), no Node/Python runtime required. v0.8.9 (workspace version, 2026).
What It Is
DeepSeek TUI is a keyboard-driven TUI coding agent that gives DeepSeek frontier models direct access to your workspace โ reading/editing files, running shell commands, managing git, searching the web, orchestrating sub-agents โ all through a fast terminal interface.
Built for DeepSeek V4 (deepseek-v4-pro / deepseek-v4-flash) with 1M-token context windows and native thinking-mode (chain-of-thought) streaming.
Key Features
Core Agent Capabilities
- Native RLM (
rlm_querytool) โ fans out 1โ16 cheapdeepseek-v4-flashchildren in parallel for batched analysis/decomposition - Thinking-mode streaming โ shows DeepSeek's chain-of-thought as it reasons in real time
- Full tool suite โ file ops, shell, git, web search/browse, apply-patch, sub-agents, MCP servers
- 1M-token context โ automatic intelligent compaction when context fills up
Interaction Modes
- Plan โ read-only exploration, no file/shell mutations
- Agent โ interactive with approval for shell + paid tools
- YOLO โ auto-approved all tools, for trusted repos
- Reasoning effort tiers โ
off โ high โ maxvia Shift+Tab
Unique Capabilities (vs OpenCode / Codex CLI)
- RLM โ sandboxed Python REPL with
llm_query()helpers for batch/bulk LLM processing; no equivalent in competitors - Automations โ scheduled recurring tasks with cron-style RRULE recurrence
- Durable tasks โ restart-aware persistent task objects with evidence tracking (gate runs, PR attempts)
- Turn revert โ undo workspace changes per turn via side-git snapshots (
/restore,revert_turn) - Data validation โ JSON/TOML validation tool
- Finance โ live stock/crypto quotes
- Web run โ headless browser interaction
- Inline LSP diagnostics โ post-edit diagnostics from rust-analyzer, pyright, gopls, clangd, typescript-language-server
Security & Extensibility
- MCP protocol โ connect to Model Context Protocol servers for extended tooling
- Lifecycle hooks โ pre/post tool execution hooks (stdout, jsonl, webhook)
- Skills system โ plugin/skill loading from
~/.deepseek/skills/,.agents/skills/,.opencode/skills/,.claude/skills/ - SSRF protection for
fetch_urlโ hostname validation, DNS pinning, blocked internal IP ranges - Project-config keys denied at workspace scope โ prevents malicious
.deepseek/config.tomloverrides
Sessions & Durability
- Session save/resume โ checkpoint and resume long sessions
- Workspace rollback โ side-git pre/post-turn snapshots without touching repo's
.git - Crash recovery โ offline queue persisted to
~/.deepseek/sessions/checkpoints/offline_queue.json - HTTP/SSE runtime API โ
deepseek serve --httpfor headless agent workflows
Architecture: Dispatcher โ TUI โ Engine โ Tools
User Interface
TUI (ratatui) | One-shot Mode | Config/CLI
โ
Core Engine
Agent Loop (core/engine.rs)
Session | Turn Mgmt | Tool Orchestration
โ
Tool & Extension Layer
Tools (shell, file, git, web, sub-agents, MCP) | Skills | Hooks | MCP Servers
โ
Runtime API + Task Management
HTTP/SSE Runtime API | Persistent Task Manager
โ
LLM Layer
LLM Client Abstraction โ DeepSeek Client (OpenAI-compatible Chat Completions API)
Core Crates (workspace members)
crates/coreโ agent loop, session management, turn orchestration, capacity flow guardrailscrates/tui-coreโ event-driven TUI state machine scaffoldcrates/tuiโ main TUI binary with ratatui, LSP subsystem, RLM sandboxcrates/agentโ model/provider registry (ModelRegistry) for resolving model IDs to endpointscrates/configโ config loading, profiles, env var precedence, per-project overlaycrates/execpolicyโ approval/sandbox policy enginecrates/hooksโ lifecycle hooks (stdout, jsonl, webhook) for pre/post tool eventscrates/mcpโ MCP client + stdio server for Model Context Protocol tool serverscrates/stateโ SQLite thread/session persistence layercrates/app-serverโ HTTP/SSE + JSON-RPC app server transport for headless workflowscrates/secretsโ OS keyring integration for API key storagecrates/toolsโ shared tool invocation primitives (tool result/error/capability types)crates/protocolโ request/response framing and protocol typescrates/cliโdeepseekdispatcher binary entry point (clap, routing)
Dependency graph (bottom-up):
Layer 0 (leaves): deepseek-protocol, deepseek-config, deepseek-state, deepseek-tui-core
Layer 1: deepseek-tools, deepseek-mcp, deepseek-hooks, deepseek-execpolicy
Layer 2: deepseek-agent
Layer 3: deepseek-core
Layer 4: deepseek-app-server, deepseek-tui
Layer 5: deepseek-tui-cli (deepseek dispatcher)
LLM Integration
- Uses DeepSeek's OpenAI-compatible Chat Completions API:
https://api.deepseek.com/v1/chat/completions - Also supports:
deepseek-v4-pro,deepseek-v4-flash, NVIDIA NIM, Fireworks, SGLang (self-hosted) - Streaming-first for responsiveness
Tool System
- File ops:
read_file,list_dir,write_file,edit_file,apply_patch - Search:
grep_files(pure-Rust regex, norgshell-out),file_search,web_search,fetch_url - Shell:
exec_shell,exec_shell_wait,exec_shell_interact,exec_shell_cancel,task_shell_start,task_shell_wait - Git:
git_status,git_diff,github_issue_context,github_pr_context,github_comment,github_close_issue - Tasks:
task_create,task_list,task_read,task_cancel,checklist_write,checklist_add/update/list - Verification:
task_gate_runโ run verification command and attach structured evidence to durable task - PR attempts:
pr_attempt_record,pr_attempt_list,pr_attempt_read,pr_attempt_preflight - Automations:
automation_create,automation_list,automation_update,automation_pause/resume/delete,automation_run - Sub-agents:
agent_spawn,agent_result,agent_assign,agent_cancel,resume_agent,agent_list,agent_send_input,agent_resume - Parallel fan-out comparison:
agent_spawnโ full sub-agent loop, 10 concurrent default (max 20), thousands of tokens per task, minutes wall-clockrlm_queryโ one-shot non-streaming, 16 children max, ~hundreds of tokens, seconds wall-clock
Sub-agent role taxonomy:
| Role | Stance | Writes? | Runs shell? | Typical use |
|---|---|---|---|---|
general |
flexible, do whatever parent says | yes | yes | default, multi-step tasks |
explore |
read-only; map relevant code fast | no | yes (read) | "find every call site of Foo" |
plan |
analyse and produce strategy | minimal | minimal | "design migration; don't execute" |
review |
read-and-grade with severity scores | no | no | "audit this PR for bugs" |
implementer |
land specific change, min edit | yes | yes | "rewrite bar.rs::Foo::bar to do X" |
verifier |
run tests/validation, report outcome | no | yes (test) | "run cargo test, report" |
custom |
explicit narrow tool allowlist | depends | depends | locked-down dispatch |
Data Flow
- User input โ TUI โ
core/engine.rs - Message โ LLM via streaming client
- Tool calls extracted from response โ dispatched through typed tool registry
- Pre-execution hooks run
- Approval requested (non-YOLO)
- Tool executed (possibly sandboxed on macOS)
- Post-execution hooks run
- LSP post-edit hook fires (if file edited and LSP enabled)
- Results stream back into transcript
Competitive Position
Where DeepSeek TUI Excels
- RLM (recursive language model) โ batch/bulk LLM processing in Python sandbox
- Finance โ live stock/crypto quotes
- Automations โ scheduled recurring tasks
- Durable tasks with evidence tracking
- Turn revert via side-git snapshots
- Data validation
- Web run (headless browser)
- Comprehensive git/GitHub operations
- Project map generation
Gaps vs Competitors (OpenCode, Codex CLI)
- LSP tool (highest priority) โ go-to-definition, find references, hover, call hierarchy. OpenCode has it, DeepSeek TUI doesn't (only post-edit diagnostics)
- Path-pattern permissions โ granular allow/deny by tool ร file path pattern
- Persistent memory โ cross-session user preferences and project conventions
- Pre/Post-tool-use hooks (DeepSeek TUI has hooks but not full event surface)
- Skill auto-discovery โ multi-location scanning (DeepSeek TUI has partial:
.deepseek/skills/) - Agent profiles with permission inheritance
- Tool search for MCP โ on-demand MCP tool discovery to avoid context bloat
- Shell sandboxing โ macOS Seatbelt, Linux bubblewrap/Landlock
System Prompt Design ("Mismanaged Genius" Hypothesis)
The system prompt (v0.8.x) has excellent safety rails but was written for a less capable model, treating RLM and sub-agents as specialty escape hatches rather than default strategic tools. The PROMPT_ANALYSIS.md documents 7 gaps:
- RLM framed as last resort โ actually has 3 patterns: CHUNK (long input), BATCH (many items), RECURSE (decomposition + critique). Prompt only acknowledges CHUNK.
- Sub-agents as "implementation only" โ contradicts Plan mode which correctly says "spawn read-only sub-agents for parallel investigation". In Agent mode (where most work happens), model underuses parallel exploration.
- No "Batch Everything" instinct โ instruction to batch independent tool calls exists but is buried; model fires one tool, waits, fires another even when independent.
- Thinking budget too conservative โ "Light" thinking for code generation understates V4's capability. Suggested bump: Medium for single-function, Deep for multi-file refactor.
- No "Verify Before Claiming" pattern โ model trusts memory over live tool output, doesn't re-read specific lines before patching.
- No composition heuristic for complex work โ model creates plan + checklist but doesn't re-evaluate plan between phases.
- Approval mode contradiction โ Agent mode waits for approval on EACH step individually instead of batching.
The fix isn't to add more rules but to reframe: parallel-first heuristic, positive sub-agent strategy, RLM as strategic not specialty tool.
Architectural Patterns
- vs OpenCode: Client/server arch (TUI is one client), plugin system (hot-loadable JS/TS), multi-provider
- vs Codex CLI: App-server protocol (v2 RPC), feature flag system (60+ flags), Bazel+Cargo dual build, snapshot testing
Installation
npm i -g deepseek-tui
deepseek
# or via cargo (Rust 1.85+)
cargo install deepseek-tui-cli --locked # provides `deepseek`
cargo install deepseek-tui --locked # provides `deepseek-tui`
# Auth
deepseek auth set --provider deepseek
Prebuilt binaries: Linux x64, Linux ARM64, macOS x64, macOS ARM64, Windows x64.
Config Files
~/.deepseek/config.tomlโ main config~/.deepseek/mcp.jsonโ MCP server config~/.deepseek/skills/โ user skills~/.deepseek/sessions/โ session history~/.deepseek/sessions/checkpoints/โ crash checkpoint + offline queue~/.deepseek/snapshots/โ side-git workspace snapshots~/.deepseek/tasks/โ background task records~/.deepseek/audit.logโ append-only audit log
Version History
- v0.8.9 (workspace) โ latest
- v0.8.8 โ TUI polish, accessibility (NO_ANIMATIONS=1), sub-agent cap 5โ10, load_skill tool, user-memory MVP, SSL_CERT_FILE support
- v0.8.7 โ selection works across transcript, self-update fix
- v0.8.6 โ AGENTS.md bootstrap (/init), inline LSP diagnostics, self-update, /share (session sharing), session save/resume
- v0.8.5 โ SSRF protection, schema-driven config editor, DeepseekCN provider, atomic file writes, panic safety
- v0.8.0 โ shell stability, Windows REPL runtime hardening
- v0.7.8 โ shell detach (Ctrl+B), exec_shell_cancel, Unicode glob fix
- v0.7.6 โ UI localization (ja, zh-Hans, pt-BR), paste burst detection, composer history search, grouped /config editor
Session Longevity (Critical)
DeepSeek TUI sessions degrade and crash if worked sequentially without management. The session accumulates every message and tool result in api_messages and history with no automatic pruning (auto-compaction disabled by default since v0.6.6). Session saves serialize the entire bloated array.
Survival rules for multi-hour sprints:
- Delegate everything to sub-agents. Sub-agents start fresh sessions. Parent stays coordinator.
- Batch tool calls. Fire 3
read_file+ 2grep_filesin one turn โ dispatcher runs them in parallel. - Compact aggressively at 60% context, not 80%. A compacted session that stays fast beats a dead session.
- Max 3 sequential turns before delegating. Turn 4 reading files one-by-one = already lost.
- Use RLM for batch classification.
rlmwithllm_query_batcheddoes 15 items in one turn. - Check every 3 turns: context <60%? Sub-agents running? PRs ready?
RLM Tool Patterns
The rlm_query tool (sandboxed Python REPL) has three distinct use cases:
| Pattern | When to use | Example |
|---|---|---|
| CHUNK | Single input too large for context (>50K tokens) | Process a whole file, transcript, multi-doc corpus |
| BATCH | Many independent items needing LLM attention | Classify 20 entries, extract from 30 docs |
| RECURSE | Problem benefits from sub-LLM critique | Decomposition + second opinion on reasoning |
llm_query_batched fans out to cheap deepseek-v4-flash children in parallel (up to 16), completing in seconds what would take 15 sequential reads.
Provider Support
DeepSeek TUI supports multiple backends:
- DeepSeek Platform (
api.deepseek.com) โ default - DeepSeek China (
api.deepseeki.com) โ for mainland China users, auto-detected viazh-*locale - NVIDIA NIM (
deepseek-ai/deepseek-v4-pro) - Fireworks AI (
accounts/fireworks/models/deepseek-v4-pro) - SGLang (self-hosted,
localhost:30000)
Accessibility
NO_ANIMATIONS=1โ startup env var forcinglow_motion=true+fancy_animations=falselow_motionโ suppresses spinners, fade-ins, footer drift, active-cell pulse; slows idle redraw to ~120mscalm_modeโ collapses tool-output details; useful for screen readersshow_thinking/show_tool_detailsโ per-setting toggles in/settings- Terminal-native: pure text transcript, works with VoiceOver/Orca on macOS/Linux terminals
User Memory
- Opt-in via
DEEPSEEK_MEMORY=onorconfig.toml [memory] enabled = true - Injects
~/.deepseek/memory.mdverbatim into system prompt every turn (above volatile boundary, survives prefix cache) - Three ways to add:
#prefix in composer (no turn fires),/memoryslash command,remembertool (auto-approved) - File format: timestamped Markdown bullets, max 100 KiB
- Sub-agents inherit memory and can also use
remember - deepseek-tui-memory concept page covers design rationale and tool shape
Operations Runbook (deepseek-tui-runbook)
deepseek doctor --jsonโ machine-readable health check for workbench integration- Incident procedures: turn hangs, network offline queue, crash recovery, MCP failures, schema errors
~/.deepseek/sessions/checkpoints/โ crash checkpoint + offline queue persistence~/.deepseek/tasks/โ durable background task recordsEsc/Ctrl+Cinterrupts turn;Ctrl+Bdetaches foreground shell
Runtime API (deepseek serve --http)
- Local-only HTTP/SSE API on
localhost:7878(configurable) - Thread/Turn/Item durable data model with append-only events and monotonic
seqfor replay - Thread:
archived,allow_shell,trust_mode,auto_approve,model,mode,title,system_promptall PATCH-able - Usage aggregation endpoint: token/cost grouped by day/model/provider/thread
- Restart semantics:
in_progressturns markedinterruptedon process restart - deepseek-tui-runtime-api concept page covers full endpoint reference
Multi-Agent Sprint Coordinator Pattern (deepseek-tui-coordinator)
- TAKEOVER_PROMPT.md describes a reusable takeover protocol: fresh V4 session takes over a branch that grew too large
- v0.8.8-coordinator-prompt.md describes git-worktree parallel sprint decomposition into 7 streams (AโG)
- Core principle: parent is coordinator, never implementer; spawn sub-agents in worktrees, merge in dependency order
- Session survival: max 5 sub-agents, 3-turn rule before delegation, compact at 60%, RLM for batch work
- Parallel spawn strategy: up to 5 concurrent sub-agents, staggered batches
- Conflict prevention: file-level collision tracking across workstreams
- deepseek-tui-coordinator concept page covers the full sprint pattern
Related
- opencode โ competitor coding agent
- claude-code โ competitor coding agent
- deepseek โ the model/API provider
- coding-agents โ broader category of AI coding tools
- llm-tools โ tool use patterns in LLMs
- deepseek-tui-memory โ user memory feature design
- deepseek-tui-runbook โ operations and incident response
- deepseek-tui-runtime-api โ HTTP/SSE runtime API reference
- deepseek-tui-coordinator โ multi-agent git-worktree sprint pattern