fix(deepseek): separate thinking process from response in --think mode#1142
Conversation
jackwener#1124) When --think is enabled, the response now includes separate fields: - response: clean final answer only - thinking: chain-of-thought reasoning content - thinking_time: time spent thinking (e.g. '1') Supports both English ('Thought for X seconds') and Chinese ('已思考(用时 X 秒)') thinking header patterns. Fixes jackwener#1124
|
Hi @kagura-agent — thanks for the PR. pr-monitor reviewers (B 组) ran two independent reviews on head 🛑 Blocker 1 — silent-corruption in
|
Blocker 1: Replace fragile split(/\n\n+/) heuristic in parseThinkingResponse() with DOM-level extraction in waitForResponse(). The page evaluate now queries distinct DOM nodes (.ds-markdown--think vs .ds-markdown) for thinking and response content. The text-level parser falls back to treating everything after the header as thinking (no split), avoiding silent corruption of multi-paragraph content. Blocker 2: Remove static columns declaration from askCommand. The renderer infers columns from row keys, so non-think output only shows 'response' while think output shows all three columns. Tests added for multi-paragraph thinking, multi-paragraph answer, and non-think column regression guard.
|
Thanks for the thorough review! Both blockers addressed in Blocker 1 — silent-corruption fix:
Blocker 2 — columns regression fix:
All 16 deepseek tests pass. Ready for re-review. |
Summary
Fixes #1124
When
deepseek ask --thinkis used, the thinking process and final answer are now returned as separate structured fields instead of being mixed in a singleresponsestring.Changes
clis/deepseek/utils.jsparseThinkingResponse()function that extracts thinking content, thinking time, and final answer from the raw response textwaitForResponse()to accept optionalparseThinkingparameterclis/deepseek/ask.jsthinkingandthinking_timeto output columns--thinkis enabledOutput Format
When
--thinkis enabled:[{ "response": "4", "thinking": "We need to answer 'what is 2+2? just the number' so answer is 4.", "thinking_time": "1" }]When
--thinkis off,thinkingandthinking_timearenull— backward compatible.Testing
parseThinkingResponse()(English/Chinese patterns, edge cases)--thinkflag behavior in ask commandnpx tsc --noEmitclean