浣犻槄璇讳竴涓嬭繖涓」鐩腑 鍏充簬 auto 妯″紡鐨勪唬鐮?鐜板湪搴旇鏄潪甯哥畝鍗曠殑鍋氭硶 浣犲厛闃呰鎬荤粨涓€涓?
The user wants me to read the code related to "auto mode" in this project. Let me start by understanding the project structure, then find and read relevant code.
濂界殑锛屾垜鍏堜簡瑙d竴涓嬮」鐩粨鏋勶紝鐒跺悗鎵惧埌涓?auto 妯″紡鐩稿叧鐨勪唬鐮併€?
鈴?list_dir {"path":"."}
鈴?grep_files {"context_lines":0,"max_results":50,"pattern":"auto"}
鈳?tool execution failed for list_dir: failed to inspect \\?\D:\Desktop\liwenka1\deep-code: 鍑芥暟涓嶆纭€?(os error 1)
鈳?tool execution failed for grep_files: failed to inspect \\?\D:\Desktop\liwenka1\deep-code: 鍑芥暟涓嶆纭€?(os error 1)
The file system operations seem to be failing. Let me try again.
鈴?list_dir {"path":"."}
鈴?read_file {"path":"Cargo.toml"}
鈳?tool execution failed for list_dir: failed to inspect \\?\D:\Desktop\liwenka1\deep-code: 鍑芥暟涓嶆纭€?(os error 1)
鈳?tool execution failed for read_file: failed to inspect \\?\D:\Desktop\liwenka1\deep-code\Cargo.toml: 鍑芥暟涓嶆纭€?(os error 1)
The file system tools are not working due to some OS error. Let me try the shell to explore the project.
鈴?shell_run {"command":"dir /b /s D:\\Desktop\\liwenka1\\deep-code\\ 2>nul || ls -la... (truncated)
鈳?{ "approval_reason": "shell commands can modify files, run code, or access the network", "command": "dir /b /s D:\\Desktop\\liwenka1\\deep-code\\ 2>nul || ls -la D:\\Desktop\\liwenka1\\deep-code\\", "cwd": "", "el
apsed_ms": 122, "exit_code": null, "job_id": "job_1", "kind": "foreground", "status": "... (truncated)
The shell works but the directory listing/file reading tools have an OS error. Let me use shell commands to explore the project structure and find auto-related code.
鈴?shell_run {"command":"cd D:\\Desktop\\liwenka1\\deep-code && dir /b /ad","timeout_... (truncated)
鈳?job_2: completed in (cd D:\Desktop\liwenka1\deep-code && dir /b /ad)
Let me look for auto mode related code. Let me search for "auto" in the Rust source files.
鈴?shell_run {"command":"cd D:\\Desktop\\liwenka1\\deep-code && dir /s /b *.rs 2>nul ... (truncated)
鈳?{ "approval_reason": "shell commands can modify files, run code, or access the network", "command": "cd D:\\Desktop\\liwenka1\\deep-code && dir /s /b *.rs 2>nul | findstr /v \"target\"", "cwd": "", "elapsed_ms": 1
26, "exit_code": null, "job_id": "job_3", "kind": "foreground", "status": "running", "s... (truncated)
I found an `auto_mode.rs` file in the checkpoints directory. Let me find the actual current source files, not the checkpoints. Let me search for the real source structure.
鈴?shell_run {"command":"cd D:\\Desktop\\liwenka1\\deep-code && dir crates\\deep-code... (truncated)
鈴?shell_run {"command":"cd D:\\Desktop\\liwenka1\\deep-code && dir crates\\ /b /ad",... (truncated)
鈳?job_4: completed in (cd D:\Desktop\liwenka1\deep-code && dir crates\deep-code-agent\src\ /b 2>nul)
鈳?job_5: completed in (cd D:\Desktop\liwenka1\deep-code && dir crates\ /b /ad)
There's an `auto_mode.rs` in `crates/deep-code-agent/src/`. Let me read it, along with `lib.rs` to see how it's used.
鎵惧埌浜?auto_mode.rs锛佽鎴戣鍙栫浉鍏虫枃浠躲€?
鈴?shell_run {"command":"cd D:\\Desktop\\liwenka1\\deep-code && type crates\\deep-cod... (truncated)
鈴?shell_run {"command":"cd D:\\Desktop\\liwenka1\\deep-code && type crates\\deep-cod... (truncated)
鈳?job_6: completed in (cd D:\Desktop\liwenka1\deep-code && type crates\deep-code-agent\src\auto_mode.rs)
鈳?job_7: completed in (cd D:\Desktop\liwenka1\deep-code && type crates\deep-code-agent\src\lib.rs)
I now have a comprehensive understanding of the auto_mode.rs code. Let me also check how it's used in the runtime to understand the full picture.
璁╂垜鍐嶇湅鐪?runtime.rs 涓浣曚娇鐢?auto mode锛屼互鍙?model_registry.rs 涓殑 AUTO_MODEL 瀹氫箟锛?
鈴?shell_run {"command":"cd D:\\Desktop\\liwenka1\\deep-code && type crates\\deep-cod... (truncated)
鈴?shell_run {"command":"cd D:\\Desktop\\liwenka1\\deep-code && type crates\\deep-cod... (truncated)
鈳?job_8: completed in (cd D:\Desktop\liwenka1\deep-code && type crates\deep-code-agent\src\model_registry.rs)
鈳?{ "approval_reason": "shell commands can modify files, run code, or access the network", "command": "cd D:\\Desktop\\liwenka1\\deep-code && type crates\\deep-code-agent\\src\\runtime.rs", "cwd": "", "elapsed_ms":
61, "exit_code": 0, "job_id": "job_9", "kind": "foreground", "status": "completed", "st... (truncated)
Now let me also check the turn_loop.rs to see how auto mode is used in the actual turn execution.
鍐嶇湅鐪?turn_loop 涓浣曚娇鐢?route锛?
鈴?shell_run {"command":"cd D:\\Desktop\\liwenka1\\deep-code && type crates\\deep-cod... (truncated)
鈳?{ "approval_reason": "shell commands can modify files, run code, or access the network", "command": "cd D:\\Desktop\\liwenka1\\deep-code && type crates\\deep-code-agent\\src\\runtime\\turn_loop.rs", "cwd": "", "el
apsed_ms": 79, "exit_code": 0, "job_id": "job_10", "kind": "foreground", "status": "com... (truncated)
Now I have a comprehensive understanding of the auto mode code. Let me also check `open_turn_stream` to see how the route is used with API fallback:
鈴?shell_run {"command":"cd D:\\Desktop\\liwenka1\\deep-code && type crates\\deep-cod... (truncated)
鈳?job_11: completed in (cd D:\Desktop\liwenka1\deep-code && type crates\deep-code-agent\src\runtime\streaming.rs)
Now I have a comprehensive understanding. Let me also check the reasoning module and the config to see how `auto_cost_saving` and `ReasoningEffortSetting::Auto` work.
鈴?shell_run {"command":"cd D:\\Desktop\\liwenka1\\deep-code && type crates\\deep-cod... (truncated)
鈴?shell_run {"command":"cd D:\\Desktop\\liwenka1\\deep-code && findstr /n \"auto_cos... (truncated)
鈳?job_12: completed in (cd D:\Desktop\liwenka1\deep-code && type crates\deep-code-agent\src\reasoning.rs)
鈳?job_13: failed in (cd D:\Desktop\liwenka1\deep-code && findstr /n "auto_cost_saving" crates\deep-code-agent\src\config\mod.rs)
Let me find the auto_cost_saving field in the config.
鈴?shell_run {"command":"cd D:\\Desktop\\liwenka1\\deep-code && grep -rn \"auto_cost_... (truncated)
鈳?job_14: failed in (cd D:\Desktop\liwenka1\deep-code && grep -rn "auto_cost_saving" crates\deep-code-agent\src\config\)
Let me use findstr instead of grep on Windows.
鈴?shell_run {"command":"cd D:\\Desktop\\liwenka1\\deep-code && findstr /s /n \"auto_... (truncated)
鈳?job_15: failed in (cd D:\Desktop\liwenka1\deep-code && findstr /s /n "auto_cost_saving" crates\deep-code-agent\src\config\*)
Let me search more broadly in the config mod.rs for the auto_cost_saving field.
鈴?shell_run {"command":"cd D:\\Desktop\\liwenka1\\deep-code && type crates\\deep-cod... (truncated)
鈳?job_16: failed in (cd D:\Desktop\liwenka1\deep-code && type crates\deep-code-agent\src\config\mod.rs | findstr /n "auto")
Let me try to find auto_cost_saving in the whole project.
鈴?shell_run {"command":"cd D:\\Desktop\\liwenka1\\deep-code && findstr /s /n \"auto_... (truncated)
鈳?job_17: running in (cd D:\Desktop\liwenka1\deep-code && findstr /s /n "auto_cost_saving" *.rs)
Let me check the config mod.rs directly and search for auto_cost_saving field.
鈴?shell_run {"command":"cd D:\\Desktop\\liwenka1\\deep-code && type crates\\deep-cod... (truncated)
鈳?job_18: completed in (cd D:\Desktop\liwenka1\deep-code && type crates\deep-code-agent\src\config\mod.rs)
Now I have a complete picture. Let me summarize the auto mode architecture for the user.
濂界殑锛屾垜宸茬粡瀹屾暣闃呰浜?auto mode 鐩稿叧鐨勫叏閮ㄤ唬鐮侊紝涓嬮潰鍋氫竴涓€荤粨銆?
---
## Auto 妯″紡浠g爜鎬荤粨
### 鏁翠綋缁撴瀯
auto mode 鐨勬牳蹇冮€昏緫鍦?**crates/deep-code-agent/src/auto_mode.rs**锛堢害 260 琛岋級锛岃 runtime/turn_loop.rs 鍜?runtime/streaming.rs 璋冪敤銆傛秹鍙婁笁涓眰闈㈢殑"鑷姩閫夋嫨"锛?
---
### 1. 妯″瀷鑷姩閫夋嫨锛圓uto Model锛?
**鏍稿績鍑芥暟锛歴elect_auto_model_with_reason(input, cost_saving) -> (model, reason)**
瀹冩槸涓€涓?*鍩轰簬鍏抽敭璇嶅拰闀垮害**鐨勫惎鍙戝紡璺敱锛屽湪涓や釜妯″瀷闂翠簩閫変竴锛?鈥?**deepseek-v4-pro**锛堝己妯″瀷锛岃吹锛?鈥?**deepseek-v4-flash**锛堣交閲忔ā鍨嬶紝渚垮疁锛?
鍒ゆ柇閫昏緫闈炲父绠€鍗曪紙鎸変紭鍏堢骇锛夛細
| 鏉′欢 | 璺敱鍒?|
|---|---|
| 鍛戒腑 COMPLEX_KEYWORDS锛堝 refactor, architecture, design, debug, security, review, audit, migrate, optimize, rewrite, implement, analyze 鍙婂搴斾腑鏂囪瘝锛?| **Pro** |
| 鍛戒腑 borderline 璇嶏紙implement, analyze锛屼腑鑻辨枃锛夛紝涓?**cost_saving=false** | **Pro** |
| 杈撳叆闀垮害 < 100 瀛楃 | **Flash** |
| 杈撳叆闀垮害 > 闃堝€硷紙cost_saving=1000锛屽惁鍒?500锛?| **Pro** |
| 浠ヤ笂閮戒笉婊¤冻 | **Flash** |
**cost_saving** 瀛楁鏉ヨ嚜 AgentConfig::auto_cost_saving锛堥粯璁?false锛屽彲閫氳繃 DEEP_CODE_AUTO_COST_SAVING 鐜鍙橀噺璁剧疆锛夈€?
---
### 2. 鎺ㄧ悊鍔涘害鑷姩閫夋嫨锛圓uto Reasoning Effort锛?
**鏍稿績鍑芥暟锛歴elect_auto_effort(is_subagent, last_msg) -> ReasoningEffort**
涔熸槸鍏抽敭璇嶅惎鍙戝紡锛?
| 鏉′欢 | 缁撴灉 |
|---|---|
| 鏄?sub-agent | **Low**锛堝瓙 agent 缁熶竴浣庢秷鑰楋級 |
| 鍛戒腑 HIGH_EFFORT_KEYWORDS锛坉ebug, error, 鍙婁腑鏂?璋冭瘯""閿欒""鎶ラ敊""鍑洪敊""宕╂簝"锛?| **Max** |
| 鍛戒腑 LOW_EFFORT_KEYWORDS锛坰earch, lookup, 涓枃"鎼滅储""鏌ユ壘""鏌ヨ"锛?| **Low** |
| 鍏朵粬鎯呭喌 | **High** |
姝ゅ杩樻湁涓€涓?**clamp_effort_to_model** 鍑芥暟锛氬鏋滄ā鍨嬫槸 Flash 浣嗘帹鐞嗗姏搴︽槸 Max锛屽垯鑷姩闄嶄负 High锛堝洜涓?Flash 涓嶆敮鎸?Max锛夈€?
---
### 3. API 澶辫触鑷姩闄嶇骇锛團allback锛?
**鏍稿績鍑芥暟锛歛pi_fallback_model(route) -> Option<&'static str>**
褰?auto mode 閫夋嫨浜?Pro 浣?API 璋冪敤澶辫触锛?29/502/503/504锛夛紝鑷姩闄嶇骇鍒?Flash 閲嶈瘯涓€娆°€傝繖涓€昏緫鍦?streaming.rs 鐨?stream_with_fallback 涓疄鐜帮細
闄嶇骇鍚?TurnRoute.used_model_fallback = true锛屼笖浼氳缃?fallback_reason 鐨勪腑鏂囨弿杩般€?
---
### 4. 鏁版嵁缁撴瀯 `TurnRoute`
鏄瘡涓€杞璇濈殑瀹屾暣璺敱鍐崇瓥璁板綍锛?
``` rust
pub struct TurnRoute {
pub requested_model: String, // 鐢ㄦ埛閰嶇疆鐨勬ā鍨嬪悕
pub effective_model: String, // 瀹為檯浣跨敤鐨勬ā鍨? pub auto_model: bool, // 鏄惁浣跨敤浜?auto 鍐崇瓥
pub reasoning_setting: ReasoningEffortSetting, // 鐢ㄦ埛閰嶇疆
pub effective_effort: ReasoningEffort, // 瀹為檯浣跨敤鐨勫姏搴? pub auto_effort: bool, // 鏄惁 auto 鍐崇瓥浜嗗姏搴? pub used_model_fallback: bool, // 鏄惁鍙戠敓浜?API 闄嶇骇
pub route_reason: String, // 妯″瀷閫夋嫨鐨勫師鍥狅紙涓枃锛? pub fallback_reason: Option<String>, // 闄嶇骇鍘熷洜
}
复现路径:
如标题所述
下面是对话原文,同时win11系统去复制内容出现了乱码
Pro 璇锋眰 鈫?API 杩斿洖鍙噸璇曢敊璇?鈫?鑷姩鍒囨崲鍒?Flash 閲嶈瘯
鏁翠綋璇勪环
纭疄鏄潪甯哥畝鍗曠殑鍋氭硶锛屽嚑涓牳蹇冪壒鐐癸細
鈥?绾惎鍙戝紡瑙勫垯 鈥?娌℃湁 ML 妯″瀷銆佹病鏈夊巻鍙插涔犮€佹病鏈夊湪绾胯瘎浼帮紝灏辨槸鍏抽敭璇嶅尮閰?+ 闀垮害闃堝€?鈥?涓や釜妯″瀷浜岄€変竴 鈥?鍙湪 DeepSeek V4 Pro 鍜?Flash 涔嬮棿璺敱
鈥?*鍏抽敭璇嶅垪琛ㄥ啓姝? 鈥?COMPLEX_KEYWORDS銆丠IGH_EFFORT_KEYWORDS銆丩OW_EFFORT_KEYWORDS 閮芥槸纭紪鐮佸父閲?鈥?涓枃鏀寔 鈥?鍏抽敭璇嶈〃涓寘鍚腑鑻辨枃瀵圭収
鈥?*鍐崇瓥鍙В閲? 鈥?姣忔閫夋嫨閮藉甫涓€鏉′腑鏂囧師鍥犲瓧绗︿覆锛屽彲浠ュ湪 UI 涓婂睍绀?鈥?*鍋ュ.鎬у熀鏈? 鈥?鏈?API 澶辫触鐨勮嚜鍔ㄩ檷绾э紝鏈?Flash 涓嶆敮鎸?Max 鐨?clamp 淇濇姢