<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>AI on Testing Observation</title><link>https://chengxiaqiucao.github.io/en/tags/ai/</link><description>Recent content in AI on Testing Observation</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>|by Daniel Wei</copyright><lastBuildDate>Thu, 16 Oct 2025 17:40:57 +0800</lastBuildDate><atom:link href="https://chengxiaqiucao.github.io/en/tags/ai/index.xml" rel="self" type="application/rss+xml"/><item><title>Chrome Launches DevTools MCP, Adding a New Option for Browser-Based AI Automation</title><link>https://chengxiaqiucao.github.io/en/post/131-dev_tools_mcp/</link><pubDate>Thu, 16 Oct 2025 17:40:57 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/131-dev_tools_mcp/</guid><description>&lt;p>In previous articles, we introduced various browser AI automation tools such as Playwright-mcp, browser-use, and midsceneJs; each can well drive a browser to complete automated tasks based on AI large models.&lt;/p>
&lt;p>Recently, Google officially launched the devtools mcp for the Chrome browser, further enriching the tools for driving a browser to complete intelligent tasks through AI, including executing automated test scripts.&lt;/p>
&lt;h2 id="what-is-devtools-mcp">What Is DevTools MCP?
&lt;/h2>&lt;p>In short, &lt;strong>DevTools MCP&lt;/strong> is Google exposing the underlying devtools methods of the Chrome browser, based on the &lt;strong>MCP&lt;/strong> (Model Context Protocol) standard, to AI large language models (LLMs) as a service, enabling AI large models to call the underlying debugging tools of the Chrome browser.&lt;/p>
&lt;p>For a detailed introduction to MCP, see my previous article 【】&lt;/p>
&lt;h3 id="chrome-devtools-mcp-architecture">Chrome DevTools MCP Architecture
&lt;/h3>&lt;p>The tool uses a layered architecture, mainly including the following modules:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>MCP Server layer&lt;/strong>: Responsible for receiving MCP requests from the LLM/agent, and performing session management and permission control.&lt;/li>
&lt;li>&lt;strong>Tool adaptation layer&lt;/strong>: Maps MCP&amp;rsquo;s high-level requests to the Chrome DevTools Protocol (CDP) or Puppeteer API, and manages long tasks (such as recording/tracing).&lt;/li>
&lt;li>&lt;strong>Chrome runtime&lt;/strong>: A real Chrome/Chromium instance (headful or headless) that performs all underlying operations and produces trace, performance, console, and other data.&lt;/li>
&lt;li>&lt;strong>Data collection and transmission&lt;/strong>: Serializes the collected trace, stack, HAR, snapshots, and other data, and returns it to the caller via MCP.&lt;/li>
&lt;/ul>
&lt;p>The specific calling process is shown below:&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/131-dev_tools_mcp/devtools-mcp.svg"
loading="lazy"
>
&lt;/p>
&lt;h3 id="tool-methods-exposed-by-chrome-devtools-mcp">Tool Methods Exposed by Chrome DevTools MCP
&lt;/h3>&lt;p>The underlying methods currently exposed by DevTools MCP mainly fall into the following six categories:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th style="text-align: left">Category&lt;/th>
&lt;th style="text-align: center">Count&lt;/th>
&lt;th>Main Functions&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td style="text-align: left">&lt;strong>Input automation&lt;/strong>&lt;/td>
&lt;td style="text-align: center">7&lt;/td>
&lt;td>click, drag, fill, fill_form, handle_dialog, hover, upload_file&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">&lt;strong>Navigation automation&lt;/strong>&lt;/td>
&lt;td style="text-align: center">7&lt;/td>
&lt;td>close_page, list_pages, navigate_page, navigate_page_history, new_page, select_page, wait_for&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">&lt;strong>Performance&lt;/strong>&lt;/td>
&lt;td style="text-align: center">3&lt;/td>
&lt;td>performance_analyze_insight, performance_start_trace, performance_stop_trace&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">&lt;strong>Debugging&lt;/strong>&lt;/td>
&lt;td style="text-align: center">4&lt;/td>
&lt;td>evaluate_script, list_console_messages, take_screenshot, take_snapshot&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">&lt;strong>Network&lt;/strong>&lt;/td>
&lt;td style="text-align: center">2&lt;/td>
&lt;td>get_network_request, list_network_requests&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td style="text-align: left">&lt;strong>Emulation&lt;/strong>&lt;/td>
&lt;td style="text-align: center">3&lt;/td>
&lt;td>emulate_cpu, emulate_network, resize_page&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="installation-and-usage">Installation and Usage
&lt;/h2>&lt;p>The tool is open-sourced on GitHub at:&lt;/p>
&lt;p>&lt;a class="link" href="https://github.com/ChromeDevTools/chrome-devtools-mcp" target="_blank" rel="noopener"
>https://github.com/ChromeDevTools/chrome-devtools-mcp&lt;/a>&lt;/p>
&lt;p>Compared with other tools, configuration and installation are extremely simple, and the homepage also provides quick configuration for various mainstream AI terminals.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/131-dev_tools_mcp/Pasted-20251020-1_hu_35bada27778d070d.webp"
width="1024"
height="743"
srcset="https://chengxiaqiucao.github.io/post/131-dev_tools_mcp/Pasted-20251020-1_hu_b50c17442dbed2e8.webp 480w, https://chengxiaqiucao.github.io/post/131-dev_tools_mcp/Pasted-20251020-1_hu_35bada27778d070d.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="137"
data-flex-basis="330px"
>
&lt;/p>
&lt;p>Taking &lt;strong>Cursor&lt;/strong> as an example, in its MCP configuration page, add the following configuration:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;span class="lnt">8
&lt;/span>&lt;span class="lnt">9
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-json" data-lang="json">&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;mcpServers&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;chrome-devtools&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;command&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;npx&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;args&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s2">&amp;#34;-y&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s2">&amp;#34;chrome-devtools-mcp@latest&amp;#34;&lt;/span>&lt;span class="p">]&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Just make sure Node.js is installed locally and can connect to the node package management server.&lt;/p>
&lt;p>After configuration, wait for dev tools to load successfully and show the supported methods, as shown below.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/131-dev_tools_mcp/Pasted-20251020-2_hu_54a5bcb9d242f78c.webp"
width="1024"
height="983"
srcset="https://chengxiaqiucao.github.io/post/131-dev_tools_mcp/Pasted-20251020-2_hu_f1b0b576276e7daf.webp 480w, https://chengxiaqiucao.github.io/post/131-dev_tools_mcp/Pasted-20251020-2_hu_54a5bcb9d242f78c.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="104"
data-flex-basis="249px"
>
&lt;/p>
&lt;h3 id="executing-automated-testing">Executing Automated Testing
&lt;/h3>&lt;p>Let&amp;rsquo;s test it with a typical automation task. Enter the prompt in Cursor:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Visit www.saucedemo.com and test the main features of the site when logging in as standard_user, and record the completed test cases and results
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Cursor will use the default large model to make an execution plan, and automatically open the browser through &lt;code>devtools mcp&lt;/code> and complete the subsequent execution&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/131-dev_tools_mcp/Pasted-20251020-3_hu_adbcbe0cb8d603a6.webp"
width="1024"
height="826"
srcset="https://chengxiaqiucao.github.io/post/131-dev_tools_mcp/Pasted-20251020-3_hu_e73595fb1731b1f0.webp 480w, https://chengxiaqiucao.github.io/post/131-dev_tools_mcp/Pasted-20251020-3_hu_adbcbe0cb8d603a6.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="124"
data-flex-basis="297px"
>
&lt;/p>
&lt;p>Launch the browser and execute&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/131-dev_tools_mcp/Pasted-20251020_hu_4e72d268ac183f77.webp"
width="1024"
height="458"
srcset="https://chengxiaqiucao.github.io/post/131-dev_tools_mcp/Pasted-20251020_hu_bc9d7525a7bdab9.webp 480w, https://chengxiaqiucao.github.io/post/131-dev_tools_mcp/Pasted-20251020_hu_4e72d268ac183f77.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="223"
data-flex-basis="537px"
>
&lt;/p>
&lt;p>On the first run, the following result was obtained&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;span class="lnt">29
&lt;/span>&lt;span class="lnt">30
&lt;/span>&lt;span class="lnt">31
&lt;/span>&lt;span class="lnt">32
&lt;/span>&lt;span class="lnt">33
&lt;/span>&lt;span class="lnt">34
&lt;/span>&lt;span class="lnt">35
&lt;/span>&lt;span class="lnt">36
&lt;/span>&lt;span class="lnt">37
&lt;/span>&lt;span class="lnt">38
&lt;/span>&lt;span class="lnt">39
&lt;/span>&lt;span class="lnt">40
&lt;/span>&lt;span class="lnt">41
&lt;/span>&lt;span class="lnt">42
&lt;/span>&lt;span class="lnt">43
&lt;/span>&lt;span class="lnt">44
&lt;/span>&lt;span class="lnt">45
&lt;/span>&lt;span class="lnt">46
&lt;/span>&lt;span class="lnt">47
&lt;/span>&lt;span class="lnt">48
&lt;/span>&lt;span class="lnt">49
&lt;/span>&lt;span class="lnt">50
&lt;/span>&lt;span class="lnt">51
&lt;/span>&lt;span class="lnt">52
&lt;/span>&lt;span class="lnt">53
&lt;/span>&lt;span class="lnt">54
&lt;/span>&lt;span class="lnt">55
&lt;/span>&lt;span class="lnt">56
&lt;/span>&lt;span class="lnt">57
&lt;/span>&lt;span class="lnt">58
&lt;/span>&lt;span class="lnt">59
&lt;/span>&lt;span class="lnt">60
&lt;/span>&lt;span class="lnt">61
&lt;/span>&lt;span class="lnt">62
&lt;/span>&lt;span class="lnt">63
&lt;/span>&lt;span class="lnt">64
&lt;/span>&lt;span class="lnt">65
&lt;/span>&lt;span class="lnt">66
&lt;/span>&lt;span class="lnt">67
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-markdown" data-lang="markdown">&lt;span class="line">&lt;span class="cl">&lt;span class="gu">### Test Scope
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Site: https://www.saucedemo.com/
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Account: standard_user / secret_sauce
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Browser: Desktop (real site interaction)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">### Test Cases and Results
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Login success
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Steps: Enter username standard_user and password secret_sauce, click login
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Expected: Enter the product list page
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Result: Passed (entered the &amp;#34;Products&amp;#34; list page)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Product list loading and detail page
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Steps: View product cards on the list page, click Sauce Labs Backpack to enter details
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Expected: Show name, description, price, and action buttons
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Result: Passed (detail page displayed completely, returning to the list works)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Add to cart and remove
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Steps:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Perform &amp;#34;Add to cart/Remove&amp;#34; on the Backpack on the detail page
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Perform &amp;#34;Add to cart/Remove&amp;#34; on the Bolt T-Shirt on the list page
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Expected: Cart badge count changes correctly; the cart page shows items and supports removal
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Result: Passed (badge count changes correctly; the cart page shows two items and supports removal)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Checkout flow (from cart to order completion)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Steps: Cart -&amp;gt; Checkout -&amp;gt; Fill First/Last/Zip -&amp;gt; Overview -&amp;gt; Finish
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Checkpoints: Amount summary (subtotal/tax/total) displayed; completion page shows &amp;#34;Thank you for your order!&amp;#34;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Result: Passed (completion page displayed successfully, returning to home works)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Sorting feature (to be completed)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Goal: Switch the filter dropdown from &amp;#34;Name (A to Z)&amp;#34; to &amp;#34;Price (low to high)&amp;#34;, and verify that products are sorted by price ascending
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Current status: Dropdown expanded but interaction timed out, final verification not completed
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Result: Pending
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Logout feature (to be completed)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Goal: Via the top-left &amp;#34;Open Menu&amp;#34; -&amp;gt; &amp;#34;Logout&amp;#34;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Current status: Not yet executed
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Result: Pending
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">### Conclusion
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Passed: Login, list and details, cart add/remove, complete checkout.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Pending: Sorting verification, logout.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>As can be seen, the expected execution task was completed successfully.&lt;/p>
&lt;p>Compared with other upper-layer tools like Playwright-mcp, Chrome DevTools, calling directly from the browser&amp;rsquo;s lower layer, should be faster and more accurate in execution, and should also be friendlier in token consumption when interacting with large models.&lt;/p>
&lt;h2 id="page-performance-assessment">Page Performance Assessment
&lt;/h2>&lt;p>Besides calling the browser to access pages, because &lt;code>DevTools MCP&lt;/code> calls the underlying methods directly, it can also provide performance data, console information, and so on that other AI browser tools find hard to collect directly, greatly facilitating AI&amp;rsquo;s more comprehensive operation of the browser and our completion of lower-level tasks.&lt;/p>
&lt;p>For example, we can complete a page performance assessment test task, taking the assessment of my blog as an example:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">Visit @https://chengxiaqiucao.github.io/ and assess the performance of this website
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>After execution, you can see that the underlying performance assessment methods provided by DevTools can be called and executed.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/131-dev_tools_mcp/Pasted-20251020-4_hu_b9391c80ab91450a.webp"
width="1024"
height="769"
srcset="https://chengxiaqiucao.github.io/post/131-dev_tools_mcp/Pasted-20251020-4_hu_4021a01d9cddb289.webp 480w, https://chengxiaqiucao.github.io/post/131-dev_tools_mcp/Pasted-20251020-4_hu_b9391c80ab91450a.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="133"
data-flex-basis="319px"
>
&lt;/p>
&lt;p>Finally, the following result was obtained:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;span class="lnt">29
&lt;/span>&lt;span class="lnt">30
&lt;/span>&lt;span class="lnt">31
&lt;/span>&lt;span class="lnt">32
&lt;/span>&lt;span class="lnt">33
&lt;/span>&lt;span class="lnt">34
&lt;/span>&lt;span class="lnt">35
&lt;/span>&lt;span class="lnt">36
&lt;/span>&lt;span class="lnt">37
&lt;/span>&lt;span class="lnt">38
&lt;/span>&lt;span class="lnt">39
&lt;/span>&lt;span class="lnt">40
&lt;/span>&lt;span class="lnt">41
&lt;/span>&lt;span class="lnt">42
&lt;/span>&lt;span class="lnt">43
&lt;/span>&lt;span class="lnt">44
&lt;/span>&lt;span class="lnt">45
&lt;/span>&lt;span class="lnt">46
&lt;/span>&lt;span class="lnt">47
&lt;/span>&lt;span class="lnt">48
&lt;/span>&lt;span class="lnt">49
&lt;/span>&lt;span class="lnt">50
&lt;/span>&lt;span class="lnt">51
&lt;/span>&lt;span class="lnt">52
&lt;/span>&lt;span class="lnt">53
&lt;/span>&lt;span class="lnt">54
&lt;/span>&lt;span class="lnt">55
&lt;/span>&lt;span class="lnt">56
&lt;/span>&lt;span class="lnt">57
&lt;/span>&lt;span class="lnt">58
&lt;/span>&lt;span class="lnt">59
&lt;/span>&lt;span class="lnt">60
&lt;/span>&lt;span class="lnt">61
&lt;/span>&lt;span class="lnt">62
&lt;/span>&lt;span class="lnt">63
&lt;/span>&lt;span class="lnt">64
&lt;/span>&lt;span class="lnt">65
&lt;/span>&lt;span class="lnt">66
&lt;/span>&lt;span class="lnt">67
&lt;/span>&lt;span class="lnt">68
&lt;/span>&lt;span class="lnt">69
&lt;/span>&lt;span class="lnt">70
&lt;/span>&lt;span class="lnt">71
&lt;/span>&lt;span class="lnt">72
&lt;/span>&lt;span class="lnt">73
&lt;/span>&lt;span class="lnt">74
&lt;/span>&lt;span class="lnt">75
&lt;/span>&lt;span class="lnt">76
&lt;/span>&lt;span class="lnt">77
&lt;/span>&lt;span class="lnt">78
&lt;/span>&lt;span class="lnt">79
&lt;/span>&lt;span class="lnt">80
&lt;/span>&lt;span class="lnt">81
&lt;/span>&lt;span class="lnt">82
&lt;/span>&lt;span class="lnt">83
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-markdown" data-lang="markdown">&lt;span class="line">&lt;span class="cl">&lt;span class="gu">### Assessment Target
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Site: https://chengxiaqiucao.github.io/ (Hugo + Stack theme)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Reference source: The site&amp;#39;s public content and this sampling result
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Homepage content reference: Qiucao&amp;#39;s Testing Observation
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">### Key Metrics (Lab)
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Desktop environment (no throttling/no slowdown)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> LCP: 477 ms (largest contentful paint is the homepage hero image, IMG)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> CLS: 0.00
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Simulated mobile (Fast 3G + CPU 4x slowdown)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> LCP: 918 ms
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> CLS: 0.00
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> LCP breakdown (desktop sample)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> TTFB: 6 ms
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Resource discovery/loading: 29 ms (discovery 24 ms, download 5 ms)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Render delay: 442 ms (~92.6%)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> LCP element: post/123-markitdown/Pasted-20250907_...png (non-blocking load, h2, 200)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">The data above comes from this lab sampling; there is no CrUX field data in the actual measurement. Reference pages and content come from elements such as the site homepage navigation and article cards; see the site homepage content snapshot and link: site homepage.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">### Conclusion
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> Excellent metrics: LCP &lt;span class="p">&amp;lt;&lt;/span> &lt;span class="nt">1s&lt;/span> &lt;span class="err">(&lt;/span>&lt;span class="na">desktop&lt;/span>&lt;span class="err">/&lt;/span>&lt;span class="na">mobile&lt;/span>&lt;span class="err">),&lt;/span> &lt;span class="na">CLS &lt;/span>&lt;span class="o">=&lt;/span> &lt;span class="s">0,&lt;/span> &lt;span class="na">overall&lt;/span> &lt;span class="na">loading&lt;/span> &lt;span class="na">chain&lt;/span> &lt;span class="na">is&lt;/span> &lt;span class="na">simple&lt;/span> &lt;span class="err">(&lt;/span>&lt;span class="na">static&lt;/span> &lt;span class="na">site&lt;/span>&lt;span class="err">,&lt;/span> &lt;span class="na">CDN&lt;/span> &lt;span class="na">caching&lt;/span> &lt;span class="na">effective&lt;/span>&lt;span class="err">,&lt;/span> &lt;span class="na">h2&lt;/span>&lt;span class="err">).&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> &lt;span class="na">The&lt;/span> &lt;span class="na">main&lt;/span> &lt;span class="na">bottleneck&lt;/span> &lt;span class="na">is&lt;/span> &lt;span class="err">&amp;#34;&lt;/span>&lt;span class="na">render&lt;/span> &lt;span class="na">delay&lt;/span>&lt;span class="err">&amp;#34;,&lt;/span> &lt;span class="na">not&lt;/span> &lt;span class="na">network&lt;/span> &lt;span class="na">or&lt;/span> &lt;span class="na">resource&lt;/span> &lt;span class="na">download&lt;/span>&lt;span class="err">.&lt;/span> &lt;span class="na">This&lt;/span> &lt;span class="na">shows&lt;/span> &lt;span class="na">the&lt;/span> &lt;span class="na">first&lt;/span> &lt;span class="na">screen&lt;/span> &lt;span class="na">is&lt;/span> &lt;span class="na">mainly&lt;/span> &lt;span class="na">spent&lt;/span> &lt;span class="na">on&lt;/span> &lt;span class="na">style&lt;/span> &lt;span class="na">computation&lt;/span>&lt;span class="err">/&lt;/span>&lt;span class="na">layout&lt;/span>&lt;span class="err">/&lt;/span>&lt;span class="na">paint&lt;/span>&lt;span class="err">,&lt;/span> &lt;span class="na">not&lt;/span> &lt;span class="na">the&lt;/span> &lt;span class="na">request&lt;/span> &lt;span class="na">chain&lt;/span>&lt;span class="err">.&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">### Suggested Optimization Directions (by priority)
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> &lt;span class="na">Critical&lt;/span> &lt;span class="na">rendering&lt;/span> &lt;span class="na">path&lt;/span> &lt;span class="na">optimization&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> &lt;span class="na">Optimize&lt;/span> &lt;span class="na">the&lt;/span> &lt;span class="na">first-screen&lt;/span> &lt;span class="na">DOM&lt;/span> &lt;span class="na">size&lt;/span> &lt;span class="na">and&lt;/span> &lt;span class="na">style&lt;/span> &lt;span class="na">complexity&lt;/span> &lt;span class="na">to&lt;/span> &lt;span class="na">reduce&lt;/span> &lt;span class="na">reflow&lt;/span>&lt;span class="err">/&lt;/span>&lt;span class="na">repaint&lt;/span> &lt;span class="na">overhead&lt;/span> &lt;span class="err">(&lt;/span>&lt;span class="na">list&lt;/span> &lt;span class="na">cards&lt;/span>&lt;span class="err">,&lt;/span> &lt;span class="na">image&lt;/span> &lt;span class="na">container&lt;/span> &lt;span class="na">shadows&lt;/span>&lt;span class="err">/&lt;/span>&lt;span class="na">rounded&lt;/span> &lt;span class="na">corners&lt;/span>&lt;span class="err">/&lt;/span>&lt;span class="na">filters&lt;/span>&lt;span class="err">,&lt;/span> &lt;span class="na">etc&lt;/span>&lt;span class="err">.&lt;/span> &lt;span class="na">can&lt;/span> &lt;span class="na">be&lt;/span> &lt;span class="na">reviewed&lt;/span>&lt;span class="err">).&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> &lt;span class="na">If&lt;/span> &lt;span class="na">web&lt;/span> &lt;span class="na">fonts&lt;/span> &lt;span class="na">are&lt;/span> &lt;span class="na">used&lt;/span>&lt;span class="err">,&lt;/span> &lt;span class="na">ensure&lt;/span> &lt;span class="na">font-display:&lt;/span> &lt;span class="na">swap&lt;/span> &lt;span class="na">to&lt;/span> &lt;span class="na">avoid&lt;/span> &lt;span class="na">render&lt;/span> &lt;span class="na">delay&lt;/span> &lt;span class="na">caused&lt;/span> &lt;span class="na">by&lt;/span> &lt;span class="na">delayed&lt;/span> &lt;span class="na">first-screen&lt;/span> &lt;span class="na">text&lt;/span> &lt;span class="na">painting&lt;/span>&lt;span class="err">.&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> &lt;span class="na">Image&lt;/span> &lt;span class="na">strategy&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> &lt;span class="na">Keep&lt;/span> &lt;span class="na">the&lt;/span> &lt;span class="na">LCP&lt;/span> &lt;span class="na">image&lt;/span> &lt;span class="err">&amp;#34;&lt;/span>&lt;span class="na">accessible&lt;/span>&lt;span class="err">&amp;#34;&lt;/span> &lt;span class="na">and&lt;/span> &lt;span class="na">non-lazy-loaded&lt;/span>&lt;span class="err">;&lt;/span> &lt;span class="na">if&lt;/span> &lt;span class="na">the&lt;/span> &lt;span class="na">size&lt;/span> &lt;span class="na">is&lt;/span> &lt;span class="na">too&lt;/span> &lt;span class="na">large&lt;/span>&lt;span class="err">,&lt;/span> &lt;span class="na">consider&lt;/span> &lt;span class="na">explicit&lt;/span> &lt;span class="na">width&lt;/span>&lt;span class="err">/&lt;/span>&lt;span class="na">height&lt;/span> &lt;span class="na">dimensions&lt;/span> &lt;span class="na">and&lt;/span> &lt;span class="na">priority&lt;/span> &lt;span class="na">hints&lt;/span> &lt;span class="err">(&lt;/span>&lt;span class="na">for&lt;/span> &lt;span class="na">supported&lt;/span> &lt;span class="na">frameworks&lt;/span>&lt;span class="err">).&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> &lt;span class="na">Enable&lt;/span> &lt;span class="na">lazy&lt;/span> &lt;span class="na">loading&lt;/span> &lt;span class="na">loading&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;lazy&amp;#34;&lt;/span> &lt;span class="na">and&lt;/span> &lt;span class="na">decoding&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">&amp;#34;async&amp;#34;&lt;/span> &lt;span class="na">for&lt;/span> &lt;span class="na">non-first-screen&lt;/span> &lt;span class="na">images&lt;/span> &lt;span class="na">to&lt;/span> &lt;span class="na">reduce&lt;/span> &lt;span class="na">first-screen&lt;/span> &lt;span class="na">decoding&lt;/span> &lt;span class="na">and&lt;/span> &lt;span class="na">layout&lt;/span> &lt;span class="na">pressure&lt;/span>&lt;span class="err">.&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> &lt;span class="na">CSS&lt;/span> &lt;span class="na">and&lt;/span> &lt;span class="na">third&lt;/span> &lt;span class="na">parties&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> &lt;span class="na">Split&lt;/span> &lt;span class="na">CSS&lt;/span> &lt;span class="na">reasonably&lt;/span>&lt;span class="err">,&lt;/span> &lt;span class="na">ensure&lt;/span> &lt;span class="na">first-screen&lt;/span> &lt;span class="na">critical&lt;/span> &lt;span class="na">styles&lt;/span> &lt;span class="na">are&lt;/span> &lt;span class="na">inlined&lt;/span> &lt;span class="na">or&lt;/span> &lt;span class="na">prioritized&lt;/span>&lt;span class="err">,&lt;/span> &lt;span class="na">reducing&lt;/span> &lt;span class="na">render&lt;/span> &lt;span class="na">blocking&lt;/span>&lt;span class="err">.&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> &lt;span class="na">Review&lt;/span> &lt;span class="na">third-party&lt;/span> &lt;span class="na">scripts&lt;/span> &lt;span class="na">and&lt;/span> &lt;span class="na">analytics&lt;/span>&lt;span class="err">,&lt;/span> &lt;span class="na">defer&lt;/span> &lt;span class="na">non-critical&lt;/span> &lt;span class="na">script&lt;/span> &lt;span class="na">execution&lt;/span> &lt;span class="na">or&lt;/span> &lt;span class="na">use&lt;/span> &lt;span class="na">defer&lt;/span>&lt;span class="err">/&lt;/span>&lt;span class="na">async&lt;/span>&lt;span class="err">,&lt;/span> &lt;span class="na">keeping&lt;/span> &lt;span class="na">the&lt;/span> &lt;span class="na">main&lt;/span> &lt;span class="na">thread&lt;/span> &lt;span class="na">for&lt;/span> &lt;span class="na">first-screen&lt;/span> &lt;span class="na">painting&lt;/span>&lt;span class="err">.&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> &lt;span class="na">Caching&lt;/span> &lt;span class="na">and&lt;/span> &lt;span class="na">delivery&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> &lt;span class="na">Keep&lt;/span> &lt;span class="na">long&lt;/span> &lt;span class="na">caching&lt;/span> &lt;span class="na">for&lt;/span> &lt;span class="na">static&lt;/span> &lt;span class="na">assets&lt;/span> &lt;span class="err">(&lt;/span>&lt;span class="na">cache-control:&lt;/span> &lt;span class="na">max-age&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s">600,&lt;/span> &lt;span class="na">etc&lt;/span>&lt;span class="err">.&lt;/span> &lt;span class="na">already&lt;/span> &lt;span class="na">seen&lt;/span>&lt;span class="err">);&lt;/span> &lt;span class="na">if&lt;/span> &lt;span class="na">content&lt;/span> &lt;span class="na">is&lt;/span> &lt;span class="na">stable&lt;/span>&lt;span class="err">,&lt;/span> &lt;span class="na">it&lt;/span> &lt;span class="na">can&lt;/span> &lt;span class="na">be&lt;/span> &lt;span class="na">extended&lt;/span> &lt;span class="na">with&lt;/span> &lt;span class="na">fingerprints&lt;/span>&lt;span class="err">.&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> &lt;span class="na">Confirm&lt;/span> &lt;span class="na">images&lt;/span> &lt;span class="na">are&lt;/span> &lt;span class="na">delivered&lt;/span> &lt;span class="na">via&lt;/span> &lt;span class="na">adapted&lt;/span> &lt;span class="na">formats&lt;/span> &lt;span class="err">(&lt;/span>&lt;span class="na">such&lt;/span> &lt;span class="na">as&lt;/span> &lt;span class="na">WebP&lt;/span>&lt;span class="err">/&lt;/span>&lt;span class="na">AVIF&lt;/span>&lt;span class="err">)&lt;/span> &lt;span class="na">with&lt;/span> &lt;span class="na">appropriate&lt;/span> &lt;span class="na">resolution&lt;/span>&lt;span class="err">/&lt;/span>&lt;span class="na">compression&lt;/span>&lt;span class="err">.&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">### Suggested Follow-up Verification
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> &lt;span class="na">On&lt;/span> &lt;span class="na">real&lt;/span> &lt;span class="na">mobile&lt;/span> &lt;span class="na">devices&lt;/span>&lt;span class="err">,&lt;/span> &lt;span class="na">use&lt;/span> &lt;span class="na">Lighthouse&lt;/span> &lt;span class="na">to&lt;/span> &lt;span class="na">test&lt;/span> &lt;span class="err">&amp;#34;&lt;/span>&lt;span class="na">cold&lt;/span> &lt;span class="na">start&lt;/span>&lt;span class="err">/&lt;/span>&lt;span class="na">second&lt;/span> &lt;span class="na">visit&lt;/span>&lt;span class="err">&amp;#34;&lt;/span> &lt;span class="na">separately&lt;/span>&lt;span class="err">,&lt;/span> &lt;span class="na">focusing&lt;/span> &lt;span class="na">on&lt;/span> &lt;span class="na">FCP&lt;/span>&lt;span class="err">,&lt;/span> &lt;span class="na">INP&lt;/span>&lt;span class="err">,&lt;/span> &lt;span class="na">and&lt;/span> &lt;span class="na">LCP&lt;/span> &lt;span class="na">fluctuations&lt;/span>&lt;span class="err">.&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> &lt;span class="na">Repeatedly&lt;/span> &lt;span class="na">sample&lt;/span> &lt;span class="na">different&lt;/span> &lt;span class="na">article&lt;/span> &lt;span class="na">pages&lt;/span> &lt;span class="err">(&lt;/span>&lt;span class="na">containing&lt;/span> &lt;span class="na">many&lt;/span> &lt;span class="na">images&lt;/span>&lt;span class="err">/&lt;/span>&lt;span class="na">code&lt;/span> &lt;span class="na">blocks&lt;/span>&lt;span class="err">),&lt;/span> &lt;span class="na">observing&lt;/span> &lt;span class="na">whether&lt;/span> &lt;span class="na">the&lt;/span> &lt;span class="na">LCP&lt;/span> &lt;span class="na">element&lt;/span> &lt;span class="na">changes&lt;/span> &lt;span class="na">and&lt;/span> &lt;span class="na">whether&lt;/span> &lt;span class="na">render&lt;/span> &lt;span class="na">delay&lt;/span> &lt;span class="na">increases&lt;/span>&lt;span class="err">.&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> &lt;span class="na">Introduce&lt;/span> &lt;span class="na">a&lt;/span> &lt;span class="na">performance&lt;/span> &lt;span class="na">budget&lt;/span>&lt;span class="err">,&lt;/span> &lt;span class="na">set&lt;/span> &lt;span class="na">thresholds&lt;/span> &lt;span class="na">for&lt;/span> &lt;span class="na">image&lt;/span> &lt;span class="na">size&lt;/span>&lt;span class="err">,&lt;/span> &lt;span class="na">CSS&lt;/span>&lt;span class="err">/&lt;/span>&lt;span class="na">JS&lt;/span> &lt;span class="na">size&lt;/span>&lt;span class="err">,&lt;/span> &lt;span class="na">and&lt;/span> &lt;span class="na">request&lt;/span> &lt;span class="na">count&lt;/span>&lt;span class="err">,&lt;/span> &lt;span class="na">and&lt;/span> &lt;span class="na">check&lt;/span> &lt;span class="na">automatically&lt;/span> &lt;span class="na">in&lt;/span> &lt;span class="na">CI&lt;/span>&lt;span class="err">.&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">### References
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> &lt;span class="na">Site:&lt;/span> &lt;span class="na">chengxiaqiucao&lt;/span>&lt;span class="err">.&lt;/span>&lt;span class="na">github&lt;/span>&lt;span class="err">.&lt;/span>&lt;span class="na">io&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> &lt;span class="na">Site&lt;/span> &lt;span class="na">content&lt;/span> &lt;span class="na">overview:&lt;/span> &lt;span class="na">Qiucao&lt;/span>&lt;span class="err">&amp;#39;&lt;/span>&lt;span class="na">s&lt;/span> &lt;span class="na">Testing&lt;/span> &lt;span class="na">Observation&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> &lt;span class="na">LCP&lt;/span> &lt;span class="na">optimization:&lt;/span> &lt;span class="na">Optimize&lt;/span> &lt;span class="na">LCP&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">-&lt;/span> &lt;span class="na">Critical&lt;/span> &lt;span class="na">rendering&lt;/span> &lt;span class="na">path:&lt;/span> &lt;span class="na">Understanding&lt;/span> &lt;span class="na">the&lt;/span> &lt;span class="na">critical&lt;/span> &lt;span class="na">path&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;p>Through the above attempts, we can see that Chrome DevTools MCP, in driving the browser to execute via AI, not only has the automated intelligent execution capability we emphasized before, but also has lower-level &amp;ldquo;&lt;strong>debugging&lt;/strong>&amp;rdquo; and &amp;ldquo;&lt;strong>diagnosis&lt;/strong>&amp;rdquo; capabilities. When selecting AI automation tools, it is worth considering as a preferred direction.&lt;/p></description></item><item><title>MarkItDown - A Document Conversion Tool Built for AI Input</title><link>https://chengxiaqiucao.github.io/en/post/122-markitdown/</link><pubDate>Sun, 07 Sep 2025 00:00:00 +0000</pubDate><guid>https://chengxiaqiucao.github.io/en/post/122-markitdown/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/122-markitdown/Pasted-20250907.webp" alt="Featured image of post MarkItDown - A Document Conversion Tool Built for AI Input" />&lt;p>In today&amp;rsquo;s booming era of AI applications, we often need to feed documents of all formats to large models for analysis, summarization, or Q&amp;amp;A. Yet a common challenge is: &lt;strong>how can we make AI truly understand our document content?&lt;/strong> And Microsoft&amp;rsquo;s open-source MarkItDown tool was born to solve exactly this core problem.&lt;/p>
&lt;h2 id="what-is-markitdown">What Is MarkItDown?
&lt;/h2>&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/122-markitdown/Pasted-20250907_hu_e5030a01f083fda6.webp"
width="1024"
height="639"
srcset="https://chengxiaqiucao.github.io/post/122-markitdown/Pasted-20250907_hu_5466569a37aec621.webp 480w, https://chengxiaqiucao.github.io/post/122-markitdown/Pasted-20250907_hu_e5030a01f083fda6.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="160"
data-flex-basis="384px"
>
&lt;/p>
&lt;p>MarkItDown is a lightweight Python tool open-sourced by Microsoft, specifically for converting various file formats into Markdown. It supports a very wide range of file types:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Office documents&lt;/strong>: Word, PowerPoint, Excel&lt;/li>
&lt;li>&lt;strong>PDF files&lt;/strong>&lt;/li>
&lt;li>&lt;strong>Images&lt;/strong>: Supports extracting EXIF metadata and OCR text recognition&lt;/li>
&lt;li>&lt;strong>Audio files&lt;/strong>: Supports speech-to-text and metadata extraction&lt;/li>
&lt;li>&lt;strong>Web content&lt;/strong>: Specially optimized for sites like Wikipedia&lt;/li>
&lt;li>&lt;strong>Other text formats&lt;/strong>: CSV, JSON, XML, etc.&lt;/li>
&lt;li>&lt;strong>Even supports&lt;/strong>: ZIP files, YouTube URLs, EPubs, etc.&lt;/li>
&lt;/ul>
&lt;p>Unlike traditional document conversion tools, MarkItDown was designed from the ground up to serve AI applications, especially the analysis needs of large language models (LLMs).&lt;/p>
&lt;h2 id="why-convert-to-markdown">Why Convert to Markdown?
&lt;/h2>&lt;p>Before diving into MarkItDown&amp;rsquo;s advantages, we need to understand why the Markdown format is so AI-friendly:&lt;/p>
&lt;h3 id="1-simplicity-and-clarity">1. Simplicity and Clarity
&lt;/h3>&lt;p>LLMs perform best in a clean environment. Markdown provides clear visual and structural separation between headings, lists, and paragraphs. When an LLM sees &lt;code># Heading&lt;/code>, it knows a new section has begun. This simplicity reduces ambiguity and helps the model understand what matters and how to respond.&lt;/p>
&lt;h3 id="2-structured-data-representation">2. Structured Data Representation
&lt;/h3>&lt;p>Markdown allows nested lists, tables, and subheadings to show information hierarchy or categories. This hierarchy is gold for LLMs; it tells the model how concepts relate to one another - what the main idea is, what the sub-points are, and what list of items needs to be extracted or reasoned about.&lt;/p>
&lt;h3 id="3-enhanced-token-efficiency">3. Enhanced Token Efficiency
&lt;/h3>&lt;p>Tokens are the currency of LLMs. Every word, punctuation mark, or even formatting tag can consume precious tokens in a prompt. Markdown is lighter than JSON, XML, or HTML; it conveys meaning with fewer characters, which means more room for meaningful data and less redundancy. More context means better answers - and lower cost when paying per token.&lt;/p>
&lt;h3 id="4-improved-prompt-formatting">4. Improved Prompt Formatting
&lt;/h3>&lt;p>Markdown makes prompt formatting clearer. You can create separated sections with headings, add bullet points to reduce noise, and use code blocks to highlight technical examples. This gives the LLM visual cues to organize its thinking - just as it does for human readers.&lt;/p>
&lt;h2 id="markitdowns-advantages-for-ai-applications">MarkItDown&amp;rsquo;s Advantages for AI Applications
&lt;/h2>&lt;p>Based on the characteristics of Markdown above, MarkItDown shows the following key advantages in AI applications:&lt;/p>
&lt;h3 id="1-unstructured-to-structured-data">1. Unstructured to Structured Data
&lt;/h3>&lt;p>MarkItDown can convert a variety of unstructured documents into structured Markdown, enabling AI to better understand the document&amp;rsquo;s organizational structure and content hierarchy. This is essential for document analysis, content extraction, and knowledge building.&lt;/p>
&lt;h3 id="2-improved-ai-comprehension-accuracy">2. Improved AI Comprehension Accuracy
&lt;/h3>&lt;p>By preserving the document&amp;rsquo;s original structure (such as headings, lists, tables, etc.), MarkItDown helps AI understand document content more accurately, reducing misunderstanding and misinterpretation.&lt;/p>
&lt;h3 id="3-optimized-rag-system-performance">3. Optimized RAG System Performance
&lt;/h3>&lt;p>In Retrieval-Augmented Generation (RAG) systems, the quality of document parsing directly affects retrieval and generation results. MarkItDown&amp;rsquo;s high-quality structured output can significantly improve RAG system performance.&lt;/p>
&lt;h3 id="4-support-for-multimodal-content-processing">4. Support for Multimodal Content Processing
&lt;/h3>&lt;p>MarkItDown not only supports text documents, but can also handle image and audio files, and can integrate multimodal LLMs like GPT-4o for image description and speech transcription, achieving true multimodal content understanding.&lt;/p>
&lt;h3 id="5-unified-format-simplifies-the-processing-pipeline">5. Unified Format Simplifies the Processing Pipeline
&lt;/h3>&lt;p>No matter what format the input document is, MarkItDown outputs a unified Markdown format, greatly simplifying downstream AI processing and reducing the workload of format adaptation.&lt;/p>
&lt;h2 id="real-comparison-case-traditional-processing-vs-markitdown">Real Comparison Case: Traditional Processing vs MarkItDown
&lt;/h2>&lt;p>To show MarkItDown&amp;rsquo;s advantages more intuitively, let&amp;rsquo;s look at a real case. This is a scenario encountered when developing an AI email assistant:&lt;/p>
&lt;h3 id="problem-background">Problem Background
&lt;/h3>&lt;p>The developer needed to build an AI email assistant that could process various documents uploaded by users (PDF, Word, Excel, etc.) and answer questions about their content. Initially, the developer used a custom document processor (built on PyPDF2, python-docx, and pandas); although it extracted text perfectly, the AI performed poorly when answering questions.&lt;/p>
&lt;h3 id="output-of-the-traditional-processor">Output of the Traditional Processor
&lt;/h3>&lt;p>When a user asked &amp;ldquo;What was Q4 revenue?&amp;rdquo;, the traditional processor&amp;rsquo;s output was as follows:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">Sales Report Q4 Revenue 2.3M Growth 15% Customer Satisfaction 94% Team Performance John 12k Sarah 15k Mike 9k
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Technically correct, but semantically useless to the AI. The table became an unreadable block of text, document headings lost their hierarchy, and the vector store could not understand content relationships.&lt;/p>
&lt;h3 id="output-of-markitdown">Output of MarkItDown
&lt;/h3>&lt;p>After processing the same document with MarkItDown, the output was as follows:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-markdown" data-lang="markdown">&lt;span class="line">&lt;span class="cl">&lt;span class="gu">## Q4 Performance
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| Metric | Value |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">|--------|-------|
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| Revenue | $2.3M |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| Growth | 15% |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| Customer Satisfaction | 94% |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">## Team Performance
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| Employee | Sales | Rating |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">|----------|-------|--------|
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| John | $12k | A+ |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| Sarah | $15k | A |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| Mike | $9k | B+ |
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="comparison-result">Comparison Result
&lt;/h3>&lt;p>The difference is striking! Through actual testing, using MarkItDown brought the following improvements:&lt;/p>
&lt;ol>
&lt;li>
&lt;p>&lt;strong>Search relevance up 34%&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Query: &amp;ldquo;What was Q4 revenue?&amp;rdquo;&lt;/li>
&lt;li>Traditional processor: found the text but lost the table context&lt;/li>
&lt;li>MarkItDown: found a structured table with clear numeric data&lt;/li>
&lt;li>Result: answer accuracy improved by 34%&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Chunking quality up 28%&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Traditional processor: arbitrary text splitting&lt;/li>
&lt;li>MarkItDown: structure-aware splitting that preserves headings and tables&lt;/li>
&lt;li>Result: chunk consistency score improved by 28%&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ol>
&lt;p>This case clearly shows how MarkItDown, by preserving document structure, significantly improves AI&amp;rsquo;s ability to understand document content.&lt;/p>
&lt;h2 id="markitdowns-technical-advantages">MarkItDown&amp;rsquo;s Technical Advantages
&lt;/h2>&lt;p>Beyond the application advantages above, MarkItDown is also unique at the technical level:&lt;/p>
&lt;h3 id="1-designed-for-llms">1. Designed for LLMs
&lt;/h3>&lt;p>Unlike traditional document conversion tools, MarkItDown considered the needs of LLMs from the very beginning, focusing on preserving document structure and content relationships rather than merely extracting text.&lt;/p>
&lt;h3 id="2-llm-integration-capability">2. LLM Integration Capability
&lt;/h3>&lt;p>MarkItDown can integrate multimodal LLMs like GPT-4o for image description and speech transcription, enabling deeper content understanding and analysis.&lt;/p>
&lt;h3 id="3-plugin-extension-system">3. Plugin Extension System
&lt;/h3>&lt;p>Supports third-party plugins, allowing features to be extended for specific needs, enhancing the tool&amp;rsquo;s flexibility and adaptability.&lt;/p>
&lt;h3 id="4-multiple-deployment-options">4. Multiple Deployment Options
&lt;/h3>&lt;p>Supports command line, Python API, and Docker deployment, and can be easily integrated into various AI applications and workflows.&lt;/p>
&lt;h2 id="practical-application-scenarios">Practical Application Scenarios
&lt;/h2>&lt;p>MarkItDown is especially valuable in the following AI application scenarios:&lt;/p>
&lt;h3 id="1-enterprise-knowledge-base-construction">1. Enterprise Knowledge Base Construction
&lt;/h3>&lt;p>Convert various internal document formats into structured Markdown to build an AI-understandable knowledge base supporting intelligent Q&amp;amp;A and content retrieval.&lt;/p>
&lt;h3 id="2-rag-system-development">2. RAG System Development
&lt;/h3>&lt;p>Serve as the document pre-processing tool for a RAG system, providing high-quality input data and improving retrieval and generation results.&lt;/p>
&lt;h3 id="3-document-automation-processing">3. Document Automation Processing
&lt;/h3>&lt;p>Automatically process large volumes of documents, extract key information, and generate summaries or reports, reducing manual work.&lt;/p>
&lt;h3 id="4-multimodal-content-analysis">4. Multimodal Content Analysis
&lt;/h3>&lt;p>Combine image and audio processing capabilities to achieve comprehensive analysis and understanding of multimedia content.&lt;/p>
&lt;h3 id="5-ai-assistant-development">5. AI Assistant Development
&lt;/h3>&lt;p>Provide AI assistants with structured document understanding capabilities, enabling them to accurately answer questions about document content.&lt;/p>
&lt;h2 id="how-to-get-started-with-markitdown">How to Get Started with MarkItDown?
&lt;/h2>&lt;p>Using MarkItDown is very simple; just a few steps:&lt;/p>
&lt;h3 id="installation">Installation
&lt;/h3>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">pip install &lt;span class="s1">&amp;#39;markitdown[all]&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="basic-usage">Basic Usage
&lt;/h3>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="kn">from&lt;/span> &lt;span class="nn">markitdown&lt;/span> &lt;span class="kn">import&lt;/span> &lt;span class="n">MarkItDown&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">md&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">MarkItDown&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">result&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">md&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">convert&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="sa">r&lt;/span>&lt;span class="s2">&amp;#34;sample.docx&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">result&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">text_content&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/122-markitdown/Pasted-20250907-1_hu_e01420d76af5161b.webp"
width="1024"
height="507"
srcset="https://chengxiaqiucao.github.io/post/122-markitdown/Pasted-20250907-1_hu_78a35d10cab3c676.webp 480w, https://chengxiaqiucao.github.io/post/122-markitdown/Pasted-20250907-1_hu_e01420d76af5161b.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="201"
data-flex-basis="484px"
>
&lt;/p>
&lt;h3 id="processing-excel-spreadsheets">Processing Excel Spreadsheets
&lt;/h3>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="kn">from&lt;/span> &lt;span class="nn">markitdown&lt;/span> &lt;span class="kn">import&lt;/span> &lt;span class="n">MarkItDown&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">md&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">MarkItDown&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">result&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">md&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">convert&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="sa">r&lt;/span>&lt;span class="s2">&amp;#34;excel.xlsx&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">result&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">text_content&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/122-markitdown/Pasted-20250907-2_hu_4a1d20fda20cd7b3.webp"
width="1024"
height="498"
srcset="https://chengxiaqiucao.github.io/post/122-markitdown/Pasted-20250907-2_hu_ecc4d227a18ff6fb.webp 480w, https://chengxiaqiucao.github.io/post/122-markitdown/Pasted-20250907-2_hu_4a1d20fda20cd7b3.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="205"
data-flex-basis="493px"
>
&lt;/p>
&lt;h3 id="batch-processing-of-compressed-files">Batch Processing of Compressed Files
&lt;/h3>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="kn">from&lt;/span> &lt;span class="nn">markitdown&lt;/span> &lt;span class="kn">import&lt;/span> &lt;span class="n">MarkItDown&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">md&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">MarkItDown&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">result&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">md&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">convert&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="sa">r&lt;/span>&lt;span class="s2">&amp;#34;sample.zip&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">result&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">text_content&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/122-markitdown/Pasted-20250907-3_hu_759809aa1788c41d.webp"
width="1024"
height="633"
srcset="https://chengxiaqiucao.github.io/post/122-markitdown/Pasted-20250907-3_hu_d03c1d196b23b8e4.webp 480w, https://chengxiaqiucao.github.io/post/122-markitdown/Pasted-20250907-3_hu_759809aa1788c41d.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="161"
data-flex-basis="387px"
>
&lt;/p>
&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;p>In AI applications, &amp;ldquo;garbage in, garbage out&amp;rdquo; is a golden rule. By converting documents of various formats into structured Markdown, MarkItDown provides AI with high-quality, easy-to-understand input data, significantly improving AI&amp;rsquo;s ability to understand document content.&lt;/p>
&lt;p>Whether you are building a RAG system, developing an AI assistant, or doing document automation, MarkItDown is a powerful tool worth trying. It not only solves the challenge of document format diversity, more importantly, by preserving document structure, it lets AI truly &amp;ldquo;understand&amp;rdquo; our document content.&lt;/p>
&lt;p>As AI applications continue to evolve, tools like MarkItDown will play an increasingly important role in connecting human knowledge with AI capabilities. If you are developing an AI application, especially one that needs to process large volumes of documents, why not try MarkItDown and experience the qualitative leap it brings to your AI application.&lt;/p></description></item><item><title>A Handy Tool for Quickly Making Sense of Open-Source Project Code, This AI Tool Is a Must-Know!</title><link>https://chengxiaqiucao.github.io/en/post/114-zread_ai/</link><pubDate>Mon, 28 Jul 2025 16:50:34 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/114-zread_ai/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/114-zread_ai/title.webp" alt="Featured image of post A Handy Tool for Quickly Making Sense of Open-Source Project Code, This AI Tool Is a Must-Know!" />&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/114-zread_ai/title_hu_1cdde587fbb134be.webp"
width="1024"
height="515"
srcset="https://chengxiaqiucao.github.io/post/114-zread_ai/title_hu_1b32f0db2922ce80.webp 480w, https://chengxiaqiucao.github.io/post/114-zread_ai/title_hu_1cdde587fbb134be.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="198"
data-flex-basis="477px"
>
&lt;/p>
&lt;p>In a previous article, we analyzed the source code of the popular AI testing tool &lt;code>Midscene.js&lt;/code>, focusing on how its main prompts for driving AI execution are set. (See that article 【】)&lt;/p>
&lt;p>Recently, I discovered another AI gem, a source-code analysis service launched by &lt;code>Zhipu AI&lt;/code>, accessible at&lt;/p>
&lt;p>&lt;code>https://zread.ai/&lt;/code>&lt;/p>
&lt;p>As a product of a Chinese company, it offers excellent support for Chinese.&lt;/p>
&lt;h2 id="using-the-tool">Using the Tool
&lt;/h2>&lt;p>After visiting the homepage, you&amp;rsquo;ll see a typical AI application interface.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/114-zread_ai/Pasted-20250728-2_hu_e22f73133e189ea1.webp"
width="1024"
height="516"
srcset="https://chengxiaqiucao.github.io/post/114-zread_ai/Pasted-20250728-2_hu_bbd5d6504c8a4a5e.webp 480w, https://chengxiaqiucao.github.io/post/114-zread_ai/Pasted-20250728-2_hu_e22f73133e189ea1.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="198"
data-flex-basis="476px"
>
&lt;/p>
&lt;p>We simply enter the GitHub address of the source-code project we want to analyze into the search box. If the project has already been indexed, pressing Enter will display an overview card for the project.&lt;/p>
&lt;p>Or more directly, we can replace &lt;code>github.com&lt;/code> in the source address with &lt;code>zread.ai&lt;/code>. For example, to analyze the &lt;code>Playwright&lt;/code> project, just visit the following address:&lt;/p>
&lt;p>&lt;code>https://zread.ai/microsoft/playwright&lt;/code>&lt;/p>
&lt;p>The analysis page is very comprehensive, covering installation and deployment, architecture analysis, core modules, and more. The figure below shows the &lt;code>Playwright&lt;/code> architecture analysis page.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/114-zread_ai/Pasted-20250728-4_hu_57ae936c071245c2.webp"
width="1024"
height="493"
srcset="https://chengxiaqiucao.github.io/post/114-zread_ai/Pasted-20250728-4_hu_9707a7801120c596.webp 480w, https://chengxiaqiucao.github.io/post/114-zread_ai/Pasted-20250728-4_hu_57ae936c071245c2.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="207"
data-flex-basis="498px"
>
&lt;/p>
&lt;p>Through the index-generated analysis, we can quickly understand the full picture of an open-source project, along with its core usage and key points.&lt;/p>
&lt;h2 id="further-empowerment-with-ai">Further Empowerment with AI
&lt;/h2>&lt;p>Beyond the tool&amp;rsquo;s own indexing and analysis of source code, with its built-in large-model integration we can go further and conduct targeted, in-depth analysis of a project to understand its specific details.&lt;/p>
&lt;p>We can use its &lt;code>Ask AI&lt;/code> feature to communicate deeply with the AI.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/114-zread_ai/Pasted-20250728-3_hu_c3ed62dadde1d7b6.webp"
width="1024"
height="596"
srcset="https://chengxiaqiucao.github.io/post/114-zread_ai/Pasted-20250728-3_hu_4585deb6459a4adf.webp 480w, https://chengxiaqiucao.github.io/post/114-zread_ai/Pasted-20250728-3_hu_c3ed62dadde1d7b6.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="171"
data-flex-basis="412px"
>
&lt;/p>
&lt;p>For example, below is a summary I asked it to put together of the key updates and applications in the last four versions of Playwright.&lt;/p>
&lt;hr>
&lt;p>The important feature updates in the latest four versions of Playwright (1.53, 1.52, 1.51, and 1.50) are as follows:&lt;/p>
&lt;h2 id="version-153">Version 1.53
&lt;/h2>&lt;ol>
&lt;li>
&lt;p>&lt;strong>Trace Viewer and HTML Reporter updates&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Added a test-step display feature, making the test execution process clearer and more visible&lt;/li>
&lt;li>The HTML reporting tool added a custom test-run title option, making it easier to distinguish different test runs&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">reporter: [[&amp;#39;html&amp;#39;, { title: &amp;#39;Custom test run #1028&amp;#39; }]]
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;/li>
&lt;li>
&lt;p>&lt;strong>New Locator.describe method&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Allows adding descriptive information to a locator, displayed in the trace viewer and reports to improve test readability&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-gdscript3" data-lang="gdscript3">&lt;span class="line">&lt;span class="cl">&lt;span class="k">const&lt;/span> &lt;span class="n">button&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">page&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">getByTestId&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;btn-sub&amp;#39;&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">describe&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;Subscribe button&amp;#39;&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="n">await&lt;/span> &lt;span class="n">button&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">click&lt;/span>&lt;span class="p">();&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;/li>
&lt;li>
&lt;p>&lt;strong>Browser version upgrades&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Chromium 138.0.7204.4&lt;/li>
&lt;li>Firefox 139.0&lt;/li>
&lt;li>WebKit 18.5&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ol>
&lt;h2 id="version-152">Version 1.52
&lt;/h2>&lt;ol>
&lt;li>
&lt;p>&lt;strong>New assertion method toContainClass&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Simplifies assertions on element class names&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">await expect(page.getByRole(&amp;#39;listitem&amp;#39;)).toContainClass(&amp;#39;done&amp;#39;);
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;/li>
&lt;li>
&lt;p>&lt;strong>Aria snapshot enhancements&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Added the &lt;code>/children&lt;/code> attribute for strict matching&lt;/li>
&lt;li>Added the &lt;code>/url&lt;/code> attribute for link verification&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Test project configuration improvements&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Added the &lt;code>workers&lt;/code> property to control the number of concurrent worker processes for a test project&lt;/li>
&lt;li>Added the &lt;code>failOnFlakyTests&lt;/code> option to ensure all tests run stably in CI/CD environments&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Important changes&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Glob URL patterns no longer support &lt;code>?&lt;/code> and &lt;code>[]&lt;/code>; regular expressions are recommended instead&lt;/li>
&lt;li>&lt;code>Route.continue&lt;/code> no longer allows overriding the &lt;code>Cookie&lt;/code> header; use &lt;code>BrowserContext.addCookies&lt;/code> instead&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ol>
&lt;h2 id="version-151">Version 1.51
&lt;/h2>&lt;ol>
&lt;li>
&lt;p>&lt;strong>IndexedDB storage state management&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Added support for saving and restoring IndexedDB content, useful for applications using services like Firebase Authentication&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">await page.context().storageState({ path: authFile, indexedDB: true });
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;/li>
&lt;li>
&lt;p>&lt;strong>Enhanced error messages - &amp;ldquo;Copy as prompt&amp;rdquo;&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Errors in the HTML report, trace viewer, and UI mode now have a &amp;ldquo;Copy prompt&amp;rdquo; button&lt;/li>
&lt;li>One-click copy of a pre-filled LLM prompt containing the error message and helpful context&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Visible element filtering&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>The &lt;code>Locator.filter&lt;/code> method gained a &lt;code>visible&lt;/code> option to match only visible elements&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-gdscript3" data-lang="gdscript3">&lt;span class="line">&lt;span class="cl">&lt;span class="k">const&lt;/span> &lt;span class="n">todoItems&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">page&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">getByTestId&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;todo-item&amp;#39;&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">filter&lt;/span>&lt;span class="p">({&lt;/span> &lt;span class="n">visible&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="bp">true&lt;/span> &lt;span class="p">});&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;/li>
&lt;li>
&lt;p>&lt;strong>Git information integration&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Added the &lt;code>captureGitInfo&lt;/code> configuration to show Git commit and diff information in the HTML report&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ol>
&lt;h2 id="version-150">Version 1.50
&lt;/h2>&lt;ol>
&lt;li>
&lt;p>&lt;strong>Test step improvements&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Added a &lt;code>test.step&lt;/code> timeout option to set a maximum runtime for individual steps&lt;/li>
&lt;li>Added the &lt;code>test.step.skip&lt;/code> method to disable execution of specific test steps&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">await test.step(&amp;#39;a step&amp;#39;, async () =&amp;gt; { // this step can have its own timeout independent of the test}, { timeout: 1000 });
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;/li>
&lt;li>
&lt;p>&lt;strong>Accessibility testing enhancements&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Extended the &lt;code>toMatchAriaSnapshot&lt;/code> method to allow storing snapshots in separate YAML files&lt;/li>
&lt;li>Added the &lt;code>toHaveAccessibleErrorMessage&lt;/code> assertion for verifying an element&amp;rsquo;s aria error message&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Snapshot update strategy improvements&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Added the &lt;code>changed&lt;/code> option for &lt;code>updateSnapshots&lt;/code> to update only changed snapshots&lt;/li>
&lt;li>Added the &lt;code>updateSourceMethod&lt;/code> option to define how source code is updated, adding &lt;code>overwrite&lt;/code> and &lt;code>3-way&lt;/code> modes&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>UI updates&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Improved attachment display in the HTML report&lt;/li>
&lt;li>Codegen added an element-picker button for generating aria snapshots&lt;/li>
&lt;li>Added detailed information about API calls into the trace display&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ol>
&lt;p>These updates together improve Playwright&amp;rsquo;s testing capabilities, debugging experience, and reporting features, making test automation more reliable and efficient.&lt;/p>
&lt;h2 id="proactive-indexing-and-private-repositories">Proactive Indexing and Private Repositories
&lt;/h2>&lt;p>Besides popular open-source projects that Zread has already indexed in advance, some newer or personal projects may not yet have been indexed; entering the project address lets you proactively start indexing, and analysis completes after a short wait.&lt;/p>
&lt;p>For example, below is a test practice project I open-sourced a while ago, with indexing triggered proactively.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/114-zread_ai/Pasted-20250728_hu_36c99b58bdefc521.webp"
width="1024"
height="652"
srcset="https://chengxiaqiucao.github.io/post/114-zread_ai/Pasted-20250728_hu_8ab561e873b2c736.webp 480w, https://chengxiaqiucao.github.io/post/114-zread_ai/Pasted-20250728_hu_36c99b58bdefc521.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="157"
data-flex-basis="376px"
>
&lt;/p>
&lt;p>Soon I got a complete introduction and core code analysis for this project.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/114-zread_ai/Pasted-20250728-1_hu_75a4762ac139fee9.webp"
width="1024"
height="522"
srcset="https://chengxiaqiucao.github.io/post/114-zread_ai/Pasted-20250728-1_hu_12610e5e1ba4f762.webp 480w, https://chengxiaqiucao.github.io/post/114-zread_ai/Pasted-20250728-1_hu_75a4762ac139fee9.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="196"
data-flex-basis="470px"
>
&lt;/p>
&lt;p>For some non-public private repositories, you can also grant code-read permission to &lt;code>Zread.ai&lt;/code> through authorization to achieve the same goal.&lt;/p>
&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;p>In short, this tool is absolutely a powerful assistant for quickly understanding an open-source project, and I highly recommend it~~&lt;/p></description></item><item><title>When AI Writes Applications, a Blessing or a Challenge for Quality?</title><link>https://chengxiaqiucao.github.io/en/post/113-test_ai_coded_app/</link><pubDate>Thu, 24 Jul 2025 16:49:36 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/113-test_ai_coded_app/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/113-test_ai_coded_app/ai_check.webp" alt="Featured image of post When AI Writes Applications, a Blessing or a Challenge for Quality?" />&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/113-test_ai_coded_app/ai_check_hu_e9cc545f9a7ff80a.webp"
width="1024"
height="587"
srcset="https://chengxiaqiucao.github.io/post/113-test_ai_coded_app/ai_check_hu_80d2c40fc4f90117.webp 480w, https://chengxiaqiucao.github.io/post/113-test_ai_coded_app/ai_check_hu_e9cc545f9a7ff80a.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="174"
data-flex-basis="418px"
>
&lt;/p>
&lt;h1 id="when-ai-writes-applications-a-blessing-or-a-challenge-for-quality">When AI Writes Applications, a Blessing or a Challenge for Quality?
&lt;/h1>&lt;p>As AI models become increasingly capable, AI programming tools represented by Copilot, Cursor, Claude Code, and Gemini Cli are gradually entering everyday software development, and &amp;ldquo;vibe coding&amp;rdquo; is increasingly becoming a trend in application development.&lt;/p>
&lt;p>So when AI becomes more and more involved in the development of real applications, is the quality of applications built in this way good or bad?&lt;/p>
&lt;p>This article shares my views based on my recent experience using several vibe coding tools.&lt;/p>
&lt;h2 id="ai-programming-looks-beautiful">AI Programming Looks Beautiful
&lt;/h2>&lt;p>From the moment people first encounter AI programming, many are amazed by its extremely fast and efficient power. Combined with good prompt engineering, it can often complete prototype design in a very short time, and the resulting product is frequently more feature-complete than expected.&lt;/p>
&lt;p>As long as we have some understanding of software application development, combined with prompt engineering, AI can help us with everything from design to code, from the front end and back end to the database. What engineers need to do seems to be continuously communicating with the AI and constantly optimizing and adjusting the output.&lt;/p>
&lt;p>It can be said that the emergence of AI programming tools has enabled many non-programmers to develop a wide range of creative applications, greatly lowering the barrier to software development.&lt;/p>
&lt;p>In major software development companies, it is gradually becoming the norm for developers to write more and more code with the help of AI tools.&lt;/p>
&lt;p>The future of AI programming is so close, and so beautiful~&lt;/p>
&lt;p>However, if the goal is not merely to validate a prototype, and we judge an AI-developed application by the standards of a production-grade application, then a complex and painful debugging process will inevitably be part of the picture.&lt;/p>
&lt;p>&amp;ldquo;Ten minutes of development, two whole days of debugging&amp;rdquo; is actually the norm when it comes to AI programming.&lt;/p>
&lt;h2 id="when-the-ais-imagination-leaves-you-speechless">When the AI&amp;rsquo;s Imagination Leaves You Speechless
&lt;/h2>&lt;p>Although &amp;ldquo;prompt engineering&amp;rdquo; summarizes and emphasizes some of the best ways to collaborate with AI, in real work, engineers often still tend to communicate with the AI using brief instructions.&lt;/p>
&lt;p>When such instructions are insufficient and imprecise, the AI will naturally imagine a great deal of code that it considers necessary but that is actually plausible yet wrong. At this point, engineers inevitably need to spend a large amount of time checking and adjusting the AI&amp;rsquo;s behavior.&lt;/p>
&lt;p>Anyone who has coded with AI has likely had the experience of spending a huge amount of time on some basic logic or front-end interface adjustment.&lt;/p>
&lt;p>For example, I once encountered a case where I simply wanted to add a field to a page form and adjust the back-end database accordingly. Yet the AI always misread the intent — either it didn&amp;rsquo;t sync the change, or it modified other unrelated forms. The back-and-forth dragged on and consumed a lot of time.&lt;/p>
&lt;p>What should have been a two-line change turned into a situation where, because I wasn&amp;rsquo;t familiar with the structure of the AI-generated code, I relied on the AI to revise it over and over. Although the desired result was finally achieved, a large amount of needless spaghetti code was inserted along the way.&lt;/p>
&lt;h2 id="weaknesses-in-integration-and-decoupling">Weaknesses in Integration and Decoupling
&lt;/h2>&lt;p>When AI generates code, it generally first determines the project&amp;rsquo;s code structure based on the initial requirements, and then fills in the code according to specific decomposed tasks.&lt;/p>
&lt;p>But as the project progresses and requirements are continuously refined, the main logic usually ends up concentrated in a few main files, which easily makes some of those files overly bloated. And because AI relies on large models, which usually have context window limitations, bloated files greatly constrain the efficiency and quality of code generation.&lt;/p>
&lt;p>Therefore, as requirements are continuously detailed and adjusted, the code becomes increasingly bloated and increasingly chaotic. It rarely undergoes proper decoupling and refactoring as it would in real engineering practice, and the AI&amp;rsquo;s own understanding of the code often becomes more and more difficult, making it hard to recapture that initial sense of amazement.&lt;/p>
&lt;p>At this point, engineer intervention is essential; otherwise, AI coding becomes more like trying to carve flowers on a dunghill.&lt;/p>
&lt;h2 id="what-you-see-is-not-necessarily-what-you-get">What You See Is Not Necessarily What You Get
&lt;/h2>&lt;p>In order to present results quickly, AI-generated code sometimes &amp;ldquo;cheats&amp;rdquo; by hard-coding the presentation of certain data effects.&lt;/p>
&lt;p>In the early stage, some mock data may be indispensable to demonstrate results. But you cannot fully trust the AI to distinguish hard-coding from properly handled logic.&lt;/p>
&lt;p>In an AI-assisted tool I once used, I pointed out to it that after I entered a certain specific piece of data, the actual result didn&amp;rsquo;t match expectations. After pretending to analyze things for a long time, the AI told me it had found the cause. But when I actually checked the code, I discovered that its handling of this part was simply an if check targeting that specific piece of data, forcing a special case and calling it a day.&lt;/p>
&lt;h2 id="challenges-to-quality">Challenges to Quality
&lt;/h2>&lt;p>So, from the explanations (and complaints) above, although AI has achieved astonishing results in assisting coding, and there is no lack of cases where it cooperates well with engineers, many applications generated with AI assistance still cannot dispel concerns about questionable quality.&lt;/p>
&lt;p>Perhaps AI itself can help you generate unit tests, but just as intelligent driving still cannot replace human decision-making, in the field of quality, the role of human test engineers remains irreplaceable. Indeed, as AI applications become more widespread, the importance of manual testing becomes ever more prominent.&lt;/p>
&lt;ul>
&lt;li>The quality of the code itself&lt;/li>
&lt;li>Overall planning of complex applications and broad-context understanding&lt;/li>
&lt;li>Deficiencies in scalability, performance, security, and other aspects&lt;/li>
&lt;li>Mock data and hard-coding&lt;/li>
&lt;/ul>
&lt;h2 id="how-test-engineers-should-respond">How Test Engineers Should Respond
&lt;/h2>&lt;p>Given the quality challenges of AI-generated applications, test engineers should also carry out targeted testing and verification of their output.&lt;/p>
&lt;p>The following aspects can be considered as priorities:&lt;/p>
&lt;h4 id="systematic-verification-against-traditional-standards">Systematic Verification Against Traditional Standards
&lt;/h4>&lt;p>As a product, testing should first and foremost verify the finished AI application from the perspectives of requirements, product goals, and user usage, ensuring that it meets product requirements and quality standards.&lt;/p>
&lt;h4 id="product-integration-scalability-performance-and-security">Product Integration, Scalability, Performance, and Security
&lt;/h4>&lt;p>In view of the weak points of AI code, focus on scenarios such as product integration, scalability, performance, and security, and carry out targeted testing.&lt;/p>
&lt;h4 id="from-black-box-to-white-box">From Black Box to White Box
&lt;/h4>&lt;p>The existence of AI illusions requires test engineers not only to verify the application from a black-box perspective, but also to pay attention to the process by which the AI generated the application. In particular, during the development process, the relevant prompts, context, and records of the AI&amp;rsquo;s responses are all sources for understanding potential quality problems. Many issues, such as hard-coding, may be hidden in some misleading interactions.&lt;/p>
&lt;h4 id="embrace-ai-and-fight-magic-with-magic">Embrace AI and Fight Magic with Magic
&lt;/h4>&lt;p>Although AI still has many problems, and using it incorrectly can produce products of poor quality, using it properly can indeed provide great help.&lt;/p>
&lt;p>With AI, we can analyze product code and sort out the project architecture, helping us better understand the implementation of the project. This includes using AI to assist with many testing tasks, including automated testing.&lt;/p>
&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;p>All in all, a good-quality product cannot do without a mature team and standardized processes. For testers, the AI era is also an opportunity to redefine our role. Embracing the challenges of AI-driven development, testers will also be indispensable participants and collaborators. Embrace AI, and embrace the future!&lt;/p></description></item><item><title>A New Trend in Using AI - From Prompt Engineering to Context Engineering</title><link>https://chengxiaqiucao.github.io/en/post/111-context_engineering/</link><pubDate>Mon, 14 Jul 2025 15:58:57 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/111-context_engineering/</guid><description>&lt;h2 id="preface">Preface
&lt;/h2>&lt;p>With the explosion of large AI models, &lt;strong>prompt engineering&lt;/strong> was once the most important and most essential technique for users to apply AI and bring its capabilities into play. But now, building on &amp;ldquo;prompt engineering,&amp;rdquo; a broader and more powerful evolved concept has been proposed—the &amp;ldquo;&lt;strong>Context Engineering&lt;/strong>&amp;rdquo; we are introducing in this article.&lt;/p>
&lt;p>Especially this year, with the explosion of AI Agents, when applying AI it has become increasingly important to effectively pass the right information into AI&amp;rsquo;s &amp;ldquo;limited memory space.&amp;rdquo; Very often, poor results from calling an AI Agent are not due to any weakness of the large model itself, but rather to a deficiency in the quality of the &lt;strong>context&lt;/strong>.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/111-context_engineering/Pasted-20250715-1_hu_ccc62d617b0cf5b4.webp"
width="1024"
height="555"
srcset="https://chengxiaqiucao.github.io/post/111-context_engineering/Pasted-20250715-1_hu_99f3f429464100d3.webp 480w, https://chengxiaqiucao.github.io/post/111-context_engineering/Pasted-20250715-1_hu_ccc62d617b0cf5b4.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="184"
data-flex-basis="442px"
>
&lt;/p>
&lt;h2 id="the-limitations-of-prompt-engineering">The Limitations of Prompt Engineering
&lt;/h2>&lt;p>&lt;strong>Prompt engineering&lt;/strong> can improve a model&amp;rsquo;s output quality by optimizing the text fed into the model.&lt;/p>
&lt;p>But as more and more Agents join in and application scenarios grow increasingly complex, relying on prompts alone makes it ever harder for large models to effectively complete increasingly complex tasks.&lt;/p>
&lt;p>For example, to build an AI-powered intelligent test case system, the following information is also needed in the process of using the large model:&lt;/p>
&lt;ul>
&lt;li>The original requirements documents and interface (API) documentation&lt;/li>
&lt;li>The system&amp;rsquo;s architectural design, database, and system framework&lt;/li>
&lt;li>The status of the various application interfaces&lt;/li>
&lt;li>Invocations of external tools such as test case management, document management, and automated testing&lt;/li>
&lt;/ul>
&lt;p>These requirements can hardly be fulfilled merely by passing prompts to the large model and its corresponding Agent.&lt;/p>
&lt;p>This is the greatest limitation of prompt engineering: &lt;strong>the lack of context understanding and state management capabilities&lt;/strong>.&lt;/p>
&lt;h2 id="what-is-context-engineering">What Is Context Engineering?
&lt;/h2>&lt;p>To understand &amp;ldquo;context engineering,&amp;rdquo; we must first clarify what &lt;strong>context&lt;/strong> is.&lt;/p>
&lt;p>Compared with a prompt, &lt;strong>context&lt;/strong> is not merely the single prompt we pass to the large model; it can be understood as &lt;strong>everything the large model sees before it returns a result&lt;/strong>.&lt;/p>
&lt;p>In summary, &lt;strong>context&lt;/strong> includes the following:&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/111-context_engineering/Pasted-20250714_hu_dc08a81cedc8595b.webp"
width="1024"
height="849"
srcset="https://chengxiaqiucao.github.io/post/111-context_engineering/Pasted-20250714_hu_960680e037ad5d36.webp 480w, https://chengxiaqiucao.github.io/post/111-context_engineering/Pasted-20250714_hu_dc08a81cedc8595b.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="120"
data-flex-basis="289px"
>
&lt;/p>
&lt;h3 id="background--system-prompt-instructions--system-prompt">Background / System Prompt (**Instructions / System Prompt)
&lt;/h3>&lt;p>This is the initial agreement between the user and the large model throughout the entire session. It includes the agreed background, the role the model plays, its expected behavior, and so on. It can be constrained through some examples and rule definitions.&lt;/p>
&lt;p>For example, in the AI-based test case generation tool we introduced earlier, the system prompt might specify&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;span class="lnt">8
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">你是一个资深测试开发专家，负责根据用户提供的接口文档，调用本地配置的AI大模型，生成一组详细的测试用例。
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">你需要确保每个测试用例都具有明确的目标、输入参数、预期结果。
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">请按照指定格式输出JSON数组，每个条目包括：
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- test_case_id: 测试用例编号
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- description: 测试描述
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- input_params: 输入参数
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- expected_output: 预期输出
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- priority: 优先级（1-5）
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="user-prompt">User Prompt
&lt;/h3>&lt;p>The user prompt, in contrast to the system prompt which applies to the entire session, is the instruction or question the user currently gives to the large model.&lt;/p>
&lt;p>It is in fact the main application of prompt engineering mentioned earlier—by optimizing how user prompts are written, one can communicate more effectively with AI.&lt;/p>
&lt;p>As in the example above, in the process of AI-assisted development, it is the specific development task we submit to AI.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">根据之前生成的项目代码结构，完成数据库创建部分的脚本，并注入部分调试数据。
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="state-and-conversation-history-short-term-memory">State and Conversation History (Short-Term Memory)
&lt;/h3>&lt;p>This mainly refers to the conversation history and the intermediate results generated during the current session.&lt;/p>
&lt;p>For example, during script development, the completed code files, the errors that appear when the program runs, and other such information.&lt;/p>
&lt;h3 id="long-term-memory">Long-Term Memory
&lt;/h3>&lt;p>This contains more durable background knowledge, including information collected from multiple previous conversations, such as learned user preferences, summaries of past projects, or information provided by the user for future use.&lt;/p>
&lt;p>As in the development process above, this includes the project&amp;rsquo;s requirements documents, architectural design, database structure, test data, and other information.&lt;/p>
&lt;h3 id="rag-retrieval-augmented-generation">RAG (Retrieval-augmented generation)
&lt;/h3>&lt;p>RAG provides the model with additional relevant information through vector databases, knowledge base retrieval, and other means. It enables the model to consult the latest, relevant context when answering questions, instead of relying on knowledge from its training.&lt;/p>
&lt;h3 id="structured-output">Structured Output
&lt;/h3>&lt;p>To make model output more controllable and parseable, and easier for Agents to handle, we usually need to define an output format—such as a JSON Schema or a specific field structure—to improve result consistency.&lt;/p>
&lt;p>For example, the system prompt above explicitly requires the model to output a JSON object containing the relevant fields.&lt;/p>
&lt;h3 id="available-tools">Available Tools
&lt;/h3>&lt;p>Through Agents or MCP, the large model can invoke tool capabilities, such as automated testing tools (Playwright), CI/CD continuous integration systems, and so on.&lt;/p>
&lt;h2 id="the-keys-to-using-context-engineering">The Keys to Using Context Engineering
&lt;/h2>&lt;p>✅ Context is not a string, but a system&lt;/p>
&lt;p>Context is system logic that runs before the LLM call; it dynamically assembles all relevant information rather than being a static template.&lt;/p>
&lt;p>✅ Context is dynamic&lt;/p>
&lt;p>Before each LLM call, context must be dynamically prepared according to the current task—for example, injecting the current date, user preferences, project configuration, and so on.&lt;/p>
&lt;p>✅ Context emphasizes the precise matching of information and tools&lt;/p>
&lt;p>One cannot simply pile up information; instead, the most relevant knowledge and capabilities must be provided at the right time. For example, inject a database connection tool only when it is needed.&lt;/p>
&lt;p>✅ Format determines output quality&lt;/p>
&lt;p>How information is presented matters. A concise summary is better than raw data, and a clear tool schema is more useful than vague instructions.&lt;/p>
&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;p>The tech industry produces new terms and new concepts every so often, and we have grown used to it. Although &amp;ldquo;&lt;strong>Context Engineering&lt;/strong>&amp;rdquo; differs from &amp;ldquo;&lt;strong>prompt engineering&lt;/strong>&amp;rdquo; at the conceptual level, their starting point and goal are in fact the same—to enable more effective communication between users and AI. In essence, this is in line with the explanation in our earlier article【】.&lt;/p>
&lt;p>It is not really a brand-new technology; we can simply understand it as a technique for using AI!&lt;/p></description></item><item><title>Collaborating with AI, the Focus Is Still Communication — A Detailed Look at Communicating with AI More Effectively</title><link>https://chengxiaqiucao.github.io/en/post/106-%E5%92%8Cai%E6%B2%9F%E9%80%9A/</link><pubDate>Wed, 02 Jul 2025 21:46:47 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/106-%E5%92%8Cai%E6%B2%9F%E9%80%9A/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/106-%E5%92%8Cai%E6%B2%9F%E9%80%9A/logo.webp" alt="Featured image of post Collaborating with AI, the Focus Is Still Communication — A Detailed Look at Communicating with AI More Effectively" />&lt;h2 id="preface">Preface
&lt;/h2>&lt;p>In my previous article 【】, we explored the central role of communication in team collaboration. Nowadays AI is being applied ever more broadly; in particular, the powerful capabilities of generative AI mean that a great deal of work can actually be accomplished with AI&amp;rsquo;s help. From AI browsers and coding assistants to workflow engines and integrations with various MCPs, AI is increasingly participating in our daily work.&lt;/p>
&lt;p>And completing work with the help of AI is, in essence, another form of team collaboration — except that here the collaborator is AI. So in collaborating with AI, the core is still communication.&lt;/p>
&lt;p>From this perspective, this article considers how to communicate and collaborate with AI more effectively.&lt;/p>
&lt;h2 id="the-johari-communication-window">The Johari Communication Window
&lt;/h2>&lt;p>In team collaboration, there is an important model and tool — the &lt;strong>Johari Communication Window&lt;/strong> we introduced earlier.&lt;/p>
&lt;p>In this window, we divide things into four quadrants according to the level of awareness held by the communication partner and by ourselves. Only by understanding which quadrant each party is in during a conversation can we communicate well.&lt;/p>
&lt;p>When we collaborate with AI, we can likewise define such a communication-window model:&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/106-%E5%92%8Cai%E6%B2%9F%E9%80%9A/Pasted-20250705_hu_fa7e7a47cfd5e8d.webp"
width="1024"
height="577"
srcset="https://chengxiaqiucao.github.io/post/106-%E5%92%8Cai%E6%B2%9F%E9%80%9A/Pasted-20250705_hu_148d14c4245577f9.webp 480w, https://chengxiaqiucao.github.io/post/106-%E5%92%8Cai%E6%B2%9F%E9%80%9A/Pasted-20250705_hu_fa7e7a47cfd5e8d.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="177"
data-flex-basis="425px"
>
&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>Open Zone&lt;/strong> — this area corresponds to information that both we and AI already possess and understand; it can be considered the shared ground between the two sides. For example, when communicating with AI we often preset a role or identity for it — such instructions belong to the Open Zone. Or, having already drafted an article, we ask AI to polish it on that basis. Both are typical examples of communicating in the Open Zone.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Blind Spot Zone&lt;/strong> — here is information we do not possess ourselves, but which AI, with its rich knowledge base, can provide to us. In this area AI is like a teacher — but a passive one, relying on us to ask questions actively to obtain knowledge. The ability to ask good questions is the key to communicating in this zone.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Unknown Zone&lt;/strong> — this area covers information that we are unclear about and that AI has not yet mastered. Communication in this zone is more like co-creating with AI — brainstorming together to explore information in unknown territory.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Hidden Zone&lt;/strong> — in this area, the information is mostly our private-domain information that AI cannot access on its own. For instance, if we simply give AI the instruction &lt;code>please help me output this week's work report&lt;/code>, AI has no way to start. So communication in this area means fully providing AI with the contextual information it needs — feeding private-domain information to AI. Things like project background, internal processes, and local data from our work — only once AI has learned and mastered this information can it go on to assist with subsequent tasks.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h2 id="communication-techniques-for-ai-in-different-quadrants">Communication Techniques for AI in Different Quadrants
&lt;/h2>&lt;p>Based on the four distinct zones defined by the window model above, we can think about the key points of communication when collaborating with AI — that is, how to use prompts better so that AI delivers results more closely aligned with our needs.&lt;/p>
&lt;h3 id="communicating-in-the-open-zone">Communicating in the Open Zone
&lt;/h3>&lt;p>In this zone, because both sides already hold the relevant information, the main thing is to make the boundaries of the Open Zone clear to AI. The clearer and more specific the information you specify, the more closely AI&amp;rsquo;s results will match our needs. So in this zone, what matters more is issuing &lt;strong>clear tasks&lt;/strong>. You should also avoid gilding the lily — vague prompt instructions can instead cause the results to diverge.&lt;/p>
&lt;p>For example:&lt;/p>
&lt;p>&lt;code>You are a senior software test engineer, proficient in test automation, familiar with Python, and familiar with various testing tools.&lt;/code>&lt;/p>
&lt;p>&lt;code>Accurately translate the English document in the attachment and return the translated content in Markdown format, without including any information that is not part of the target content&lt;/code> is better than &lt;code>Translate the attached English document in a witty, lively style that rides current internet trends&lt;/code> — it preserves the key points of the original content without adding a lot of extra material that may not be appropriate, and the returned content can be generated directly in the format we need.&lt;/p>
&lt;h3 id="communicating-in-the-blind-spot-zone">Communicating in the Blind Spot Zone
&lt;/h3>&lt;p>The Blind Spot Zone is the area where leveraging AI&amp;rsquo;s capabilities can most easily help us improve ourselves. Through AI, we fill gaps in our knowledge and eliminate our blind spots.&lt;/p>
&lt;p>In this area, the key to communicating efficiently with AI is the ability to ask questions. For relatively complex information, we can proceed step by step, asking progressive questions, so that AI gradually builds a complete knowledge system, identifies our blind spots, and strengthens them. In prompt engineering, there is a dedicated technical term for this — &lt;strong>Chain-of-Thought (COT)&lt;/strong> — which can guide AI to think progressively and step by step to arrive at the knowledge we truly need.&lt;/p>
&lt;p>For this, you can also refer to the &lt;strong>5 Whys technique&lt;/strong> we introduced earlier, gradually focusing on the root cause of a problem.&lt;/p>
&lt;p>For example, if we want to master the POM model in test automation and actually solve specific problems in implementation, we can ask questions step by step to focus on solving real problems:&lt;/p>
&lt;ul>
&lt;li>&lt;code>What is the POM model?&lt;/code>&lt;/li>
&lt;li>&lt;code>In which scenarios of test automation is the POM model more suitable?&lt;/code>&lt;/li>
&lt;li>&lt;code>For the login scenario of a web portal site such as www.saucedemo.com, give an example of implementing POM in Python and explain the key points&lt;/code>&lt;/li>
&lt;li>&lt;code>In the above example, what other general approaches are suitable for unified encapsulation, such as element identification and driver definition?&lt;/code>&lt;/li>
&lt;/ul>
&lt;h3 id="communicating-in-the-unknown-zone">Communicating in the Unknown Zone
&lt;/h3>&lt;p>The Unknown Zone is content that neither we nor AI has mastered. This is more about innovative scenarios, where through continuous iteration and brainstorming with AI we gradually discover what we truly need.&lt;/p>
&lt;p>For example, when using an AI coding assistant to help develop an application, we may only have sketched out the basic functions. AI will help generate the application interface based on the information provided, and we in turn will have further ideas for improvement based on that interface. Through such continuous communication and iteration, we ultimately complete a software product with good usability.&lt;/p>
&lt;p>So the emphasis of communication here is &lt;strong>co-innovation and continuous iteration&lt;/strong>.&lt;/p>
&lt;h3 id="communicating-in-the-hidden-zone">Communicating in the Hidden Zone
&lt;/h3>&lt;p>The Hidden Zone is beyond the reach of AI&amp;rsquo;s current capabilities; it often has to be completed based on internal information and local data. To make good use of AI in such cases, we need to build a sufficiently informative context — feeding our local information and data to AI, letting it digest them, and making up for the part of the information it does not know. Once communication moves from the Hidden Zone to the Open Zone, we can issue clear tasks to have things handled.&lt;/p>
&lt;p>The key to communication in this area is actually to give AI the ability to reach knowledge blind spots through approaches such as RAG, model fine-tuning, building a local knowledge base, or exposing local capability calls via MCP.&lt;/p>
&lt;p>The focus of communication in this area is to fully provide AI with background and related information it does not yet understand, so that after &lt;strong>feeding and digesting information&lt;/strong> the purpose of normal collaboration can be achieved.&lt;/p>
&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;p>When we want to treat AI as a collaborator that can genuinely help us, we should establish good communication with that collaborator. The Johari Window provides a sound communication model that can offer good guidance in helping us make effective use of AI.&lt;/p>
&lt;hr></description></item><item><title>Will MCP Fail? Questions About MCP</title><link>https://chengxiaqiucao.github.io/en/post/105-mcp_must_fail/</link><pubDate>Sun, 29 Jun 2025 21:25:34 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/105-mcp_must_fail/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/105-mcp_must_fail/Pasted-20250629.webp" alt="Featured image of post Will MCP Fail? Questions About MCP" />&lt;blockquote>
&lt;p>&lt;strong>Model-Context Protocol (MCP&lt;/strong> has attracted widespread attention and rapid adoption since its launch. A large number of AI tools now support MCP. (For a detailed introduction to MCP, see my previous article【】) But as MCP has risen to prominence, doubts about it have gradually begun to emerge—for example, concerns about its security limitations (see my previous article【】). Recently, Edgenesis founder Yongli, Chen also published an article arguing that MCP is destined to fail. Here I have organized his main points into this article (see the link at the end for the original), so that you may use them as a reference and form your own judgment.&lt;/p>&lt;/blockquote>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/105-mcp_must_fail/Pasted-20250629_hu_e9f2634ec35fe931.webp"
width="1024"
height="576"
srcset="https://chengxiaqiucao.github.io/post/105-mcp_must_fail/Pasted-20250629_hu_5d057b90ccc7264f.webp 480w, https://chengxiaqiucao.github.io/post/105-mcp_must_fail/Pasted-20250629_hu_e9f2634ec35fe931.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="177"
data-flex-basis="426px"
>
&lt;/p>
&lt;h2 id="introduction">Introduction
&lt;/h2>&lt;p>&lt;strong>Model-Context Protocol (MCP)&lt;/strong> has been in the spotlight since its very inception. It has been hailed as a universal standard aimed at seamless integration between artificial intelligence (AI) models and all kinds of software tools. On the surface, the protocol does address a genuine industry pain point: &lt;strong>replacing today&amp;rsquo;s chaotic jumble of custom application programming interfaces (APIs) and proprietary plugins with one simple, standard solution&lt;/strong>. MCP&amp;rsquo;s proponents paint a future in which AI agents can effortlessly connect to countless applications without tedious custom integration.&lt;/p>
&lt;p>Yet for all its technical elegance and the enormous attention it drew early on, MCP is destined to struggle. This is not due to any technical defect, but because it fundamentally misunderstands a crucial economic reality: in the digital business landscape, end-user attention is the key to commercial success.&lt;/p>
&lt;p>Every company will go to great lengths to guard user attention, because it is their primary source of monetization. Tool vendors therefore simply cannot afford the price of reducing themselves to mere backend functions by adopting MCP across the board.&lt;/p>
&lt;h2 id="the-real-battleground---ownership-of-attention">The Real Battleground - Ownership of Attention
&lt;/h2>&lt;p>To understand why MCP faces resistance, we must first consider a basic fact: &lt;strong>whoever controls the user interface controls the user relationship&lt;/strong>. A company that owns the interface thereby owns user engagement, data, and the revenue opportunities that arise from them. Services relegated to the backend, by contrast, become freely replaceable commodities—not only easy to substitute, but also stripped of any direct contact with their customers.&lt;/p>
&lt;p>History has repeatedly proved this law. Facebook, for example, built its business empire precisely by turning third-party applications into pure content providers. The early social-gaming giant Zynga learned this lesson the hard way. When Facebook changed its platform rules and tightened restrictions, the visibility of Zynga&amp;rsquo;s games plummeted. Zynga&amp;rsquo;s fate was sealed, because Facebook held a firm grip on user attention and thus dictated Zynga&amp;rsquo;s revenue and customer interaction.&lt;/p>
&lt;p>Similarly, Twitter blocked third-party clients because these clients allowed users to bypass Twitter&amp;rsquo;s advertising system, which amounted to &amp;ldquo;stealing&amp;rdquo; the platform&amp;rsquo;s user attention. Apple&amp;rsquo;s attitude toward web apps is another highly persuasive example: for years, Apple deliberately limited the functionality of web apps on iOS to ensure that native apps in the App Store stayed dominant, thereby preserving Apple&amp;rsquo;s direct relationship with users and its revenue streams.&lt;/p>
&lt;h2 id="mcps-naive-proposal">MCP&amp;rsquo;s Naive Proposal
&lt;/h2>&lt;p>MCP is, in effect, asking software vendors to voluntarily accept a new model: &lt;strong>turning their core functionality into simple backend services accessed primarily through AI-driven interfaces&lt;/strong>.&lt;/p>
&lt;p>Imagine a future in which booking a trip is done entirely through an AI assistant that interacts invisibly behind the scenes with airlines, hotels, and travel agencies via MCP. In this model, the interface—the point of user contact and decision-making—belongs entirely to the AI assistant, leaving the vendors unable to reach user attention directly.&lt;/p>
&lt;p>This effectively demotes vendors from &amp;ldquo;destinations&amp;rdquo; with differentiated brands and customer loyalty to standardized &amp;ldquo;utilities.&amp;rdquo; Such a shift would seriously threaten the core ability of vendors to capture value.&lt;/p>
&lt;p>Software-as-a-Service (SaaS) and tool vendors rely heavily on direct interaction with users to monetize their businesses—for example, upselling value-added features, crafting branded experiences, and collecting valuable user data.&lt;/p>
&lt;p>Once they fully embrace MCP, these vendors hand the user interface over to external AI aggregators, inevitably losing their customer relationships and direct monetization channels.&lt;/p>
&lt;h2 id="evidence-from-the-current-ai-ecosystem">Evidence from the Current AI Ecosystem
&lt;/h2>&lt;p>In reality, major software companies have behaved very cautiously in handling their relationships with AI-driven platforms such as OpenAI&amp;rsquo;s &lt;strong>ChatGPT&lt;/strong> and Anthropic&amp;rsquo;s &lt;strong>Claude&lt;/strong>.&lt;/p>
&lt;p>Whether Salesforce, Microsoft, or Google, all of them are seeking to embed AI capabilities deeply into their own proprietary interfaces, rather than allowing their tools to be fully invoked by external AI agents.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/105-mcp_must_fail/Pasted-20250629-1_hu_1c27de0fc4a773cd.webp"
width="1024"
height="686"
srcset="https://chengxiaqiucao.github.io/post/105-mcp_must_fail/Pasted-20250629-1_hu_a8f15bf055ce4acc.webp 480w, https://chengxiaqiucao.github.io/post/105-mcp_must_fail/Pasted-20250629-1_hu_1c27de0fc4a773cd.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="149"
data-flex-basis="358px"
>
&lt;/p>
&lt;p>For example, Einstein GPT from Salesforce integrates AI directly into its customer relationship management (CRM) system, locking users firmly inside its own ecosystem. Similarly, Microsoft has prioritized deeply embedding Copilot AI into the Office and Windows environments. When tool vendors do attempt external AI integration, they usually provide only limited functionality—enough to attract users, but not enough to fully replace their own interfaces. A travel app, for instance, might let an AI assistant browse flight information, but will ultimately steer users back to its own platform to complete the booking, so as to preserve the crucial customer interaction and upselling opportunity.&lt;/p>
&lt;h2 id="mcp-is-bound-to-face-difficulties">MCP Is Bound to Face Difficulties
&lt;/h2>&lt;p>Past experience clearly reveals why MCP has struggled to gain widespread adoption—especially since the large software vendors that dominate market attention could never pivot fully to MCP.&lt;/p>
&lt;p>If these vendors truly believed it was worthwhile to give up user attention in exchange for open integration, they would have long since offered fully featured public APIs for free. The opposite is true: they typically build tightly controlled ecosystems, attracting new users through selective integration, and would never voluntarily surrender control over the user experience or revenue.&lt;/p>
&lt;p>This careful balancing act highlights MCP&amp;rsquo;s fundamental flaw: no matter how elegant or superior a protocol may be on the technical side, software vendors have no incentive to hand their precious customer relationships and monetization capabilities over to external aggregators.&lt;/p>
&lt;h2 id="platform-economics-is-the-foundation-of-technology">Platform Economics Is the Foundation of Technology
&lt;/h2>&lt;p>Ultimately, what decides MCP&amp;rsquo;s fate is not its technical merits or demerits, but commercial incentives and the dynamics of platform economics. Platform owners will inevitably find ways to protect their core asset—the direct connection with users. The approach MCP proposes fundamentally upends this dynamic, setting it against deeply entrenched economic incentives.&lt;/p>
&lt;p>In practice, MCP may gain limited adoption among some smaller vendors or niche communities where openness itself has intrinsic value. Among the mainstream SaaS vendors and large platforms that dominate today&amp;rsquo;s digital economy, however, adopting MCP is at best more about extending one&amp;rsquo;s own reach than exposing one&amp;rsquo;s own capabilities.&lt;/p>
&lt;p>In essence, although MCP aspires to become a universal standard, it faces a harsh economic reality: no company wants to resign itself to becoming an invisible backdrop. Every company will fight tooth and nail to defend its control over the user interface (that is, &lt;strong>control of the user relationship&lt;/strong>) and to limit any integration that might threaten its strategic position.&lt;/p>
&lt;h3 id="conclusion">Conclusion
&lt;/h3>&lt;p>The vision of seamless, universal AI integration painted by MCP is undeniably compelling, but in the business world, striking technology alone rarely decides success or failure.&lt;/p>
&lt;p>The battle over standards is ultimately a battle over economic power. MCP&amp;rsquo;s design challenges the very incentive structures that have driven the digital economy for decades. It is precisely for this reason that MCP faces enormous obstacles on the road to widespread adoption.&lt;/p>
&lt;p>Until it can better align with platform economics and vendors&amp;rsquo; inherent incentives, MCP&amp;rsquo;s ambition to become the universal standard for AI-tool integration is likely to remain a distant dream.&lt;/p>
&lt;p>Original article link:
&lt;a class="link" href="https://www.forbes.com/councils/forbestechcouncil/2025/06/12/mcp-will-fail-and-heres-why/" target="_blank" rel="noopener"
>https://www.forbes.com/councils/forbestechcouncil/2025/06/12/mcp-will-fail-and-heres-why/&lt;/a>&lt;/p></description></item><item><title>The Sky Is Falling for Cursor - Google Open-Sources Gemini-cli, the Ultimate Overachiever of Coding Assistants Is Here</title><link>https://chengxiaqiucao.github.io/en/post/102-gemini-cli/</link><pubDate>Thu, 26 Jun 2025 13:21:59 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/102-gemini-cli/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/102-gemini-cli/Pasted-20250626.webp" alt="Featured image of post The Sky Is Falling for Cursor - Google Open-Sources Gemini-cli, the Ultimate Overachiever of Coding Assistants Is Here" />&lt;h2 id="preface">Preface
&lt;/h2>&lt;p>Yesterday (2025-6-25), Google made a big splash by open-sourcing a command-line-based AI coding Agent, &lt;code>Gemini-Cli&lt;/code>, which deeply integrates AI-assisted programming into the Terminal command-line interface that developers know best. It also directly incorporates Google&amp;rsquo;s latest &lt;code>Gemini 2.5 Pro&lt;/code> capabilities, free for developers to use (with a cap, but a generous one). In just one day, it shot up to 20K stars on GitHub, a clear sign of just how enthusiastic developers are about this tool!!&lt;/p>
&lt;p>Open-source project address: &lt;a class="link" href="https://github.com/google-gemini/gemini-cli" target="_blank" rel="noopener"
>https://github.com/google-gemini/gemini-cli&lt;/a>&lt;/p>
&lt;p>The star history, a terrifying vertical climb 😂&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/102-gemini-cli/Pasted-20250626-4_hu_9ba2719d9e18f57f.webp"
width="1024"
height="620"
srcset="https://chengxiaqiucao.github.io/post/102-gemini-cli/Pasted-20250626-4_hu_ca39a5294cde2743.webp 480w, https://chengxiaqiucao.github.io/post/102-gemini-cli/Pasted-20250626-4_hu_9ba2719d9e18f57f.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="165"
data-flex-basis="396px"
>
&lt;/p>
&lt;p>Below we bring you an out-of-the-box hands-on experience!&lt;/p>
&lt;h2 id="installation">Installation
&lt;/h2>&lt;p>Installing &lt;code>Gemini-Cli&lt;/code> is very convenient. It depends on &lt;code>node.js&lt;/code>; make sure Node.js 18 or above is installed on your machine, then simply run:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">npx https://github.com/google-gemini/gemini-cli
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Or install it with npm and then run &lt;code>gemini&lt;/code>&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">npm install -g @google/gemini-cli
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">gemini
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>This brings you to the command-line startup screen:&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/102-gemini-cli/Pasted-20250626_hu_901185c6c0de428e.webp"
width="1024"
height="569"
srcset="https://chengxiaqiucao.github.io/post/102-gemini-cli/Pasted-20250626_hu_adad402076698165.webp 480w, https://chengxiaqiucao.github.io/post/102-gemini-cli/Pasted-20250626_hu_901185c6c0de428e.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="180"
data-flex-basis="432px"
>
&lt;/p>
&lt;p>Pick a coding theme you like, and you will then be prompted to authenticate; usually you can simply sign in with your Google account. Once authorization shows the following information, you can continue using it.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/102-gemini-cli/Pasted-20250626-1_hu_86837983014c8082.webp"
width="1024"
height="454"
srcset="https://chengxiaqiucao.github.io/post/102-gemini-cli/Pasted-20250626-1_hu_89fd95b2ff82e500.webp 480w, https://chengxiaqiucao.github.io/post/102-gemini-cli/Pasted-20250626-1_hu_86837983014c8082.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="225"
data-flex-basis="540px"
>
&lt;/p>
&lt;p>After authorization, you have access to a number of large AI models by default, including Gemini 25 pro, and it &amp;ldquo;lavishly&amp;rdquo; provides &lt;strong>60 requests per minute and 1,000 per day&lt;/strong> of AI calls. Compared with many other large models that still impose limits by token count, this is genuinely generous! Compared with &lt;code>Cursor&lt;/code>&amp;rsquo;s paid tier, which caps usage at 500 requests per month, Cursor must be crying in the bathroom by now~~&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/102-gemini-cli/Pasted-20250626-2_hu_b11c4ab5019493ba.webp"
width="1024"
height="533"
srcset="https://chengxiaqiucao.github.io/post/102-gemini-cli/Pasted-20250626-2_hu_b24c6619c8c4fc3e.webp 480w, https://chengxiaqiucao.github.io/post/102-gemini-cli/Pasted-20250626-2_hu_b11c4ab5019493ba.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="192"
data-flex-basis="461px"
>
&lt;/p>
&lt;h2 id="hands-on-results">Hands-on Results
&lt;/h2>&lt;p>Without further ado, as a testing professional, I first asked it to help build an AI-based test case generation tool.&lt;/p>
&lt;p>The instruction I gave is as follows&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-gdscript3" data-lang="gdscript3">&lt;span class="line">&lt;span class="cl">&lt;span class="n">Write&lt;/span> &lt;span class="n">a&lt;/span> &lt;span class="n">web&lt;/span> &lt;span class="n">program&lt;/span> &lt;span class="n">that&lt;/span> &lt;span class="n">supports&lt;/span> &lt;span class="n">uploading&lt;/span> &lt;span class="n">a&lt;/span> &lt;span class="n">requirements&lt;/span> &lt;span class="n">document&lt;/span> &lt;span class="ow">and&lt;/span> &lt;span class="n">calls&lt;/span> &lt;span class="n">AI&lt;/span> &lt;span class="n">capabilities&lt;/span> &lt;span class="n">to&lt;/span> &lt;span class="nb">convert&lt;/span> &lt;span class="n">it&lt;/span> &lt;span class="n">into&lt;/span> &lt;span class="n">test&lt;/span> &lt;span class="n">cases&lt;/span>&lt;span class="o">.&lt;/span> &lt;span class="n">The&lt;/span> &lt;span class="n">cases&lt;/span> &lt;span class="n">are&lt;/span> &lt;span class="n">displayed&lt;/span> &lt;span class="n">on&lt;/span> &lt;span class="n">the&lt;/span> &lt;span class="n">page&lt;/span> &lt;span class="ow">in&lt;/span> &lt;span class="n">table&lt;/span> &lt;span class="n">form&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">with&lt;/span> &lt;span class="n">fields&lt;/span> &lt;span class="n">including&lt;/span> &lt;span class="n">Case&lt;/span> &lt;span class="n">ID&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">Case&lt;/span> &lt;span class="n">Name&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">Description&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">Test&lt;/span> &lt;span class="n">Steps&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">Priority&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">Pass&lt;/span> &lt;span class="n">Criteria&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">Associated&lt;/span> &lt;span class="n">Requirement&lt;/span> &lt;span class="n">ID&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="n">optional&lt;/span>&lt;span class="p">),&lt;/span> &lt;span class="n">etc&lt;/span>&lt;span class="o">.&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Very quickly, after a brief analysis, it produced an implementation plan.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/102-gemini-cli/Pasted-20250626-5_hu_f2097fe25442f51d.webp"
width="1024"
height="606"
srcset="https://chengxiaqiucao.github.io/post/102-gemini-cli/Pasted-20250626-5_hu_22ed59e752fe3f16.webp 480w, https://chengxiaqiucao.github.io/post/102-gemini-cli/Pasted-20250626-5_hu_f2097fe25442f51d.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="168"
data-flex-basis="405px"
>
&lt;/p>
&lt;p>As the actual work began, it automatically created the relevant code files and guided me step by step to complete everything from data mocking to real AI capability integration.&lt;/p>
&lt;p>After more than half an hour of collaboration (mostly pasting error messages back to it whenever errors came up), we finally succeeded in building a basic AI test case generation tool.&lt;/p>
&lt;p>For example, I uploaded the requirements &lt;code>req-sprint0.md&lt;/code> from a testing practice site I had open-sourced earlier:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt"> 10
&lt;/span>&lt;span class="lnt"> 11
&lt;/span>&lt;span class="lnt"> 12
&lt;/span>&lt;span class="lnt"> 13
&lt;/span>&lt;span class="lnt"> 14
&lt;/span>&lt;span class="lnt"> 15
&lt;/span>&lt;span class="lnt"> 16
&lt;/span>&lt;span class="lnt"> 17
&lt;/span>&lt;span class="lnt"> 18
&lt;/span>&lt;span class="lnt"> 19
&lt;/span>&lt;span class="lnt"> 20
&lt;/span>&lt;span class="lnt"> 21
&lt;/span>&lt;span class="lnt"> 22
&lt;/span>&lt;span class="lnt"> 23
&lt;/span>&lt;span class="lnt"> 24
&lt;/span>&lt;span class="lnt"> 25
&lt;/span>&lt;span class="lnt"> 26
&lt;/span>&lt;span class="lnt"> 27
&lt;/span>&lt;span class="lnt"> 28
&lt;/span>&lt;span class="lnt"> 29
&lt;/span>&lt;span class="lnt"> 30
&lt;/span>&lt;span class="lnt"> 31
&lt;/span>&lt;span class="lnt"> 32
&lt;/span>&lt;span class="lnt"> 33
&lt;/span>&lt;span class="lnt"> 34
&lt;/span>&lt;span class="lnt"> 35
&lt;/span>&lt;span class="lnt"> 36
&lt;/span>&lt;span class="lnt"> 37
&lt;/span>&lt;span class="lnt"> 38
&lt;/span>&lt;span class="lnt"> 39
&lt;/span>&lt;span class="lnt"> 40
&lt;/span>&lt;span class="lnt"> 41
&lt;/span>&lt;span class="lnt"> 42
&lt;/span>&lt;span class="lnt"> 43
&lt;/span>&lt;span class="lnt"> 44
&lt;/span>&lt;span class="lnt"> 45
&lt;/span>&lt;span class="lnt"> 46
&lt;/span>&lt;span class="lnt"> 47
&lt;/span>&lt;span class="lnt"> 48
&lt;/span>&lt;span class="lnt"> 49
&lt;/span>&lt;span class="lnt"> 50
&lt;/span>&lt;span class="lnt"> 51
&lt;/span>&lt;span class="lnt"> 52
&lt;/span>&lt;span class="lnt"> 53
&lt;/span>&lt;span class="lnt"> 54
&lt;/span>&lt;span class="lnt"> 55
&lt;/span>&lt;span class="lnt"> 56
&lt;/span>&lt;span class="lnt"> 57
&lt;/span>&lt;span class="lnt"> 58
&lt;/span>&lt;span class="lnt"> 59
&lt;/span>&lt;span class="lnt"> 60
&lt;/span>&lt;span class="lnt"> 61
&lt;/span>&lt;span class="lnt"> 62
&lt;/span>&lt;span class="lnt"> 63
&lt;/span>&lt;span class="lnt"> 64
&lt;/span>&lt;span class="lnt"> 65
&lt;/span>&lt;span class="lnt"> 66
&lt;/span>&lt;span class="lnt"> 67
&lt;/span>&lt;span class="lnt"> 68
&lt;/span>&lt;span class="lnt"> 69
&lt;/span>&lt;span class="lnt"> 70
&lt;/span>&lt;span class="lnt"> 71
&lt;/span>&lt;span class="lnt"> 72
&lt;/span>&lt;span class="lnt"> 73
&lt;/span>&lt;span class="lnt"> 74
&lt;/span>&lt;span class="lnt"> 75
&lt;/span>&lt;span class="lnt"> 76
&lt;/span>&lt;span class="lnt"> 77
&lt;/span>&lt;span class="lnt"> 78
&lt;/span>&lt;span class="lnt"> 79
&lt;/span>&lt;span class="lnt"> 80
&lt;/span>&lt;span class="lnt"> 81
&lt;/span>&lt;span class="lnt"> 82
&lt;/span>&lt;span class="lnt"> 83
&lt;/span>&lt;span class="lnt"> 84
&lt;/span>&lt;span class="lnt"> 85
&lt;/span>&lt;span class="lnt"> 86
&lt;/span>&lt;span class="lnt"> 87
&lt;/span>&lt;span class="lnt"> 88
&lt;/span>&lt;span class="lnt"> 89
&lt;/span>&lt;span class="lnt"> 90
&lt;/span>&lt;span class="lnt"> 91
&lt;/span>&lt;span class="lnt"> 92
&lt;/span>&lt;span class="lnt"> 93
&lt;/span>&lt;span class="lnt"> 94
&lt;/span>&lt;span class="lnt"> 95
&lt;/span>&lt;span class="lnt"> 96
&lt;/span>&lt;span class="lnt"> 97
&lt;/span>&lt;span class="lnt"> 98
&lt;/span>&lt;span class="lnt"> 99
&lt;/span>&lt;span class="lnt">100
&lt;/span>&lt;span class="lnt">101
&lt;/span>&lt;span class="lnt">102
&lt;/span>&lt;span class="lnt">103
&lt;/span>&lt;span class="lnt">104
&lt;/span>&lt;span class="lnt">105
&lt;/span>&lt;span class="lnt">106
&lt;/span>&lt;span class="lnt">107
&lt;/span>&lt;span class="lnt">108
&lt;/span>&lt;span class="lnt">109
&lt;/span>&lt;span class="lnt">110
&lt;/span>&lt;span class="lnt">111
&lt;/span>&lt;span class="lnt">112
&lt;/span>&lt;span class="lnt">113
&lt;/span>&lt;span class="lnt">114
&lt;/span>&lt;span class="lnt">115
&lt;/span>&lt;span class="lnt">116
&lt;/span>&lt;span class="lnt">117
&lt;/span>&lt;span class="lnt">118
&lt;/span>&lt;span class="lnt">119
&lt;/span>&lt;span class="lnt">120
&lt;/span>&lt;span class="lnt">121
&lt;/span>&lt;span class="lnt">122
&lt;/span>&lt;span class="lnt">123
&lt;/span>&lt;span class="lnt">124
&lt;/span>&lt;span class="lnt">125
&lt;/span>&lt;span class="lnt">126
&lt;/span>&lt;span class="lnt">127
&lt;/span>&lt;span class="lnt">128
&lt;/span>&lt;span class="lnt">129
&lt;/span>&lt;span class="lnt">130
&lt;/span>&lt;span class="lnt">131
&lt;/span>&lt;span class="lnt">132
&lt;/span>&lt;span class="lnt">133
&lt;/span>&lt;span class="lnt">134
&lt;/span>&lt;span class="lnt">135
&lt;/span>&lt;span class="lnt">136
&lt;/span>&lt;span class="lnt">137
&lt;/span>&lt;span class="lnt">138
&lt;/span>&lt;span class="lnt">139
&lt;/span>&lt;span class="lnt">140
&lt;/span>&lt;span class="lnt">141
&lt;/span>&lt;span class="lnt">142
&lt;/span>&lt;span class="lnt">143
&lt;/span>&lt;span class="lnt">144
&lt;/span>&lt;span class="lnt">145
&lt;/span>&lt;span class="lnt">146
&lt;/span>&lt;span class="lnt">147
&lt;/span>&lt;span class="lnt">148
&lt;/span>&lt;span class="lnt">149
&lt;/span>&lt;span class="lnt">150
&lt;/span>&lt;span class="lnt">151
&lt;/span>&lt;span class="lnt">152
&lt;/span>&lt;span class="lnt">153
&lt;/span>&lt;span class="lnt">154
&lt;/span>&lt;span class="lnt">155
&lt;/span>&lt;span class="lnt">156
&lt;/span>&lt;span class="lnt">157
&lt;/span>&lt;span class="lnt">158
&lt;/span>&lt;span class="lnt">159
&lt;/span>&lt;span class="lnt">160
&lt;/span>&lt;span class="lnt">161
&lt;/span>&lt;span class="lnt">162
&lt;/span>&lt;span class="lnt">163
&lt;/span>&lt;span class="lnt">164
&lt;/span>&lt;span class="lnt">165
&lt;/span>&lt;span class="lnt">166
&lt;/span>&lt;span class="lnt">167
&lt;/span>&lt;span class="lnt">168
&lt;/span>&lt;span class="lnt">169
&lt;/span>&lt;span class="lnt">170
&lt;/span>&lt;span class="lnt">171
&lt;/span>&lt;span class="lnt">172
&lt;/span>&lt;span class="lnt">173
&lt;/span>&lt;span class="lnt">174
&lt;/span>&lt;span class="lnt">175
&lt;/span>&lt;span class="lnt">176
&lt;/span>&lt;span class="lnt">177
&lt;/span>&lt;span class="lnt">178
&lt;/span>&lt;span class="lnt">179
&lt;/span>&lt;span class="lnt">180
&lt;/span>&lt;span class="lnt">181
&lt;/span>&lt;span class="lnt">182
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-markdown" data-lang="markdown">&lt;span class="line">&lt;span class="cl">&lt;span class="gu">### Personal Book Management System - Iteration 1 Requirements Document
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gs">**Version**&lt;/span>: v1.0
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gs">**Goal**&lt;/span>: Implement basic create, read, update, and delete (CRUD) functions for personal books
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">---
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">#### **User Story 1 - Adding a Book**
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gs">**As a**&lt;/span> book collector
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gs">**I want to**&lt;/span> add a new book to my library
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gs">**So that**&lt;/span> I can keep a record of the books I own
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gs">**Acceptance Criteria (Given-When-Then):**&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">1.&lt;/span> &lt;span class="gs">**Successful Addition**&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *Given* the user is on the &amp;#34;Add Book&amp;#34; page
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *When* the required fields (Book Title, Author) are filled in and Submit is clicked
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *Then* the system saves the book, shows an &amp;#34;Added successfully&amp;#34; message, and navigates to the book list page
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">2.&lt;/span> &lt;span class="gs">**Addition Failed (Missing Validation)**&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *Given* the user has not filled in &amp;#34;Book Title&amp;#34; or &amp;#34;Author&amp;#34;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *When* the Submit button is clicked
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *Then* the system shows a red error message below the corresponding field
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">---
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">#### **User Story 2 - Viewing the Book List**
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gs">**As a**&lt;/span> book collector
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gs">**I want to**&lt;/span> view the list of all books
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gs">**So that**&lt;/span> I can quickly browse my collection
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gs">**Acceptance Criteria:**&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">1.&lt;/span> &lt;span class="gs">**Basic List Display**&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *Given* at least one book exists
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *When* the user visits the home page
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *Then* all books are shown in a table (including at least name, author, and reading status)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">2.&lt;/span> &lt;span class="gs">**Empty State Handling**&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *Given* there are no books
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *When* the user visits the home page
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *Then* a &amp;#34;No books yet, click to add&amp;#34; prompt and a navigation link are shown
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">---
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">#### **User Story 3 - Editing Book Information**
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gs">**As a**&lt;/span> book collector
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gs">**I want to**&lt;/span> edit book information
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gs">**So that**&lt;/span> I can update a book&amp;#39;s status or notes
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gs">**Acceptance Criteria:**&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">1.&lt;/span> &lt;span class="gs">**Successful Edit**&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *Given* the user enters a book&amp;#39;s &amp;#34;Edit&amp;#34; page from the list page
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *When* a field is modified (such as updating the reading status to &amp;#34;Read&amp;#34;) and submitted
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *Then* the system saves the changes, returns to the list page, and shows the updated data
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">2.&lt;/span> &lt;span class="gs">**Invalid Data Interception**&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *Given* the user enters letters in the price field
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *When* Submit is clicked
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *Then* the system blocks submission and shows &amp;#34;Please enter a valid number&amp;#34;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">---
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">#### **User Story 4 - Deleting a Book**
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gs">**As a**&lt;/span> book collector
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gs">**I want to**&lt;/span> delete books I no longer need
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gs">**So that**&lt;/span> my library stays tidy
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gs">**Acceptance Criteria:**&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">1.&lt;/span> &lt;span class="gs">**Deletion Operation**&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *Given* the user is on the book list page
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *When* a book&amp;#39;s &amp;#34;Delete&amp;#34; button is clicked
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *Then* the system removes the book and the list refreshes in real time
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">---
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">#### **User Story 5 - Searching Books**
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gs">**As a**&lt;/span> book collector
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gs">**I want to**&lt;/span> search books by name or author
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gs">**So that**&lt;/span> I can quickly locate the book I want
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gs">**Acceptance Criteria:**&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">1.&lt;/span> &lt;span class="gs">**Basic Search**&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *Given* the user types a keyword into the search box at the top of the list page
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *When* the &amp;#34;Search&amp;#34; button is clicked
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> *Then* the system shows books whose name or author matches (case-insensitive)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">---
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">### Field Definitions (Book Attributes)
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| Field | Type | Required | Description | Example |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">|--------------|----------|------|-------------------------------|----------------------|
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| Book Title | Text | ✓ | Book title (length ≤ 100 characters) | The Three-Body Problem |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| Author | Text | ✓ | Author name (length ≤ 50 characters) | Liu Cixin |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| Synopsis | Long Text | ✗ | Book description (length ≤ 500 characters) | A sci-fi masterpiece... |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| Publication Date | Date | ✗ | YYYY-MM-DD format | 2008-01-01 |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| List Price | Decimal | ✗ | Positive number (≥ 0) | 68.5 |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| User Purchase Price | Decimal | ✗ | Positive number (≥ 0) | 52.0 |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| User Notes | Long Text | ✗ | Reading notes (length ≤ 1000 characters) | A stunning view of the cosmos... |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| Reading Status | Enum | ✗ | To Read / Read / Reading (default To Read) | To Read |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| In-Library Status | Enum | ✗ | In Library / Borrowed In / Lent Out / Archived (default In Library) | Lent Out |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| Self-Rating | Integer | ✗ | 1-5 stars (default 3 stars) | 5 |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">---
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">### Tech Stack
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="gu">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| Module | Technology Choice |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">|--------|-----------------------|
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| Backend | Python + FastAPI |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| Database | SQLite |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| Frontend | HTML/CSS + Bootstrap |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| API Interaction| AJAX (Fetch API) |
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>The developed program calls DeepSeek deployed locally via Ollama, and then generates test cases! The interface is as follows:&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/102-gemini-cli/Pasted-20250626-3_hu_b9140ae6eededed1.webp"
width="1024"
height="618"
srcset="https://chengxiaqiucao.github.io/post/102-gemini-cli/Pasted-20250626-3_hu_6c7fdeaaa31fb612.webp 480w, https://chengxiaqiucao.github.io/post/102-gemini-cli/Pasted-20250626-3_hu_b9140ae6eededed1.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="165"
data-flex-basis="397px"
>
&lt;/p>
&lt;p>It really is too good to pass up! Go recommend it to your friends~~&lt;/p>
&lt;hr>
&lt;p>Reply with &lt;code>进群&lt;/code> to join Qiucao&amp;rsquo;s tech discussion group, share techniques with friends, and exchange news~~
Reply with &lt;code>大纲&lt;/code> to view the detailed syllabus of Qiucao&amp;rsquo;s advanced systematic testing technology course 😉😉😉&lt;/p></description></item><item><title>Source Code Analysis of the AI Automation Tool Midscene.js</title><link>https://chengxiaqiucao.github.io/en/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/</link><pubDate>Sun, 22 Jun 2025 00:00:00 +0000</pubDate><guid>https://chengxiaqiucao.github.io/en/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/snap_20250621-5.webp" alt="Featured image of post Source Code Analysis of the AI Automation Tool Midscene.js" />&lt;h2 id="preface">Preface
&lt;/h2>&lt;p>In a previous article 【】we learned about the AI testing tool &lt;code>Midscene.js&lt;/code> launched by ByteDance. Whether it is intelligent project parsing, test execution, or the final report generation, it is quite impressive; moreover, in addition to browser-based web applications, it also supports the automation of Android apps.&lt;/p>
&lt;p>So how exactly does this project use AI intelligence to complete test execution tasks? In this article, we will draw on the open-source project source code of Midscene.js to conduct an in-depth analysis of the project&amp;rsquo;s implementation as well as its application of large models.&lt;/p>
&lt;h2 id="overall-project-architecture">Overall Project Architecture
&lt;/h2>&lt;p>Through the analysis of the project source code, the overall architecture of the project can be summarized by the following diagram:
&lt;img src="https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/midscene_arch_hu_aacd2c6e6996adc4.webp"
width="1024"
height="467"
srcset="https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/midscene_arch_hu_bb82451fd09cd442.webp 480w, https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/midscene_arch_hu_aacd2c6e6996adc4.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="219"
data-flex-basis="526px"
>
&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>User&lt;/strong>: The user is the starting point of Midscene, defining automation tasks and goals through natural language descriptions, the JavaScript SDK, or YAML scripts.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>MCP Clients&lt;/strong>: Midscene also supports other MCP clients directly using its capabilities, which indicates that it may have an API or integration point for other systems to call.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Midscene Core&lt;/strong>: This is the core logic layer of Midscene. It is responsible for parsing user instructions, interacting with AI models, and coordinating automation agents to perform operations. It also manages report generation and caching.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>AI Models&lt;/strong>: Midscene supports multiple AI models, including:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>Multimodal LLM&lt;/strong>: such as GPT-4o and Gemini-2.5-Pro, used to understand more complex instructions and context.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Visual-Language Models&lt;/strong>: such as Qwen2.5-VL, Doubao-1.5-thinking-vision-pro, and UI-TARS, which are especially recommended for UI automation because they can better understand visual information. The AI model receives requests from Midscene Core and returns instructions to execute actions or retrieve information.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Automation Agent&lt;/strong>: This is a key execution layer, responsible for actually operating the target application or UI according to the instructions of Midscene Core. It can obtain the UI state and screenshots and feed them back to Midscene Core.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Target Application/UI&lt;/strong>: This is the actual object of automation operations, which can be:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Browser&lt;/strong>: Web automation through tools such as Playwright or Puppeteer.&lt;/li>
&lt;li>&lt;strong>Android App&lt;/strong>: Performing Android automation.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Visual Reports&lt;/strong>: Midscene provides visual reports to help users understand, replay, and debug the entire automation process.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Playground&lt;/strong>: The built-in Playground environment allows users to debug through natural language instructions.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Caching Mechanism&lt;/strong>: Midscene uses a caching mechanism to improve efficiency, allowing scripts to replay more quickly to obtain results.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h2 id="main-built-in-system-prompts">Main Built-in System Prompts
&lt;/h2>&lt;p>The intelligent parsing capability of &lt;code>MidScene&lt;/code> mainly relies on LLM large models, so when calling the LLM, its configured system prompts are especially critical. By analyzing the source code, we can see that MidScene has set different system prompts for different types of tasks. They are summarized as follows:&lt;/p>
&lt;h3 id="1-task-planning-system-prompts">1. Task Planning System Prompts
&lt;/h3>&lt;p>The project contains three different task planning prompts:&lt;/p>
&lt;p>&lt;strong>Task planning prompt for traditional LLM models&lt;/strong> - Used to guide traditional language models to decompose user instructions into a series of executable UI operation actions.&lt;/p>
&lt;p>&lt;code>packages/core/src/ai-model/prompt/llm-planning.ts&lt;/code>&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;span class="lnt">29
&lt;/span>&lt;span class="lnt">30
&lt;/span>&lt;span class="lnt">31
&lt;/span>&lt;span class="lnt">32
&lt;/span>&lt;span class="lnt">33
&lt;/span>&lt;span class="lnt">34
&lt;/span>&lt;span class="lnt">35
&lt;/span>&lt;span class="lnt">36
&lt;/span>&lt;span class="lnt">37
&lt;/span>&lt;span class="lnt">38
&lt;/span>&lt;span class="lnt">39
&lt;/span>&lt;span class="lnt">40
&lt;/span>&lt;span class="lnt">41
&lt;/span>&lt;span class="lnt">42
&lt;/span>&lt;span class="lnt">43
&lt;/span>&lt;span class="lnt">44
&lt;/span>&lt;span class="lnt">45
&lt;/span>&lt;span class="lnt">46
&lt;/span>&lt;span class="lnt">47
&lt;/span>&lt;span class="lnt">48
&lt;/span>&lt;span class="lnt">49
&lt;/span>&lt;span class="lnt">50
&lt;/span>&lt;span class="lnt">51
&lt;/span>&lt;span class="lnt">52
&lt;/span>&lt;span class="lnt">53
&lt;/span>&lt;span class="lnt">54
&lt;/span>&lt;span class="lnt">55
&lt;/span>&lt;span class="lnt">56
&lt;/span>&lt;span class="lnt">57
&lt;/span>&lt;span class="lnt">58
&lt;/span>&lt;span class="lnt">59
&lt;/span>&lt;span class="lnt">60
&lt;/span>&lt;span class="lnt">61
&lt;/span>&lt;span class="lnt">62
&lt;/span>&lt;span class="lnt">63
&lt;/span>&lt;span class="lnt">64
&lt;/span>&lt;span class="lnt">65
&lt;/span>&lt;span class="lnt">66
&lt;/span>&lt;span class="lnt">67
&lt;/span>&lt;span class="lnt">68
&lt;/span>&lt;span class="lnt">69
&lt;/span>&lt;span class="lnt">70
&lt;/span>&lt;span class="lnt">71
&lt;/span>&lt;span class="lnt">72
&lt;/span>&lt;span class="lnt">73
&lt;/span>&lt;span class="lnt">74
&lt;/span>&lt;span class="lnt">75
&lt;/span>&lt;span class="lnt">76
&lt;/span>&lt;span class="lnt">77
&lt;/span>&lt;span class="lnt">78
&lt;/span>&lt;span class="lnt">79
&lt;/span>&lt;span class="lnt">80
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-typescript" data-lang="typescript">&lt;span class="line">&lt;span class="cl">&lt;span class="kr">const&lt;/span> &lt;span class="nx">llmLocateParam&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="sb">`locate: {{&amp;#34;id&amp;#34;: string, &amp;#34;prompt&amp;#34;: string}} | null`&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kr">const&lt;/span> &lt;span class="nx">systemTemplateOfLLM&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="p">({&lt;/span> &lt;span class="nx">pageType&lt;/span> &lt;span class="p">}&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">pageType&lt;/span>: &lt;span class="kt">PageType&lt;/span> &lt;span class="p">})&lt;/span> &lt;span class="o">=&amp;gt;&lt;/span> &lt;span class="sb">`
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">## Role
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">You are a versatile professional in software UI automation. Your outstanding contributions will impact the user experience of billions of users.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">## Objective
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">- Decompose the instruction user asked into a series of actions
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">- Locate the target element if possible
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">- If the instruction cannot be accomplished, give a further plan.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">## Workflow
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">1. Receive the screenshot, element description of screenshot(if any), user&amp;#39;s instruction and previous logs.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">2. Decompose the user&amp;#39;s task into a sequence of actions, and place it in the \`actions\` field. There are different types of actions (Tap / Hover / Input / KeyboardPress / Scroll / FalsyConditionStatement / Sleep &lt;/span>&lt;span class="si">${&lt;/span>&lt;span class="nx">pageType&lt;/span> &lt;span class="o">===&lt;/span> &lt;span class="s1">&amp;#39;android&amp;#39;&lt;/span> &lt;span class="o">?&lt;/span> &lt;span class="s1">&amp;#39;/ AndroidBackButton / AndroidHomeButton / AndroidRecentAppsButton&amp;#39;&lt;/span> &lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;&amp;#39;&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="sb">). The &amp;#34;About the action&amp;#34; section below will give you more details.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">3. Precisely locate the target element if it&amp;#39;s already shown in the screenshot, put the location info in the \`locate\` field of the action.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">4. If some target elements is not shown in the screenshot, consider the user&amp;#39;s instruction is not feasible on this page. Follow the next steps.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">5. Consider whether the user&amp;#39;s instruction will be accomplished after all the actions
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - If yes, set \`taskWillBeAccomplished\` to true
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - If no, don&amp;#39;t plan more actions by closing the array. Get ready to reevaluate the task. Some talent people like you will handle this. Give him a clear description of what have been done and what to do next. Put your new plan in the \`furtherPlan\` field. The &amp;#34;How to compose the \`taskWillBeAccomplished\` and \`furtherPlan\` fields&amp;#34; section will give you more details.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">## Constraints
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">- All the actions you composed MUST be based on the page context information you get.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">- Trust the &amp;#34;What have been done&amp;#34; field about the task (if any), don&amp;#39;t repeat actions in it.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">- Respond only with valid JSON. Do not write an introduction or summary or markdown prefix like \`\`\`json\`\`\`.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">- If the screenshot and the instruction are totally irrelevant, set reason in the \`error\` field.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">## About the \`actions\` field
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">The \`locate\` param is commonly used in the \`param\` field of the action, means to locate the target element to perform the action, it conforms to the following scheme:
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">type LocateParam = {{
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> &amp;#34;id&amp;#34;: string, // the id of the element found. It should either be the id marked with a rectangle in the screenshot or the id described in the description.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> &amp;#34;prompt&amp;#34;?: string // the description of the element to find. It can only be omitted when locate is null.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">}} | null // If it&amp;#39;s not on the page, the LocateParam should be null
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">## Supported actions
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">Each action has a \`type\` and corresponding \`param\`. To be detailed:
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">- type: &amp;#39;Tap&amp;#39;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> * {{ &lt;/span>&lt;span class="si">${&lt;/span>&lt;span class="nx">llmLocateParam&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="sb"> }}
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">- type: &amp;#39;RightClick&amp;#39;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> * {{ &lt;/span>&lt;span class="si">${&lt;/span>&lt;span class="nx">llmLocateParam&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="sb"> }}
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">- type: &amp;#39;Hover&amp;#39;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> * {{ &lt;/span>&lt;span class="si">${&lt;/span>&lt;span class="nx">llmLocateParam&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="sb"> }}
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">- type: &amp;#39;Input&amp;#39;, replace the value in the input field
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> * {{ &lt;/span>&lt;span class="si">${&lt;/span>&lt;span class="nx">llmLocateParam&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="sb">, param: {{ value: string }} }}
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> * \`value\` is the final value that should be filled in the input field. No matter what modifications are required, just provide the final value user should see after the action is done.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">- type: &amp;#39;KeyboardPress&amp;#39;, press a key
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> * {{ param: {{ value: string }} }}
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">- type: &amp;#39;Scroll&amp;#39;, scroll up or down.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> * {{
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> &lt;/span>&lt;span class="si">${&lt;/span>&lt;span class="nx">llmLocateParam&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="sb">,
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> param: {{
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> direction: &amp;#39;down&amp;#39;(default) | &amp;#39;up&amp;#39; | &amp;#39;right&amp;#39; | &amp;#39;left&amp;#39;,
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> scrollType: &amp;#39;once&amp;#39; (default) | &amp;#39;untilBottom&amp;#39; | &amp;#39;untilTop&amp;#39; | &amp;#39;untilRight&amp;#39; | &amp;#39;untilLeft&amp;#39;,
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> distance: null | number
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> }}
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> }}
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> * To scroll some specific element, put the element at the center of the region in the \`locate\` field. If it&amp;#39;s a page scroll, put \`null\` in the \`locate\` field.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> * \`param\` is required in this action. If some fields are not specified, use direction \`down\`, \`once\` scroll type, and \`null\` distance.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> * {{ param: {{ button: &amp;#39;Back&amp;#39; | &amp;#39;Home&amp;#39; | &amp;#39;RecentApp&amp;#39; }} }}
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">- type: &amp;#39;ExpectedFalsyCondition&amp;#39;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> * {{ param: {{ reason: string }} }}
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> * use this action when the conditional statement talked about in the instruction is falsy.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">- type: &amp;#39;Sleep&amp;#39;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> * {{ param: {{ timeMs: number }} }}
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">&lt;/span>&lt;span class="si">${&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">pageType&lt;/span> &lt;span class="o">===&lt;/span> &lt;span class="s1">&amp;#39;android&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="o">?&lt;/span> &lt;span class="sb">`- type: &amp;#39;AndroidBackButton&amp;#39;, trigger the system &amp;#34;back&amp;#34; operation on Android devices
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> * {{ param: {{}} }}
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">- type: &amp;#39;AndroidHomeButton&amp;#39;, trigger the system &amp;#34;home&amp;#34; operation on Android devices
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> * {{ param: {{}} }}
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">- type: &amp;#39;AndroidRecentAppsButton&amp;#39;, trigger the system &amp;#34;recent apps&amp;#34; operation on Android devices
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> * {{ param: {{}} }}`&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="si">}&lt;/span>&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">`&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;strong>Task planning prompt for visual-language models&lt;/strong> - Specifically designed for AI models with visual capabilities (such as Qwen-VL and Gemini), able to directly process screenshots and plan the next action.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/snap_20250621_hu_6926387f76c94f6c.webp"
width="1024"
height="462"
srcset="https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/snap_20250621_hu_f7b37730f5926b68.webp 480w, https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/snap_20250621_hu_6926387f76c94f6c.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="221"
data-flex-basis="532px"
>
&lt;/p>
&lt;p>&lt;strong>Task planning prompt for the UI-Tars model&lt;/strong> - A GUI agent prompt specifically designed for UI-Tars, adopting a think-act format.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/snap_20250621-1_hu_5a6b6af294bf16.webp"
width="1024"
height="463"
srcset="https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/snap_20250621-1_hu_fd6046f84b1e202b.webp 480w, https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/snap_20250621-1_hu_5a6b6af294bf16.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="220"
data-flex-basis="530px"
>
&lt;/p>
&lt;h3 id="2-element-locating-system-prompts">2. Element Locating System Prompts
&lt;/h3>&lt;p>&lt;strong>Element locating prompt&lt;/strong> - Used to precisely locate target elements in page screenshots and element descriptions, supporting both traditional LLM and visual-language model modes.
&lt;img src="https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/snap_20250621-2_hu_794412b4956ea81a.webp"
width="1024"
height="493"
srcset="https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/snap_20250621-2_hu_b974cd93440bf69c.webp 480w, https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/snap_20250621-2_hu_794412b4956ea81a.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="207"
data-flex-basis="498px"
>
&lt;/p>
&lt;p>&lt;strong>Region locating prompt&lt;/strong> - Used to locate the page region containing the target element, usually an area no larger than 300x300 pixels.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/snap_20250621-3_hu_7778d0f9d172b0af.webp"
width="1024"
height="463"
srcset="https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/snap_20250621-3_hu_e17b445ca9a858d0.webp 480w, https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/snap_20250621-3_hu_7778d0f9d172b0af.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="220"
data-flex-basis="530px"
>
&lt;/p>
&lt;h3 id="3-data-extraction-system-prompts">3. Data Extraction System Prompts
&lt;/h3>&lt;p>&lt;strong>Data extraction prompt&lt;/strong> - Guides the AI to extract structured data from the UI, supporting multiple data types and format requirements.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/snap_20250621-4_hu_c08d31eb5b85587c.webp"
width="1024"
height="463"
srcset="https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/snap_20250621-4_hu_b89d8169ac029c30.webp 480w, https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/snap_20250621-4_hu_c08d31eb5b85587c.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="220"
data-flex-basis="530px"
>
&lt;/p>
&lt;h3 id="4-assertion-verification-system-prompts">4. Assertion Verification System Prompts
&lt;/h3>&lt;p>&lt;strong>Assertion verification prompt&lt;/strong> - Used to verify whether the page state meets the expected assertion conditions, supporting both the UI-Tars and ordinary model formats.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;span class="lnt">8
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-typescript" data-lang="typescript">&lt;span class="line">&lt;span class="cl">&lt;span class="kr">const&lt;/span> &lt;span class="nx">defaultAssertionPrompt&lt;/span> &lt;span class="o">=&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s1">&amp;#39;You are a senior testing engineer. User will give an assertion and a screenshot of a page. By carefully viewing the screenshot, please tell whether the assertion is truthy.&amp;#39;&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kr">const&lt;/span> &lt;span class="nx">defaultAssertionResponseJsonFormat&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="sb">`Return in the following JSON format:
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">{
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> pass: boolean, // whether the assertion is truthy
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> thought: string | null, // string, if the result is falsy, give the reason why it is falsy. Otherwise, put null.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">}`&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="5-element-description-system-prompts">5. Element Description System Prompts
&lt;/h3>&lt;p>&lt;strong>Element description prompt&lt;/strong> - Used to generate precise element descriptions to help identify specific UI elements in the page (given elements).&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-typescript" data-lang="typescript">&lt;span class="line">&lt;span class="cl"> &lt;span class="kr">export&lt;/span> &lt;span class="kr">const&lt;/span> &lt;span class="nx">elementDescriberInstruction&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="p">()&lt;/span> &lt;span class="o">=&amp;gt;&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">return&lt;/span> &lt;span class="sb">`Describe the element in the red rectangle for precise identification. Use &lt;/span>&lt;span class="si">${&lt;/span>&lt;span class="nx">getPreferredLanguage&lt;/span>&lt;span class="p">()&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="sb">.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">Rules:
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">1. Start with element type (button, input, link, etc.)
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">2. Include key identifiers:
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - Text content: &amp;#34;with text &amp;#39;Submit&amp;#39;&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - Visual features: &amp;#34;blue background&amp;#34;, &amp;#34;icon only&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - Position: &amp;#34;top-right&amp;#34;, &amp;#34;below search bar&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">3. Keep description under 20 words
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">4. Don&amp;#39;t mention the red rectangle
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">Return JSON:
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">{
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> &amp;#34;description&amp;#34;: &amp;#34;brief element type with key identifiers&amp;#34;,
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> &amp;#34;error&amp;#34;?: &amp;#34;error message if any&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">}`&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">};&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="6-code-generation-system-prompts">6. Code Generation System Prompts
&lt;/h3>&lt;p>&lt;strong>Playwright test code generation prompt&lt;/strong> - Generates executable Playwright test code based on recorded browser session events.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-typescript" data-lang="typescript">&lt;span class="line">&lt;span class="cl"> &lt;span class="c1">// Create system prompt
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="kr">const&lt;/span> &lt;span class="nx">systemPrompt&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="sb">`You are an expert test automation engineer specializing in Playwright and Midscene.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">Your task is to generate a complete, executable Playwright test using @midscene/web/playwright that reproduces a recorded browser session.
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;blockquote>
&lt;p>By adopting a modular design for these system prompts, they are dynamically adjusted according to different AI model types (traditional LLM vs. visual-language model) and page types (web vs. Android). The project also includes complete JSON schema definitions to ensure structured and consistent AI output, and supports multi-language environments &lt;code>${getPreferredLanguage()}&lt;/code>&lt;/p>&lt;/blockquote>
&lt;h2 id="supplements-and-constraints-on-user-prompts">Supplements and Constraints on User Prompts
&lt;/h2>&lt;p>Beyond the configuration of these system prompts that helps the LLM better understand the current task, the user&amp;rsquo;s input instructions — namely the &lt;code>user prompts&lt;/code> — inevitably require a certain degree of expansion and constraint supplementation during actual processing.&lt;/p>
&lt;p>Here we further analyze the handling of user prompts:&lt;/p>
&lt;h3 id="1-intelligent-generation-of-background-context">&lt;strong>1. Intelligent Generation of Background Context&lt;/strong>
&lt;/h3>&lt;p>The project adds structured background context to user instructions through the &lt;code>generateTaskBackgroundContext&lt;/code> function, including high-priority knowledge and historical execution logs, to prevent repeating the same operations.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;span class="lnt">29
&lt;/span>&lt;span class="lnt">30
&lt;/span>&lt;span class="lnt">31
&lt;/span>&lt;span class="lnt">32
&lt;/span>&lt;span class="lnt">33
&lt;/span>&lt;span class="lnt">34
&lt;/span>&lt;span class="lnt">35
&lt;/span>&lt;span class="lnt">36
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-typescript" data-lang="typescript">&lt;span class="line">&lt;span class="cl">&lt;span class="kr">export&lt;/span> &lt;span class="kr">const&lt;/span> &lt;span class="nx">generateTaskBackgroundContext&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="p">(&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">userInstruction&lt;/span>: &lt;span class="kt">string&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">log?&lt;/span>: &lt;span class="kt">string&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">userActionContext?&lt;/span>: &lt;span class="kt">string&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">)&lt;/span> &lt;span class="o">=&amp;gt;&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">log&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">return&lt;/span> &lt;span class="sb">`
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">Here is the user&amp;#39;s instruction:
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">&amp;lt;instruction&amp;gt;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> &amp;lt;high_priority_knowledge&amp;gt;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> &lt;/span>&lt;span class="si">${&lt;/span>&lt;span class="nx">userActionContext&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> &amp;lt;/high_priority_knowledge&amp;gt;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> &lt;/span>&lt;span class="si">${&lt;/span>&lt;span class="nx">userInstruction&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">&amp;lt;/instruction&amp;gt;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">These are the logs from previous executions, which indicate what was done in the previous actions.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">Do NOT repeat these actions.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">&amp;lt;previous_logs&amp;gt;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">&lt;/span>&lt;span class="si">${&lt;/span>&lt;span class="nx">log&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">&amp;lt;/previous_logs&amp;gt;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">`&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">return&lt;/span> &lt;span class="sb">`
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">Here is the user&amp;#39;s instruction:
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">&amp;lt;instruction&amp;gt;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> &amp;lt;high_priority_knowledge&amp;gt;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> &lt;/span>&lt;span class="si">${&lt;/span>&lt;span class="nx">userActionContext&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> &amp;lt;/high_priority_knowledge&amp;gt;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> &lt;/span>&lt;span class="si">${&lt;/span>&lt;span class="nx">userInstruction&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">&amp;lt;/instruction&amp;gt;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">`&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">};&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="2-multimodal-adapted-user-prompts">&lt;strong>2. Multimodal-Adapted User Prompts&lt;/strong>
&lt;/h3>&lt;p>Depending on the capabilities of the AI model, user prompts adopt different formats. For visual-language models, the task background is passed directly; for traditional LLMs, page description information is combined.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-typescript" data-lang="typescript">&lt;span class="line">&lt;span class="cl">&lt;span class="kr">export&lt;/span> &lt;span class="kr">const&lt;/span> &lt;span class="nx">automationUserPrompt&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="p">(&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">vlMode&lt;/span>: &lt;span class="kt">ReturnType&lt;/span>&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">typeof&lt;/span> &lt;span class="na">vlLocateMode&lt;/span>&lt;span class="p">&amp;gt;,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">)&lt;/span> &lt;span class="o">=&amp;gt;&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">vlMode&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">return&lt;/span> &lt;span class="k">new&lt;/span> &lt;span class="nx">PromptTemplate&lt;/span>&lt;span class="p">({&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">template&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;{taskBackgroundContext}&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">inputVariables&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;taskBackgroundContext&amp;#39;&lt;/span>&lt;span class="p">],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">});&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">return&lt;/span> &lt;span class="k">new&lt;/span> &lt;span class="nx">PromptTemplate&lt;/span>&lt;span class="p">({&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">template&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="sb">`
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">pageDescription:
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">=====================================
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">{pageDescription}
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">=====================================
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">{taskBackgroundContext}`&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">inputVariables&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;pageDescription&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;taskBackgroundContext&amp;#39;&lt;/span>&lt;span class="p">],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">});&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">};&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="3-structured-json-schema-validation">&lt;strong>3. Structured JSON Schema Validation&lt;/strong>
&lt;/h3>&lt;p>The project uses OpenAI&amp;rsquo;s structured output schema to strictly constrain the AI&amp;rsquo;s response format, ensuring that the returned data conforms to a predefined structure, including necessary fields such as actions, log, and error.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt"> 10
&lt;/span>&lt;span class="lnt"> 11
&lt;/span>&lt;span class="lnt"> 12
&lt;/span>&lt;span class="lnt"> 13
&lt;/span>&lt;span class="lnt"> 14
&lt;/span>&lt;span class="lnt"> 15
&lt;/span>&lt;span class="lnt"> 16
&lt;/span>&lt;span class="lnt"> 17
&lt;/span>&lt;span class="lnt"> 18
&lt;/span>&lt;span class="lnt"> 19
&lt;/span>&lt;span class="lnt"> 20
&lt;/span>&lt;span class="lnt"> 21
&lt;/span>&lt;span class="lnt"> 22
&lt;/span>&lt;span class="lnt"> 23
&lt;/span>&lt;span class="lnt"> 24
&lt;/span>&lt;span class="lnt"> 25
&lt;/span>&lt;span class="lnt"> 26
&lt;/span>&lt;span class="lnt"> 27
&lt;/span>&lt;span class="lnt"> 28
&lt;/span>&lt;span class="lnt"> 29
&lt;/span>&lt;span class="lnt"> 30
&lt;/span>&lt;span class="lnt"> 31
&lt;/span>&lt;span class="lnt"> 32
&lt;/span>&lt;span class="lnt"> 33
&lt;/span>&lt;span class="lnt"> 34
&lt;/span>&lt;span class="lnt"> 35
&lt;/span>&lt;span class="lnt"> 36
&lt;/span>&lt;span class="lnt"> 37
&lt;/span>&lt;span class="lnt"> 38
&lt;/span>&lt;span class="lnt"> 39
&lt;/span>&lt;span class="lnt"> 40
&lt;/span>&lt;span class="lnt"> 41
&lt;/span>&lt;span class="lnt"> 42
&lt;/span>&lt;span class="lnt"> 43
&lt;/span>&lt;span class="lnt"> 44
&lt;/span>&lt;span class="lnt"> 45
&lt;/span>&lt;span class="lnt"> 46
&lt;/span>&lt;span class="lnt"> 47
&lt;/span>&lt;span class="lnt"> 48
&lt;/span>&lt;span class="lnt"> 49
&lt;/span>&lt;span class="lnt"> 50
&lt;/span>&lt;span class="lnt"> 51
&lt;/span>&lt;span class="lnt"> 52
&lt;/span>&lt;span class="lnt"> 53
&lt;/span>&lt;span class="lnt"> 54
&lt;/span>&lt;span class="lnt"> 55
&lt;/span>&lt;span class="lnt"> 56
&lt;/span>&lt;span class="lnt"> 57
&lt;/span>&lt;span class="lnt"> 58
&lt;/span>&lt;span class="lnt"> 59
&lt;/span>&lt;span class="lnt"> 60
&lt;/span>&lt;span class="lnt"> 61
&lt;/span>&lt;span class="lnt"> 62
&lt;/span>&lt;span class="lnt"> 63
&lt;/span>&lt;span class="lnt"> 64
&lt;/span>&lt;span class="lnt"> 65
&lt;/span>&lt;span class="lnt"> 66
&lt;/span>&lt;span class="lnt"> 67
&lt;/span>&lt;span class="lnt"> 68
&lt;/span>&lt;span class="lnt"> 69
&lt;/span>&lt;span class="lnt"> 70
&lt;/span>&lt;span class="lnt"> 71
&lt;/span>&lt;span class="lnt"> 72
&lt;/span>&lt;span class="lnt"> 73
&lt;/span>&lt;span class="lnt"> 74
&lt;/span>&lt;span class="lnt"> 75
&lt;/span>&lt;span class="lnt"> 76
&lt;/span>&lt;span class="lnt"> 77
&lt;/span>&lt;span class="lnt"> 78
&lt;/span>&lt;span class="lnt"> 79
&lt;/span>&lt;span class="lnt"> 80
&lt;/span>&lt;span class="lnt"> 81
&lt;/span>&lt;span class="lnt"> 82
&lt;/span>&lt;span class="lnt"> 83
&lt;/span>&lt;span class="lnt"> 84
&lt;/span>&lt;span class="lnt"> 85
&lt;/span>&lt;span class="lnt"> 86
&lt;/span>&lt;span class="lnt"> 87
&lt;/span>&lt;span class="lnt"> 88
&lt;/span>&lt;span class="lnt"> 89
&lt;/span>&lt;span class="lnt"> 90
&lt;/span>&lt;span class="lnt"> 91
&lt;/span>&lt;span class="lnt"> 92
&lt;/span>&lt;span class="lnt"> 93
&lt;/span>&lt;span class="lnt"> 94
&lt;/span>&lt;span class="lnt"> 95
&lt;/span>&lt;span class="lnt"> 96
&lt;/span>&lt;span class="lnt"> 97
&lt;/span>&lt;span class="lnt"> 98
&lt;/span>&lt;span class="lnt"> 99
&lt;/span>&lt;span class="lnt">100
&lt;/span>&lt;span class="lnt">101
&lt;/span>&lt;span class="lnt">102
&lt;/span>&lt;span class="lnt">103
&lt;/span>&lt;span class="lnt">104
&lt;/span>&lt;span class="lnt">105
&lt;/span>&lt;span class="lnt">106
&lt;/span>&lt;span class="lnt">107
&lt;/span>&lt;span class="lnt">108
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-typescript" data-lang="typescript">&lt;span class="line">&lt;span class="cl">&lt;span class="kr">export&lt;/span> &lt;span class="kr">const&lt;/span> &lt;span class="nx">planSchema&lt;/span>: &lt;span class="kt">ResponseFormatJSONSchema&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;json_schema&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">json_schema&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">name&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;action_items&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">strict&lt;/span>: &lt;span class="kt">true&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">schema&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;object&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">strict&lt;/span>: &lt;span class="kt">true&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">properties&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">actions&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1">// TODO
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;array&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">items&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;object&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">strict&lt;/span>: &lt;span class="kt">true&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">properties&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">thought&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;string&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">description&lt;/span>&lt;span class="o">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s1">&amp;#39;Reasons for generating this task, and why this task is feasible on this page&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;string&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">description&lt;/span>&lt;span class="o">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s1">&amp;#39;Type of action, one of &amp;#34;Tap&amp;#34;, &amp;#34;RightClick&amp;#34;, &amp;#34;Hover&amp;#34; , &amp;#34;Input&amp;#34;, &amp;#34;KeyboardPress&amp;#34;, &amp;#34;Scroll&amp;#34;, &amp;#34;ExpectedFalsyCondition&amp;#34;, &amp;#34;Sleep&amp;#34;, &amp;#34;AndroidBackButton&amp;#34;, &amp;#34;AndroidHomeButton&amp;#34;, &amp;#34;AndroidRecentAppsButton&amp;#34;&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">param&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">anyOf&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;null&amp;#39;&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;object&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">properties&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">value&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;string&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;number&amp;#39;&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="p">}&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">required&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;value&amp;#39;&lt;/span>&lt;span class="p">],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">additionalProperties&lt;/span>: &lt;span class="kt">false&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;object&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">properties&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">timeMs&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;number&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;string&amp;#39;&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="p">}&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">required&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;timeMs&amp;#39;&lt;/span>&lt;span class="p">],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">additionalProperties&lt;/span>: &lt;span class="kt">false&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;object&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">properties&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">direction&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;string&amp;#39;&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">scrollType&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;string&amp;#39;&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">distance&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;number&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;string&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;null&amp;#39;&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">required&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;direction&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;scrollType&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;distance&amp;#39;&lt;/span>&lt;span class="p">],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">additionalProperties&lt;/span>: &lt;span class="kt">false&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;object&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">properties&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">reason&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;string&amp;#39;&lt;/span> &lt;span class="p">}&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">required&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;reason&amp;#39;&lt;/span>&lt;span class="p">],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">additionalProperties&lt;/span>: &lt;span class="kt">false&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;object&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">properties&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">button&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;string&amp;#39;&lt;/span> &lt;span class="p">}&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">required&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;button&amp;#39;&lt;/span>&lt;span class="p">],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">additionalProperties&lt;/span>: &lt;span class="kt">false&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">description&lt;/span>&lt;span class="o">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s1">&amp;#39;Parameter of the action, can be null ONLY when the type field is Tap or Hover&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">locate&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;object&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;null&amp;#39;&lt;/span>&lt;span class="p">],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">properties&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">id&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;string&amp;#39;&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">prompt&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;string&amp;#39;&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">required&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;id&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;prompt&amp;#39;&lt;/span>&lt;span class="p">],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">additionalProperties&lt;/span>: &lt;span class="kt">false&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">description&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;Location information for the target element&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">required&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;thought&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;type&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;param&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;locate&amp;#39;&lt;/span>&lt;span class="p">],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">additionalProperties&lt;/span>: &lt;span class="kt">false&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">description&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;List of actions to be performed&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">more_actions_needed_by_instruction&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;boolean&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">description&lt;/span>&lt;span class="o">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s1">&amp;#39;If all the actions described in the instruction have been covered by this action and logs, set this field to false.&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">log&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;string&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">description&lt;/span>&lt;span class="o">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s1">&amp;#39;Log what these planned actions do. Do not include further actions that have not been planned.&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">error&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kr">type&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s1">&amp;#39;string&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s1">&amp;#39;null&amp;#39;&lt;/span>&lt;span class="p">],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">description&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;Error messages about unexpected situations&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">required&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s1">&amp;#39;actions&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s1">&amp;#39;more_actions_needed_by_instruction&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s1">&amp;#39;log&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s1">&amp;#39;error&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">additionalProperties&lt;/span>: &lt;span class="kt">false&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">};&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;blockquote>
&lt;p>Through these multi-layered enhancement and constraint mechanisms, the AI model is ensured to accurately understand user intent while its behavioral boundaries are strictly controlled. Judging from the definition of the prompts, the project places great emphasis on preventing the AI from hallucinating or performing operations beyond the scope of user instructions, which is crucial for scenarios such as UI automation that require high-precision operations.&lt;/p>&lt;/blockquote>
&lt;h2 id="large-model-context-window-limitations">Large Model Context Window Limitations
&lt;/h2>&lt;p>When using various AI large models to complete intelligent tasks, a very important constraint is that large models usually have a &lt;code>context window size limit&lt;/code>; historical information exceeding this limit is discarded in order to conserve the resources of the large model and improve performance.&lt;/p>
&lt;p>For an automated testing task, however, the execution chain after decomposition is often long and usually exceeds the LLM&amp;rsquo;s context limit.&lt;/p>
&lt;p>So here we further analyze how this project handles the context window limit.&lt;/p>
&lt;h3 id="1-token-count-limit-control">1. Token Count Limit Control
&lt;/h3>&lt;p>The project sets the maximum number of tokens in the response through the &lt;code>OPENAI_MAX_TOKENS&lt;/code> environment variable&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/snap_20250621-6_hu_7d543a71488ff914.webp"
width="1024"
height="413"
srcset="https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/snap_20250621-6_hu_eb15cf7c4eb277d3.webp 480w, https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/snap_20250621-6_hu_7d543a71488ff914.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="248"
data-flex-basis="595px"
>
&lt;/p>
&lt;h3 id="2-image-size-limits-and-automatic-adjustment">2. Image Size Limits and Automatic Adjustment
&lt;/h3>&lt;p>The project implements image size limits for different models, especially strict size control for the GPT-4o model. When it detects that the image size exceeds the maximum input limit of GPT-4o (2000x768 or 768x2000 pixels), the system issues a warning.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-typescript" data-lang="typescript">&lt;span class="line">&lt;span class="cl">&lt;span class="kd">let&lt;/span> &lt;span class="nx">warned&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="kc">false&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kr">export&lt;/span> &lt;span class="kd">function&lt;/span> &lt;span class="nx">warnGPT4oSizeLimit&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">size&lt;/span>: &lt;span class="kt">Size&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">warned&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="k">return&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">getModelName&lt;/span>&lt;span class="p">()&lt;/span>&lt;span class="o">?&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">toLowerCase&lt;/span>&lt;span class="p">().&lt;/span>&lt;span class="nx">includes&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;gpt-4o&amp;#39;&lt;/span>&lt;span class="p">))&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kr">const&lt;/span> &lt;span class="nx">warningMsg&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="sb">`GPT-4o has a maximum image input size of 2000x768 or 768x2000, but got &lt;/span>&lt;span class="si">${&lt;/span>&lt;span class="nx">size&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">width&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="sb">x&lt;/span>&lt;span class="si">${&lt;/span>&lt;span class="nx">size&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">height&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="sb">. Please set your page to a smaller resolution. Otherwise, the result may be inaccurate.`&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="p">(&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">Math&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">max&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">size&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">width&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nx">size&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">height&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">&amp;gt;&lt;/span> &lt;span class="mi">2000&lt;/span> &lt;span class="o">||&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">Math&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">min&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">size&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">width&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nx">size&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">height&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="o">&amp;gt;&lt;/span> &lt;span class="mi">768&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">console&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">warn&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">warningMsg&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">warned&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="kc">true&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span> &lt;span class="k">else&lt;/span> &lt;span class="k">if&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">size&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">width&lt;/span> &lt;span class="o">&amp;gt;&lt;/span> &lt;span class="mi">1800&lt;/span> &lt;span class="o">||&lt;/span> &lt;span class="nx">size&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">height&lt;/span> &lt;span class="o">&amp;gt;&lt;/span> &lt;span class="mi">1800&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">console&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">warn&lt;/span>&lt;span class="p">(&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="sb">`The image size seems too large (&lt;/span>&lt;span class="si">${&lt;/span>&lt;span class="nx">size&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">width&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="sb">x&lt;/span>&lt;span class="si">${&lt;/span>&lt;span class="nx">size&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">height&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="sb">). It may lead to more token usage, slower response, and inaccurate result.`&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">warned&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="kc">true&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="3-image-compression-and-optimization">3. Image Compression and Optimization
&lt;/h3>&lt;p>The system reduces the amount of data transferred through image compression (&lt;code>packages/shared/src/img/transform.ts&lt;/code>), including:&lt;/p>
&lt;ul>
&lt;li>Setting the image quality to 90% to balance quality and file size&lt;/li>
&lt;li>Providing image resizing functionality&lt;/li>
&lt;li>Supporting image processing and conversion in base64 format&lt;/li>
&lt;/ul>
&lt;h3 id="4-choosing-the-right-model-architecture">4. Choosing the Right Model Architecture
&lt;/h3>&lt;p>The project supports two different types of AI models to optimize token usage:&lt;/p>
&lt;p>&lt;strong>General-purpose multimodal LLM (such as GPT-4o)&lt;/strong>: Requires sending both the screenshot and the DOM tree, resulting in higher token consumption.&lt;/p>
&lt;p>&lt;strong>Visual grounding VL model (such as Qwen-2.5-VL)&lt;/strong>: Supports visual grounding and does not need to send the DOM tree, saving 30% to 50% of tokens.&lt;/p>
&lt;p>See the explanation in the &lt;code>apps/site/docs/zh/choose-a-model.mdx&lt;/code> document&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/snap_20250621-7_hu_913b7eab79ce8506.webp"
width="1024"
height="309"
srcset="https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/snap_20250621-7_hu_e335fd6cdfa834bc.webp 480w, https://chengxiaqiucao.github.io/post/081-midscene%E6%BA%90%E7%A0%81%E8%A7%A3%E6%9E%90/snap_20250621-7_hu_913b7eab79ce8506.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="331"
data-flex-basis="795px"
>
&lt;/p>
&lt;h3 id="5-token-usage-monitoring">5. Token Usage Monitoring
&lt;/h3>&lt;p>The project also provides detailed token usage tracking and debugging features, recording prompt tokens, completion tokens, and the total number of tokens.&lt;/p>
&lt;p>In summary, the project&amp;rsquo;s strategy for handling context window limits mainly focuses on three aspects:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Controlling the input data volume&lt;/strong> (through image compression and size limits)&lt;/li>
&lt;li>&lt;strong>Choosing the right model architecture&lt;/strong> (VL model vs. general-purpose LLM)&lt;/li>
&lt;li>&lt;strong>Monitoring and optimizing token usage&lt;/strong>&lt;/li>
&lt;/ul>
&lt;p>This multi-layered approach effectively reduces the need for large context windows while also maintaining functional completeness.&lt;/p>
&lt;h2 id="memory-management-for-long-chain-tasks">Memory Management for Long-Chain Tasks
&lt;/h2>&lt;p>For large models, the memory of completed steps and historical tasks is of great significance for ensuring result accuracy, avoiding unnecessary repetition, and saving costs. As introduced in our previous articles, tools such as &lt;code>Browser-Use&lt;/code> bring in memory frameworks like &lt;code>mem0&lt;/code> to implement AI memory capabilities; so how does Midscene handle this aspect?&lt;/p>
&lt;p>Based on the analysis of the Midscene code, memory management for long-chain tasks is mainly implemented through the following core mechanisms:&lt;/p>
&lt;h3 id="task-caching-mechanism">Task Caching Mechanism
&lt;/h3>&lt;p>Midscene implements an intelligent task caching system to manage the memory of AI operations. This system caches planning results and element location information to avoid repeated AI calls, thereby reducing memory consumption and improving execution efficiency.&lt;/p>
&lt;p>&lt;code>packages/web-integration/src/common/task-cache.ts&lt;/code>&lt;/p>
&lt;p>The caching system supports two types of cache:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Planning Cache (PlanningCache)&lt;/strong> is used to store the AI-planned YAML workflows&lt;/li>
&lt;li>&lt;strong>Locate Cache (LocateCache)&lt;/strong> is used to store the XPath information of elements.&lt;/li>
&lt;/ul>
&lt;h3 id="conversation-history-management">Conversation History Management
&lt;/h3>&lt;p>To prevent the conversation history in long-chain tasks from growing indefinitely and causing memory overflow, Midscene implements an intelligent conversation history management strategy. The system limits user image messages to a maximum of 4 retained entries and adopts a first-in-first-out (FIFO) strategy to automatically clean up old conversation records.&lt;/p>
&lt;p>&lt;code>packages/web-integration/src/common/tasks.ts&lt;/code>&lt;/p>
&lt;h3 id="replanning-limit-mechanism">Replanning Limit Mechanism
&lt;/h3>&lt;p>To prevent the AI from falling into an infinite replanning loop in long-chain tasks, the system sets a limit on the number of replanning attempts. When the number of replanning attempts exceeds the limit, the task proactively terminates and returns an error message.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-typescript" data-lang="typescript">&lt;span class="line">&lt;span class="cl">&lt;span class="k">while&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">planningTask&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">replanCount&lt;/span> &lt;span class="o">&amp;gt;&lt;/span> &lt;span class="nx">replanningCountLimit&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="kr">const&lt;/span> &lt;span class="nx">errorMsg&lt;/span> &lt;span class="o">=&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s1">&amp;#39;Replanning too many times, please split the task into multiple steps&amp;#39;&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">return&lt;/span> &lt;span class="k">this&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">appendErrorPlan&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">taskExecutor&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nx">errorMsg&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="resource-cleanup-mechanism">Resource Cleanup Mechanism
&lt;/h3>&lt;p>Midscene uses the FreeFn pattern to ensure that all resources — including network connections, temporary files, timers, and so on — are properly cleaned up after a long-chain task is completed. Even under exceptional circumstances, the resource cleanup mechanism guarantees that system resources are released.&lt;/p>
&lt;p>&lt;code>packages/web-integration/src/yaml/player.ts&lt;/code>&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-typescript" data-lang="typescript">&lt;span class="line">&lt;span class="cl">&lt;span class="nx">freeFn&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="p">[&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">...(&lt;/span>&lt;span class="nx">newFreeFn&lt;/span> &lt;span class="o">||&lt;/span> &lt;span class="p">[]),&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">name&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s1">&amp;#39;restore-agent-onTaskStartTip&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">fn&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">()&lt;/span> &lt;span class="o">=&amp;gt;&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">agent&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nx">agent&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">onTaskStartTip&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nx">originalOnTaskStartTip&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">];&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">....&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">// free the resources
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="k">for&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="kr">const&lt;/span> &lt;span class="nx">fn&lt;/span> &lt;span class="k">of&lt;/span> &lt;span class="nx">freeFn&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">try&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1">// console.log(&amp;#39;freeing&amp;#39;, fn.name);
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="k">await&lt;/span> &lt;span class="nx">fn&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">fn&lt;/span>&lt;span class="p">();&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1">// console.log(&amp;#39;freed&amp;#39;, fn.name);
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="p">}&lt;/span> &lt;span class="k">catch&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="nx">e&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1">// console.error(&amp;#39;error freeing&amp;#39;, fn.name, e);
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="context-optimization">Context Optimization
&lt;/h3>&lt;p>To reduce memory usage, Midscene also implements several context optimization strategies:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Visible element filtering&lt;/strong>: Only extract the visible elements on the page, reducing the size of the DOM tree&lt;/li>
&lt;li>&lt;strong>Image compression&lt;/strong>: Intelligently compress screenshots to reduce memory and transmission overhead&lt;/li>
&lt;li>&lt;strong>Viewport cropping&lt;/strong>: Crop context data according to the viewport range&lt;/li>
&lt;/ul>
&lt;blockquote>
&lt;p>It can be seen that although Mdscene has not introduced a dedicated memory framework to handle historical memory, it has nevertheless established a memory management mechanism to handle this collaboratively, enabling Midscene to maintain efficient memory usage when processing complex long-chain tasks. Through conversation history management to control memory growth, replanning limits to prevent infinite loops, and resource cleanup to ensure system stability, it ultimately achieves a reliable long-chain task execution system.&lt;/p>&lt;/blockquote>
&lt;hr>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;span class="lnt">29
&lt;/span>&lt;span class="lnt">30
&lt;/span>&lt;span class="lnt">31
&lt;/span>&lt;span class="lnt">32
&lt;/span>&lt;span class="lnt">33
&lt;/span>&lt;span class="lnt">34
&lt;/span>&lt;span class="lnt">35
&lt;/span>&lt;span class="lnt">36
&lt;/span>&lt;span class="lnt">37
&lt;/span>&lt;span class="lnt">38
&lt;/span>&lt;span class="lnt">39
&lt;/span>&lt;span class="lnt">40
&lt;/span>&lt;span class="lnt">41
&lt;/span>&lt;span class="lnt">42
&lt;/span>&lt;span class="lnt">43
&lt;/span>&lt;span class="lnt">44
&lt;/span>&lt;span class="lnt">45
&lt;/span>&lt;span class="lnt">46
&lt;/span>&lt;span class="lnt">47
&lt;/span>&lt;span class="lnt">48
&lt;/span>&lt;span class="lnt">49
&lt;/span>&lt;span class="lnt">50
&lt;/span>&lt;span class="lnt">51
&lt;/span>&lt;span class="lnt">52
&lt;/span>&lt;span class="lnt">53
&lt;/span>&lt;span class="lnt">54
&lt;/span>&lt;span class="lnt">55
&lt;/span>&lt;span class="lnt">56
&lt;/span>&lt;span class="lnt">57
&lt;/span>&lt;span class="lnt">58
&lt;/span>&lt;span class="lnt">59
&lt;/span>&lt;span class="lnt">60
&lt;/span>&lt;span class="lnt">61
&lt;/span>&lt;span class="lnt">62
&lt;/span>&lt;span class="lnt">63
&lt;/span>&lt;span class="lnt">64
&lt;/span>&lt;span class="lnt">65
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">graph TD
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> A[User] --&amp;gt;|Provide natural language description/JS SDK/YAML script| B(Midscene Core)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> B --&amp;gt;|Call| C{AI Model}
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> C --&amp;gt;|Return action/info| B
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> B --&amp;gt;|Control| D[Automation Agent]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> D --&amp;gt;|Operate| E[Target App/UI]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> E --&amp;gt;|Return UI state/screenshot| D
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> D --&amp;gt;|Send| B
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> B --&amp;gt;|Generate| F[Visual Reports]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> B --&amp;gt;|Provide| G[Playground&amp;lt;Debug&amp;gt; ]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> B --&amp;gt;|Use| H[Caching Mechanism]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> subgraph Target Platforms
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> E -- Web --&amp;gt; E1[Browser&amp;lt;Playwright/Puppeteer&amp;gt;]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> E -- Android --&amp;gt; E2[Android App]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> end
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> subgraph AI Model Types
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> C -- Multimodal LLM --&amp;gt; C1[GPT-4o, Gemini-2.5-Pro]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> C -- Visual-Language Model --&amp;gt; C2[Qwen2.5-VL, Doubao-1.5-thinking-vision-pro, UI-TARS]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> end
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> subgraph Auxiliary Tools
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> F --&amp;gt; F1[Report Files]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> G --&amp;gt; G1[Built-in Debug Environment]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> H --&amp;gt; H1[Improve efficiency/replay]
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> end
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> I[MCP Clients] --&amp;gt;|Use capabilities directly| B
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div></description></item><item><title>A Review of the AI Automation Tool Midscene.js</title><link>https://chengxiaqiucao.github.io/en/post/098-midscene.js%E7%9A%84%E4%BD%BF%E7%94%A8/</link><pubDate>Sun, 01 Jun 2025 00:00:00 +0000</pubDate><guid>https://chengxiaqiucao.github.io/en/post/098-midscene.js%E7%9A%84%E4%BD%BF%E7%94%A8/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/098-midscene.js%E7%9A%84%E4%BD%BF%E7%94%A8/snap_20250521.webp" alt="Featured image of post A Review of the AI Automation Tool Midscene.js" />&lt;h2 id="introduction">Introduction
&lt;/h2>&lt;p>AI has been working its way ever more deeply into our day-to-day jobs. In the field of software testing, new AI-related testing tools and methods are emerging one after another. Previously we introduced a case of AI-driven testing combined with an mcp server; in this article we will introduce a domestically developed AI testing tool that has recently come to prominence, &lt;code>Midscene.js&lt;/code>.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/098-midscene.js%E7%9A%84%E4%BD%BF%E7%94%A8/snap_20250521_hu_4e0eed2c1d7f613e.webp"
width="1024"
height="972"
srcset="https://chengxiaqiucao.github.io/post/098-midscene.js%E7%9A%84%E4%BD%BF%E7%94%A8/snap_20250521_hu_ed4d15700d5e45f4.webp 480w, https://chengxiaqiucao.github.io/post/098-midscene.js%E7%9A%84%E4%BD%BF%E7%94%A8/snap_20250521_hu_4e0eed2c1d7f613e.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="105"
data-flex-basis="252px"
>
&lt;/p>
&lt;h2 id="introduction-to-midscenejs">Introduction to Midscene.js
&lt;/h2>&lt;p>&lt;code>MidScene.js&lt;/code> is an open-source AI automation testing tool released by the web-infra team at ByteDance. Built on multimodal large models, it understands our natural-language instructions through intelligent visual parsing of the page and then carries out automated operations. It can significantly reduce the complexity of writing automated test scripts, adapt better to changes in page structure and elements, and greatly improve the stability of automated test scripts.&lt;/p>
&lt;p>Official website: &lt;a class="link" href="https://midscenejs.com/" target="_blank" rel="noopener"
>https://midscenejs.com/&lt;/a>&lt;/p>
&lt;h2 id="how-midscene-works">How Midscene Works
&lt;/h2>&lt;p>Unlike the mcp server we discussed earlier, which used a general-purpose large model to understand the page and extended capabilities by calling local tools, Midscene uses multimodal large models such as &lt;code>ChatGPT-4o&lt;/code>, &lt;code>qwen-vl&lt;/code>, and ByteDance&amp;rsquo;s &lt;code>UI-TARS&lt;/code>-that is, large models that support visual input-to understand the page, which is much closer to the way we actually perform functional testing.&lt;/p>
&lt;p>MidScene first captures the current page screenshot along with detailed page structure information, then submits them together with the user instruction to the large model, which determines the location of the page control to be operated and decides the next action.&lt;/p>
&lt;p>Take entering &amp;ldquo;Today I will learn Playwright&amp;rdquo; into the task box on a to-do page as an example:&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/098-midscene.js%E7%9A%84%E4%BD%BF%E7%94%A8/snap_20250521-3_hu_1919dbe52d59b75c.webp"
width="1024"
height="359"
srcset="https://chengxiaqiucao.github.io/post/098-midscene.js%E7%9A%84%E4%BD%BF%E7%94%A8/snap_20250521-3_hu_96263881e447c2c5.webp 480w, https://chengxiaqiucao.github.io/post/098-midscene.js%E7%9A%84%E4%BD%BF%E7%94%A8/snap_20250521-3_hu_1919dbe52d59b75c.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="285"
data-flex-basis="684px"
>
&lt;/p>
&lt;p>MidScene&amp;rsquo;s internal operations are roughly as follows:&lt;/p>
&lt;ol>
&lt;li>Get the user instruction &amp;ldquo;Enter Learning Playwright in the task box and press Enter&amp;rdquo;&lt;/li>
&lt;li>MidScene takes a screenshot and obtains the overall element structure of the page&lt;/li>
&lt;li>Submit it to the large model to extract page features&lt;/li>
&lt;li>Obtain the large model&amp;rsquo;s analysis result and determine the next operation type (Tap) and the specific position (coordinates) of the control&lt;/li>
&lt;li>Plan the next operation&lt;/li>
&lt;li>Complete the execution&lt;/li>
&lt;/ol>
&lt;h2 id="choosing-a-large-model">Choosing a Large Model
&lt;/h2>&lt;p>From the analysis of Midscene&amp;rsquo;s principles above, MidScene mainly relies on the following capabilities of multimodal large models&lt;/p>
&lt;ol>
&lt;li>The ability to understand screenshots and  &lt;em>plan&lt;/em>  operation steps.&lt;/li>
&lt;li>The ability to give the coordinate information of a specified element (Visual Grounding).&lt;/li>
&lt;/ol>
&lt;p>The large models that support the above capabilities, as currently listed on the official site, include the following:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>OPENAI GPT-4o&lt;/strong>&lt;/li>
&lt;li>&lt;strong>Alibaba Qwen-2.5-VL&lt;/strong>&lt;/li>
&lt;li>&lt;strong>ByteDance UI-TARS&lt;/strong>&lt;/li>
&lt;li>&lt;strong>ByteDance Volcano Engine Doubao-1.5-thinking-vision-pro&lt;/strong>&lt;/li>
&lt;li>&lt;strong>Google Gemini-2.5-Pro&lt;/strong>&lt;/li>
&lt;/ul>
&lt;p>In terms of how it works, information such as screenshots and page structure has to be supplied to the large model, so the token consumption is fairly considerable. According to the official assessment, each operation usually consumes at least several thousand tokens. Among them, the model with the best cost-performance ratio recommended by the official team is QWen-VL.&lt;/p>
&lt;h2 id="using-the-chrome-extension">Using the Chrome Extension
&lt;/h2>&lt;p>The no-code Chrome extension approach can help us quickly understand how MidScene is applied.&lt;/p>
&lt;p>You can install it directly from the Chrome Web Store &lt;a class="link" href="https://chromewebstore.google.com/detail/midscenejs/gbldofcpkknbggpkmbdaefngejllnief" target="_blank" rel="noopener"
>Midscene Extension&lt;/a>&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/098-midscene.js%E7%9A%84%E4%BD%BF%E7%94%A8/snap_20250521-2_hu_f739d517918e3f2d.webp"
width="1024"
height="319"
srcset="https://chengxiaqiucao.github.io/post/098-midscene.js%E7%9A%84%E4%BD%BF%E7%94%A8/snap_20250521-2_hu_b7c9efe7ea7afa.webp 480w, https://chengxiaqiucao.github.io/post/098-midscene.js%E7%9A%84%E4%BD%BF%E7%94%A8/snap_20250521-2_hu_f739d517918e3f2d.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="320"
data-flex-basis="770px"
>
&lt;/p>
&lt;h3 id="configuring-the-large-model">Configuring the Large Model
&lt;/h3>&lt;p>After enabling the extension, you need to configure the large model to use. Here we use the Alibaba Qwen multimodal model &lt;code>qwen-vl-max-latest&lt;/code>, which consumes relatively few tokens; you can apply for the corresponding API Key through the Alibaba Cloud Bailian platform, and applications currently come with a free quota of 1 million tokens.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/098-midscene.js%E7%9A%84%E4%BD%BF%E7%94%A8/snap_20250520-2_hu_1e7b7a961f3d0cf4.webp"
width="1024"
height="185"
srcset="https://chengxiaqiucao.github.io/post/098-midscene.js%E7%9A%84%E4%BD%BF%E7%94%A8/snap_20250520-2_hu_6291bcebb25b5578.webp 480w, https://chengxiaqiucao.github.io/post/098-midscene.js%E7%9A%84%E4%BD%BF%E7%94%A8/snap_20250520-2_hu_1e7b7a961f3d0cf4.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="552"
data-flex-basis="1326px"
>
&lt;/p>
&lt;p>After the application is complete, configure the corresponding large model parameters in the extension&amp;rsquo;s model settings screen; the Qwen model requires the following four parameters&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">OPENAI_BASE_URL=&amp;#34;https://dashscope.aliyuncs.com/compatible-mode/v1&amp;#34;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">OPENAI_API_KEY=&amp;#34;sk- your API KEY&amp;#34;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">MIDSCENE_MODEL_NAME=&amp;#34;qwen-vl-max-latest&amp;#34;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">MIDSCENE_USE_QWEN_VL=1
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="operating-the-browser">Operating the Browser
&lt;/h3>&lt;p>Next you can experience Midscene&amp;rsquo;s control of the browser in the extension interface. It mainly supports four behaviors:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Action&lt;/strong>: Corresponds to AI-planned operations; Midscene automatically plans the operation steps and executes them. It is smarter but slower, and the results depend on the quality of the large model.&lt;/li>
&lt;li>&lt;strong>Query&lt;/strong>: Extracts data directly from the UI and, with the reasoning ability of multimodal AI, achieves intelligent extraction&lt;/li>
&lt;li>&lt;strong>Assert&lt;/strong>: Describes an assertion condition in natural language and lets the AI judge whether the condition is true&lt;/li>
&lt;li>&lt;strong>Tap&lt;/strong>: Corresponds to an immediate page-click operation; Midscene executes it directly, and the large model only handles low-level tasks such as element locating. It is more efficient and is suitable when the operation to perform is already determined&lt;/li>
&lt;/ul>
&lt;p>We can enter prompt instructions using AI prompts close to natural language; for different behavior modes, the extension drives the browser to perform different operations and reports the results.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/098-midscene.js%E7%9A%84%E4%BD%BF%E7%94%A8/snap_20250520_hu_88f879538f9c0fc9.webp"
width="1024"
height="482"
srcset="https://chengxiaqiucao.github.io/post/098-midscene.js%E7%9A%84%E4%BD%BF%E7%94%A8/snap_20250520_hu_a705150c5ab15621.webp 480w, https://chengxiaqiucao.github.io/post/098-midscene.js%E7%9A%84%E4%BD%BF%E7%94%A8/snap_20250520_hu_88f879538f9c0fc9.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="212"
data-flex-basis="509px"
>
&lt;/p>
&lt;p>The concrete execution process can also be seen in the video demo below.&lt;/p>
&lt;h2 id="script-integration">Script Integration
&lt;/h2>&lt;p>Besides calling Midscene through the browser extension, the more recommended approach is to integrate Midscene capabilities through test framework scripts.&lt;/p>
&lt;p>With script integration, you also need to configure the relevant model call parameters, the same variable values configured in the extension, except that the relevant variables need to be set as &lt;strong>system environment variables&lt;/strong>&lt;/p>
&lt;p>Because Midscene is a JS-based tool, integrating it with a test framework here also requires JS support. Here we take Playwright as an example&lt;/p>
&lt;h3 id="installation">Installation
&lt;/h3>&lt;p>First, of course, you need the Playwright framework; enter the project directory, initialize and install Playwright, then install Midscene&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-powershell" data-lang="powershell">&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">npm&lt;/span> &lt;span class="n">init&lt;/span> &lt;span class="n">playwright&lt;/span>&lt;span class="nv">@latest&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">npm&lt;/span> &lt;span class="n">install&lt;/span> &lt;span class="nv">@midscene&lt;/span>&lt;span class="p">/&lt;/span>&lt;span class="n">web&lt;/span> &lt;span class="p">-&lt;/span>&lt;span class="n">-save-dev&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="playwright-framework-configuration">Playwright Framework Configuration
&lt;/h3>&lt;p>In the &lt;code>playwright.config.ts&lt;/code> file, configure the framework&amp;rsquo;s test discovery directory and test scripts, load environment variables, and set basic configurations such as browser type and execution strategy&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;span class="lnt">29
&lt;/span>&lt;span class="lnt">30
&lt;/span>&lt;span class="lnt">31
&lt;/span>&lt;span class="lnt">32
&lt;/span>&lt;span class="lnt">33
&lt;/span>&lt;span class="lnt">34
&lt;/span>&lt;span class="lnt">35
&lt;/span>&lt;span class="lnt">36
&lt;/span>&lt;span class="lnt">37
&lt;/span>&lt;span class="lnt">38
&lt;/span>&lt;span class="lnt">39
&lt;/span>&lt;span class="lnt">40
&lt;/span>&lt;span class="lnt">41
&lt;/span>&lt;span class="lnt">42
&lt;/span>&lt;span class="lnt">43
&lt;/span>&lt;span class="lnt">44
&lt;/span>&lt;span class="lnt">45
&lt;/span>&lt;span class="lnt">46
&lt;/span>&lt;span class="lnt">47
&lt;/span>&lt;span class="lnt">48
&lt;/span>&lt;span class="lnt">49
&lt;/span>&lt;span class="lnt">50
&lt;/span>&lt;span class="lnt">51
&lt;/span>&lt;span class="lnt">52
&lt;/span>&lt;span class="lnt">53
&lt;/span>&lt;span class="lnt">54
&lt;/span>&lt;span class="lnt">55
&lt;/span>&lt;span class="lnt">56
&lt;/span>&lt;span class="lnt">57
&lt;/span>&lt;span class="lnt">58
&lt;/span>&lt;span class="lnt">59
&lt;/span>&lt;span class="lnt">60
&lt;/span>&lt;span class="lnt">61
&lt;/span>&lt;span class="lnt">62
&lt;/span>&lt;span class="lnt">63
&lt;/span>&lt;span class="lnt">64
&lt;/span>&lt;span class="lnt">65
&lt;/span>&lt;span class="lnt">66
&lt;/span>&lt;span class="lnt">67
&lt;/span>&lt;span class="lnt">68
&lt;/span>&lt;span class="lnt">69
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-typescript" data-lang="typescript">&lt;span class="line">&lt;span class="cl">&lt;span class="kr">import&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">defineConfig&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nx">devices&lt;/span> &lt;span class="p">}&lt;/span> &lt;span class="kr">from&lt;/span> &lt;span class="s2">&amp;#34;@playwright/test&amp;#34;&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kr">import&lt;/span> &lt;span class="nx">dotenv&lt;/span> &lt;span class="kr">from&lt;/span> &lt;span class="s2">&amp;#34;dotenv&amp;#34;&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="cm">/* Load environment variables from the .env file via dotenv */&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nx">dotenv&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">config&lt;/span>&lt;span class="p">();&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kr">export&lt;/span> &lt;span class="k">default&lt;/span> &lt;span class="nx">defineConfig&lt;/span>&lt;span class="p">({&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="nx">testDir&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s2">&amp;#34;./e2e&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="nx">testMatch&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s2">&amp;#34;**/*.spec.ts&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="nx">timeout&lt;/span>: &lt;span class="kt">10&lt;/span> &lt;span class="o">*&lt;/span> &lt;span class="mi">60&lt;/span> &lt;span class="o">*&lt;/span> &lt;span class="mi">1000&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="cm">/* Run tests in files in parallel */&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="nx">fullyParallel&lt;/span>: &lt;span class="kt">false&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="cm">/* Fail the build on CI if you accidentally left test.only in the source code. */&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="nx">forbidOnly&lt;/span>: &lt;span class="kt">Boolean&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">process&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">env&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">CI&lt;/span>&lt;span class="p">),&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="cm">/* Retry on CI only */&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="nx">retries&lt;/span>: &lt;span class="kt">process.env.CI&lt;/span> &lt;span class="o">?&lt;/span> &lt;span class="nx">2&lt;/span> : &lt;span class="kt">0&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="cm">/* Opt out of parallel tests on CI. */&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="nx">workers&lt;/span>: &lt;span class="kt">process.env.CI&lt;/span> &lt;span class="o">?&lt;/span> &lt;span class="nx">1&lt;/span> : &lt;span class="kt">undefined&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="cm">/* Reporter to use. See https://playwright.dev/docs/test-reporters */&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="nx">reporter&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[[&lt;/span>&lt;span class="s2">&amp;#34;line&amp;#34;&lt;/span>&lt;span class="p">],&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s2">&amp;#34;@midscene/web/playwright-report&amp;#34;&lt;/span>&lt;span class="p">]],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="cm">/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="nx">use&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    &lt;span class="cm">/* Base URL to use in actions like `await page.goto(&amp;#39;/&amp;#39;)`. */&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    &lt;span class="c1">// baseURL: &amp;#39;http://127.0.0.1:3000&amp;#39;,
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    &lt;span class="cm">/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    &lt;span class="nx">trace&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s2">&amp;#34;on-first-retry&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="cm">/* Configure projects for major browsers */&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="nx">projects&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">[&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">      &lt;span class="nx">name&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="s2">&amp;#34;chromium&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">      &lt;span class="nx">use&lt;/span>&lt;span class="o">:&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="p">...&lt;/span>&lt;span class="nx">devices&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="s2">&amp;#34;Desktop Chrome&amp;#34;&lt;/span>&lt;span class="p">]&lt;/span> &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    &lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="p">],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">});&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="test-scripts">Test Scripts
&lt;/h3>&lt;p>Import the Midscene library through a separate fixture script&lt;/p>
&lt;p>fixture.ts&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-typescript" data-lang="typescript">&lt;span class="line">&lt;span class="cl">&lt;span class="kr">import&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">test&lt;/span> &lt;span class="kr">as&lt;/span> &lt;span class="nx">base&lt;/span> &lt;span class="p">}&lt;/span> &lt;span class="kr">from&lt;/span> &lt;span class="s1">&amp;#39;@playwright/test&amp;#39;&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kr">import&lt;/span> &lt;span class="kr">type&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">PlayWrightAiFixtureType&lt;/span> &lt;span class="p">}&lt;/span> &lt;span class="kr">from&lt;/span> &lt;span class="s1">&amp;#39;@midscene/web/playwright&amp;#39;&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kr">import&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">PlaywrightAiFixture&lt;/span> &lt;span class="p">}&lt;/span> &lt;span class="kr">from&lt;/span> &lt;span class="s1">&amp;#39;@midscene/web/playwright&amp;#39;&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kr">export&lt;/span> &lt;span class="kr">const&lt;/span> &lt;span class="nx">test&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nx">base&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">extend&lt;/span>&lt;span class="p">&amp;lt;&lt;/span>&lt;span class="nt">PlayWrightAiFixtureType&lt;/span>&lt;span class="p">&amp;gt;(&lt;/span>&lt;span class="nx">PlaywrightAiFixture&lt;/span>&lt;span class="p">({&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="nx">waitForNetworkIdleTimeout&lt;/span>: &lt;span class="kt">10000&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="c1">// Optional, the timeout for waiting for network idle during interaction; default is 2000ms; set to 0 to disable the timeout
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}));&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Write a script to test the &lt;code>https://todomvc.com/&lt;/code> to-do list sample project, using API methods such as &lt;code>.ai&lt;/code>, &lt;code>.aiTap&lt;/code>, &lt;code>.aiQuery&lt;/code>, and &lt;code>.aiAssert&lt;/code>, corresponding to the four typical operations mentioned earlier.&lt;/p>
&lt;p>todo_spec.ts&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;span class="lnt">29
&lt;/span>&lt;span class="lnt">30
&lt;/span>&lt;span class="lnt">31
&lt;/span>&lt;span class="lnt">32
&lt;/span>&lt;span class="lnt">33
&lt;/span>&lt;span class="lnt">34
&lt;/span>&lt;span class="lnt">35
&lt;/span>&lt;span class="lnt">36
&lt;/span>&lt;span class="lnt">37
&lt;/span>&lt;span class="lnt">38
&lt;/span>&lt;span class="lnt">39
&lt;/span>&lt;span class="lnt">40
&lt;/span>&lt;span class="lnt">41
&lt;/span>&lt;span class="lnt">42
&lt;/span>&lt;span class="lnt">43
&lt;/span>&lt;span class="lnt">44
&lt;/span>&lt;span class="lnt">45
&lt;/span>&lt;span class="lnt">46
&lt;/span>&lt;span class="lnt">47
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-typescript" data-lang="typescript">&lt;span class="line">&lt;span class="cl">&lt;span class="kr">import&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">expect&lt;/span> &lt;span class="p">}&lt;/span> &lt;span class="kr">from&lt;/span> &lt;span class="s2">&amp;#34;@playwright/test&amp;#34;&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kr">import&lt;/span> &lt;span class="p">{&lt;/span> &lt;span class="nx">test&lt;/span> &lt;span class="p">}&lt;/span> &lt;span class="kr">from&lt;/span> &lt;span class="s2">&amp;#34;./fixture&amp;#34;&lt;/span>&lt;span class="p">;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nx">test&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">beforeEach&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="kr">async&lt;/span> &lt;span class="p">({&lt;/span> &lt;span class="nx">page&lt;/span> &lt;span class="p">})&lt;/span> &lt;span class="o">=&amp;gt;&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="k">await&lt;/span> &lt;span class="nx">page&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="kr">goto&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;https://todomvc.com/examples/react/dist/&amp;#34;&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">});&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nx">test&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;ai todo - Chinese Prompt&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="kr">async&lt;/span> &lt;span class="p">({&lt;/span> &lt;span class="nx">ai&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nx">aiQuery&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nx">aiAssert&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="nx">aiTap&lt;/span> &lt;span class="p">})&lt;/span> &lt;span class="o">=&amp;gt;&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="c1">// .ai - Generic AI operation method
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="k">await&lt;/span> &lt;span class="nx">ai&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;在任务框 input 输入 今天学习 Playwright，按回车键&amp;#34;&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="k">await&lt;/span> &lt;span class="nx">ai&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;在任务框 input 输入 明天学习 js脚本，按回车键&amp;#34;&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="k">await&lt;/span> &lt;span class="nx">ai&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;在任务框 input 输入 后天学习 AI测试，按回车键&amp;#34;&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="k">await&lt;/span> &lt;span class="nx">ai&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;将鼠标移动到任务列表中的第二项&amp;#34;&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="k">await&lt;/span> &lt;span class="nx">aiTap&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;第二项任务右边的删除按钮&amp;#34;&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="c1">// .aiTap - Specify the operation type
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="k">await&lt;/span> &lt;span class="nx">aiTap&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;第二条任务左边的勾选按钮&amp;#34;&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="k">await&lt;/span> &lt;span class="nx">aiTap&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;任务列表下面的 completed 状态按钮&amp;#34;&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1">// .aiQuery - Page information extraction operation
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>  &lt;span class="kr">const&lt;/span> &lt;span class="nx">list&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="k">await&lt;/span> &lt;span class="nx">aiQuery&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;string[], 完整的任务列表&amp;#34;&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="nx">expect&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nx">list&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nx">length&lt;/span>&lt;span class="p">).&lt;/span>&lt;span class="nx">toEqual&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1">// .aiAssert - Assertion operation
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">  &lt;span class="k">await&lt;/span> &lt;span class="nx">aiAssert&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;列表下方有一个区域显示有 &amp;#34;1 item left&amp;#34;&amp;#39;&lt;/span>&lt;span class="p">);&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">});&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Run the script:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-powershell" data-lang="powershell">&lt;span class="line">&lt;span class="cl">&lt;span class="n">npx&lt;/span> &lt;span class="n">playwright&lt;/span> &lt;span class="n">test&lt;/span> &lt;span class="p">-&lt;/span>&lt;span class="n">-headed&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>The execution process can be seen in the video I recorded&lt;/p>
&lt;p>【】&lt;/p>
&lt;h3 id="visual-result-report">Visual Result Report
&lt;/h3>&lt;p>The report is one of Midscene&amp;rsquo;s highlights. Through it you can replay the entire execution process, with detailed display of the AI&amp;rsquo;s spatial judgment process and concrete operation details, making it easy to debug and optimize scripts.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/098-midscene.js%E7%9A%84%E4%BD%BF%E7%94%A8/snap_20250520-1_hu_fb7e8fb8ed9ae66b.webp"
width="1024"
height="479"
srcset="https://chengxiaqiucao.github.io/post/098-midscene.js%E7%9A%84%E4%BD%BF%E7%94%A8/snap_20250520-1_hu_adf181060651d5e3.webp 480w, https://chengxiaqiucao.github.io/post/098-midscene.js%E7%9A%84%E4%BD%BF%E7%94%A8/snap_20250520-1_hu_fb7e8fb8ed9ae66b.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="213"
data-flex-basis="512px"
>
&lt;/p>
&lt;h2 id="yaml-file-driven">YAML File-Driven
&lt;/h2>&lt;p>Besides integration through test framework scripts, Midscene also supports writing test scripts directly with YAML files, enabling no-code script driving, similar to the keyword-driven approach of traditional automation.&lt;/p>
&lt;p>In essence, this approach still converts the corresponding keywords into the relevant APIs supported by Midscene for driving.&lt;/p>
&lt;p>A format like the following, operating a weather website:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-YAML" data-lang="YAML">&lt;span class="line">&lt;span class="cl">&lt;span class="nt">web&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">url&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">https://www.bing.com&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">tasks&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">搜索天气&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">flow&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">ai&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">搜索 &amp;#34;今日天气&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">sleep&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="m">3000&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">name&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">检查结果&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">flow&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>- &lt;span class="nt">aiAssert&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">结果中展示了天气信息&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>To run YAML-format scripts, you need to install Midscene&amp;rsquo;s command-line support&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-powershell" data-lang="powershell">&lt;span class="line">&lt;span class="cl">&lt;span class="n">npm&lt;/span> &lt;span class="n">install&lt;/span> &lt;span class="nv">@midscene&lt;/span>&lt;span class="p">/&lt;/span>&lt;span class="nb">cli &lt;/span>&lt;span class="p">-&lt;/span>&lt;span class="n">-save-dev&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c"># Run&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">npx&lt;/span> &lt;span class="n">midscene&lt;/span> &lt;span class="p">./&lt;/span>&lt;span class="n">weather&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="py">yaml&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h2 id="mcp-approach">MCP Approach
&lt;/h2>&lt;p>Beyond the methods above, Midscene also offers a way to act as a local MCP server. This approach essentially wraps MidScene&amp;rsquo;s Chrome extension as a local capability inside MCP, then drives the browser by combining a large model with the mcp server.&lt;/p>
&lt;p>For an introduction to and usage of mcp server, see my earlier related article 【】&lt;/p>
&lt;p>mcp server configuration:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-json" data-lang="json">&lt;span class="line">&lt;span class="cl">&lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;mcpServers&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;mcp-midscene&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;command&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;npx&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;args&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="s2">&amp;#34;-y&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s2">&amp;#34;@midscene/mcp&amp;#34;&lt;/span>&lt;span class="p">],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;env&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;MIDSCENE_MODEL_NAME&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;REPLACE_WITH_YOUR_MODEL_NAME&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;OPENAI_API_KEY&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;REPLACE_WITH_YOUR_OPENAI_API_KEY&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;MCP_SERVER_REQUEST_TIMEOUT&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;800000&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h2 id="limitations-of-the-current-version">Limitations of the Current Version
&lt;/h2>&lt;p>Although the Midsence tool has already shown considerable potential and is still being continuously updated and iterated, it still has quite a few shortcomings in practical use, mainly in the following areas:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Limited interaction types&lt;/strong>: Currently only click, drag (supported only in the UI-TARS model), input, keyboard, and scroll operations are supported.&lt;/li>
&lt;li>&lt;strong>Stability risks&lt;/strong>: The return values of AI models cannot be guaranteed to be 100% accurate. Writing good prompts is demanding&lt;/li>
&lt;li>&lt;strong>Element recognition&lt;/strong>: Some large models are not very good at recognizing elements, such as interactions with iframe and canvas elements. Moreover, Chrome&amp;rsquo;s native controls like pop-up prompts and right-click menus are not yet supported.&lt;/li>
&lt;li>&lt;strong>Higher cost&lt;/strong>: Being based on visual recognition, token consumption is considerable, and if a paid large model is used, the cost can be high.&lt;/li>
&lt;/ul>
&lt;p>But these flaws do not overshadow the merits: Midscene has already taken a solid step forward in improving UI automation testing with AI capabilities! We will continue to follow its further development!&lt;/p>
&lt;hr>
&lt;h3 id="further-reading">Further Reading:
&lt;/h3>&lt;p>【】
【】&lt;/p>
&lt;p>Join the group, outline&lt;/p></description></item><item><title>Microsoft Releases Magentic UI, a Hands-On Review of the Interactive AI Agent Assistant</title><link>https://chengxiaqiucao.github.io/en/post/096-magenticui%E8%AF%84%E6%B5%8B/</link><pubDate>Fri, 30 May 2025 00:00:00 +0000</pubDate><guid>https://chengxiaqiucao.github.io/en/post/096-magenticui%E8%AF%84%E6%B5%8B/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/096-magenticui%E8%AF%84%E6%B5%8B/magentic_logo.webp" alt="Featured image of post Microsoft Releases Magentic UI, a Hands-On Review of the Interactive AI Agent Assistant" />&lt;h2 id="what-is-magentic-ui">What Is Magentic UI?
&lt;/h2>&lt;p>&lt;code>Magentic UI&lt;/code> is an open-source Agent assistant that Microsoft released with much fanfare on May 19, and it just updated to its second version, 0.04, on the 24th&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/096-magenticui%E8%AF%84%E6%B5%8B/snap_20250526_hu_9b68e96ee9a20ceb.webp"
width="1024"
height="284"
srcset="https://chengxiaqiucao.github.io/post/096-magenticui%E8%AF%84%E6%B5%8B/snap_20250526_hu_987fa047fbc9f36d.webp 480w, https://chengxiaqiucao.github.io/post/096-magenticui%E8%AF%84%E6%B5%8B/snap_20250526_hu_9b68e96ee9a20ceb.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="361"
data-flex-basis="866px"
>
&lt;/p>
&lt;p>Judging from the official introduction, the goal is to build a &lt;strong>human-centered&lt;/strong> intelligent assistant, powered at its core by several different agent systems, capable of web browsing and operation, code generation and execution, and file generation and analysis.&lt;/p>
&lt;p>What mainly sets it apart from other AI browser tools is its &lt;strong>transparent and controllable interactive interface&lt;/strong>, which supports efficient human-AI collaborative participation. The system is built on Microsoft&amp;rsquo;s agent-building framework AutoGen and is currently still at the prototype research stage.&lt;/p>
&lt;p>Core features include:&lt;/p>
&lt;p>🧑‍🤝‍🧑 &lt;strong>Collaborative planning&lt;/strong>: users and the AI work together through chat and a plan editor to create and revise step-by-step execution plans.&lt;br>
🤝 &lt;strong>Collaborative tasks&lt;/strong>: users can intervene in real time and guide task execution directly through the web browser or the chat interface. Magentic-UI can proactively ask for confirmation or request assistance when needed.&lt;br>
🛡️ &lt;strong>Action guard&lt;/strong>: sensitive operations require explicit user approval before they can be executed.&lt;br>
🧠 &lt;strong>Plan learning and retrieval&lt;/strong>: it learns from past tasks to optimize future automation workflows and saves good solutions into a plan library. Stored plans can be invoked automatically or manually in subsequent tasks.&lt;br>
🔀 &lt;strong>Parallel task execution&lt;/strong>: it supports running multiple tasks in parallel, and a session status indicator shows in real time when Magentic-UI needs your input or has completed a task.&lt;/p>
&lt;h2 id="design-architecture">Design Architecture
&lt;/h2>&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/096-magenticui%E8%AF%84%E6%B5%8B/snap_20250526-1_hu_6105176311731903.webp"
width="1024"
height="777"
srcset="https://chengxiaqiucao.github.io/post/096-magenticui%E8%AF%84%E6%B5%8B/snap_20250526-1_hu_8ee1935638f54b1e.webp 480w, https://chengxiaqiucao.github.io/post/096-magenticui%E8%AF%84%E6%B5%8B/snap_20250526-1_hu_6105176311731903.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="131"
data-flex-basis="316px"
>
&lt;/p>
&lt;p>The underlying system of &lt;strong>Magentic-UI&lt;/strong> consists of a group of specialized agents adapted from AutoGen&amp;rsquo;s &lt;strong>Magentic-One&lt;/strong> system (shown in the figure above), with each agent implementing different functions through modular collaboration:&lt;/p>
&lt;h3 id="agent-functionality">Agent Functionality
&lt;/h3>&lt;h4 id="orchestrator">&lt;strong>Orchestrator&lt;/strong>
&lt;/h4>&lt;ul>
&lt;li>&lt;strong>Functional role&lt;/strong>: the main LLM-based controlling agent, responsible for collaboratively making plans with the user, deciding when to request user feedback, and assigning subtasks to other agents.&lt;/li>
&lt;li>&lt;strong>Collaboration flow&lt;/strong>:
&lt;ol>
&lt;li>Jointly create a step-by-step execution plan with the user;&lt;/li>
&lt;li>Dynamically determine the points where user intervention is needed;&lt;/li>
&lt;li>Dispatch subtasks to other agents for execution.&lt;/li>
&lt;/ol>
&lt;/li>
&lt;/ul>
&lt;h4 id="websurfer">&lt;strong>WebSurfer&lt;/strong>
&lt;/h4>&lt;ul>
&lt;li>&lt;strong>Functional role&lt;/strong>: an LLM agent equipped with a web browser, supporting multi-round web interaction operations.&lt;/li>
&lt;li>&lt;strong>Core capabilities&lt;/strong>:
&lt;ul>
&lt;li>Following the Orchestrator&amp;rsquo;s instructions, perform operations such as clicking, typing, scrolling, and page navigation;&lt;/li>
&lt;li>&lt;strong>Beyond AutoGen&amp;rsquo;s multimodal web browser&lt;/strong>: adds tab management, option selection, file upload, and multimodal query support.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;h4 id="coder">&lt;strong>Coder&lt;/strong>
&lt;/h4>&lt;ul>
&lt;li>&lt;strong>Functional role&lt;/strong>: an LLM agent equipped with a Docker code execution container.&lt;/li>
&lt;li>&lt;strong>Core capabilities&lt;/strong>:
&lt;ul>
&lt;li>Write and execute Python and Shell commands;&lt;/li>
&lt;li>Feed the execution results back to the Orchestrator.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;h4 id="filesurfer">**FileSurfer
&lt;/h4>&lt;p>**&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Functional role&lt;/strong>: an LLM agent integrating a Docker container with the MarkItDown package file-conversion tool.&lt;/li>
&lt;li>&lt;strong>Core capabilities&lt;/strong>:
&lt;ul>
&lt;li>Locate files in Magentic-UI&amp;rsquo;s controlled directory;&lt;/li>
&lt;li>Convert files to Markdown format and support question answering over their content.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;h4 id="userproxy">&lt;strong>UserProxy&lt;/strong>
&lt;/h4>&lt;ul>
&lt;li>&lt;strong>Functional role&lt;/strong>: the agent role that interacts with the system on behalf of the user.&lt;/li>
&lt;li>&lt;strong>Collaboration mode&lt;/strong>: the Orchestrator can delegate tasks directly to the user (rather than to other agents) to complete.&lt;/li>
&lt;/ul>
&lt;h3 id="user-interaction-flow">User Interaction Flow
&lt;/h3>&lt;p>The interaction flow of a user using Magentic UI can be illustrated by the following diagram:
&lt;a class="link" href="https://mermaid.live/edit#pako:eNplVFtPGlEQ_ivkPKOyiCKYtGm9VFut9zbpwgPKqiSVNSsk2g2JNl5AUaCo0YgXLF7SVNCmliqif4Zzdvdf9OyZZcW6Tztzvm_mmzkzR0Zjol9AbjQh-aYnLcPtnqCFfq94ZfOcRIs4kVKvi2qhSK6-ei11dS8sr3n1Po2XTsj2Csn8bNB2F_HqEd67V2Ir3lYgv2bANrnXNyEEQ4GxupFui7J5SKJJHF0mFydqPouj3yIGuo2ijWMdsXrI2O2GAPVhjyYDhnK3rd6nlK24tn_sfc7GuSv19wnk5niSSCq5WwiirayT7UvQbRI5KIea4GiHSDoeEkFShuqQwUXS65Vypqq8Q2eQYok2oAFHj7TdXEPlIU82b2iN2o8c1FGLVbJ5NZ_D-ThVy047eTJfIhtnldJ3JbmML3bw13NI6zV1dTLkGx4nC3jVOCWxMzUbx3dbJL1RLegNw3XJJB7Tsrf4NgEg0BIxw3UxWLeMy2kcW4dT5aqED9ZeVuuaCY_CNOClYqWcBgxEA4D--QOSMBYKiEFLz-Cjt1sv86MwOhSWxgWJpXrLA1Upp7TsNXSwqtmktNEhBPg73rjNmz_A03tztPCM0Rn4LNRk6eFxbpH2kI5lpfTnGXpkRpD6JXF2joF7n0wHia3Rxj4VJgT91Ya9ZZT3stGGnQJOnsKgwkWabXsHQMPqeWL1mhbY79no7BSYu08msXmSiUEGvL-Ci7_-i83wNDHD9_Nq_hKXt7TNXbVQwBuHeO_ocV76GWZABqVaZl49XTAW4GyRzo4Zc6BWwyAPS25sXf4vThRqWdXGDIKQOFlMwKbV-snaN6W0z_xDvFKKkotjcr2gnK95a1NWyxgyJffVKhk2BoBk5mkIpZQmB-a19NXyu0z-MLNH6IqkjGcrFVU2Lp9yRxjoA6979w-9rchK37yAH7lDUliwoilBmvLpJpJ1vAeFJoUpwYPc9HdclISZkAd5ghHKmvYFP4niVJUoieGJSeQe932eoVZ42u8LCe0BH92gRwgdJ0FqE8PBEHJzLhYCuWU0i9yNLU31dpvLaWtq4Zycw95kRXPI7eDqHZzdaXM4XdTlbOQiVvSF5bTVu2wue6O92c412m0tDluzFQn-QEiUeuEdZ8955B-N54jD" target="_blank" rel="noopener"
>&lt;img src="https://mermaid.ink/img/pako:eNplVFtPGlEQ_ivkPKOyiCKYtGm9VFut9zbpwgPKqiSVNSsk2g2JNl5AUaCo0YgXLF7SVNCmliqif4Zzdvdf9OyZZcW6Tztzvm_mmzkzR0Zjol9AbjQh-aYnLcPtnqCFfq94ZfOcRIs4kVKvi2qhSK6-ei11dS8sr3n1Po2XTsj2Csn8bNB2F_HqEd67V2Ir3lYgv2bANrnXNyEEQ4GxupFui7J5SKJJHF0mFydqPouj3yIGuo2ijWMdsXrI2O2GAPVhjyYDhnK3rd6nlK24tn_sfc7GuSv19wnk5niSSCq5WwiirayT7UvQbRI5KIea4GiHSDoeEkFShuqQwUXS65Vypqq8Q2eQYok2oAFHj7TdXEPlIU82b2iN2o8c1FGLVbJ5NZ_D-ThVy047eTJfIhtnldJ3JbmML3bw13NI6zV1dTLkGx4nC3jVOCWxMzUbx3dbJL1RLegNw3XJJB7Tsrf4NgEg0BIxw3UxWLeMy2kcW4dT5aqED9ZeVuuaCY_CNOClYqWcBgxEA4D--QOSMBYKiEFLz-Cjt1sv86MwOhSWxgWJpXrLA1Upp7TsNXSwqtmktNEhBPg73rjNmz_A03tztPCM0Rn4LNRk6eFxbpH2kI5lpfTnGXpkRpD6JXF2joF7n0wHia3Rxj4VJgT91Ya9ZZT3stGGnQJOnsKgwkWabXsHQMPqeWL1mhbY79no7BSYu08msXmSiUEGvL-Ci7_-i83wNDHD9_Nq_hKXt7TNXbVQwBuHeO_ocV76GWZABqVaZl49XTAW4GyRzo4Zc6BWwyAPS25sXf4vThRqWdXGDIKQOFlMwKbV-snaN6W0z_xDvFKKkotjcr2gnK95a1NWyxgyJffVKhk2BoBk5mkIpZQmB-a19NXyu0z-MLNH6IqkjGcrFVU2Lp9yRxjoA6979w-9rchK37yAH7lDUliwoilBmvLpJpJ1vAeFJoUpwYPc9HdclISZkAd5ghHKmvYFP4niVJUoieGJSeQe932eoVZ42u8LCe0BH92gRwgdJ0FqE8PBEHJzLhYCuWU0i9yNLU31dpvLaWtq4Zycw95kRXPI7eDqHZzdaXM4XdTlbOQiVvSF5bTVu2wue6O92c412m0tDluzFQn-QEiUeuEdZ8955B-N54jD?type=png"
loading="lazy"
>
&lt;/a>&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;span class="lnt">29
&lt;/span>&lt;span class="lnt">30
&lt;/span>&lt;span class="lnt">31
&lt;/span>&lt;span class="lnt">32
&lt;/span>&lt;span class="lnt">33
&lt;/span>&lt;span class="lnt">34
&lt;/span>&lt;span class="lnt">35
&lt;/span>&lt;span class="lnt">36
&lt;/span>&lt;span class="lnt">37
&lt;/span>&lt;span class="lnt">38
&lt;/span>&lt;span class="lnt">39
&lt;/span>&lt;span class="lnt">40
&lt;/span>&lt;span class="lnt">41
&lt;/span>&lt;span class="lnt">42
&lt;/span>&lt;span class="lnt">43
&lt;/span>&lt;span class="lnt">44
&lt;/span>&lt;span class="lnt">45
&lt;/span>&lt;span class="lnt">46
&lt;/span>&lt;span class="lnt">47
&lt;/span>&lt;span class="lnt">48
&lt;/span>&lt;span class="lnt">49
&lt;/span>&lt;span class="lnt">50
&lt;/span>&lt;span class="lnt">51
&lt;/span>&lt;span class="lnt">52
&lt;/span>&lt;span class="lnt">53
&lt;/span>&lt;span class="lnt">54
&lt;/span>&lt;span class="lnt">55
&lt;/span>&lt;span class="lnt">56
&lt;/span>&lt;span class="lnt">57
&lt;/span>&lt;span class="lnt">58
&lt;/span>&lt;span class="lnt">59
&lt;/span>&lt;span class="lnt">60
&lt;/span>&lt;span class="lnt">61
&lt;/span>&lt;span class="lnt">62
&lt;/span>&lt;span class="lnt">63
&lt;/span>&lt;span class="lnt">64
&lt;/span>&lt;span class="lnt">65
&lt;/span>&lt;span class="lnt">66
&lt;/span>&lt;span class="lnt">67
&lt;/span>&lt;span class="lnt">68
&lt;/span>&lt;span class="lnt">69
&lt;/span>&lt;span class="lnt">70
&lt;/span>&lt;span class="lnt">71
&lt;/span>&lt;span class="lnt">72
&lt;/span>&lt;span class="lnt">73
&lt;/span>&lt;span class="lnt">74
&lt;/span>&lt;span class="lnt">75
&lt;/span>&lt;span class="lnt">76
&lt;/span>&lt;span class="lnt">77
&lt;/span>&lt;span class="lnt">78
&lt;/span>&lt;span class="lnt">79
&lt;/span>&lt;span class="lnt">80
&lt;/span>&lt;span class="lnt">81
&lt;/span>&lt;span class="lnt">82
&lt;/span>&lt;span class="lnt">83
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">graph TD
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    A[用户发起请求] --&amp;gt; B[输入文本/附加图片];
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    B --&amp;gt; C{Magentic-UI 生成分步计划};
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    C -- 生成成功 --&amp;gt; D[用户进入计划编辑界面];
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    C -- 生成失败 --&amp;gt; C1[提示用户重新输入];
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    C1 --&amp;gt; B;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    D -- 用户编辑计划 --&amp;gt; E{编辑操作};
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    E -- 添加/删除/修改步骤 --&amp;gt; D;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    E -- 确认完成 --&amp;gt; F[总控代理存储计划];
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    F --&amp;gt; G[启动计划执行引擎];
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    G --&amp;gt; H{按顺序执行步骤};
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    H --&amp;gt; I{当前步骤类型?};
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    subgraph 具体步骤执行
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">        direction LR
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">        I -- WebSurfer --&amp;gt; J[执行网页操作];
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">        I -- Coder --&amp;gt; K[生成并执行代码];
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">        I -- FileSurfer --&amp;gt; L[处理文件];
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">        I -- UserProxy --&amp;gt; M[提示用户手动操作];
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    end
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    J --&amp;gt; N{步骤是否成功完成?};
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    K --&amp;gt; N;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    L --&amp;gt; N;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    M --&amp;gt; N;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    N -- 是 --&amp;gt; O{所有步骤均已完成?};
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    N -- 否 --&amp;gt; P[记录错误原因];
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    P --&amp;gt; Q{是否需要重新规划?};
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    Q -- 是 --&amp;gt; R[请求用户许可重新规划];
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    R -- 同意 --&amp;gt; C;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    R -- 拒绝 --&amp;gt; S[终止流程];
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    Q -- 否 --&amp;gt; S;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    O -- 是 --&amp;gt; T[生成最终结果];
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    O -- 否 --&amp;gt; H;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    T --&amp;gt; U[向用户呈现结果];
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">    U --&amp;gt; V[结束];
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;hr>
&lt;ol>
&lt;li>
&lt;p>&lt;strong>Input and plan generation&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>The user triggers the flow through text/images, and the system generates an initial plan. If it fails, the user is prompted to re-enter.&lt;/li>
&lt;li>The user iteratively refines the plan through the editing interface, and after confirmation, moves to the execution phase.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Plan execution logic&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>The Orchestrator assigns tasks step by step to the corresponding agents (WebSurfer/Coder/FileSurfer) or to the user.&lt;/li>
&lt;li>After each step is completed, the status is verified; if it fails, a decision is made on whether replanning is needed (requiring user authorization).&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Dynamic control and termination&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>The user can intervene at any time: pause execution, modify the plan, or terminate the flow.&lt;/li>
&lt;li>Once all steps are completed, the final result is delivered, with transparent error feedback provided in exceptional cases.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ol>
&lt;h2 id="tool-deployment">Tool Deployment
&lt;/h2>&lt;p>&lt;strong>Magentic AI&lt;/strong> is mainly developed in Python, with the web part based on FastAPI. Its AI control primarily uses Playwright to control a virtual browser inside a &lt;strong>Docker&lt;/strong> container, which can be displayed to the user in real time. The large model behind it is mainly used through the API access methods of various open large models.&lt;/p>
&lt;p>Therefore, to deploy Magentic UI, you first need to confirm the relevant prerequisites:&lt;/p>
&lt;ul>
&lt;li>Docker is installed; if it is a Windows system, install Docker Desktop and integrate it with WSL&lt;/li>
&lt;li>Provide the &lt;strong>API KEY&lt;/strong> for accessing the large model; the default is &lt;strong>OPENAI&lt;/strong>&amp;rsquo;s API KEY&lt;/li>
&lt;li>A Python runtime environment with a version &lt;strong>&amp;gt;3.10&lt;/strong>&lt;/li>
&lt;/ul>
&lt;p>The tool was deployed in WSL. First create a Python virtual environment, then install Magentic AI and its related dependencies&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">python3 -m venv .venv
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">source&lt;/span> .venv/bin/activate
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">pip3 install magentic-ui
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Make sure Docker is started, and before running Magentic UI there should be no related containers running&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">docker ps
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>For the large model, you can use OPENAI on Microsoft Azure AI; after completing the configuration, set the corresponding api key as the environment variable &lt;code>OPENAI_API_KEY&lt;/code>&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">&lt;span class="nb">export&lt;/span> &lt;span class="nv">OPENAI_API_KEY&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s2">&amp;#34;YOUR_API_KEY&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>In addition, Magentic UI itself needs to be configured for the large model; the Azure AI configuration template is as follows:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;span class="lnt">29
&lt;/span>&lt;span class="lnt">30
&lt;/span>&lt;span class="lnt">31
&lt;/span>&lt;span class="lnt">32
&lt;/span>&lt;span class="lnt">33
&lt;/span>&lt;span class="lnt">34
&lt;/span>&lt;span class="lnt">35
&lt;/span>&lt;span class="lnt">36
&lt;/span>&lt;span class="lnt">37
&lt;/span>&lt;span class="lnt">38
&lt;/span>&lt;span class="lnt">39
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-YAML" data-lang="YAML">&lt;span class="line">&lt;span class="cl">&lt;span class="nt">model_config&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">&amp;amp;client&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">  &lt;/span>&lt;span class="nt">provider&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">AzureOpenAIChatCompletionClient&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">  &lt;/span>&lt;span class="nt">config&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">    &lt;/span>&lt;span class="nt">model&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">gpt-4o&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">    &lt;/span>&lt;span class="nt">azure_endpoint&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;&amp;lt;YOUR ENDPOINT&amp;gt;&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">    &lt;/span>&lt;span class="nt">azure_deployment&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;&amp;lt;YOUR DEPLOYMENT&amp;gt;&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">    &lt;/span>&lt;span class="nt">api_version&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;2024-10-21&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">    &lt;/span>&lt;span class="nt">azure_ad_token_provider&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">      &lt;/span>&lt;span class="nt">provider&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">autogen_ext.auth.azure.AzureTokenProvider&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">      &lt;/span>&lt;span class="nt">config&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">        &lt;/span>&lt;span class="nt">provider_kind&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">DefaultAzureCredential&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">        &lt;/span>&lt;span class="nt">scopes&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">          &lt;/span>- &lt;span class="l">https://cognitiveservices.azure.com/.default&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">    &lt;/span>&lt;span class="nt">max_retries&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="m">10&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">orchestrator_client&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">*client&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">coder_client&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">*client&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">web_surfer_client&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">*client&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">file_surfer_client&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">*client&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">action_guard_client&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="cp">*client&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h2 id="running">Running
&lt;/h2>&lt;p>Then run Magentic ui, which uses port 8081 by default. The first run will download multiple different docker images and related dependencies, which takes a long time, so wait for the installation to complete&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">magentic ui --port &lt;span class="m">8081&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Once the following information appears in the running log, startup has succeeded&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">| INFO | magentic_ui.backend.web.app:lifespan:59 - Application startup complete. Navigate to http://127.0.0.1:8081
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Access &lt;code>http://localhost:8081&lt;/code> in the browser&lt;/p>
&lt;p>You will see the following interface
&lt;img src="https://chengxiaqiucao.github.io/post/096-magenticui%E8%AF%84%E6%B5%8B/snap_20250526-3_hu_ea89256ed7f35d1d.webp"
width="1024"
height="434"
srcset="https://chengxiaqiucao.github.io/post/096-magenticui%E8%AF%84%E6%B5%8B/snap_20250526-3_hu_459c3f4957a6bae0.webp 480w, https://chengxiaqiucao.github.io/post/096-magenticui%E8%AF%84%E6%B5%8B/snap_20250526-3_hu_ea89256ed7f35d1d.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="236"
data-flex-basis="566px"
>
&lt;/p>
&lt;p>After starting a session, for example, ask the AI to help us complete a test&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">Please test whether the login functionality for different users on the saucedemo.com website works correctly, and summarize the issues in markdown format
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>If the installation is correct and the large model calls work normally, Magentic UI will plan the relevant task plan and ask the user to confirm&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/096-magenticui%E8%AF%84%E6%B5%8B/snap_20250526-5_hu_5eabeac52c2fb4c8.webp"
width="1024"
height="462"
srcset="https://chengxiaqiucao.github.io/post/096-magenticui%E8%AF%84%E6%B5%8B/snap_20250526-5_hu_442cb3d2ba4e44b1.webp 480w, https://chengxiaqiucao.github.io/post/096-magenticui%E8%AF%84%E6%B5%8B/snap_20250526-5_hu_5eabeac52c2fb4c8.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="221"
data-flex-basis="532px"
>
&lt;/p>
&lt;p>The user can also adjust the plan based on the feedback, and during plan execution can interact with the AI to change its execution path. For a concrete execution demonstration, see the video below.&lt;/p>
&lt;p>At this point, checking the docker runtime information in WSL, you can see that 3 containers are running, two of which are mangenti UI&amp;rsquo;s &lt;code>coder&lt;/code> and &lt;code>file surfer&lt;/code> agents, and the other is a remotely viewable &lt;code>vnc_browser&lt;/code> container&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/096-magenticui%E8%AF%84%E6%B5%8B/snap_20250526-2_hu_3fe0d746923ab871.webp"
width="1024"
height="243"
srcset="https://chengxiaqiucao.github.io/post/096-magenticui%E8%AF%84%E6%B5%8B/snap_20250526-2_hu_1150e5ae89cc54be.webp 480w, https://chengxiaqiucao.github.io/post/096-magenticui%E8%AF%84%E6%B5%8B/snap_20250526-2_hu_3fe0d746923ab871.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="420"
data-flex-basis="1009px"
>
&lt;/p>
&lt;p>After the series of steps is completed, Magentic UI obtains the following markdown-format result summary based on the initial instruction.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-markdown" data-lang="markdown">&lt;span class="line">&lt;span class="cl">以下是对saucedemo.com网站不同用户登录功能测试的结果汇总：
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">1.&lt;/span> &lt;span class="gs">**标准用户**&lt;/span> (&lt;span class="sb">`standard_user`&lt;/span>):
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> 登录成功。
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> 无问题，用户可以正常访问库存页面并浏览产品。
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">2.&lt;/span> &lt;span class="gs">**被锁定用户**&lt;/span> (&lt;span class="sb">`locked_out_user`&lt;/span>):
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> 登录失败。
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> 显示错误消息 &amp;#34;Epic sadface: Sorry, this user has been locked out.&amp;#34; 账户已被锁定，无法访问。
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">3.&lt;/span> &lt;span class="gs">**问题用户**&lt;/span> (&lt;span class="sb">`problem_user`&lt;/span>):
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> 登录成功。
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> 产品图像存在不匹配的问题，图像错误是已知问题。
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">4.&lt;/span> &lt;span class="gs">**性能故障用户**&lt;/span> (&lt;span class="sb">`performance_glitch_user`&lt;/span>):
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> 登录成功。
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">-&lt;/span> 无明显系统减慢或异常，用户可以正常导航。
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">这些结果表明网站能够正确处理不同账户类型的登录场景。如果您想亲自测试，可以访问 [&lt;span class="nt">saucedemo.com&lt;/span>](&lt;span class="na">https://www.saucedemo.com/&lt;/span>)。
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h2 id="hands-on-impressions">Hands-On Impressions
&lt;/h2>&lt;p>Overall, after using it, repositioning AI as an assistant role is clearly more in line with the reality of current AI applications, and displaying the AI&amp;rsquo;s operation process in real time through the container makes AI task execution no longer a black box, which is indeed much friendlier.&lt;/p>
&lt;p>However, in use I still feel the practicality is not very good. Although the official statement says it is still research-oriented at this stage, there is still considerable room for improvement.&lt;/p>
&lt;ol>
&lt;li>Installation and configuration are relatively complex, with numerous dependency packages, and it takes a long time&lt;/li>
&lt;li>The capability of the large model itself has a large impact on the execution process, including whether interactions can be completed normally. There are many call failures and exceptions.&lt;/li>
&lt;li>The token consumption of the large model is considerable; to complete one task, it actually breaks down into dozens of different requests, and the token consumption of each request is also in the thousands, so with a paid model the cost is high&lt;/li>
&lt;/ol>
&lt;p>The figure below shows the token consumption during my trial as viewed in the Azure backend, which is quite considerable.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/096-magenticui%E8%AF%84%E6%B5%8B/snap_20250526-4_hu_e098ae694e9d64ff.webp"
width="1024"
height="261"
srcset="https://chengxiaqiucao.github.io/post/096-magenticui%E8%AF%84%E6%B5%8B/snap_20250526-4_hu_97df20c8bdae3d29.webp 480w, https://chengxiaqiucao.github.io/post/096-magenticui%E8%AF%84%E6%B5%8B/snap_20250526-4_hu_e098ae694e9d64ff.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="392"
data-flex-basis="942px"
>
&lt;/p>
&lt;p>In short, the development direction of Magentic UI is worth looking forward to, but for now we still need to wait for its further refinement.&lt;/p>
&lt;hr></description></item><item><title>mem0, Giving AI Memory, the Cornerstone of Building Personalized Assistants</title><link>https://chengxiaqiucao.github.io/en/post/097-mem0/</link><pubDate>Tue, 27 May 2025 00:00:00 +0000</pubDate><guid>https://chengxiaqiucao.github.io/en/post/097-mem0/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/097-mem0/Pasted-20250722.webp" alt="Featured image of post mem0, Giving AI Memory, the Cornerstone of Building Personalized Assistants" />&lt;p>In today&amp;rsquo;s world of rapidly evolving AI large models, all kinds of intelligent applications are emerging one after another. However, many current large language models (LLMs) still face one core challenge: &lt;strong>the lack of memory&lt;/strong>. That is, they are often &amp;ldquo;stateless&amp;rdquo;; for performance reasons, many AI tools impose fairly strict context window limits, and historical interaction information beyond that window gets discarded. As a result, AI cannot continuously remember context across different sessions, or even within complex interactions in the same session; conversations lack coherence, information is frequently repeated, and long-term tasks cannot be handled.&lt;/p>
&lt;p>For a personalized AI assistant, if it &amp;ldquo;forgets&amp;rdquo; everything with every exchange and cannot be guided by your preferences and habits, the experience is undoubtedly frustrating. It is precisely to solve this pain point that an open-source project called &lt;code>Mem0&lt;/code> came into being. It aims to provide AI applications with scalable, persistent, and pluggable memory capabilities, giving your AI a real &amp;ldquo;brain&amp;rdquo;.&lt;/p>
&lt;p>In fact, the open-source project Browser-Use, which we introduced in a previous article, uses &lt;code>Mem0&lt;/code> to implement task memory.&lt;/p>
&lt;p>In this article, we will take a detailed look at &lt;code>Mem0&lt;/code>&amp;rsquo;s core philosophy and technical features.&lt;/p>
&lt;h2 id="why-does-ai-need-memory">Why Does AI Need &amp;ldquo;Memory&amp;rdquo;?
&lt;/h2>&lt;p>The power of current LLMs is mainly reflected in their efficient processing of a single input. They can generate fluent text and answer complex questions, but these capabilities are often confined to the current &amp;ldquo;prompt&amp;rdquo; window. Once the conversation ends or the context exceeds the window limit, previous interaction information is forgotten.&lt;/p>
&lt;p>This &amp;ldquo;stateless&amp;rdquo; nature leads to the following problems:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Context loss&lt;/strong>: in long conversations, AI cannot remember earlier content, leading to repeated questions or misunderstanding.&lt;/li>
&lt;li>&lt;strong>Lack of personalization&lt;/strong>: AI cannot provide customized services based on the user&amp;rsquo;s historical behavior and preferences.&lt;/li>
&lt;li>&lt;strong>Limited long-term tasks&lt;/strong>: for tasks that require multiple rounds of interaction and accumulated information to complete (such as project management and complex planning), a memoryless AI is hard pressed to cope.&lt;/li>
&lt;li>&lt;strong>Low efficiency&lt;/strong>: users have to repeatedly provide background information, reducing interaction efficiency.&lt;/li>
&lt;/ul>
&lt;p>The emergence of Mem0 bridges this &amp;ldquo;memory gap&amp;rdquo;, allowing AI to accumulate experience and learn and grow.&lt;/p>
&lt;h2 id="what-is-mem0">What Is Mem0?
&lt;/h2>&lt;p>&lt;strong>Mem0&lt;/strong> is an open-source, modular framework designed specifically to give LLMs &lt;strong>scalable, persistent, and pluggable&lt;/strong> memory capabilities. It abstracts AI memory into different layers and provides a unified API, enabling developers to easily add memory functionality to any LLM application.&lt;/p>
&lt;p>Simply put, Mem0 is an external &amp;ldquo;memory bank&amp;rdquo; for AI applications. It can capture, store, and retrieve all relevant information generated during interactions between the AI and the user, and inject it into the LLM&amp;rsquo;s context when needed, thereby enabling more coherent and intelligent conversations and task execution.&lt;/p>
&lt;h2 id="explanation-of-mem0s-core-features">Explanation of Mem0&amp;rsquo;s Core Features
&lt;/h2>&lt;p>The strength of Mem0 lies in its carefully designed architecture and rich feature set:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>Layered memory architecture&lt;/strong>: Mem0 divides memory into different types to suit different needs:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Ephemeral Memory&lt;/strong>: stores short-term, in-session contextual information, similar to human short-term memory.&lt;/li>
&lt;li>&lt;strong>Long-Term Memory&lt;/strong>: stores important knowledge and experience that needs to be retained long term, with efficient retrieval achieved through semantic embeddings.&lt;/li>
&lt;li>&lt;strong>Archival Memory&lt;/strong>: used for backup and auditing, ensuring every interaction is traceable.&lt;/li>
&lt;li>&lt;strong>Knowledge Memory&lt;/strong>: designed specifically for storing external knowledge bases, such as documents and web pages.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Highly pluggable (Pluggable)&lt;/strong>: Mem0 offers flexible integration capabilities, supporting seamless collaboration with a variety of mainstream LLM services (such as OpenAI, Anthropic, Groq, etc.) and vector databases (such as Qdrant, Pinecone, ChromaDB, etc.). This means developers can freely choose backend services according to their own needs and preferences.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Multi-tenancy support&lt;/strong>: Mem0 supports a multi-tenant architecture, allowing independent memory spaces to be created for different users or application instances, ensuring data isolation and security, which is especially important for building SaaS products.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Developer friendly&lt;/strong>: it provides a concise and easy-to-use Python SDK, with plans to support JavaScript/TypeScript, greatly lowering the barrier for developers to integrate memory functionality.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Integration with mainstream frameworks&lt;/strong>: native support for popular LLM application development frameworks such as LangChain and LlamaIndex, accelerating the development process.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h2 id="analysis-of-browser-uses-application-of-mem0">Analysis of Browser-Use&amp;rsquo;s Application of Mem0
&lt;/h2>&lt;p>&lt;strong>Browser-Use&lt;/strong> aims to enable AI agents to perform complex tasks in the browser just as humans do. It leverages Mem0 to give AI agents &amp;ldquo;memory&amp;rdquo; capabilities; when executing tasks, it can, as configured, record the detailed information of up to 100 or even more operation steps as a reference for subsequent steps.&lt;/p>
&lt;p>By integrating Mem0, the AI agents in the Browser-Use project gain the following key capabilities:&lt;/p>
&lt;h3 id="browsing-history-memory-and-navigation-optimization">&lt;strong>Browsing History Memory and Navigation Optimization&lt;/strong>
&lt;/h3>&lt;p>Every URL visited and every interaction (click, input) by the AI agent can be stored via Mem0 as &lt;strong>ephemeral memory&lt;/strong> or transformed into &lt;strong>long-term memory&lt;/strong>.&lt;/p>
&lt;p>When a user asks the agent to &amp;ldquo;&lt;code>go back to the previously searched results page&lt;/code>&amp;rdquo;, the agent no longer needs to search from scratch, but can directly retrieve the historical URL from Mem0 and navigate to it, greatly improving efficiency and user experience.&lt;/p>
&lt;h3 id="context-maintenance-for-complex-tasks">&lt;strong>Context Maintenance for Complex Tasks&lt;/strong>
&lt;/h3>&lt;p>For example, an AI agent needs to complete an online shopping flow spanning multiple pages: search for products -&amp;gt; add to cart -&amp;gt; fill in address -&amp;gt; pay.&lt;/p>
&lt;p>Mem0 can store the current page state, user input, product details, and other &lt;strong>ephemeral memory&lt;/strong> at every step. Even if the flow is interrupted, the agent can load the previous context from Mem0 and accurately continue from where it left off, rather than &amp;ldquo;forgetting&amp;rdquo; and starting over.&lt;/p>
&lt;p>For example, the agent can remember the color and size the user selected on a certain product page, and this information still exists even after jumping to the cart page and back.&lt;/p>
&lt;h3 id="user-operation-pattern-and-preference-learning">&lt;strong>User Operation Pattern and Preference Learning&lt;/strong>
&lt;/h3>&lt;p>If a user often has the AI agent perform similar tasks on a particular website (such as checking the headlines of a news site every morning), Mem0 can transform these high-frequency behavior patterns into &lt;strong>long-term memory&lt;/strong>.&lt;/p>
&lt;p>In the future, the AI agent can more intelligently predict user needs, and even proactively recommend or preload related content, achieving a truly personalized browser operation experience.&lt;/p>
&lt;h3 id="persistence-of-multi-session-tasks">&lt;strong>Persistence of Multi-Session Tasks&lt;/strong>
&lt;/h3>&lt;p>For complex research tasks that take several days to complete (such as collecting material on a topic), the AI agent can store the key findings, visited resources, and task progress from each browsing session in Mem0&amp;rsquo;s &lt;strong>long-term memory&lt;/strong>.&lt;/p>
&lt;p>Even after closing the browser, on the next startup the agent can load these memories and continue the previous research, ensuring task continuity and completeness.&lt;/p>
&lt;blockquote>
&lt;p>Through the above analysis, we can clearly see how Mem0 helps the AI agent in the Browser-Use project transform from a &amp;ldquo;use-and-discard&amp;rdquo; tool into an intelligent assistant that understands the browser environment, remembers historical operations, and continuously executes complex tasks.
It makes the AI agent no longer merely mechanically execute instructions, but able to accumulate experience, adapt to the environment, and provide a smoother, more humanized automated browsing experience.&lt;/p>&lt;/blockquote>
&lt;h3 id="summary">Summary
&lt;/h3>&lt;p>When building truly intelligent AI applications capable of complex interactions, memory capability is an indispensable part. &lt;strong>Mem0&lt;/strong>, as an open-source framework focused on providing LLMs with scalable, persistent, and pluggable memory, undoubtedly offers developers a powerful tool. Through layered memory, flexible integration capabilities, and developer-friendly design, it greatly simplifies the implementation of AI memory functionality.&lt;/p>
&lt;p>Whether it is empowering an AI browser agent like Browser-Use to have persistent memory in complex web interactions, or building smarter personal assistants and customer service bots, Mem0 can provide a solid foundation.&lt;/p>
&lt;p>For those who want to build personalized assistants or make their AI Agent better fit real application scenarios, Mem0 is an AI ecosystem tool you cannot afford not to know.&lt;/p></description></item><item><title>Building a Personal Knowledge Base - Deploying DeepSeek with WSL + Ollama and Integrating It with VS Code</title><link>https://chengxiaqiucao.github.io/en/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/</link><pubDate>Thu, 15 May 2025 00:00:00 +0000</pubDate><guid>https://chengxiaqiucao.github.io/en/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/snap_20250419-3.webp" alt="Featured image of post Building a Personal Knowledge Base - Deploying DeepSeek with WSL + Ollama and Integrating It with VS Code" />&lt;p>At present, large-model applications are in full swing. Major LLMs such as &lt;code>Deepseek&lt;/code> also provide online assistant services, and combined with &lt;code>mcp-server&lt;/code> they can further extend into local tool capabilities.&lt;/p>
&lt;p>But for materials strongly tied to local business and data, online large-model training datasets generally cannot cover them, especially some sensitive data or data with high security requirements, for which using online large models is impractical. Therefore, in both personal use and real work, deploying large models locally and adding a local knowledge base is also a rigid requirement.&lt;/p>
&lt;p>This article records and shares the process of building a local large model in WSL through Ollama and CherryStudio, and integrating the local model into VS Code&amp;rsquo;s AI assistant.&lt;/p>
&lt;h2 id="ollama-introduction">Ollama Introduction
&lt;/h2>&lt;p>Ollama is a simple, easy-to-use local large language model runtime framework developed in Go, designed specifically for conveniently deploying and running large language models (LLMs) on local machines. Ollama is short for &lt;strong>Omni-Layer Learning Language Acquisition Model (all-round learning language acceptance model)&lt;/strong>.&lt;/p>
&lt;h2 id="deepseek-local-models-and-runtime-configuration">Deepseek Local Models and Runtime Configuration
&lt;/h2>&lt;p>Deepseek currently comes in multiple versions based on the size of the parameter set used for local deployment, ranging from &lt;strong>1.5B&lt;/strong> to &lt;strong>671B&lt;/strong> and beyond. The larger the parameter set, the more intelligent the AI, but the higher the hardware requirements accordingly.&lt;/p>
&lt;p>Generally, the recommended hardware configurations for different Deepseek model versions are as follows:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Model&lt;/th>
&lt;th>CPU&lt;/th>
&lt;th>Memory&lt;/th>
&lt;th>Disk&lt;/th>
&lt;th>VRAM&lt;/th>
&lt;th>Use Case&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>DeepSeek-R1-1.5B&lt;/td>
&lt;td>4 cores&lt;/td>
&lt;td>8 GB+&lt;/td>
&lt;td>3 GB+&lt;/td>
&lt;td>Not required (GTX 1650 optional for CPU acceleration)&lt;/td>
&lt;td>Personal use, such as laptops and desktops&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>DeepSeek-R1-7B&lt;/td>
&lt;td>8 cores&lt;/td>
&lt;td>16 GB+&lt;/td>
&lt;td>8 GB+&lt;/td>
&lt;td>8 GB+ VRAM (e.g. RTX 3070/4060)&lt;/td>
&lt;td>Local development for small and medium enterprises&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>DeepSeek-R1-8B&lt;/td>
&lt;td>8 cores&lt;/td>
&lt;td>16 GB+&lt;/td>
&lt;td>8 GB+&lt;/td>
&lt;td>8 GB+ VRAM&lt;/td>
&lt;td>Local development for SMEs (lightweight tasks with improved accuracy)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>DeepSeek-R1-14B&lt;/td>
&lt;td>12 cores&lt;/td>
&lt;td>32 GB+&lt;/td>
&lt;td>15 GB+&lt;/td>
&lt;td>16 GB+ VRAM (e.g. RTX 4090 or A5000)&lt;/td>
&lt;td>Local development for SMEs (medium-weight tasks)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>DeepSeek-R1-32B&lt;/td>
&lt;td>16 cores&lt;/td>
&lt;td>64 GB+&lt;/td>
&lt;td>30 GB+&lt;/td>
&lt;td>24 GB+ VRAM (e.g. A100 40 GB or RTX 3090)&lt;/td>
&lt;td>Professional domain tasks, such as healthcare, research, and law&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>DeepSeek-R1-70B&lt;/td>
&lt;td>32 cores&lt;/td>
&lt;td>128 GB+&lt;/td>
&lt;td>70 GB+&lt;/td>
&lt;td>Multi-GPU parallel (e.g. 2x A100 80GB or 4x RTX 4090)&lt;/td>
&lt;td>Large enterprises or research institutions, professional domain tasks&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>DeepSeek-R1-671B (Full Version)&lt;/td>
&lt;td>64 cores&lt;/td>
&lt;td>512 GB+&lt;/td>
&lt;td>300 GB+&lt;/td>
&lt;td>Multi-GPU parallel (e.g. 8x A100/H100)&lt;/td>
&lt;td>National-level research tasks&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>For individual users like us, we usually choose from 1.5B to 14B based on our own computer configuration. Of course, if you do not use local models frequently, my personal suggestion is to match one tier lower in both configuration and recommended model.&lt;/td>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="deploying-local-deepseek-in-wsl-with-ollama">Deploying Local Deepseek in WSL with Ollama
&lt;/h2>&lt;p>Because the author currently mainly wants to connect some local data to Deepseek and has no need to use local LLMs frequently, here I choose to deploy &lt;strong>DeepSeek-R1-14B&lt;/strong>. In addition, to avoid the LLM consuming large amounts of resources every time the computer starts up, I want to run the LLM under WSL on a Windows machine.&lt;/p>
&lt;h3 id="wsl-configuration">WSL Configuration
&lt;/h3>&lt;p>If WSL is not yet enabled on the current system, you can enable it first (the process will not be described in detail; in Windows 11, running WSL install [corresponding Linux distribution] is sufficient to install it).&lt;/p>
&lt;p>Check the &lt;strong>WSL&lt;/strong> status from the command line:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-batch" data-lang="batch">&lt;span class="line">&lt;span class="cl">C&lt;span class="p">:&lt;/span>&lt;span class="nl">\qiucao&lt;/span>&lt;span class="c1">&amp;gt;wsl --status&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Default Distribution: Ubuntu-24.04
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Default Version: 2
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>WSL&amp;rsquo;s default network mode is NAT. Here you can use the &lt;code>WSL Setting&lt;/code> program to modify the current configuration and change it to &lt;code>Mirrored&lt;/code> mode, sharing the host network.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/snap_20250419-1_hu_c0aec88b4901f7c9.webp"
width="1024"
height="617"
srcset="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/snap_20250419-1_hu_c9a189f1a5c9e75c.webp 480w, https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/snap_20250419-1_hu_c0aec88b4901f7c9.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="165"
data-flex-basis="398px"
>
&lt;/p>
&lt;h3 id="installing-ollama">Installing Ollama
&lt;/h3>&lt;p>Go to the Ollama official website (&lt;a class="link" href="https://ollama.com/" target="_blank" rel="noopener"
>https://ollama.com/&lt;/a>) download page. Because we are deploying in WSL, choose the Linux installation.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/snap_20250419_hu_384914324e87dc5e.webp"
width="1024"
height="508"
srcset="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/snap_20250419_hu_cd1b689f9bb6a91b.webp 480w, https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/snap_20250419_hu_384914324e87dc5e.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="201"
data-flex-basis="483px"
>
&lt;/p>
&lt;p>Execute the following command and wait for the download and automatic installation to complete.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">curl -fsSL https://ollama.com/install.sh &lt;span class="p">|&lt;/span> sh
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Check the version after installation&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">~$ ollama --version
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">ollama version is 0.6.5
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="deploying-deepseek">Deploying Deepseek
&lt;/h3>&lt;p>After Ollama is installed, you can select the corresponding large model to install from the list of large models provided by Ollama. The currently supported model list can be found at the following address on the official website: &lt;a class="link" href="https://ollama.com/library" target="_blank" rel="noopener"
>https://ollama.com/library&lt;/a>&lt;/p>
&lt;p>Execute the following command to download and run Deepseek.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">ollama run deepseek-r1:14b
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/ollama_deepseek_hu_658fb0f6c9a8fd17.webp"
width="1024"
height="209"
srcset="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/ollama_deepseek_hu_72e5171ab0ef0d81.webp 480w, https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/ollama_deepseek_hu_658fb0f6c9a8fd17.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="490"
data-flex-basis="1178px"
>
&lt;/p>
&lt;p>After a successful installation, you can ask a question to test whether Deepseek is providing service normally.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/snap_20250419-2_hu_4bae2e8f62d8f2bf.webp"
width="1024"
height="115"
srcset="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/snap_20250419-2_hu_808f18f03c643d04.webp 480w, https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/snap_20250419-2_hu_4bae2e8f62d8f2bf.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="888"
data-flex-basis="2132px"
>
&lt;/p>
&lt;h3 id="adding-a-knowledge-base-analysis-model">Adding a Knowledge Base Analysis Model
&lt;/h3>&lt;p>At this point, Deepseek is actually deployed locally. But if we want to use local data and documents through Deepseek, we also need to deploy a &lt;strong>semantic vector model&lt;/strong> (Embedding Model) to convert local data into knowledge base data that the large model can analyze. Here we choose the &lt;strong>bge-m3&lt;/strong> model, a general-purpose vector model that supports multiple languages, long texts, and a variety of retrieval methods.&lt;/p>
&lt;p>Execute:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-shell" data-lang="shell">&lt;span class="line">&lt;span class="cl">ollama pull bge-m3
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/ollama_bge_hu_d88878aa76f5f5ad.webp"
width="1024"
height="178"
srcset="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/ollama_bge_hu_a53ecd7c9e2fb6b6.webp 480w, https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/ollama_bge_hu_d88878aa76f5f5ad.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="576"
data-flex-basis="1383px"
>
&lt;/p>
&lt;h2 id="managing-the-knowledge-base-and-providing-a-local-interface-with-cherry-studio">Managing the Knowledge Base and Providing a Local Interface with Cherry Studio
&lt;/h2>&lt;p>After installing Deepseek, although we can interact with Deepseek from the command line, it is still not friendly enough, and managing the local knowledge base is not convenient either. So here we can also install Cherry Studio, an open-source local AI assistant and knowledge base client. Just download the Windows version from the official website (&lt;a class="link" href="https://cherry-ai.com" target="_blank" rel="noopener"
>https://cherry-ai.com&lt;/a>) and install it.
&lt;img src="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/snap_20250419-3_hu_5bc6c662290996b6.webp"
width="1024"
height="472"
srcset="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/snap_20250419-3_hu_dfe9fd0678b8fbb1.webp 480w, https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/snap_20250419-3_hu_5bc6c662290996b6.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="217"
data-flex-basis="520px"
>
&lt;/p>
&lt;p>Open Cherry Studio and follow the steps below to add the Deepseek we just deployed through Ollama.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/cherry_hu_8f63401f090a0a07.webp"
width="1024"
height="629"
srcset="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/cherry_hu_49a630e5e64cbdfe.webp 480w, https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/cherry_hu_8f63401f090a0a07.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="162"
data-flex-basis="390px"
>
&lt;/p>
&lt;p>You will see the already installed model; add it in.
&lt;img src="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/cherry_model_hu_85f7b6ff325ab5da.webp"
width="1024"
height="694"
srcset="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/cherry_model_hu_2086e4f3a5e5df0e.webp 480w, https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/cherry_model_hu_85f7b6ff325ab5da.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="147"
data-flex-basis="353px"
>
Then you can use Cherry Studio&amp;rsquo;s knowledge base management to bring the local documents we want to add into the large model&amp;rsquo;s dataset. This includes methods such as adding files directly, specifying a directory directly, and collecting from websites, which is very convenient.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/add_knowledge_hu_b3fb53dfd217be9e.webp"
width="1024"
height="629"
srcset="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/add_knowledge_hu_78d09a45838d4d91.webp 480w, https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/add_knowledge_hu_b3fb53dfd217be9e.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="162"
data-flex-basis="390px"
>
&lt;/p>
&lt;h2 id="integrating-local-deepseek-into-vs-code">Integrating Local Deepseek into VS Code
&lt;/h2>&lt;p>Once we have a local LLM, if we want to use it in VS Code, we can use VS Code&amp;rsquo;s &lt;code>AI Toolkit&lt;/code> extension to add the local LLM as follows.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/vs_code_1_hu_1ae13ebc1a2661dd.webp"
width="1024"
height="513"
srcset="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/vs_code_1_hu_230244637f7e1dfa.webp 480w, https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/vs_code_1_hu_1ae13ebc1a2661dd.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="199"
data-flex-basis="478px"
>
&lt;/p>
&lt;p>Test the capabilities of the local library in VS Code.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/vs_code_2_hu_db60771e5812785.webp"
width="1024"
height="721"
srcset="https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/vs_code_2_hu_7b2b7e3e9d687df6.webp 480w, https://chengxiaqiucao.github.io/post/093-deepseek%E6%9C%AC%E5%9C%B0%E9%83%A8%E7%BD%B2/vs_code_2_hu_db60771e5812785.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="142"
data-flex-basis="340px"
>
&lt;/p>
&lt;p>The above is our hands-on sharing of deploying local Deepseek.&lt;/p></description></item><item><title>How Can Test Developers Make Good Use of Cursor?</title><link>https://chengxiaqiucao.github.io/en/post/092-cursor%E7%9A%8412rules/</link><pubDate>Tue, 13 May 2025 00:00:00 +0000</pubDate><guid>https://chengxiaqiucao.github.io/en/post/092-cursor%E7%9A%8412rules/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/092-cursor%E7%9A%8412rules/cursor.webp" alt="Featured image of post How Can Test Developers Make Good Use of Cursor?" />&lt;h2 id="preface">Preface
&lt;/h2>&lt;p>Many people who are new to AI-assisted programming have probably heard of how powerful &lt;code>Cursor&lt;/code> is. For beginners, the free quota of the free version of Cursor is more than enough to let everyone experience its formidable capabilities.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/092-cursor%E7%9A%8412rules/cursor_hu_781815639c7e7dae.webp"
width="1024"
height="464"
srcset="https://chengxiaqiucao.github.io/post/092-cursor%E7%9A%8412rules/cursor_hu_4f511162cee92d8f.webp 480w, https://chengxiaqiucao.github.io/post/092-cursor%E7%9A%8412rules/cursor_hu_781815639c7e7dae.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="220"
data-flex-basis="529px"
>
&lt;/p>
&lt;p>However, in real-world use — based on my own experience — if you simply treat it as a conversation partner and complete development tasks the way you would communicate with a person, you will waste a great deal of time correcting its misunderstandings, and there is a very high chance that after some conversation it will alter your original work beyond recognition, wasting a large amount of effort.&lt;/p>
&lt;h2 id="cursors-12-rules">Cursor&amp;rsquo;s 12 Rules
&lt;/h2>&lt;p>In fact, whether Cursor can work more effectively has a lot to do with how you use it. Cursor&amp;rsquo;s chief designer &lt;strong>Ryo Lu&lt;/strong> earlier shared on X 12 rules for making good use of Cursor:&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/092-cursor%E7%9A%8412rules/cursor_12_rules_hu_2dfe3009b7e98df0.webp"
width="1024"
height="2035"
srcset="https://chengxiaqiucao.github.io/post/092-cursor%E7%9A%8412rules/cursor_12_rules_hu_8048ba0d67a4cf92.webp 480w, https://chengxiaqiucao.github.io/post/092-cursor%E7%9A%8412rules/cursor_12_rules_hu_2dfe3009b7e98df0.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="50"
data-flex-basis="120px"
>
&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Set clear project rules:&lt;/strong> Before starting a project, define 5-10 clear project rules so Cursor understands your code structure and constraints. For existing codebases, you can try the &lt;code>/generate rules&lt;/code> command to generate rules.&lt;/li>
&lt;li>&lt;strong>Be specific in prompts:&lt;/strong> Be very specific in your prompts, detailing the tech stack, expected behavior, and constraints, just like writing a mini spec.&lt;/li>
&lt;li>&lt;strong>Work file by file:&lt;/strong> Handle a small portion each time; generate, test, and review while staying focused.&lt;/li>
&lt;li>&lt;strong>Tests first:&lt;/strong> Write tests first, lock down the test cases, then generate code until all tests pass.&lt;/li>
&lt;li>&lt;strong>Strict review and correction:&lt;/strong> Always review the AI&amp;rsquo;s output and manually fix any errors, then tell Cursor to use those corrections as examples.&lt;/li>
&lt;li>&lt;strong>Limit the scope:&lt;/strong> Use commands such as &lt;code>@ file&lt;/code>, &lt;code>@ folders&lt;/code>, and &lt;code>@ git&lt;/code> to restrict Cursor&amp;rsquo;s attention to specific parts of the codebase.&lt;/li>
&lt;li>&lt;strong>Provide full context:&lt;/strong> Keep design documents and checklists in the &lt;code>.cursor/&lt;/code> directory so the Cursor agent can fully understand what needs to be done next.&lt;/li>
&lt;li>&lt;strong>Fix wrong code directly:&lt;/strong> If the generated code is wrong, just modify it manually. Cursor learns faster from edits than from explanations.&lt;/li>
&lt;li>&lt;strong>Leverage chat history:&lt;/strong> Use chat history to iterate on old prompts without starting from scratch.&lt;/li>
&lt;li>&lt;strong>Choose models wisely:&lt;/strong> Select models purposefully according to your needs. For example, Gemini suits the pursuit of precision, while Claude suits scenarios requiring broader knowledge.&lt;/li>
&lt;li>&lt;strong>Handle new or unfamiliar stacks:&lt;/strong> When working with a new or unfamiliar tech stack, paste in links to the relevant documentation. Have Cursor explain all errors and fixes line by line.&lt;/li>
&lt;li>&lt;strong>Optimize performance for large projects:&lt;/strong> For large projects, let it index overnight and limit the context scope to keep performance smooth.&lt;/li>
&lt;/ol>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">Using Cursor well = fast, clean code.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Using it wrong = AI spaghetti you’ll be cleaning up all week.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Here’s how to actually use it right:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. Set 5-10 clear project rules upfront so Cursor knows your structure and constraints. Try /generate rules for existing codebases.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2. Be specific in prompts. Spell out tech stack, behavior, and constraints like a mini spec.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">3. Work file by file; generate, test, and review in small, focused chunks.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">4. Write tests first, lock them, and generate code until all tests pass.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">5. Always review AI output and hard‑fix anything that breaks, then tell Cursor to use them as examples.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">6. Use @ file, @ folders, @ git to scope Cursor’s attention to the right parts of your codebase.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">7. Keep design docs and checklists in .cursor/ so the agent has full context on what to do next.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">8. If code is wrong, just write it yourself. Cursor learns faster from edits than explanations.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">9. Use chat history to iterate on old prompts without starting over.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">10. Choose models intentionally. Gemini for precision, Claude for breadth.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">11. In new or unfamiliar stacks, paste in link to documentation. Make Cursor explain all errors and fixes line by line.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">12.Let big projects index overnight and limit context scope to keep performance snappy.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Structure and control wins (for now)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Treat Cursor agent like a powerful junior — it can go far, fast, if you show it the way.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h2 id="how-can-test-developers-make-good-use-of-cursor">How Can Test Developers Make Good Use of Cursor?
&lt;/h2>&lt;p>As a test developer or test automation engineer, how can we make good use of Cursor when writing test scripts or tools to better improve our efficiency and output? In this article, referring to the 12 rules above, we summarize a set of relevant practical guidelines.&lt;/p>
&lt;h3 id="initialization-and-context-building---training-cursor-into-a-test-domain-expert">Initialization and Context Building - Training Cursor into a &amp;ldquo;Test Domain Expert&amp;rdquo;
&lt;/h3>&lt;p>At the start of a project or when joining it midway, the first priority is to let Cursor fully understand the standards and constraints of the current testing environment. High-quality context input is the prerequisite for high-quality code output.&lt;/p>
&lt;h4 id="define-project-testing-rules-and-conventions-rule-1">Define Project Testing Rules and Conventions (Rule 1)
&lt;/h4>&lt;p>In test automation projects, consistency in coding standards, framework selection, and design patterns is crucial. Based on &lt;code>Rule 1: Set clear project rules&lt;/code>, we can use the &lt;code>.cursor/rules.md&lt;/code> file to make this tacit team knowledge explicit and provide Cursor with a clear program of action. For existing projects, you can first use the &lt;code>/generate rules&lt;/code> command to initially extract the rules, and then add to them manually.&lt;/p>
&lt;p>&lt;strong>Practical example&lt;/strong>: In a Python Flask-based web project, the testing stack is Pytest and Selenium. You can define the following rules in &lt;code>.cursor/rules.md&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;span class="lnt">8
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-mysql" data-lang="mysql">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># .cursor/rules.md
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">cite_start&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="k">All&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">unit&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">test&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">files&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">are&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">named&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="n">test_&lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">py&lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">UI&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">test&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">files&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">are&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">named&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="n">ui_test_&lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">py&lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">cite_start&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="n">Test&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">functions&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">must&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">start&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">with&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="n">test_&lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">cite_start&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="k">Use&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Pytest&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">fixtures&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">for&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">test&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">environment&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">setup&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">and&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">teardown&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">cite_start&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="n">UI&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">tests&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">follow&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Page&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Object&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">pattern&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">with&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">page&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">objects&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">encapsulated&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="n">cite_start&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="n">Avoid&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">hard&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="n">coded&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">waits&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">prefer&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">WebDriver&lt;/span>&lt;span class="s1">&amp;#39;s explicit wait mechanism
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1">- [cite_start]Test reports are generated uniformly with the Allure framework
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h4 id="provide-detailed-instructions-to-simulate-test-scenarios-rule-2">Provide Detailed Instructions to Simulate &amp;ldquo;Test Scenarios&amp;rdquo; (Rule 2)
&lt;/h4>&lt;p>The quality of your interaction with AI directly determines the quality of the output code. Instructions for test automation especially demand precision, because they must fully describe the feature under test, input data, expected behavior, and even exceptional paths.&lt;/p>
&lt;p>&lt;strong>Practical example&lt;/strong>: Write integration tests for the user login feature.&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Ineffective instruction&lt;/strong>: &lt;code>Write a login test.&lt;/code>&lt;/li>
&lt;li>&lt;strong>Well-structured instruction&lt;/strong>:&lt;/li>
&lt;/ul>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">Please use the Pytest framework to write integration tests for the user login feature of a Flask application (endpoint POST /api/login, accepting username and password). The following three scenarios need to be covered:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. Successful login (using admin/password123);
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2. Incorrect password (using admin/wrongpass);
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">3. User does not exist (using nonexistent/anypass). For the success scenario, assert that the HTTP status code is 200 and the response contains a non-empty token. For the failure scenarios, assert that the status code is 401.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="iterative-development-and-correction---achieving-continuous-integration-of-test-code">Iterative Development and Correction - Achieving &amp;ldquo;Continuous Integration of Test Code&amp;rdquo;
&lt;/h3>&lt;p>Breaking down complex testing tasks and developing through an agile loop of &amp;ldquo;generate - verify - correct&amp;rdquo; is an effective strategy for ensuring code quality and project progress.&lt;/p>
&lt;h4 id="small-steps-incremental-verification-rule-3">Small Steps, Incremental Verification (Rule 3)
&lt;/h4>&lt;p>You should resist the temptation to generate all the tests for an entire complex module in one go.&lt;/p>
&lt;p>The right approach is to break the task down into the smallest verifiable units and tackle them one by one.&lt;/p>
&lt;p>For example, when writing tests for a set of RESTful APIs, you should follow the logical order of &amp;ldquo;create user -&amp;gt; get user -&amp;gt; update user -&amp;gt; delete user&amp;rdquo;, generating and verifying the test code one at a time&lt;/p>
&lt;p>This approach helps locate problems quickly and avoids the accumulation of errors.&lt;/p>
&lt;h4 id="applying-test-driven-development-tdd-rule-4">Applying Test-Driven Development (TDD) (Rule 4)
&lt;/h4>&lt;p>Test-driven development is a classic model for ensuring code quality, and Cursor can be a powerful accelerator for it. Engineers first define the expected behavior of a function (that is, write the test cases), then have the AI generate implementation code that satisfies those tests.&lt;/p>
&lt;p>&lt;strong>Practical example&lt;/strong>: Implement a discount calculation function &lt;code>calculate_discount(price, discount_rate)&lt;/code>.&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Define the test&lt;/strong>: First ask Cursor: &lt;code>Generate a Pytest test case for the calculate_discount function. When price=100 and discount_rate=0.1, the expected return value is 90; when discount_rate is negative, a ValueError exception should be raised.&lt;/code>&lt;/li>
&lt;li>&lt;strong>Generate the implementation&lt;/strong>: After the test code &lt;code>test_calculate_discount.py&lt;/code> is generated, run it (it will fail at this point), then give Cursor a new instruction: &lt;code>Based on the test cases just generated, implement the calculate_discount function.&lt;/code>&lt;/li>
&lt;li>&lt;strong>Close the verification loop&lt;/strong>: Once Cursor generates the function implementation, run the tests again until they all pass.&lt;/li>
&lt;/ol>
&lt;h4 id="proactive-correction-and-mutual-learning-rule-5">Proactive Correction and Mutual Learning (Rule 5)
&lt;/h4>&lt;p>It is worth noting that AI-generated code is not always correct, and the engineer&amp;rsquo;s review and correction is the last line of defense. Fixing errors directly in the code is the most effective way to train Cursor, far better than explaining to it in natural language.&lt;/p>
&lt;p>&lt;strong>Practical example&lt;/strong>:
For example, in a UI test generated by Cursor, it used an unstable and incorrect XPath locator &lt;code>//button[@id='submit']&lt;/code>. After the test run fails, we can directly change it manually to a correct locator, such as &lt;code>//input[@value='Login']&lt;/code>. After the correction, you can leave a note in the chat to reinforce its learning: &lt;code>&amp;quot;I have fixed the locator for the login button; the new locator is more accurate. Please refer to this pattern in subsequent tasks.&amp;quot;&lt;/code> .&lt;/p>
&lt;h3 id="fine-grained-management---achieving-intelligent-scheduling-of-test-resources">Fine-Grained Management - Achieving &amp;ldquo;Intelligent Scheduling of Test Resources&amp;rdquo;
&lt;/h3>&lt;p>In large projects, how to keep Cursor focused on the right information is key to determining its efficiency and relevance.&lt;/p>
&lt;h4 id="precisely-limit-the-context-scope-rule-6">Precisely Limit the Context Scope (Rule 6)
&lt;/h4>&lt;p>In a large codebase, testing tasks are often related only to a specific module or service. By using the &lt;code>@folders&lt;/code> or &lt;code>@file&lt;/code> commands, you can significantly narrow Cursor&amp;rsquo;s analysis scope and keep it focused on the necessary context.&lt;/p>
&lt;p>&lt;strong>Practical example&lt;/strong>:
When writing API tests for the &lt;code>user_service&lt;/code> microservice, all relevant code resides in the &lt;code>services/user_service/&lt;/code> directory. In this case, you should first enter &lt;code>@folders services/user_service/&lt;/code> before asking, and then describe the specific testing requirements.&lt;/p>
&lt;h4 id="accumulate-project-knowledge-to-support-decisions-rule-7">Accumulate Project Knowledge to Support Decisions (Rule 7)
&lt;/h4>&lt;p>You can distill key information such as testing strategy, UI locator priorities, and data mocking conventions into documents stored in the &lt;code>.cursor/&lt;/code> directory. This is equivalent to providing Cursor with a &amp;ldquo;project-level knowledge base&amp;rdquo;.&lt;/p>
&lt;p>&lt;strong>Practical example&lt;/strong>:
Create a &lt;code>.cursor/ui_locators_priority.md&lt;/code> file with the content: &amp;ldquo;UI element locator priority order: ID &amp;gt; Name &amp;gt; CSS Selector &amp;gt; XPath&amp;rdquo;. You can then reference it when asking: &lt;code>Please refer to the strategy in .cursor/ui_locators_priority.md and generate Selenium locator code for the 'Submit' button on the registration page.&lt;/code>.&lt;/p>
&lt;h3 id="problem-solving-and-efficiency-optimization---becoming-a-test-efficiency-accelerator">Problem Solving and Efficiency Optimization - Becoming a &amp;ldquo;Test Efficiency Accelerator&amp;rdquo;
&lt;/h3>&lt;p>Mastering advanced usage can further transform Cursor from an everyday assistant into a powerful tool for solving complex problems and accelerating learning.&lt;/p>
&lt;h4 id="choose-ai-models-wisely-rule-10">Choose AI Models Wisely (Rule 10)
&lt;/h4>&lt;p>Different AI models have different strengths. Choosing the right model based on the characteristics of the testing task can get you twice the result with half the effort.&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Gemini (precision first)&lt;/strong>: suited to generating unit tests with strict syntax requirements, algorithm validation, or fine-grained test code using specific frameworks (such as React Testing Library).&lt;/li>
&lt;li>&lt;strong>Claude (breadth first)&lt;/strong>: better suited to scenarios that require understanding large amounts of context, such as generating comprehensive integration tests from API documentation, designing end-to-end (E2E) test scenarios, or exploring and suggesting test points in an unfamiliar codebase.&lt;/li>
&lt;/ul>
&lt;h4 id="use-documentation-to-quickly-master-new-technologies-rule-11">Use Documentation to Quickly Master New Technologies (Rule 11)
&lt;/h4>&lt;p>When a team introduces a new testing framework (such as Playwright), engineers can use Cursor to quickly get over the learning curve.&lt;/p>
&lt;p>&lt;strong>Practical example&lt;/strong>:
Provide Cursor directly with a link to the official Playwright documentation and ask it to generate example code. When the generated code throws an error at runtime, you can paste the error message and ask: &amp;ldquo;This is an error that occurred while running a Playwright script; please explain the cause of the error line by line based on the official documentation and provide suggestions for fixing it.&amp;rdquo;.&lt;/p>
&lt;h4 id="limit-the-context-scope-rule-12">Limit the Context Scope (Rule 12)
&lt;/h4>&lt;p>When the project codebase is large, index it overnight and limit the context scope.&lt;/p>
&lt;p>&lt;strong>Practical example&lt;/strong>:&lt;/p>
&lt;p>When working on a large testing project, allow Cursor to handle indexing in the background and do the actual code generation the next day, so as to keep performance smooth.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Prioritize indexing core modules&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">@folder tests/unit
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Defer loading integration tests&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">@defer tests/integration
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;p>For our actual work, the essence of successfully using Cursor is a process of shifting from an &amp;ldquo;instruction giver&amp;rdquo; to an &amp;ldquo;intelligent collaborator&amp;rdquo; and a &amp;ldquo;knowledge guide&amp;rdquo;. The emphasis is on highlighting its systematic role in &lt;strong>intelligent collaboration, knowledge accumulation, and efficiency improvement&lt;/strong>.&lt;/p></description></item><item><title>Cursor Charges Money? No Worries, We Still Have CodeBuddy!</title><link>https://chengxiaqiucao.github.io/en/post/091-codebuddy/</link><pubDate>Fri, 09 May 2025 00:00:00 +0000</pubDate><guid>https://chengxiaqiucao.github.io/en/post/091-codebuddy/</guid><description>&lt;p>Previously we introduced generating automated test code with AI, as well as controlling a browser through an mcp server, using the AI programming IDE &lt;strong>Cursor&lt;/strong>. With its powerful intelligent analysis and assisted-programming capabilities, Cursor can automatically complete the code implementation for us when we describe a programming requirement in natural language; it is efficient and works very well. But Cursor is not free software; once the trial period ends, using it as a daily tool is still rather expensive.&lt;/p>
&lt;p>But now Tencent has also stepped in and launched a code assistant, the very protagonist of this article, CodeBuddy. Its programming capability is in no way inferior to Cursor&amp;rsquo;s, and it even has a halo bonus for applications within the Tencent ecosystem such as Mini Programs. More importantly, it is completely free!&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/091-codebuddy/snap_20250601_hu_5064eee1ffdebe82.webp"
width="1024"
height="411"
srcset="https://chengxiaqiucao.github.io/post/091-codebuddy/snap_20250601_hu_6e7d79e31f87f6c3.webp 480w, https://chengxiaqiucao.github.io/post/091-codebuddy/snap_20250601_hu_5064eee1ffdebe82.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="249"
data-flex-basis="598px"
>
&lt;/p>
&lt;h2 id="installation">Installation
&lt;/h2>&lt;p>CodeBuddy itself does not provide a standalone IDE, but it offers plugin support for all the mainstream IDEs&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/091-codebuddy/snap_20250601-2_hu_8c0e21920f8c3155.webp"
width="1024"
height="261"
srcset="https://chengxiaqiucao.github.io/post/091-codebuddy/snap_20250601-2_hu_497b50c7656ea15e.webp 480w, https://chengxiaqiucao.github.io/post/091-codebuddy/snap_20250601-2_hu_8c0e21920f8c3155.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="392"
data-flex-basis="942px"
>
&lt;/p>
&lt;p>Search for &amp;ldquo;Tencent Cloud Code Assistant&amp;rdquo; in the plugin marketplace of each development tool and you will find the corresponding plugin; just install it accordingly&lt;/p>
&lt;p>Taking VS Code as an example, once the plugin is installed, open the plugin panel and you can get programming assistance similar to the assistant pages of Copilot or Cursor. In CodeBuddy, this is called &lt;strong>Craft&lt;/strong> mode&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/091-codebuddy/snap_20250601-3_hu_f7fe79dd89fb2073.webp"
width="1024"
height="576"
srcset="https://chengxiaqiucao.github.io/post/091-codebuddy/snap_20250601-3_hu_d9b4e2195d74a504.webp 480w, https://chengxiaqiucao.github.io/post/091-codebuddy/snap_20250601-3_hu_f7fe79dd89fb2073.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="177"
data-flex-basis="426px"
>
&lt;/p>
&lt;p>Besides this mode of assisting with code generation, there is also a Chat mode, which allows conversational interaction much like generative AI.&lt;/p>
&lt;p>In addition, Code Review mode helps with reviewing existing code, while Unit Test automatically writes unit test scripts for the current code.&lt;/p>
&lt;h2 id="hands-on-mini-program-development">Hands-on Mini Program Development
&lt;/h2>&lt;p>And since CodeBuddy itself is built on the Tencent ecosystem, for work like Mini Program development it enjoys a natural built-in advantage.&lt;/p>
&lt;p>Here, after installing the CodeBuddy plugin in WeChat Developer Tools, with just a few interactive Q&amp;amp;A rounds, it helped me complete the implementation of a Mini Program.&lt;/p>
&lt;p>Below is the implementation I completed with it, which fetches the most popular GitHub repositories of the past month. It took roughly a bit over ten minutes in total, and in actual testing it works and the interface is friendly.&lt;/p>
&lt;p>In the future, perhaps everyone really will be a developer; even without knowing much about programming, as long as you have an idea, you can easily turn it into reality!&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/091-codebuddy/snap_20250601-1_hu_df975022180cddc2.webp"
width="1024"
height="519"
srcset="https://chengxiaqiucao.github.io/post/091-codebuddy/snap_20250601-1_hu_1a44fdc99fa15d72.webp 480w, https://chengxiaqiucao.github.io/post/091-codebuddy/snap_20250601-1_hu_df975022180cddc2.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="197"
data-flex-basis="473px"
>
&lt;/p>
&lt;p>The complete interaction process for finishing this application is attached below&lt;/p>
&lt;blockquote>
&lt;p>Please help me develop a simple Mini Program that fetches the introductions of the 5 hottest GitHub repos of the day, with the interface highlighting the key points and ensuring visual appeal.&lt;/p>&lt;/blockquote>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;span class="lnt">29
&lt;/span>&lt;span class="lnt">30
&lt;/span>&lt;span class="lnt">31
&lt;/span>&lt;span class="lnt">32
&lt;/span>&lt;span class="lnt">33
&lt;/span>&lt;span class="lnt">34
&lt;/span>&lt;span class="lnt">35
&lt;/span>&lt;span class="lnt">36
&lt;/span>&lt;span class="lnt">37
&lt;/span>&lt;span class="lnt">38
&lt;/span>&lt;span class="lnt">39
&lt;/span>&lt;span class="lnt">40
&lt;/span>&lt;span class="lnt">41
&lt;/span>&lt;span class="lnt">42
&lt;/span>&lt;span class="lnt">43
&lt;/span>&lt;span class="lnt">44
&lt;/span>&lt;span class="lnt">45
&lt;/span>&lt;span class="lnt">46
&lt;/span>&lt;span class="lnt">47
&lt;/span>&lt;span class="lnt">48
&lt;/span>&lt;span class="lnt">49
&lt;/span>&lt;span class="lnt">50
&lt;/span>&lt;span class="lnt">51
&lt;/span>&lt;span class="lnt">52
&lt;/span>&lt;span class="lnt">53
&lt;/span>&lt;span class="lnt">54
&lt;/span>&lt;span class="lnt">55
&lt;/span>&lt;span class="lnt">56
&lt;/span>&lt;span class="lnt">57
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">CodeBuddy
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">The user needs a Mini Program to display the 5 hottest repositories of the day on GitHub, and requires the interface to have striking visuals. I need to understand the user&amp;#39;s needs further and gather some information in order to make a suitable plan.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">First, I need to clarify the following points:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. The platform of the Mini Program - is it a Web app, a mobile app, or a desktop app?
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2. Tech stack preference - does the user have a specific programming language or framework preference?
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">3. The definition of &amp;#34;hottest of the day&amp;#34; - is it based on star count, fork count, or some other metric?
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">4. Specific visual requirements - what particular expectations does the user have for UI/UX?
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">5. Functional requirements - besides displaying repository introductions, are other features needed, such as clicking through to the repository page?
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Let me first look at the project directory structure to understand the current environment:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">0 files in the root directory
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Completed
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Understood, this is a brand-new project. Let me clarify the requirements with the user so as to plan the project better. I need to ask some key questions to make sure we can develop an application that meets the user&amp;#39;s expectations.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">To better help you develop this application that displays trending GitHub repositories, I need to confirm some key details:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. **Platform Selection**:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Do you expect this application to be a Web App or a Desktop App?
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2. **Tech Stack Preference**:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Do you have a specific programming language or framework preference?
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- For example:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Web apps: React, Vue, Angular, etc.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Desktop apps: Electron, Python+Qt, etc.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">3. **UI/Visual Requirements**:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- What specific expectations do you have for the visuals? For example:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Modern minimalist style
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Dark/light theme
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Card-based layout
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Animation effects, etc.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">4. **Feature Details**:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Besides showing the repository name and introduction, do you need to display:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Repository star count
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Author information
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Programming language
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Direct jump link
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Do you need an auto-refresh feature?
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Please tell me your preferences so that I can work out a concrete implementation plan that better suits your needs.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;blockquote>
&lt;p>Platform: WeChat Mini Program; Tech preference: vue; Visual style: modern minimalist; Features: include the currently suggested features&lt;/p>&lt;/blockquote>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;span class="lnt">29
&lt;/span>&lt;span class="lnt">30
&lt;/span>&lt;span class="lnt">31
&lt;/span>&lt;span class="lnt">32
&lt;/span>&lt;span class="lnt">33
&lt;/span>&lt;span class="lnt">34
&lt;/span>&lt;span class="lnt">35
&lt;/span>&lt;span class="lnt">36
&lt;/span>&lt;span class="lnt">37
&lt;/span>&lt;span class="lnt">38
&lt;/span>&lt;span class="lnt">39
&lt;/span>&lt;span class="lnt">40
&lt;/span>&lt;span class="lnt">41
&lt;/span>&lt;span class="lnt">42
&lt;/span>&lt;span class="lnt">43
&lt;/span>&lt;span class="lnt">44
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">CodeBuddy
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Thanks for the user&amp;#39;s reply; now I have clearer requirement information:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. Platform: WeChat Mini Program
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2. Tech preference: Vue (in WeChat Mini Programs, we can use a Vue-like MVVM framework, that is, the native WeChat Mini Program development approach)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">3. Visual style: modern minimalist style
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">4. Features: include the features I suggested, namely:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Display repository name and introduction
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Display repository star count
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Display author information
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Display programming language
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Provide a direct jump link
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Now I can work out a more concrete implementation plan. WeChat Mini Program development requires WeChat Developer Tools, and it needs to call the GitHub API to fetch trending repository information.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Thanks for your reply! Based on the information you provided, we will develop a **WeChat Mini Program**, using a **Vue-like development approach**, with a **modern minimalist** visual style, to display the 5 hottest GitHub repositories of the day.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">There are still a few technical details to confirm:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. **GitHub API Access Method**:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- WeChat Mini Programs have restrictions on cross-origin requests, so we need to consider how to call the GitHub API
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Option 1: Use a cloud function as the middle layer (recommended, more secure and avoids cross-origin issues)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Option 2: Call the API directly in the Mini Program (may face cross-origin restrictions)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2. **Definition of Trending Repositories**:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- The GitHub API offers multiple sorting methods; which metric would you like to use to define &amp;#34;trending&amp;#34;?
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Most new stars added today
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Most total stars
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Newly created today and highly followed
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">3. **Refresh Mechanism**:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Do you need a pull-to-refresh feature?
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Do you need scheduled auto-refresh (such as updating once per hour)?
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">This information will help me design a Mini Program solution that better meets your expectations.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;blockquote>
&lt;p>Use cloud functions for the github API; trending metric: most new stars added today; just refresh when the App starts&lt;/p>&lt;/blockquote>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt"> 10
&lt;/span>&lt;span class="lnt"> 11
&lt;/span>&lt;span class="lnt"> 12
&lt;/span>&lt;span class="lnt"> 13
&lt;/span>&lt;span class="lnt"> 14
&lt;/span>&lt;span class="lnt"> 15
&lt;/span>&lt;span class="lnt"> 16
&lt;/span>&lt;span class="lnt"> 17
&lt;/span>&lt;span class="lnt"> 18
&lt;/span>&lt;span class="lnt"> 19
&lt;/span>&lt;span class="lnt"> 20
&lt;/span>&lt;span class="lnt"> 21
&lt;/span>&lt;span class="lnt"> 22
&lt;/span>&lt;span class="lnt"> 23
&lt;/span>&lt;span class="lnt"> 24
&lt;/span>&lt;span class="lnt"> 25
&lt;/span>&lt;span class="lnt"> 26
&lt;/span>&lt;span class="lnt"> 27
&lt;/span>&lt;span class="lnt"> 28
&lt;/span>&lt;span class="lnt"> 29
&lt;/span>&lt;span class="lnt"> 30
&lt;/span>&lt;span class="lnt"> 31
&lt;/span>&lt;span class="lnt"> 32
&lt;/span>&lt;span class="lnt"> 33
&lt;/span>&lt;span class="lnt"> 34
&lt;/span>&lt;span class="lnt"> 35
&lt;/span>&lt;span class="lnt"> 36
&lt;/span>&lt;span class="lnt"> 37
&lt;/span>&lt;span class="lnt"> 38
&lt;/span>&lt;span class="lnt"> 39
&lt;/span>&lt;span class="lnt"> 40
&lt;/span>&lt;span class="lnt"> 41
&lt;/span>&lt;span class="lnt"> 42
&lt;/span>&lt;span class="lnt"> 43
&lt;/span>&lt;span class="lnt"> 44
&lt;/span>&lt;span class="lnt"> 45
&lt;/span>&lt;span class="lnt"> 46
&lt;/span>&lt;span class="lnt"> 47
&lt;/span>&lt;span class="lnt"> 48
&lt;/span>&lt;span class="lnt"> 49
&lt;/span>&lt;span class="lnt"> 50
&lt;/span>&lt;span class="lnt"> 51
&lt;/span>&lt;span class="lnt"> 52
&lt;/span>&lt;span class="lnt"> 53
&lt;/span>&lt;span class="lnt"> 54
&lt;/span>&lt;span class="lnt"> 55
&lt;/span>&lt;span class="lnt"> 56
&lt;/span>&lt;span class="lnt"> 57
&lt;/span>&lt;span class="lnt"> 58
&lt;/span>&lt;span class="lnt"> 59
&lt;/span>&lt;span class="lnt"> 60
&lt;/span>&lt;span class="lnt"> 61
&lt;/span>&lt;span class="lnt"> 62
&lt;/span>&lt;span class="lnt"> 63
&lt;/span>&lt;span class="lnt"> 64
&lt;/span>&lt;span class="lnt"> 65
&lt;/span>&lt;span class="lnt"> 66
&lt;/span>&lt;span class="lnt"> 67
&lt;/span>&lt;span class="lnt"> 68
&lt;/span>&lt;span class="lnt"> 69
&lt;/span>&lt;span class="lnt"> 70
&lt;/span>&lt;span class="lnt"> 71
&lt;/span>&lt;span class="lnt"> 72
&lt;/span>&lt;span class="lnt"> 73
&lt;/span>&lt;span class="lnt"> 74
&lt;/span>&lt;span class="lnt"> 75
&lt;/span>&lt;span class="lnt"> 76
&lt;/span>&lt;span class="lnt"> 77
&lt;/span>&lt;span class="lnt"> 78
&lt;/span>&lt;span class="lnt"> 79
&lt;/span>&lt;span class="lnt"> 80
&lt;/span>&lt;span class="lnt"> 81
&lt;/span>&lt;span class="lnt"> 82
&lt;/span>&lt;span class="lnt"> 83
&lt;/span>&lt;span class="lnt"> 84
&lt;/span>&lt;span class="lnt"> 85
&lt;/span>&lt;span class="lnt"> 86
&lt;/span>&lt;span class="lnt"> 87
&lt;/span>&lt;span class="lnt"> 88
&lt;/span>&lt;span class="lnt"> 89
&lt;/span>&lt;span class="lnt"> 90
&lt;/span>&lt;span class="lnt"> 91
&lt;/span>&lt;span class="lnt"> 92
&lt;/span>&lt;span class="lnt"> 93
&lt;/span>&lt;span class="lnt"> 94
&lt;/span>&lt;span class="lnt"> 95
&lt;/span>&lt;span class="lnt"> 96
&lt;/span>&lt;span class="lnt"> 97
&lt;/span>&lt;span class="lnt"> 98
&lt;/span>&lt;span class="lnt"> 99
&lt;/span>&lt;span class="lnt">100
&lt;/span>&lt;span class="lnt">101
&lt;/span>&lt;span class="lnt">102
&lt;/span>&lt;span class="lnt">103
&lt;/span>&lt;span class="lnt">104
&lt;/span>&lt;span class="lnt">105
&lt;/span>&lt;span class="lnt">106
&lt;/span>&lt;span class="lnt">107
&lt;/span>&lt;span class="lnt">108
&lt;/span>&lt;span class="lnt">109
&lt;/span>&lt;span class="lnt">110
&lt;/span>&lt;span class="lnt">111
&lt;/span>&lt;span class="lnt">112
&lt;/span>&lt;span class="lnt">113
&lt;/span>&lt;span class="lnt">114
&lt;/span>&lt;span class="lnt">115
&lt;/span>&lt;span class="lnt">116
&lt;/span>&lt;span class="lnt">117
&lt;/span>&lt;span class="lnt">118
&lt;/span>&lt;span class="lnt">119
&lt;/span>&lt;span class="lnt">120
&lt;/span>&lt;span class="lnt">121
&lt;/span>&lt;span class="lnt">122
&lt;/span>&lt;span class="lnt">123
&lt;/span>&lt;span class="lnt">124
&lt;/span>&lt;span class="lnt">125
&lt;/span>&lt;span class="lnt">126
&lt;/span>&lt;span class="lnt">127
&lt;/span>&lt;span class="lnt">128
&lt;/span>&lt;span class="lnt">129
&lt;/span>&lt;span class="lnt">130
&lt;/span>&lt;span class="lnt">131
&lt;/span>&lt;span class="lnt">132
&lt;/span>&lt;span class="lnt">133
&lt;/span>&lt;span class="lnt">134
&lt;/span>&lt;span class="lnt">135
&lt;/span>&lt;span class="lnt">136
&lt;/span>&lt;span class="lnt">137
&lt;/span>&lt;span class="lnt">138
&lt;/span>&lt;span class="lnt">139
&lt;/span>&lt;span class="lnt">140
&lt;/span>&lt;span class="lnt">141
&lt;/span>&lt;span class="lnt">142
&lt;/span>&lt;span class="lnt">143
&lt;/span>&lt;span class="lnt">144
&lt;/span>&lt;span class="lnt">145
&lt;/span>&lt;span class="lnt">146
&lt;/span>&lt;span class="lnt">147
&lt;/span>&lt;span class="lnt">148
&lt;/span>&lt;span class="lnt">149
&lt;/span>&lt;span class="lnt">150
&lt;/span>&lt;span class="lnt">151
&lt;/span>&lt;span class="lnt">152
&lt;/span>&lt;span class="lnt">153
&lt;/span>&lt;span class="lnt">154
&lt;/span>&lt;span class="lnt">155
&lt;/span>&lt;span class="lnt">156
&lt;/span>&lt;span class="lnt">157
&lt;/span>&lt;span class="lnt">158
&lt;/span>&lt;span class="lnt">159
&lt;/span>&lt;span class="lnt">160
&lt;/span>&lt;span class="lnt">161
&lt;/span>&lt;span class="lnt">162
&lt;/span>&lt;span class="lnt">163
&lt;/span>&lt;span class="lnt">164
&lt;/span>&lt;span class="lnt">165
&lt;/span>&lt;span class="lnt">166
&lt;/span>&lt;span class="lnt">167
&lt;/span>&lt;span class="lnt">168
&lt;/span>&lt;span class="lnt">169
&lt;/span>&lt;span class="lnt">170
&lt;/span>&lt;span class="lnt">171
&lt;/span>&lt;span class="lnt">172
&lt;/span>&lt;span class="lnt">173
&lt;/span>&lt;span class="lnt">174
&lt;/span>&lt;span class="lnt">175
&lt;/span>&lt;span class="lnt">176
&lt;/span>&lt;span class="lnt">177
&lt;/span>&lt;span class="lnt">178
&lt;/span>&lt;span class="lnt">179
&lt;/span>&lt;span class="lnt">180
&lt;/span>&lt;span class="lnt">181
&lt;/span>&lt;span class="lnt">182
&lt;/span>&lt;span class="lnt">183
&lt;/span>&lt;span class="lnt">184
&lt;/span>&lt;span class="lnt">185
&lt;/span>&lt;span class="lnt">186
&lt;/span>&lt;span class="lnt">187
&lt;/span>&lt;span class="lnt">188
&lt;/span>&lt;span class="lnt">189
&lt;/span>&lt;span class="lnt">190
&lt;/span>&lt;span class="lnt">191
&lt;/span>&lt;span class="lnt">192
&lt;/span>&lt;span class="lnt">193
&lt;/span>&lt;span class="lnt">194
&lt;/span>&lt;span class="lnt">195
&lt;/span>&lt;span class="lnt">196
&lt;/span>&lt;span class="lnt">197
&lt;/span>&lt;span class="lnt">198
&lt;/span>&lt;span class="lnt">199
&lt;/span>&lt;span class="lnt">200
&lt;/span>&lt;span class="lnt">201
&lt;/span>&lt;span class="lnt">202
&lt;/span>&lt;span class="lnt">203
&lt;/span>&lt;span class="lnt">204
&lt;/span>&lt;span class="lnt">205
&lt;/span>&lt;span class="lnt">206
&lt;/span>&lt;span class="lnt">207
&lt;/span>&lt;span class="lnt">208
&lt;/span>&lt;span class="lnt">209
&lt;/span>&lt;span class="lnt">210
&lt;/span>&lt;span class="lnt">211
&lt;/span>&lt;span class="lnt">212
&lt;/span>&lt;span class="lnt">213
&lt;/span>&lt;span class="lnt">214
&lt;/span>&lt;span class="lnt">215
&lt;/span>&lt;span class="lnt">216
&lt;/span>&lt;span class="lnt">217
&lt;/span>&lt;span class="lnt">218
&lt;/span>&lt;span class="lnt">219
&lt;/span>&lt;span class="lnt">220
&lt;/span>&lt;span class="lnt">221
&lt;/span>&lt;span class="lnt">222
&lt;/span>&lt;span class="lnt">223
&lt;/span>&lt;span class="lnt">224
&lt;/span>&lt;span class="lnt">225
&lt;/span>&lt;span class="lnt">226
&lt;/span>&lt;span class="lnt">227
&lt;/span>&lt;span class="lnt">228
&lt;/span>&lt;span class="lnt">229
&lt;/span>&lt;span class="lnt">230
&lt;/span>&lt;span class="lnt">231
&lt;/span>&lt;span class="lnt">232
&lt;/span>&lt;span class="lnt">233
&lt;/span>&lt;span class="lnt">234
&lt;/span>&lt;span class="lnt">235
&lt;/span>&lt;span class="lnt">236
&lt;/span>&lt;span class="lnt">237
&lt;/span>&lt;span class="lnt">238
&lt;/span>&lt;span class="lnt">239
&lt;/span>&lt;span class="lnt">240
&lt;/span>&lt;span class="lnt">241
&lt;/span>&lt;span class="lnt">242
&lt;/span>&lt;span class="lnt">243
&lt;/span>&lt;span class="lnt">244
&lt;/span>&lt;span class="lnt">245
&lt;/span>&lt;span class="lnt">246
&lt;/span>&lt;span class="lnt">247
&lt;/span>&lt;span class="lnt">248
&lt;/span>&lt;span class="lnt">249
&lt;/span>&lt;span class="lnt">250
&lt;/span>&lt;span class="lnt">251
&lt;/span>&lt;span class="lnt">252
&lt;/span>&lt;span class="lnt">253
&lt;/span>&lt;span class="lnt">254
&lt;/span>&lt;span class="lnt">255
&lt;/span>&lt;span class="lnt">256
&lt;/span>&lt;span class="lnt">257
&lt;/span>&lt;span class="lnt">258
&lt;/span>&lt;span class="lnt">259
&lt;/span>&lt;span class="lnt">260
&lt;/span>&lt;span class="lnt">261
&lt;/span>&lt;span class="lnt">262
&lt;/span>&lt;span class="lnt">263
&lt;/span>&lt;span class="lnt">264
&lt;/span>&lt;span class="lnt">265
&lt;/span>&lt;span class="lnt">266
&lt;/span>&lt;span class="lnt">267
&lt;/span>&lt;span class="lnt">268
&lt;/span>&lt;span class="lnt">269
&lt;/span>&lt;span class="lnt">270
&lt;/span>&lt;span class="lnt">271
&lt;/span>&lt;span class="lnt">272
&lt;/span>&lt;span class="lnt">273
&lt;/span>&lt;span class="lnt">274
&lt;/span>&lt;span class="lnt">275
&lt;/span>&lt;span class="lnt">276
&lt;/span>&lt;span class="lnt">277
&lt;/span>&lt;span class="lnt">278
&lt;/span>&lt;span class="lnt">279
&lt;/span>&lt;span class="lnt">280
&lt;/span>&lt;span class="lnt">281
&lt;/span>&lt;span class="lnt">282
&lt;/span>&lt;span class="lnt">283
&lt;/span>&lt;span class="lnt">284
&lt;/span>&lt;span class="lnt">285
&lt;/span>&lt;span class="lnt">286
&lt;/span>&lt;span class="lnt">287
&lt;/span>&lt;span class="lnt">288
&lt;/span>&lt;span class="lnt">289
&lt;/span>&lt;span class="lnt">290
&lt;/span>&lt;span class="lnt">291
&lt;/span>&lt;span class="lnt">292
&lt;/span>&lt;span class="lnt">293
&lt;/span>&lt;span class="lnt">294
&lt;/span>&lt;span class="lnt">295
&lt;/span>&lt;span class="lnt">296
&lt;/span>&lt;span class="lnt">297
&lt;/span>&lt;span class="lnt">298
&lt;/span>&lt;span class="lnt">299
&lt;/span>&lt;span class="lnt">300
&lt;/span>&lt;span class="lnt">301
&lt;/span>&lt;span class="lnt">302
&lt;/span>&lt;span class="lnt">303
&lt;/span>&lt;span class="lnt">304
&lt;/span>&lt;span class="lnt">305
&lt;/span>&lt;span class="lnt">306
&lt;/span>&lt;span class="lnt">307
&lt;/span>&lt;span class="lnt">308
&lt;/span>&lt;span class="lnt">309
&lt;/span>&lt;span class="lnt">310
&lt;/span>&lt;span class="lnt">311
&lt;/span>&lt;span class="lnt">312
&lt;/span>&lt;span class="lnt">313
&lt;/span>&lt;span class="lnt">314
&lt;/span>&lt;span class="lnt">315
&lt;/span>&lt;span class="lnt">316
&lt;/span>&lt;span class="lnt">317
&lt;/span>&lt;span class="lnt">318
&lt;/span>&lt;span class="lnt">319
&lt;/span>&lt;span class="lnt">320
&lt;/span>&lt;span class="lnt">321
&lt;/span>&lt;span class="lnt">322
&lt;/span>&lt;span class="lnt">323
&lt;/span>&lt;span class="lnt">324
&lt;/span>&lt;span class="lnt">325
&lt;/span>&lt;span class="lnt">326
&lt;/span>&lt;span class="lnt">327
&lt;/span>&lt;span class="lnt">328
&lt;/span>&lt;span class="lnt">329
&lt;/span>&lt;span class="lnt">330
&lt;/span>&lt;span class="lnt">331
&lt;/span>&lt;span class="lnt">332
&lt;/span>&lt;span class="lnt">333
&lt;/span>&lt;span class="lnt">334
&lt;/span>&lt;span class="lnt">335
&lt;/span>&lt;span class="lnt">336
&lt;/span>&lt;span class="lnt">337
&lt;/span>&lt;span class="lnt">338
&lt;/span>&lt;span class="lnt">339
&lt;/span>&lt;span class="lnt">340
&lt;/span>&lt;span class="lnt">341
&lt;/span>&lt;span class="lnt">342
&lt;/span>&lt;span class="lnt">343
&lt;/span>&lt;span class="lnt">344
&lt;/span>&lt;span class="lnt">345
&lt;/span>&lt;span class="lnt">346
&lt;/span>&lt;span class="lnt">347
&lt;/span>&lt;span class="lnt">348
&lt;/span>&lt;span class="lnt">349
&lt;/span>&lt;span class="lnt">350
&lt;/span>&lt;span class="lnt">351
&lt;/span>&lt;span class="lnt">352
&lt;/span>&lt;span class="lnt">353
&lt;/span>&lt;span class="lnt">354
&lt;/span>&lt;span class="lnt">355
&lt;/span>&lt;span class="lnt">356
&lt;/span>&lt;span class="lnt">357
&lt;/span>&lt;span class="lnt">358
&lt;/span>&lt;span class="lnt">359
&lt;/span>&lt;span class="lnt">360
&lt;/span>&lt;span class="lnt">361
&lt;/span>&lt;span class="lnt">362
&lt;/span>&lt;span class="lnt">363
&lt;/span>&lt;span class="lnt">364
&lt;/span>&lt;span class="lnt">365
&lt;/span>&lt;span class="lnt">366
&lt;/span>&lt;span class="lnt">367
&lt;/span>&lt;span class="lnt">368
&lt;/span>&lt;span class="lnt">369
&lt;/span>&lt;span class="lnt">370
&lt;/span>&lt;span class="lnt">371
&lt;/span>&lt;span class="lnt">372
&lt;/span>&lt;span class="lnt">373
&lt;/span>&lt;span class="lnt">374
&lt;/span>&lt;span class="lnt">375
&lt;/span>&lt;span class="lnt">376
&lt;/span>&lt;span class="lnt">377
&lt;/span>&lt;span class="lnt">378
&lt;/span>&lt;span class="lnt">379
&lt;/span>&lt;span class="lnt">380
&lt;/span>&lt;span class="lnt">381
&lt;/span>&lt;span class="lnt">382
&lt;/span>&lt;span class="lnt">383
&lt;/span>&lt;span class="lnt">384
&lt;/span>&lt;span class="lnt">385
&lt;/span>&lt;span class="lnt">386
&lt;/span>&lt;span class="lnt">387
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">CodeBuddy
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Many thanks for the user&amp;#39;s further clarification. Now I have the complete requirement information:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. Platform: WeChat Mini Program
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2. Tech preference: Vue-style WeChat Mini Program development
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">3. Visual style: modern minimalist style
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">4. GitHub API access method: use a cloud function as the middle layer
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">5. Trending repository definition: most new stars added today
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">6. Refresh mechanism: refresh when the App starts
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Based on this information, I can work out a detailed implementation plan, including the project structure, main functional modules, UI design ideas, and development steps.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"># GitHub Trending Repositories WeChat Mini Program Development Plan
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">**Project Overview**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Develop a WeChat Mini Program that displays the 5 GitHub repositories with the most new stars added today, using a modern minimalist UI design and calling the GitHub API through cloud functions.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">**Tech Stack**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Frontend: native WeChat Mini Program development (WXML, WXSS, JS)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Backend: WeChat Cloud Development (cloud functions)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- API: GitHub REST API
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">**Project Structure**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">`├── miniprogram/ # Mini program frontend code │ ├── pages/ # Page files │ │ ├── index/ # Main page │ │ └── detail/ # Detail page (optional) │ ├── components/ # Custom components │ │ └── repo-card/ # Repository card component │ ├── images/ # Icons and image assets │ ├── styles/ # Common styles │ └── utils/ # Utility functions └── cloudfunctions/ # Cloud functions └── getHotRepos/ # Cloud function for fetching trending repositories`
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">**Functional Modules**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">**1. Cloud Function Module**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Create the `getHotRepos` cloud function, responsible for:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Call the GitHub API to fetch the repositories with the most new stars added today
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Data processing and filtering, returning detailed information for the top 5 repositories
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Handle API request limits and error conditions
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">**2. Frontend Display Module**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Main page (index):
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Top title bar showing the application name and refresh status
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Repository list area, using a card-based layout to show the 5 trending repositories
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Loading state and error prompts
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Repository card component (repo-card):
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Repository name and description
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Author information and avatar
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Star count (total and today&amp;#39;s new additions)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Programming language (with a color indicator)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Jump button (can open a web-view or copy the link)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">**3. Data Interaction Module**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Automatically call the cloud function to fetch data when the app starts
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Implement a pull-to-refresh feature (optional)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Data caching mechanism to reduce unnecessary API calls
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">**UI Design Ideas**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Color scheme:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Primary color: GitHub dark blue (#0366d6)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Background color: light gray or white (#f6f8fa)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Accent color: GitHub green (#2ea44f)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Card design:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Rounded rectangle cards
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Appropriate shadow effects
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Clear information hierarchy
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Motion effects:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Loading animation
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Card click feedback
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Smooth list scrolling
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">**Development Steps**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. **Project Initialization**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Create a WeChat Mini Program project
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Configure the cloud development environment
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2. **Cloud Function Development**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Write the cloud function that fetches trending GitHub repositories
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Test API calls and data processing
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">3. **Frontend Page Development**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Design and implement the main page layout
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Develop the repository card component
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Implement the data loading and display logic
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">4. **Style Optimization**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Apply the modern minimalist style
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Optimize the visuals and interaction experience
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">5. **Functional Testing and Optimization**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Test data loading and display
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Optimize performance and user experience
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">6. **Release and Deployment**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Configure the Mini Program&amp;#39;s basic information
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Submit for review and publish
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">**Notes**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- The GitHub API has request rate limits, so a sensible caching strategy needs to be designed
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- WeChat Mini Programs have limits on network requests and page size, so attention must be paid to performance optimization
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Ensure the UI displays well on devices of different sizes
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">According to the development plan provided by the user, I need to develop a WeChat Mini Program that displays the 5 GitHub repositories with the most new stars added today. This project requires native WeChat Mini Program development and cloud development.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">First, I need to create the basic project structure, including:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. Create the Mini Program frontend code structure
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2. Create the cloud function
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">3. Implement the main functional modules
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Let me first check whether the current directory is empty, and then start creating the project structure.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">0 files in the root directory
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Completed
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">The directory is empty, so we need to create the project structure from scratch. First, create the basic project directory structure, including the Mini Program frontend code and the cloud functions directory.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Let&amp;#39;s first create the following key files:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. project.config.json - Mini Program project configuration file
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2. app.json - Mini Program global configuration file
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">3. app.js - Mini Program entry file
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">4. app.wxss - Mini Program global style file
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Let&amp;#39;s first create the project configuration file.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">project.config.json
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">+78 -0
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Accepted
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Now that we have created the project configuration file, next we need to create the basic Mini Program structure. First create the miniprogram directory, then create the app.js, app.json, and app.wxss files inside it.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. Create the miniprogram directory
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2. Create app.js - Mini Program entry file
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">3. Create app.json - Mini Program global configuration file
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">4. Create app.wxss - Mini Program global style file
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Let&amp;#39;s first create the miniprogram directory, and then create these basic files.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">mkdir -p miniprogram
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">The directory was created successfully; now let&amp;#39;s create the basic Mini Program files. First create app.json, configuring the Mini Program&amp;#39;s global settings, including page paths, window styles, and so on.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">miniprogram/app.json
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">+16 -0
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Accepted
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Now create the app.js file, which is the Mini Program&amp;#39;s entry file used to initialize the Mini Program. We will initialize the cloud development environment here.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">miniprogram/app.js
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">+22 -0
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Accepted
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Next create the app.wxss file, which defines global styles. We will use GitHub&amp;#39;s color scheme and define some common styles.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">miniprogram/app.wxss
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">+80 -0
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Accepted
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Now we need to create the files for the main page (index). We need to create the following files under the miniprogram/pages/index/ directory:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. index.js - Page logic
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2. index.wxml - Page structure
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">3. index.wxss - Page styles
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">4. index.json - Page configuration
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">First create the index directory, then create these files.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">mkdir -p miniprogram/pages/index
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">The directory was created successfully; now let&amp;#39;s create the files for the index page. First create index.wxml, designing the basic page structure, including the loading state, the repository list, and so on.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">miniprogram/pages/index/index.wxml
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">+58 -2
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Accepted
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Now create the index.wxss file to add styles to the main page. We will use a modern minimalist design style, including a card-based layout, appropriate shadow effects, and so on.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">miniprogram/pages/index/index.wxss
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">+144 -0
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Accepted
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Next create the index.js file, implementing the page&amp;#39;s business logic, including:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. Fetching trending repository data when the page loads
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2. Handling refresh operations
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">3. Implementing features such as copying links and opening repositories
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">miniprogram/pages/index/index.js
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">+78 -40
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Accepted
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Now create the index.json file, configuring the page&amp;#39;s basic settings, including enabling features such as pull-to-refresh. Then we need to create the getHotRepos cloud function to fetch trending GitHub repository data.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">miniprogram/pages/index/index.json
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">+7 -0
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Accepted
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Now we need to create some necessary image assets. We need to create an images folder under the miniprogram directory and prepare some basic icons, such as a loading icon and a star icon.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">First create the images directory:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">mkdir -p miniprogram/images
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Now we need to create the getHotRepos cloud function. First create the cloudfunctions directory and the getHotRepos cloud function directory, then create the cloud function&amp;#39;s related files.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. Create the cloudfunctions/getHotRepos directory
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2. Create the package.json and index.js files
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">mkdir -p cloudfunctions/getHotRepos
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Now create the cloud function&amp;#39;s package.json file, adding the necessary dependencies, including axios for making HTTP requests.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">cloudfunctions/getHotRepos/package.json
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">+17 -0
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Accepted
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Now create the cloud function&amp;#39;s main file, index.js, implementing the logic for fetching trending GitHub repositories. We will:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. Use the GitHub API to search repositories
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2. Sort by the number of new stars added today
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">3. Fetch detailed information for the top 5 repositories
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">4. Handle error conditions and API limits
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">cloudfunctions/getHotRepos/index.js
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">+144 -0
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Accepted
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Now we need to create some basic icon files. Since we cannot directly create binary image files, we can create a sitemap.json file, which is a required file for WeChat Mini Programs, used to configure the Mini Program&amp;#39;s indexing rules.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Then, we can create a README.md file that provides the project&amp;#39;s description and usage guide.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">miniprogram/sitemap.json
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">+8 -0
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Accepted
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Now let&amp;#39;s create a README.md file that provides a detailed project description, installation steps, and a usage guide. This will help other developers understand and use this project.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">README.md
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">+88 -0
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Accepted
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Now we have completed the development of the project&amp;#39;s basic structure and core features. Let&amp;#39;s summarize the work completed and the next steps that require the user&amp;#39;s action:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. Work completed:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Created the complete project structure
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Implemented the main page&amp;#39;s UI and logic
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Implemented the cloud function for fetching trending GitHub repositories
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Created the project documentation
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2. Actions the user needs to take:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Configure WeChat Developer Tools and the AppID
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Enable the cloud development environment
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Configure the GitHub Token
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Upload and deploy the cloud function
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Add the necessary icon files to the images directory
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Let me use the attempt_completion tool to summarize the project&amp;#39;s completion status and next steps.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"># GitHub Trending Repositories Mini Program Development Complete
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">**Development Work Completed**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. **Project Structure Setup**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Created the complete WeChat Mini Program project structure
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Configured the necessary project files (project.config.json, app.json, etc.)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Created the cloud functions directory structure
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2. **Frontend Development**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Implemented the full functionality of the main page (index)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Designed a modern minimalist UI interface
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Implemented interactive features such as pull-to-refresh
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">3. **Backend Development**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Implemented the getHotRepos cloud function
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Integrated GitHub API calls
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Implemented data processing and error handling
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">4. **Documentation**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Created a detailed README.md file
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Provided complete installation and usage instructions
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">**Next Steps**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">To run this project, you need to:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. **Environment Configuration**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Open the project with WeChat Developer Tools
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Configure your AppID in project.config.json
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Enable cloud development and create a cloud environment
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Configure the cloud environment ID in app.js
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2. **Resource Preparation**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Add the necessary icons under the miniprogram/images/ directory:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- loading.gif (loading animation)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- star.png (star icon)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">3. **Cloud Function Deployment**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Enter the cloudfunctions/getHotRepos directory
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Install dependencies: npm install
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Configure the GitHub Token in the cloud development console (optional)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Upload and deploy the cloud function
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">4. **Running Tests**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Compile and run the project
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Test the data loading feature
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Test the pull-to-refresh feature
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Test the repository link copying feature
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">**Notes**
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. Make sure all necessary environment variables and configuration items are correctly configured
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2. It is recommended to configure a GitHub Token to avoid API limits
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">3. On the first run, wait for the cloud function deployment to complete
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">4. If you run into problems, see the detailed instructions in README.md
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">The project source code is ready; you can start using and testing it by following the steps above. If you have any questions, feel free to refer to the README.md file or ask.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div></description></item><item><title>The Definitive Guide to Prompt Engineering - The Art and Science of Empowering Software Testing</title><link>https://chengxiaqiucao.github.io/en/post/080-%E6%8F%90%E7%A4%BA%E8%AF%8D%E5%B7%A5%E7%A8%8B/</link><pubDate>Sun, 20 Apr 2025 00:00:00 +0000</pubDate><guid>https://chengxiaqiucao.github.io/en/post/080-%E6%8F%90%E7%A4%BA%E8%AF%8D%E5%B7%A5%E7%A8%8B/</guid><description>&lt;p>As the wave of artificial intelligence (AI) and large language models (LLMs) sweeps across the globe, the field of software testing is undergoing a profound transformation. Traditional testing methods are merging with cutting-edge AI technologies, and &lt;strong>Prompt Engineering&lt;/strong> is precisely the core skill for steering this transformation. This guide delves into the theory, practice, and advanced techniques of prompt engineering, and offers a series of concrete examples tailored to software testing roles, aiming to help test engineers and teams effectively leverage AI to improve testing efficiency, coverage, and depth.&lt;/p>
&lt;hr>
&lt;h3 id="chapter-1---getting-to-know-prompt-engineering-the-art-of-efficient-dialogue-with-ai">Chapter 1 - Getting to Know Prompt Engineering, the Art of Efficient Dialogue with AI
&lt;/h3>&lt;h4 id="11-what-is-prompt-engineering">1.1 What Is Prompt Engineering?
&lt;/h4>&lt;p>&lt;strong>Prompt engineering&lt;/strong> is a discipline devoted to designing, constructing, and optimizing input text (that is, &amp;ldquo;prompts&amp;rdquo;) so as to guide large language models (LLMs) such as GPT-4 and Claude to generate the high-quality, relevant outputs we expect. If an LLM is a powerful engine packed with vast knowledge, then the prompt is the steering wheel and accelerator that control that engine.&lt;/p>
&lt;p>For software testing, prompt engineering is far more than simply &amp;ldquo;asking AI a question&amp;rdquo;; it is a &lt;strong>strategic form of communication&lt;/strong>. With carefully designed prompts, testers can drive AI to complete a range of complex testing tasks, such as:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Generating test cases&lt;/strong>: Based on requirements documents, user stories, or code snippets, automatically create functional, boundary, exception, and other types of test cases.&lt;/li>
&lt;li>&lt;strong>Creating test data&lt;/strong>: Generate diverse test data that conforms to specific formats and business rules.&lt;/li>
&lt;li>&lt;strong>Writing automation scripts&lt;/strong>: Assist in writing, or directly generate, automation test scripts for frameworks such as Selenium, Cypress, and Playwright.&lt;/li>
&lt;li>&lt;strong>Analyzing test results&lt;/strong>: Summarize, classify, and perform root cause analysis on large volumes of test logs and reports.&lt;/li>
&lt;li>&lt;strong>Simulating user behavior&lt;/strong>: Create interaction scenarios that match specific user personas, for User Acceptance Testing (UAT) or exploratory testing.&lt;/li>
&lt;/ul>
&lt;p>Mastering prompt engineering means test engineers can hand tedious, repetitive work over to AI, freeing them to devote more energy to more creative and strategic testing activities.&lt;/p>
&lt;h4 id="12-core-principles---clarity-specificity-and-context">1.2 Core Principles - Clarity, Specificity, and Context
&lt;/h4>&lt;p>Successful prompt engineering follows one core principle: &lt;strong>Garbage In, Garbage Out (GIGO)&lt;/strong>. The quality of the information you give AI directly determines the quality of its output. Therefore, a good prompt typically has the following characteristics:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Clear &amp;amp; Specific&lt;/strong>: Avoid vague, general language. Tell AI directly what you want.&lt;/li>
&lt;li>&lt;strong>Contextual&lt;/strong>: Provide AI with ample background information, such as descriptions of the feature under test, relevant code, user personas, and business rules.&lt;/li>
&lt;li>&lt;strong>Role Assignment&lt;/strong>: Have AI play a specific role—for example, &amp;ldquo;You are a senior software testing expert&amp;rdquo;—which helps the model respond from a more professional perspective and tone.&lt;/li>
&lt;li>&lt;strong>Format Specification&lt;/strong>: Clearly define the output format you want, such as JSON, CSV, Markdown tables, or bulleted lists.&lt;/li>
&lt;li>&lt;strong>Iterative Refinement&lt;/strong>: Few prompts are perfect on the first try. Be prepared to make multiple attempts and adjustments based on AI&amp;rsquo;s feedback.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h3 id="chapter-2---a-glossary-of-prompt-engineering-terminology">Chapter 2 - A Glossary of Prompt Engineering Terminology
&lt;/h3>&lt;p>To better understand and apply prompt engineering, it is essential to be familiar with the following key terms.&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;/th>
&lt;th>&lt;/th>
&lt;th>&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;strong>Term&lt;/strong>&lt;/td>
&lt;td>&lt;strong>Chinese Explanation&lt;/strong>&lt;/td>
&lt;td>&lt;strong>Description&lt;/strong>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Prompt&lt;/strong>&lt;/td>
&lt;td>Prompt&lt;/td>
&lt;td>The input text a user provides to an LLM to guide its response.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Zero-shot Prompting&lt;/strong>&lt;/td>
&lt;td>Zero-shot prompting&lt;/td>
&lt;td>Directly asking the LLM to complete a task without providing any examples. Suitable for tasks the model has already mastered.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Few-shot Prompting&lt;/strong>&lt;/td>
&lt;td>Few-shot prompting&lt;/td>
&lt;td>Providing a small number (usually 1-5) of examples in the prompt to show the LLM the expected input-output format and style.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Chain-of-Thought (CoT) Prompting&lt;/strong>&lt;/td>
&lt;td>Chain-of-thought prompting&lt;/td>
&lt;td>Guiding the LLM to reason step by step before giving the final answer, triggered by phrases such as &amp;ldquo;Let&amp;rsquo;s think step by step&amp;rdquo;.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Role Prompting / Persona&lt;/strong>&lt;/td>
&lt;td>Role prompting / persona&lt;/td>
&lt;td>Assigning the LLM a specific role or identity (such as &amp;ldquo;senior security test engineer&amp;rdquo;) to influence the style, tone, and professional depth of its responses.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Context Window&lt;/strong>&lt;/td>
&lt;td>Context window&lt;/td>
&lt;td>The amount of information (measured in tokens) an LLM can remember and process in a single conversation. Information beyond this window is forgotten.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Token&lt;/strong>&lt;/td>
&lt;td>Token&lt;/td>
&lt;td>The basic unit of text an LLM processes, which may be a word, a character, or a word root.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Hallucination&lt;/strong>&lt;/td>
&lt;td>Hallucination&lt;/td>
&lt;td>The phenomenon where an LLM generates information that seems plausible but is actually false or inconsistent with the facts.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Temperature&lt;/strong>&lt;/td>
&lt;td>Temperature parameter&lt;/td>
&lt;td>A parameter controlling output randomness (usually between 0 and 1). A lower temperature makes output more deterministic and consistent, while a higher one makes it more creative and diverse.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Self-Consistency&lt;/strong>&lt;/td>
&lt;td>Self-consistency&lt;/td>
&lt;td>An advanced technique that generates multiple times (using a higher temperature) and &amp;ldquo;votes&amp;rdquo; on the results to select the most consistent answer, improving accuracy on complex reasoning tasks.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>ReAct (Reasoning and Acting)&lt;/strong>&lt;/td>
&lt;td>Reasoning and acting&lt;/td>
&lt;td>An advanced framework that lets an LLM not only reason but also perform certain &amp;ldquo;actions&amp;rdquo; (such as calling external APIs or executing code) and fold the results of those actions into the next step of reasoning.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Delimiter&lt;/strong>&lt;/td>
&lt;td>Delimiter&lt;/td>
&lt;td>Using special characters or tags (such as ```, ###, &amp;lt;tag&amp;gt;) to clearly separate different parts of a prompt (such as instructions, context, and examples).&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;hr>
&lt;h3 id="chapter-3---prompt-engineering-in-software-testing-practice">Chapter 3 - Prompt Engineering in Software Testing Practice
&lt;/h3>&lt;p>This chapter uses concrete cases to show how to apply prompt engineering at each stage of software testing.&lt;/p>
&lt;h4 id="31-case-1---generating-test-cases-from-user-stories-functional-testing">3.1 Case 1 - Generating Test Cases from User Stories (Functional Testing)
&lt;/h4>&lt;p>Suppose we have a &lt;strong>user story&lt;/strong> for an e-commerce platform: &amp;ldquo;As a logged-in user, I want to be able to add products to the shopping cart so that I can check out all at once later.&amp;rdquo;&lt;/p>
&lt;p>&lt;strong>A poor prompt 👎:&lt;/strong>&lt;/p>
&lt;blockquote>
&lt;p>Write test cases for the add-to-cart feature.&lt;/p>&lt;/blockquote>
&lt;p>This prompt is too vague and provides no context; AI may produce very generic, low-value test cases.&lt;/p>
&lt;p>&lt;strong>A good prompt (using Few-shot and role prompting) 👍:&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl"># Instructions
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">You are an experienced e-commerce software testing expert. Based on the following user story and business rules, generate a comprehensive set of functional test cases for the &amp;#34;add product to shopping cart&amp;#34; feature.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"># Role
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- You are highly detail-oriented and able to consider all kinds of boundary cases and exception scenarios.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Your test cases should include: case ID, test title, preconditions, test steps, expected result, and case type (positive/negative).
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- The output format should be a Markdown table.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"># Context - User Story
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&amp;#34;As a logged-in user, I want to be able to add products to the shopping cart so that I can check out all at once later.&amp;#34;
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"># Context - Business Rules
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. The user must be logged in to add products.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2. The cart can hold at most 50 different products.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">3. The maximum purchase quantity for a single product is 99.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">4. Products that are removed from sale or have zero stock cannot be added to the cart.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">5. After a successful add, the cart icon in the upper-right corner of the page should update the product count in real time.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"># Example (Few-shot)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Here is a reference example:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| Case ID | Test Title | Preconditions | Test Steps | Expected Result | Case Type |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| :--- | :--- | :--- | :--- | :--- | :--- |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">| TC-CART-001 | Verify a logged-in user can successfully add one product to the cart | User is logged in; cart is empty | 1. Browse to a product detail page with stock available.&amp;lt;br&amp;gt;2. Click the &amp;#34;Add to Cart&amp;#34; button. | 1. The page shows &amp;#34;Product successfully added to cart&amp;#34;.&amp;lt;br&amp;gt;2. The cart icon count updates to 1. | Positive |
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"># Task
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Now, based on the above information, generate at least 10 detailed test cases for this feature, covering positive, negative, and boundary scenarios.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Possible AI output:&lt;/p>
&lt;p>AI will follow the instructions and, in the specified Markdown table format, generate a series of high-quality test cases, including verifying unlogged-in users, adding products up to the limit, adding out-of-stock products, and validating quantity input boundary values (0, 1, 99, 100).&lt;/p>
&lt;h4 id="32-case-2---generating-test-data-in-a-specific-format-data-driven-testing">3.2 Case 2 - Generating Test Data in a Specific Format (Data-Driven Testing)
&lt;/h4>&lt;p>When performing data-driven testing, we often need large amounts of data that conform to specific formats and rules.&lt;/p>
&lt;p>&lt;strong>Scenario&lt;/strong> - Testing a user registration form that has specific requirements for username, password, and email format.&lt;/p>
&lt;p>&lt;strong>A good prompt (using instructions and format specification) 👍:&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-mysql" data-lang="mysql">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Role
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="n">You&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">are&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">test&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">data&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">generator&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1"># Task
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="n">Generate&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">20&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">sets&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">of&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">test&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">data&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">for&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">user&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">registration&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">feature&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">and&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">output&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">them&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">in&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">CSV&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">format&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1"># Data Requirements
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="n">The&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">data&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">should&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">contain&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">three&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">columns&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="n">username&lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="n">password&lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="n">email&lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1"># Column Definitions and Rules
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="n">username&lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Must&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">be&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">6&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="mi">15&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">characters&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">May&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">contain&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">only&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">lowercase&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">letters&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">and&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">digits&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Include&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">both&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">valid&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">and&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">invalid&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nf">usernames&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="k">for&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">example&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">too&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">short&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">too&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">long&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">or&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">containing&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">special&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">characters&lt;/span>&lt;span class="p">).&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="mi">2&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="n">password&lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Must&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">be&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">8&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="mi">20&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">characters&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Must&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">contain&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">at&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">least&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">one&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">uppercase&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">letter&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">one&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">lowercase&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">letter&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">one&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">digit&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">and&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">one&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">special&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">character&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="o">!@&lt;/span>&lt;span class="c1">#$%^&amp;amp;*).
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Include&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">strong&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">passwords&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">that&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">comply&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">with&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">rules&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">and&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">weak&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">passwords&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">that&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">do&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">not&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="mi">3&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="n">email&lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Must&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">be&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">in&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">valid&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">email&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">format&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Include&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">some&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">common&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">email&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nf">providers&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">such&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">as&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">gmail&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">com&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">outlook&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">com&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">yahoo&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">com&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">as&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">well&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">as&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">some&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">invalid&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="n">format&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nf">emails&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="k">for&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">example&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">missing&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">@&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">symbol&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">or&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">having&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">an&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">invalid&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">domain&lt;/span>&lt;span class="p">).&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1"># Output Format
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="n">Please&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">strictly&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">follow&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">CSV&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">format&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">below&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">including&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">header&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">```&lt;/span>&lt;span class="n">csv&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="n">username&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="n">password&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="n">email&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;strong>Possible AI output:&lt;/strong>
AI will generate a text block in CSV format containing 20 rows of data that mix valid data with deliberately constructed invalid data, ready to be used directly in automated test scripts or manual testing.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-csv" data-lang="csv">&lt;span class="line">&lt;span class="cl">&lt;span class="s">username&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s">password&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s">email&lt;/span>&lt;span class="p">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&lt;/span>&lt;span class="s">validuser1&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s">ValidPass1!&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s">test.user1@gmail.com&lt;/span>&lt;span class="p">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&lt;/span>&lt;span class="s">short&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s">WeakPass1&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s">test.user2@outlook.com&lt;/span>&lt;span class="p">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&lt;/span>&lt;span class="s">toolongusername123&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s">AnotherGoodP@ss&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s">test.user3@yahoo.com&lt;/span>&lt;span class="p">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&lt;/span>&lt;span class="s">invalid-user&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s">Weak1&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s">invalid-email&lt;/span>&lt;span class="p">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&lt;/span>&lt;span class="s">user.123&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s">StrongerP@ssword123&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s">test.user4@gmail.com&lt;/span>&lt;span class="p">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">&lt;/span>&lt;span class="s">... (and so on)&lt;/span>&lt;span class="p">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h4 id="33-case-3---assisting-in-writing-automation-test-scripts-test-automation">3.3 Case 3 - Assisting in Writing Automation Test Scripts (Test Automation)
&lt;/h4>&lt;p>For test automation engineers, AI can become a powerful programming assistant.&lt;/p>
&lt;p>&lt;strong>Scenario&lt;/strong> - You need to write an automated test script using Selenium and Python for the &amp;ldquo;add to cart&amp;rdquo; feature mentioned earlier.&lt;/p>
&lt;p>&lt;strong>A good prompt (using chain-of-thought and code generation) 👍:&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl"># Role
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">You are a senior test automation engineer, proficient in Python and Selenium WebDriver.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"># Task
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">For the test scenario &amp;#34;Verify a logged-in user can successfully add one product to the cart&amp;#34;, write a complete, executable Python Selenium automation test script.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"># Instructions and Thought Process (Chain-of-Thought)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Let&amp;#39;s complete this task step by step:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. **Set up the environment**: Import the necessary Selenium libraries, initialize the WebDriver (use the Chrome browser), and set an implicit wait.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2. **Login operation**: First, write a function `login(username, password)` that navigates to the login page, enters the username and password, and then clicks the login button. Use ID selectors to locate elements.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">3. **Navigate to the product page**: After logging in, navigate to a specific product page. Assume the product page URL is &amp;#34;[http://example.com/product/123](http://example.com/product/123)&amp;#34;.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">4. **Perform the add operation**: Locate the &amp;#34;Add to Cart&amp;#34; button (assume its ID is `add-to-cart-button`) and click it.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">5. **Assertion verification**:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> * Add an explicit wait for the success message to appear (assume its CSS selector is `.success-message`).
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> * Get the text of that message and assert that its content is &amp;#34;Product successfully added to cart&amp;#34;.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> * Get the text of the count element next to the cart icon (assume its ID is `cart-item-count`) and assert that its value is &amp;#34;1&amp;#34;.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">6. **Cleanup**: Finally, close the browser with `driver.quit()`.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">7. **Code structure**: Wrap all operations in a main function or test class, and add comments to explain the key steps.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"># Please output the complete Python code.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>Possible AI output:&lt;/p>
&lt;p>Based on this detailed, step-by-step instruction, AI will generate a well-structured, fully commented Python Selenium script containing all the necessary operations and assertions. This approach is far more efficient and accurate than a simple request such as &amp;ldquo;write me a Selenium script&amp;rdquo;.&lt;/p>
&lt;hr>
&lt;h3 id="chapter-4---advanced-prompt-engineering-techniques">Chapter 4 - Advanced Prompt Engineering Techniques
&lt;/h3>&lt;p>Once you have mastered the basics, you can apply more advanced techniques to tackle complex testing challenges.&lt;/p>
&lt;h4 id="41-deeper-applications-of-chain-of-thought-cot">4.1 Deeper Applications of Chain-of-Thought (CoT)
&lt;/h4>&lt;p>For tasks requiring complex logical reasoning, such as &lt;strong>Root Cause Analysis&lt;/strong>, deepening the application of CoT is crucial.&lt;/p>
&lt;p>&lt;strong>Scenario&lt;/strong> - An API test fails, returning a 500 error, and you need to analyze the possible causes.&lt;/p>
&lt;p>&lt;strong>Prompt:&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;span class="lnt">29
&lt;/span>&lt;span class="lnt">30
&lt;/span>&lt;span class="lnt">31
&lt;/span>&lt;span class="lnt">32
&lt;/span>&lt;span class="lnt">33
&lt;/span>&lt;span class="lnt">34
&lt;/span>&lt;span class="lnt">35
&lt;/span>&lt;span class="lnt">36
&lt;/span>&lt;span class="lnt">37
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-mysql" data-lang="mysql">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Role
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="n">You&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">are&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">top&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="n">tier&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Site&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Reliability&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nf">Engineer&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">SRE&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">diagnosing&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">an&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">API&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">failure&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1"># Context
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="n">API&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">endpoint&lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">`/&lt;/span>&lt;span class="n">api&lt;/span>&lt;span class="o">/&lt;/span>&lt;span class="n">v1&lt;/span>&lt;span class="o">/&lt;/span>&lt;span class="n">users&lt;/span>&lt;span class="o">/&lt;/span>&lt;span class="err">{&lt;/span>&lt;span class="n">userId&lt;/span>&lt;span class="err">}&lt;/span>&lt;span class="o">/&lt;/span>&lt;span class="n">profile&lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="n">Problem&lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">During&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">high&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="n">concurrency&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">load&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">testing&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">this&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">endpoint&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">occasionally&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">returns&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">an&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">HTTP&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">500&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Internal&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Server&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Error&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="n">Log&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">snippet&lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="o">```&lt;/span>&lt;span class="n">log&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">ERROR&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Connection&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">pool&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">exhausted&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Could&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">not&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">get&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">connection&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">from&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">pool&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="p">...&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">Caused&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">by&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">java&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="k">sql&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">SQLTransientConnectionException&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">HikariPool&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Connection&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">is&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">not&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">available&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">request&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">timed&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">out&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">after&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">30000&lt;/span>&lt;span class="n">ms&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1"># Task
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="n">Please&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">use&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;chain-of-thought&amp;#34;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">method&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">to&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">analyze&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">potential&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">root&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">causes&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">of&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">this&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">problem&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">step&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">by&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">step&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">and&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">for&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">each&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">cause&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">propose&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">concrete&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">investigation&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">steps&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">and&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">solution&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">recommendations&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Think&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">like&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">an&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">expert&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">and&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">analyze&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">from&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">multiple&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nf">layers&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">application&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">layer&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">database&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">layer&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">configuration&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">layer&lt;/span>&lt;span class="p">).&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="n">Thinking&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">begins&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="n">Log&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">analysis&lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">The&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">log&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">explicitly&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">states&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;Connection pool exhausted&amp;#34;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">database&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">connection&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">pool&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">is&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">exhausted&lt;/span>&lt;span class="p">).&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">This&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">is&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">most&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">direct&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">clue&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="mi">2&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="n">Why&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">is&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">connection&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">pool&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">exhausted&lt;/span>&lt;span class="o">?**&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="n">Cause&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">A&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Connections&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">are&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">not&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">released&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">Is&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">there&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">logic&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">branch&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">in&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">application&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">code&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">that&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">does&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">not&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">properly&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">close&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nf">connection&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="n">connection&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="nf">close&lt;/span>&lt;span class="p">()&lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">after&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">querying&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">database&lt;/span>&lt;span class="o">?&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="n">Cause&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">B&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">The&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">connection&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">pool&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">is&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">too&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">small&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">Is&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="n">maximumPoolSize&lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">configuration&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">of&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="n">HikariCP&lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="kt">set&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">too&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">low&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">for&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">current&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">concurrent&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">load&lt;/span>&lt;span class="o">?&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="n">Cause&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">C&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">The&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">queries&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">themselves&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">are&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">too&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">slow&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Are&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">there&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">slow&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">queries&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">that&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">hold&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">connections&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">for&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">long&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="kt">time&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">rapidly&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">exhausting&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">pool&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">under&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">high&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">concurrency&lt;/span>&lt;span class="o">?&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="n">Cause&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">D&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">A&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">database&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">performance&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">bottleneck&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Has&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">database&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">server&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">itself&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">hit&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">CPU&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">memory&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">or&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">I&lt;/span>&lt;span class="o">/&lt;/span>&lt;span class="n">O&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">bottleneck&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">causing&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">queries&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">to&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">respond&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">slowly&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">and&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">indirectly&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">exhausting&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">connection&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">pool&lt;/span>&lt;span class="o">?&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="mi">3&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="n">How&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">to&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">investigate&lt;/span>&lt;span class="o">?**&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="k">For&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Cause&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">A&lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Review&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">all&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">code&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">paths&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">that&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">handle&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">`/&lt;/span>&lt;span class="n">api&lt;/span>&lt;span class="o">/&lt;/span>&lt;span class="n">v1&lt;/span>&lt;span class="o">/&lt;/span>&lt;span class="n">users&lt;/span>&lt;span class="o">/&lt;/span>&lt;span class="err">{&lt;/span>&lt;span class="n">userId&lt;/span>&lt;span class="err">}&lt;/span>&lt;span class="o">/&lt;/span>&lt;span class="n">profile&lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">requests&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">especially&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">exception&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="n">handling&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">blocks&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">to&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">ensure&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">connections&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">are&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">properly&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">closed&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">in&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="n">finally&lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">blocks&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="k">For&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Cause&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">B&lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">Check&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">application&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">configuration&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nf">files&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">such&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">as&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="n">application&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">properties&lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">or&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="n">yml&lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">for&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">value&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">of&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="n">spring&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">datasource&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">hikari&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">maximum&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="n">pool&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="n">size&lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Monitor&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="kt">real&lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="kt">time&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">connection&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">pool&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">usage&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="k">For&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Cause&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">C&lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Enable&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">database&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">slow&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">query&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">log&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">and&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">analyze&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">whether&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">there&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">are&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">slow&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">query&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">records&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">at&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="kt">time&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">problem&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">occurred&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Run&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="k">EXPLAIN&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">ANALYZE&lt;/span>&lt;span class="o">`&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">on&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">SQL&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">statements&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">involved&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">in&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">this&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">API&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="k">For&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Cause&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">D&lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">Check&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">database&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">server&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">monitoring&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nf">dashboard&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">CPU&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">usage&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">memory&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">disk&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">I&lt;/span>&lt;span class="o">/&lt;/span>&lt;span class="n">O&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">active&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">connections&lt;/span>&lt;span class="p">).&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="mi">4&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">**&lt;/span>&lt;span class="n">Solution&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">recommendations&lt;/span>&lt;span class="o">?**&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">...&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1"># Output
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="n">Based&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">on&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">chain&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">of&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">thought&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">above&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">organize&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">it&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">into&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">formal&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">incident&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">analysis&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">report&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>This kind of CoT prompt not only guides AI to a conclusion but, more importantly, forces it to display a structured, logically clear analysis process—something extremely valuable for complex diagnostic tasks.&lt;/p>
&lt;h4 id="42-self-consistency-for-exploratory-testing">4.2 Self-Consistency for Exploratory Testing
&lt;/h4>&lt;p>In &lt;strong>exploratory testing&lt;/strong>, which demands creative and divergent thinking, you can leverage &lt;code>Self-Consistency&lt;/code> to generate a more diverse set of testing ideas.&lt;/p>
&lt;p>&lt;strong>Scenario&lt;/strong> - Designing exploratory testing ideas for a new &amp;ldquo;online document collaboration&amp;rdquo; feature.&lt;/p>
&lt;p>&lt;strong>Prompt:&lt;/strong>&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-mysql" data-lang="mysql">&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1"># Role
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="n">You&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">are&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">highly&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">creative&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">and&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">destructive&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">software&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">tester&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">skilled&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">at&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">finding&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">bugs&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">that&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">users&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">never&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">expect&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1"># Task
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">For&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;real-time online document collaboration&amp;#34;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">feature&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">generate&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">5&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">different&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">creative&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">exploratory&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">testing&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nf">ideas&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">charters&lt;/span>&lt;span class="p">).&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">What&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">I&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">need&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">are&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">diverse&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">unconventional&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">ideas&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="c1"># Instructions
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">I&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">will&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">run&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">this&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">prompt&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">multiple&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">times&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="mi">2&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Please&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">think&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">about&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">and&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">generate&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">5&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">testing&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">ideas&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">focusing&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">on&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">concurrent&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">operations&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">network&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">latency&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">data&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">conflicts&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">and&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">unconventional&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">user&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">interactions&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="mi">3&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">Please&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">output&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">in&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">form&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">of&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">a&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">bulleted&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">list&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">You&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">can&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">turn&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">up&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">the&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">model&lt;/span>&lt;span class="s1">&amp;#39;s `temperature` parameter, for example to 0.8, and then run this prompt multiple times)
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>&lt;strong>Possible output for Run 1:&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Simulate disconnect and reconnect&lt;/strong>: Two users edit simultaneously; one suddenly loses connectivity, makes a large number of changes, and then reconnects—observe how the data merges.&lt;/li>
&lt;li>&lt;strong>Frantic cursor movement&lt;/strong>: Multiple users furiously type, delete, and move cursors on the same line, testing rendering performance and synchronization accuracy.&lt;/li>
&lt;li>&amp;hellip;&lt;/li>
&lt;/ul>
&lt;p>&lt;strong>Possible output for Run 2:&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Dynamic permission change&lt;/strong>: While one user is editing, an administrator suddenly downgrades their permission from &amp;ldquo;editable&amp;rdquo; to &amp;ldquo;read-only&amp;rdquo;—observe the behavior of their client.&lt;/li>
&lt;li>&lt;strong>Mixing rich text and plain text&lt;/strong>: One user pastes complex rich text (with formatting and images) while another simultaneously types plain text nearby—check whether the formatting gets scrambled.&lt;/li>
&lt;li>&amp;hellip;&lt;/li>
&lt;/ul>
&lt;p>By generating multiple times and synthesizing all the unique ideas, testers can obtain an exploratory testing checklist far richer and more comprehensive than what a single request would yield.&lt;/p>
&lt;hr>
&lt;h3 id="chapter-5---summary-and-outlook">Chapter 5 - Summary and Outlook
&lt;/h3>&lt;p>Prompt engineering is rapidly becoming one of the core competencies of software test engineers. It is not meant to replace testers&amp;rsquo; thinking, but to augment their capabilities, freeing them from repetitive labor so they can take on tasks that demand greater wisdom and insight.&lt;/p>
&lt;p>&lt;strong>The key to success lies in practice&lt;/strong>. Starting today, try applying the techniques introduced in this article to your daily work. Begin with small tasks—for example, having AI polish a defect report for you, or brainstorming some edge cases for the feature you are currently testing. As your understanding of the model&amp;rsquo;s &amp;ldquo;temperament&amp;rdquo; deepens, you will be able to build increasingly powerful prompts, truly achieving efficient collaboration with AI and lifting the efficiency and quality of software testing to an entirely new level.&lt;/p>
&lt;p>The future of software testing will be an era of deep integration between human wisdom and artificial intelligence—and prompt engineering is precisely the key that opens this door.&lt;/p>
&lt;hr></description></item><item><title>A Prompt-Writing Framework for Test Engineers to Use Large AI Models Effectively</title><link>https://chengxiaqiucao.github.io/en/post/079-%E8%BD%AF%E4%BB%B6%E6%B5%8B%E8%AF%95%E6%8F%90%E7%A4%BA%E8%AF%8D/</link><pubDate>Wed, 16 Apr 2025 00:00:00 +0000</pubDate><guid>https://chengxiaqiucao.github.io/en/post/079-%E8%BD%AF%E4%BB%B6%E6%B5%8B%E8%AF%95%E6%8F%90%E7%A4%BA%E8%AF%8D/</guid><description>&lt;h2 id="preface">Preface
&lt;/h2>&lt;p>With the widespread application of large AI models in software testing, prompt engineering has become a key skill for test engineers to improve efficiency. Through precise prompt design, we can quickly generate test cases, optimize test scenarios, generate automation scripts, and even achieve intelligent test coverage.&lt;/p>
&lt;p>So how can we use large models more effectively and have them help us reach the desired results more efficiently? Good prompts let us achieve twice the result with half the effort. The following summarizes, for test engineers, how to write a good prompt framework.&lt;/p>
&lt;h2 id="breaking-down-complex-requirements-and-describing-problems-precisely">Breaking Down Complex Requirements and Describing Problems Precisely
&lt;/h2>&lt;p>The effectiveness of large AI models depends heavily on the clarity of the input prompt, that is, on minimizing ambiguity as much as possible. So when entering a prompt, you should break complex tasks down into concrete requirements as much as possible, for example:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Scenario-based descriptions&lt;/strong>: specify the test objective (e.g., &amp;ldquo;generate boundary-value test cases for the login function&amp;rdquo;) rather than a vague instruction (e.g., &amp;ldquo;help me write test cases&amp;rdquo;).&lt;/li>
&lt;li>&lt;strong>Constraints&lt;/strong>: add format requirements (e.g., &amp;ldquo;output in table form&amp;rdquo;), priorities (e.g., &amp;ldquo;include only high-risk scenarios&amp;rdquo;), or technical limitations (e.g., &amp;ldquo;no third-party APIs involved&amp;rdquo;).&lt;/li>
&lt;li>&lt;strong>Example guidance&lt;/strong>: provide sample data or templates to help the model understand the expected output structure.&lt;/li>
&lt;/ul>
&lt;h2 id="using-a-structured-framework-to-improve-output-stability">Using a Structured Framework to Improve Output Stability
&lt;/h2>&lt;p>By defining a structured prompt framework, you can constrain model behavior and reduce random interference:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Role setting&lt;/strong>: specify a professional role for the model to play (e.g., &amp;ldquo;you are a senior testing expert skilled at designing high-coverage test scenarios&amp;rdquo;).&lt;/li>
&lt;li>&lt;strong>Step-by-step instructions&lt;/strong>: break a complex task into multiple steps (e.g., &amp;ldquo;Step 1: analyze the requirements document; Step 2: identify critical paths; Step 3: generate cases&amp;rdquo;).&lt;/li>
&lt;li>&lt;strong>Chain-of-Thought&lt;/strong>: although many models now offer deep-thinking capabilities, guiding the model&amp;rsquo;s analysis through prompts can simplify the direction of its reasoning. For example, &amp;ldquo;first analyze the user operation flow, then focus on generating test cases for exception scenarios&amp;rdquo;.&lt;/li>
&lt;/ol>
&lt;h2 id="progressive-iterative-optimization-and-continuous-prompt-improvement">Progressive Iterative Optimization and Continuous Prompt Improvement
&lt;/h2>&lt;p>Large models usually retain conversation context; for the result of each round of feedback, you should keep correcting and gradually move toward the best output.&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Feedback correction&lt;/strong>: promptly point out errors in the model&amp;rsquo;s output (e.g., &amp;ldquo;case 2 does not cover the timeout scenario, please add it&amp;rdquo;) and ask for regeneration.&lt;/li>
&lt;li>&lt;strong>Parameter tuning&lt;/strong>: control output length (e.g., &amp;ldquo;describe in 50 characters or less&amp;rdquo;) and the Temperature coefficient to balance the model&amp;rsquo;s creativity and accuracy.&lt;/li>
&lt;li>&lt;strong>Cross-comparison&lt;/strong>: there are many open large models today with varying capabilities, and their analysis results can differ considerably. Judge comprehensively and extract the best result.&lt;/li>
&lt;/ul>
&lt;p>Some common correction scenarios:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>&lt;strong>Problem&lt;/strong>&lt;/th>
&lt;th>&lt;strong>Cause&lt;/strong>&lt;/th>
&lt;th>&lt;strong>Improvement&lt;/strong>&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Output too broad&lt;/td>
&lt;td>Vague requirement description&lt;/td>
&lt;td>Add specific scenarios, format, and priority constraints&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Repeated or redundant results&lt;/td>
&lt;td>Output scope not clearly limited&lt;/td>
&lt;td>Exclude unwanted scenarios (e.g., specify &amp;ldquo;output only uncovered boundary-value scenarios&amp;rdquo;)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Incorrect technical terminology&lt;/td>
&lt;td>Model lacks domain knowledge&lt;/td>
&lt;td>Provide a glossary or specify a role (e.g., &amp;ldquo;financial systems testing expert&amp;rdquo;)&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h2 id="case-study">Case Study
&lt;/h2>&lt;p>Based on the principles above, taking the shopping flow of the website &lt;a class="link" href="https://www.saucedemo.com" target="_blank" rel="noopener"
>https://www.saucedemo.com&lt;/a> that we want to test as an example, to use a large model to help us generate a series of test cases, the prompt framework can be set up as follows:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;span class="lnt">29
&lt;/span>&lt;span class="lnt">30
&lt;/span>&lt;span class="lnt">31
&lt;/span>&lt;span class="lnt">32
&lt;/span>&lt;span class="lnt">33
&lt;/span>&lt;span class="lnt">34
&lt;/span>&lt;span class="lnt">35
&lt;/span>&lt;span class="lnt">36
&lt;/span>&lt;span class="lnt">37
&lt;/span>&lt;span class="lnt">38
&lt;/span>&lt;span class="lnt">39
&lt;/span>&lt;span class="lnt">40
&lt;/span>&lt;span class="lnt">41
&lt;/span>&lt;span class="lnt">42
&lt;/span>&lt;span class="lnt">43
&lt;/span>&lt;span class="lnt">44
&lt;/span>&lt;span class="lnt">45
&lt;/span>&lt;span class="lnt">46
&lt;/span>&lt;span class="lnt">47
&lt;/span>&lt;span class="lnt">48
&lt;/span>&lt;span class="lnt">49
&lt;/span>&lt;span class="lnt">50
&lt;/span>&lt;span class="lnt">51
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="line">&lt;span class="cl">Assume you are an experienced software test engineer responsible for end-to-end functional testing of the core shopping flow of the e-commerce website https://www.saucedemo.com/
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Task: Generate detailed, high-priority positive and negative test cases for the following user scenarios. Focus on the complete flow from product selection to a successful order.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Site under test: https://www.saucedemo.com/
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Test user credentials:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">• Standard User: standard_user / secret_sauce
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">• Problem User: problem_user / secret_sauce (used to observe specific erroneous behavior)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Core shopping flow steps:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. User login
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">2. Browse the product list (Inventory Page)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">3. Select at least two different products and add them to the cart
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">4. View the cart (Cart Page)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">5. On the cart page, verify product information (name, quantity, price) and the total price
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">6. Enter the checkout information page (Checkout: Your Information)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">7. Fill in valid checkout information (first name, last name, postal code)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">8. Enter the checkout overview page (Checkout: Overview)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">9. On the overview page, verify product information and the total price (including tax)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">10. Complete the purchase (Checkout: Complete!)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">11. Verify the order success message
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Test case requirements:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">• Positive test cases: cover every step of a successful shopping flow using the standard user, ensuring the functionality works as expected.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">• Negative test cases:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> • Attempt to enter invalid data on the checkout information page (for example, empty or malformed first name, last name, or postal code).
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> • Attempt to check out when the cart is empty.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> • (Optional) Log in with problem_user to observe and record any abnormal behavior in the shopping flow, especially product images, adding to cart, or the checkout step.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Output requirements:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">• Each test case should include: Case ID (TC_SAUCE_SHOP_XXX), Test Description, Preconditions (e.g., logged in with products added), Test Steps (clear and executable), Expected Result, Actual Result (left blank), Status (left blank), and Priority (High/Medium/Low).
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">• Prioritize generating high-priority test cases.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Output format: Output the test cases as a Markdown table containing the following columns: Case ID, Test Description, Preconditions, Test Steps, Expected Result, Priority.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Constraints:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">• Assume a tax rate of 8%.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">• Focus on the correctness of UI element interactions and page navigation.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">• If you are unsure about the ID or Class of certain elements, use a generic description, for example &amp;#34;click the Add to Cart button&amp;#34; or &amp;#34;enter the name field&amp;#34;.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>The prompt above maps fairly well to the relevant prompt framework principles:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Clear role&lt;/strong>: &amp;ldquo;Assume you are an experienced software test engineer&amp;hellip;&amp;rdquo;&lt;/li>
&lt;li>&lt;strong>Clear task&lt;/strong>: &amp;ldquo;Generate detailed, high-priority positive and negative test cases for the following user scenarios. Focus on the complete flow from product selection to a successful order&amp;rdquo;&lt;/li>
&lt;li>&lt;strong>Sufficient contextual information&lt;/strong>: the URL under test, user information, case focus, and tax rate assumptions&lt;/li>
&lt;li>&lt;strong>Specified output format&lt;/strong>: &amp;ldquo;Output the test cases as a Markdown table containing the following columns: &lt;code>Case ID&lt;/code>, &lt;code>Test Description&lt;/code>, &lt;code>Preconditions&lt;/code>, &lt;code>Test Steps&lt;/code>, &lt;code>Expected Result&lt;/code>, &lt;code>Priority&lt;/code>.&amp;rdquo;&lt;/li>
&lt;li>&lt;strong>Clear specific requirements and constraints&lt;/strong>: the specific requirements for cases and output,&lt;/li>
&lt;li>&lt;strong>Guiding the direction of thinking&lt;/strong>: using problem_user to generate exception cases&lt;/li>
&lt;/ul>
&lt;p>Finally, with such a prompt, through Deepseek we obtain the following set of generated test cases:&lt;/p>
&lt;h3 id="high-priority-core-shopping-flow-test-cases">High-Priority Core Shopping Flow Test Cases
&lt;/h3>&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Case ID&lt;/th>
&lt;th>Test Description&lt;/th>
&lt;th>Preconditions&lt;/th>
&lt;th>Test Steps&lt;/th>
&lt;th>Expected Result&lt;/th>
&lt;th>Priority&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;strong>Positive Test Cases&lt;/strong>&lt;/td>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>TC_SAUCE_SHOP_001&lt;/td>
&lt;td>Standard user logs in successfully and enters the product list page&lt;/td>
&lt;td>None&lt;/td>
&lt;td>1. Visit &lt;code>https://www.saucedemo.com/&lt;/code> &lt;br>2. Enter username &lt;code>standard_user&lt;/code> and password &lt;code>secret_sauce&lt;/code> &lt;br>3. Click the login button&lt;/td>
&lt;td>Login succeeds, redirecting to the product list page (Inventory Page)&lt;/td>
&lt;td>High&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>TC_SAUCE_SHOP_002&lt;/td>
&lt;td>Add two different products to the cart and verify the quantity&lt;/td>
&lt;td>User logged in&lt;/td>
&lt;td>1. On the product list page, select two different products and click the &amp;ldquo;Add to Cart&amp;rdquo; button for each &lt;br>2. Check that the cart icon shows a quantity of 2&lt;/td>
&lt;td>The cart icon quantity updates to 2, and both products appear on the cart page&lt;/td>
&lt;td>High&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>TC_SAUCE_SHOP_003&lt;/td>
&lt;td>Verify product information and total price (excluding tax) on the cart page&lt;/td>
&lt;td>User has added two products to the cart&lt;/td>
&lt;td>1. Click the cart icon to enter the cart page &lt;br>2. Check the product name, quantity, and unit price &lt;br>3. Calculate the total price (product 1 price + product 2 price)&lt;/td>
&lt;td>Product information is correct, and the total price shows the sum of the two products&lt;/td>
&lt;td>High&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>TC_SAUCE_SHOP_004&lt;/td>
&lt;td>Complete valid checkout information and verify the tax-inclusive total&lt;/td>
&lt;td>User has entered the checkout information page&lt;/td>
&lt;td>1. On the checkout information page, enter a valid first name, last name, and postal code (e.g., John/Doe/12345) &lt;br>2. Click the &amp;ldquo;Continue&amp;rdquo; button &lt;br>3. On the overview page, verify the total price (total = product total * 1.08)&lt;/td>
&lt;td>Redirected to the checkout overview page, total includes 8% tax and is calculated correctly&lt;/td>
&lt;td>High&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>TC_SAUCE_SHOP_005&lt;/td>
&lt;td>Complete the purchase and verify the order success message&lt;/td>
&lt;td>User has entered the checkout overview page&lt;/td>
&lt;td>1. Click the &amp;ldquo;Finish&amp;rdquo; button&lt;/td>
&lt;td>Displays the &amp;ldquo;THANK YOU FOR YOUR ORDER&amp;rdquo; success message and returns to the product list page&lt;/td>
&lt;td>High&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Negative Test Cases&lt;/strong>&lt;/td>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>TC_SAUCE_SHOP_006&lt;/td>
&lt;td>Submit the form with an empty name on the checkout information page&lt;/td>
&lt;td>User has entered the checkout information page&lt;/td>
&lt;td>1. Leave the name field blank and enter a valid postal code (e.g., 12345) &lt;br>2. Click the &amp;ldquo;Continue&amp;rdquo; button&lt;/td>
&lt;td>Shows &amp;ldquo;First Name is required&amp;rdquo; and blocks navigation&lt;/td>
&lt;td>High&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>TC_SAUCE_SHOP_007&lt;/td>
&lt;td>Invalid postal code format on the checkout information page (e.g., non-numeric)&lt;/td>
&lt;td>User has entered the checkout information page&lt;/td>
&lt;td>1. Enter a valid first name and last name, with postal code &amp;ldquo;ABC12&amp;rdquo; &lt;br>2. Click the &amp;ldquo;Continue&amp;rdquo; button&lt;/td>
&lt;td>Shows &amp;ldquo;Postal Code is invalid&amp;rdquo; and blocks navigation&lt;/td>
&lt;td>High&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>TC_SAUCE_SHOP_008&lt;/td>
&lt;td>Attempt to check out with an empty cart&lt;/td>
&lt;td>User logged in with an empty cart&lt;/td>
&lt;td>1. Click the cart icon to enter the cart page &lt;br>2. Click the &amp;ldquo;Checkout&amp;rdquo; button&lt;/td>
&lt;td>Shows &amp;ldquo;Cart is empty&amp;rdquo; or blocks navigation to the checkout page&lt;/td>
&lt;td>High&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Problem User Test Cases&lt;/strong>&lt;/td>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;td>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>TC_SAUCE_SHOP_009&lt;/td>
&lt;td>Problem User shows abnormal product images when adding products&lt;/td>
&lt;td>Problem User logged in&lt;/td>
&lt;td>1. Browse the product list page &lt;br>2. Check whether product images load correctly (e.g., misplaced or failing to display)&lt;/td>
&lt;td>Product images display abnormally (e.g., blank or wrong images)&lt;/td>
&lt;td>Medium&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>TC_SAUCE_SHOP_010&lt;/td>
&lt;td>Problem User total price calculation error at checkout&lt;/td>
&lt;td>Problem User has added products to the cart&lt;/td>
&lt;td>1. Complete the checkout flow up to the overview page &lt;br>2. Verify whether the total equals product total * 1.08&lt;/td>
&lt;td>Total price calculation error (e.g., tax not included or deviated value)&lt;/td>
&lt;td>Medium&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;h4 id="supplementary-notes">&lt;strong>Supplementary Notes&lt;/strong>
&lt;/h4>&lt;ol>
&lt;li>&lt;strong>Priority assignment&lt;/strong>: core flows (login, adding products, checkout) and key exception scenarios (empty fields, invalid data) are set to high priority.&lt;/li>
&lt;li>&lt;strong>Problem User&lt;/strong>: used to verify specific abnormal behaviors (such as UI rendering errors or logic flaws).&lt;/li>
&lt;li>&lt;strong>Actual Result/Status&lt;/strong>: to be filled in based on actual observations during execution (such as &amp;ldquo;Pass&amp;rdquo;, &amp;ldquo;Fail&amp;rdquo;, or &amp;ldquo;Blocked&amp;rdquo;).&lt;/li>
&lt;li>&lt;strong>Tax calculation&lt;/strong>: assuming the product total is &lt;code>$X&lt;/code>, the tax-inclusive total should be &lt;code>X * 1.08&lt;/code>, rounded to two decimal places (e.g., &lt;code>$21.99 * 1.08 = $23.75&lt;/code>).&lt;/li>
&lt;/ol></description></item><item><title>The Hidden Concerns Behind the MCP Boom</title><link>https://chengxiaqiucao.github.io/en/post/076-mcp%E5%A4%A7%E6%B5%81%E8%A1%8C%E8%83%8C%E5%90%8E%E7%9A%84%E9%9A%90%E5%BF%A7/</link><pubDate>Mon, 14 Apr 2025 15:28:24 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/076-mcp%E5%A4%A7%E6%B5%81%E8%A1%8C%E8%83%8C%E5%90%8E%E7%9A%84%E9%9A%90%E5%BF%A7/</guid><description>&lt;p>Over the past few weeks, the Model Context Protocol (MCP) has rapidly emerged as the de facto standard for connecting third-party data and tools to LLM-based conversational systems. In a short time, the internet has been flooded with all kinds of flashy application cases, and the room for imagination is enormous. Yet behind this protocol there also lurk some subtle security risks and functional limitations.&lt;/p>
&lt;h1 id="background">Background
&lt;/h1>&lt;p>The essence of MCP is to act as a bridge for building an &amp;ldquo;intelligent assistant plugin ecosystem&amp;rdquo;, allowing users to provide local extension capabilities to various large models and AI clients that support the MCP protocol, so that these LLM-based intelligent interfaces can perform non-text operations through MCP&amp;rsquo;s &amp;ldquo;tool calls&amp;rdquo;. The MCP protocol in effect standardizes the way LLMs interface with local data and tools.&lt;/p>
&lt;p>For example, in the previous article, we simply told the large model in &lt;code> Cursor&lt;/code>: &lt;em>&amp;ldquo;Visit the &lt;a class="link" href="https://www.saucedemo.com" target="_blank" rel="noopener"
>www.saucedemo.com&lt;/a> website, log in with problem_user, verify the complete workflow of the site, and record any issues found&amp;rdquo;&lt;/em> , and Cursor then used the &lt;code>playwright-mcp&lt;/code> MCP server to call the &lt;code>playwright&lt;/code> framework to carry out a series of activities such as launching the browser, visiting, browsing, testing, and recording issues—completing testing activities similar to those of a manual test engineer&lt;/p>
&lt;p>So through MCP, its core value is that it breaks through the original role of large AI models as text-based advisory assistants and turns them into actual executors, better able to directly operate local tools and data, providing large models with a universal socket.&lt;/p>
&lt;h1 id="the-potential-hidden-concerns">The Potential Hidden Concerns
&lt;/h1>&lt;p>But while we recognize MCP&amp;rsquo;s enormous potential, we must also see that MCP, as a foundational protocol that has only recently gotten started, is far from perfect, and there are still the following hidden concerns:&lt;/p>
&lt;h2 id="hidden-concern-1---security-of-the-protocol-itself">&lt;strong>Hidden Concern 1 - Security of the Protocol Itself&lt;/strong>
&lt;/h2>&lt;h3 id="authentication-mechanisms">&lt;strong>Authentication Mechanisms&lt;/strong>
&lt;/h3>&lt;p>The initial version of MCP did not define an authentication specification, leaving each MCP server to do as it pleased—from cumbersome verification to sensitive data being left completely exposed, a veritable chaos. Although authentication schemes were introduced later, their implementation complexity has sparked new controversy.&lt;/p>
&lt;h3 id="the-risk-of-local-malicious-code-execution">&lt;strong>The Risk of Local Malicious Code Execution&lt;/strong>
&lt;/h3>&lt;p>The protocol supports running MCP servers via standard input/output, which, while lowering the barrier to use, also provides a breeding ground for the spread of malicious code. If a non-technical user runs third-party malicious MCP code and causes a local device security failure, this has become a new attack vector.&lt;/p>
&lt;h3 id="mcp">&lt;strong>MCP&amp;rsquo;s Trust in User Input&lt;/strong>
&lt;/h3>&lt;p>Many MCP servers directly execute user input instructions. When user intent is translated by the LLM and takes effect on the system, traditional security models face a severe challenge: the boundary between user input instructions and attacks on the system is no longer clear.&lt;/p>
&lt;h2 id="hidden-concern-2---limitations-in-interaction-design">&lt;strong>Hidden Concern 2 - Limitations in Interaction Design&lt;/strong>
&lt;/h2>&lt;p>The MCP protocol is oriented more toward LLM interaction, but for users, the interaction is hardly easy to use or friendly.&lt;/p>
&lt;h3 id="the-lack-of-risk-grading-for-different-levels-of-operations">&lt;strong>The Lack of Risk Grading for Different Levels of Operations&lt;/strong>
&lt;/h3>&lt;p>Many assistant tools provide a global operation-confirmation mechanism, but the &amp;ldquo;auto-confirm&amp;rdquo; habit formed around many harmless tools often leads to serious misoperations, such as the deletion of important local files or sending emails by mistake.&lt;/p>
&lt;h3 id="cost-control-capability">&lt;strong>Cost Control Capability&lt;/strong>
&lt;/h3>&lt;p>Unlike traditional protocols, in LLM scenarios different volumes of returned tokens incur varying costs, and the cost of serving users depends heavily on the token efficiency of MCP tools, yet the current protocol has no limit on return length to strengthen cost control.&lt;/p>
&lt;h3 id="sacrificing-the-advantages-of-structured-data">&lt;strong>Sacrificing the Advantages of Structured Data&lt;/strong>
&lt;/h3>&lt;p>To accommodate LLM preferences, MCP tends to adopt human-readable formats such as plain text / images / audio clips for transmission, sacrificing the advantages of structured data. For services such as maps or Didi-style ride-hailing, which need to ensure location accuracy, trip-detail feedback, and real-time status updates, the current protocol is hardly up to the task. Solving such problems for now still requires some workaround designs at the tool layer.&lt;/p>
&lt;hr>
&lt;h2 id="hidden-concern-3---llm-security">&lt;strong>Hidden Concern 3 - LLM Security&lt;/strong>
&lt;/h2>&lt;p>The discussion around the security of large models themselves is still unresolved, and introducing MCP to connect more data and tools makes this problem even more prominent.&lt;/p>
&lt;h3 id="mcp-makes-prompt-injection-more-powerful">&lt;strong>MCP Makes Prompt Injection More Powerful&lt;/strong>
&lt;/h3>&lt;p>LLMs usually have two layers of instructions: &lt;strong>system-level prompts&lt;/strong> (which control the assistant&amp;rsquo;s behavior and policies) and &lt;strong>user-level prompts&lt;/strong> (provided by the user). Usually, when &lt;strong>prompt injection&lt;/strong> was mentioned in the past, it referred to malicious user input. A fairly significant vulnerability of the MCP model is that it allows tools provided by third parties to be trusted as part of the assistant&amp;rsquo;s system-level prompt, thereby granting them greater privileges to override the agent&amp;rsquo;s behavior.&lt;/p>
&lt;h3 id="sensitive-data-leakage">&lt;strong>Sensitive Data Leakage&lt;/strong>
&lt;/h3>&lt;p>Beyond malicious hijacking via malicious tools, MCP can also cause users to leak sensitive data unintentionally. Even if a user strictly confirms every operation, data may still be exfiltrated in a &amp;ldquo;reasonable&amp;rdquo; way. For example, with your instruction: &amp;ldquo;Explain my personal medical records to me&amp;rdquo;, the assistant may launch a medical-retrieval multi-tenant MCP tool and leak your private personal information to the service provider.&lt;/p>
&lt;p>MCP servers can also easily hijack or alter user intent through disguised prompts and their actual tool implementations.&lt;/p>
&lt;h2 id="hidden-concern-4---breaking-traditional-enterprise-data-access-controls">Hidden Concern 4 - &lt;strong>Breaking Traditional Enterprise Data Access Controls&lt;/strong>
&lt;/h2>&lt;p>Unlike the direct leakage of sensitive data, after an enterprise connects large amounts of internal data to an LLM via MCP, ordinary employees may be able to access or infer data they are not authorized to access.&lt;/p>
&lt;p>For example, if all of an enterprise&amp;rsquo;s internal documents are connected to an LLM, an employee, through the assistant:&lt;/p>
&lt;p>&lt;em>&amp;ldquo;Based on all the documents I have permission to access and the company&amp;rsquo;s appointment and removal notices, infer major events that have not yet been announced, such as layoffs&amp;rdquo;&lt;/em>&lt;/p>
&lt;p>Or someone at the manager level:&lt;/p>
&lt;p>&lt;em>&amp;ldquo;I saw an anonymous negative comment about XXX on the internal wiki, the content is XXXX; please analyze the speaking records of members in the XX team and infer who most likely wrote this comment&amp;rdquo;&lt;/em>&lt;/p>
&lt;h2 id="hidden-concern-5---the-inherent-capability-limits-of-llms">&lt;strong>Hidden Concern 5 - The Inherent Capability Limits of LLMs&lt;/strong>
&lt;/h2>&lt;p>For large-scale MCP integration, the load capacity of the LLM itself may well be unable to cope. Google&amp;rsquo;s &lt;strong>A2A protocol (Agent to Agent)&lt;/strong> may be a solution, but that is another matter.&lt;/p>
&lt;h3 id="mcp-1">&lt;strong>MCP&amp;rsquo;s Effectiveness Depends on the LLM Integrated into the Assistant&lt;/strong>
&lt;/h3>&lt;p>One fact is that &lt;strong>it is not the case that the more tools and the more data, the more accurate the results&lt;/strong>; on the contrary, the more similar data and tools there are, the worse the precision of the final output becomes. As the number of MCP servers grows and more tools are integrated, the performance of AI assistants will also decline significantly, and the cost of requests and analysis will increase.&lt;/p>
&lt;h3 id="the-gap-between-tool-implementation-and-user-expectations">&lt;strong>The Gap Between Tool Implementation and User Expectations&lt;/strong>
&lt;/h3>&lt;p>In implementation, many MCP servers are essentially functions or methods written to call tools that already exist locally, so their capabilities are mainly constrained by those functions and methods. If users have little understanding of the specific function implementations and simply interact with the LLM following ordinary human communication patterns, they are likely to struggle to get satisfactory results.&lt;/p>
&lt;p>&lt;em>&amp;ldquo;Please find for me all recent blog articles related to AI testing&amp;rdquo;&lt;/em>; this instruction actually requires the local MCP server to have the ability to full-text search local text content, but if the integrated MCP server only includes file-finding functionality, naturally no corresponding results can be obtained.&lt;/p>
&lt;h1 id="conclusion-and-outlook">Conclusion and Outlook
&lt;/h1>&lt;p>The birth of MCP answers the data-integration needs of the AI era, and its everyday application value is beyond doubt. But we also need a sober awareness: the MCP protocol is still in its growth phase, and while we embrace its applications, we must also recognize the risks within it; combining LLMs with data amplifies existing risks and gives rise to new types of threats.&lt;/p>
&lt;hr>
&lt;p>Most of the views in this article are drawn from Shrivu&amp;rsquo;s blog (Read the original article)&lt;/p></description></item><item><title>Google Launches the A2A Protocol</title><link>https://chengxiaqiucao.github.io/en/post/075-google%E6%8E%A8%E5%87%BAa2a%E5%8D%8F%E8%AE%AE/</link><pubDate>Fri, 11 Apr 2025 11:36:52 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/075-google%E6%8E%A8%E5%87%BAa2a%E5%8D%8F%E8%AE%AE/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/075-google%E6%8E%A8%E5%87%BAa2a%E5%8D%8F%E8%AE%AE/Pasted-20250411.webp" alt="Featured image of post Google Launches the A2A Protocol" />&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/075-google%E6%8E%A8%E5%87%BAa2a%E5%8D%8F%E8%AE%AE/Pasted-20250411_hu_5e28383edd3073c.webp"
width="1024"
height="352"
srcset="https://chengxiaqiucao.github.io/post/075-google%E6%8E%A8%E5%87%BAa2a%E5%8D%8F%E8%AE%AE/Pasted-20250411_hu_ba1edaf83d481e4f.webp 480w, https://chengxiaqiucao.github.io/post/075-google%E6%8E%A8%E5%87%BAa2a%E5%8D%8F%E8%AE%AE/Pasted-20250411_hu_5e28383edd3073c.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="290"
data-flex-basis="697px"
>
&lt;/p>
&lt;blockquote>
&lt;p>On April 9, Google made a major release of the &lt;strong>A2A (Agent to Agent)&lt;/strong> protocol, adding more fuel to the opening-up and standardization of AI Agent capabilities. So what exactly does this &lt;strong>A2A protocol&lt;/strong> do? What is its relationship with the previously red-hot &lt;strong>MCP Server&lt;/strong>? Will it give rise to a standards war? In this article, let&amp;rsquo;s get to know this freshly baked A2A protocol and its application scenarios.&lt;/p>&lt;/blockquote>
&lt;h2 id="a2a-and-mcp">A2A and MCP
&lt;/h2>&lt;p>&lt;strong>A2A&lt;/strong>, namely the Agent to Agent protocol, is an open-source foundational AI protocol just launched by Google, aimed at enabling communication and interoperability between AI Agents. By providing agents with a standardized way to collaborate — that is, regardless of their underlying framework or vendor — different AI Agents can securely exchange information and collaborate, and can work across a variety of enterprise platforms and applications.&lt;/p>
&lt;p>This protocol provides a common communication standard between Agent and Agent.&lt;/p>
&lt;p>It and the recently red-hot &lt;strong>MCP (Model Context Protocol)&lt;/strong> (introduced in the previous article 【】) are actually not in a competitive relationship. Google&amp;rsquo;s official release statement also emphasized that this protocol is in fact a complement to the MCP protocol.&lt;/p>
&lt;p>&lt;strong>MCP&lt;/strong> is an open protocol launched late last year by the AI company Anthropic (the parent company of Claude), aimed at standardizing the interaction interface between large language models (LLMs) and external data sources and tools.&lt;/p>
&lt;p>As mainstream large models such as OpenAI announce support for MCP integration, MCP currently has great potential to become a foundational specification in the AI application field; the recent proliferation of all kinds of MCP Servers springing up like mushrooms after rain also proves that this protocol has gained wide recognition.&lt;/p>
&lt;p>As the saying goes, &lt;strong>third-rate companies make products, second-rate companies make brands, first-rate companies make standards&lt;/strong>; Google has keenly captured a very important piece of the puzzle in the AI Agent application standards beyond MCP.&lt;/p>
&lt;p>That is, MCP defines the connection between LLMs and Agents, and can use Agents to extend LLM capabilities. In the future there will surely also be Agent stores similar to the App Store, integrating all kinds of different Agents.&lt;/p>
&lt;p>But for subsequent large-scale AI applications, many Agents will be integrated to collaborate together, and the interaction between these Agents is precisely the missing piece of the puzzle at present. This is the role A2A plays — very similar to the inter-service communication protocol in a microservices system.&lt;/p>
&lt;h2 id="a2as-design-principles">A2A&amp;rsquo;s Design Principles
&lt;/h2>&lt;p>The official side has given the design principles of the A2A protocol:&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>Embrace agentic capabilities&lt;/strong> — A2A is committed to enabling agents to collaborate in natural, unstructured modes, even when they do not share memory, tools, and context. We are enabling truly multi-agent scenarios, rather than confining agents to being a single &amp;ldquo;tool&amp;rdquo;.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Built on existing standards&lt;/strong> — the protocol is built on top of existing popular standards, including HTTP, SSE, and JSON-RPC, which means it is easier to integrate with the existing IT stacks that enterprises use every day.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Secure by default&lt;/strong> — A2A is designed to support enterprise-grade authentication and authorization, matching OpenAPI&amp;rsquo;s authentication schemes at launch.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Support for long-running tasks&lt;/strong> — A2A was designed with flexibility in mind and supports a variety of scenarios, enabling it to excel at a wide range of tasks, from quick tasks to deep research that may take hours or even days (if humans are involved). Along the way, A2A can provide users with real-time feedback, notifications, and status updates.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Modality agnostic&lt;/strong> — the world of agents is not limited to text, which is why we designed A2A to support a variety of modalities, including audio and video streaming.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;h2 id="main-features">Main Features
&lt;/h2>&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/075-google%E6%8E%A8%E5%87%BAa2a%E5%8D%8F%E8%AE%AE/Pasted-20250412_hu_4219795f3fed0417.webp"
width="1024"
height="815"
srcset="https://chengxiaqiucao.github.io/post/075-google%E6%8E%A8%E5%87%BAa2a%E5%8D%8F%E8%AE%AE/Pasted-20250412_hu_aec75ac54f36259a.webp 480w, https://chengxiaqiucao.github.io/post/075-google%E6%8E%A8%E5%87%BAa2a%E5%8D%8F%E8%AE%AE/Pasted-20250412_hu_4219795f3fed0417.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="125"
data-flex-basis="301px"
>
&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>Capability discovery&lt;/strong> — agents can advertise their capabilities using a JSON-format &amp;ldquo;Agent Card&amp;rdquo;, allowing client agents to identify the best agent able to perform a task and use A2A to communicate with remote agents.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Task management&lt;/strong> — communication between client and remote agents is oriented toward task completion, with the agent responsible for executing the end user&amp;rsquo;s request. This &amp;ldquo;task&amp;rdquo; object is defined by the protocol and has a lifecycle. It can be completed immediately, or, for long-running tasks, each agent can communicate to stay in sync with one another about the task&amp;rsquo;s latest completion status. The output of a task is called an &amp;ldquo;artifact&amp;rdquo;.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Collaboration&lt;/strong> — agents can send messages to one another to convey context, replies, artifacts, or user instructions.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>User experience negotiation&lt;/strong> — each message contains &amp;ldquo;parts&amp;rdquo;, that is, fully formed content fragments such as a generated image. Each part has a specified content type, allowing the client and remote agents to negotiate the correct format needed, and explicitly including negotiation of user UI capabilities (such as iframe, video, Web forms, and so on).&lt;/p>
&lt;/li>
&lt;/ul>
&lt;p>The relationship between A2A, MCP, and LLMs:&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/075-google%E6%8E%A8%E5%87%BAa2a%E5%8D%8F%E8%AE%AE/Pasted-20250411-1_hu_359ec77ba0900eec.webp"
width="1024"
height="710"
srcset="https://chengxiaqiucao.github.io/post/075-google%E6%8E%A8%E5%87%BAa2a%E5%8D%8F%E8%AE%AE/Pasted-20250411-1_hu_e4cd7fea2eafa3d5.webp 480w, https://chengxiaqiucao.github.io/post/075-google%E6%8E%A8%E5%87%BAa2a%E5%8D%8F%E8%AE%AE/Pasted-20250411-1_hu_359ec77ba0900eec.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="144"
data-flex-basis="346px"
>
&lt;/p>
&lt;h2 id="protocol-specification">Protocol Specification
&lt;/h2>&lt;p>The protocol is currently open source on GitHub, mainly a format specification file in json schema form (for an introduction to json schema, see 【】); the concrete definitions can be found in the source document.&lt;/p>
&lt;p>Here is an explanation of the main parts it contains and their roles:&lt;/p>
&lt;h3 id="1-agentauthentication">&lt;strong>1. AgentAuthentication&lt;/strong>
&lt;/h3>&lt;p>This part defines the supported authentication methods, such as OAuth or API keys.&lt;/p>
&lt;h3 id="2-agentcapabilities">&lt;strong>2. AgentCapabilities&lt;/strong>
&lt;/h3>&lt;p>Used to identify the scope of an Agent&amp;rsquo;s capabilities, such as whether it supports real-time communication.&lt;/p>
&lt;h3 id="3-agentcard">&lt;strong>3. AgentCard&lt;/strong>
&lt;/h3>&lt;p>Provides an Agent&amp;rsquo;s core information, such as its functions and skills, to facilitate discovery.&lt;/p>
&lt;h3 id="4-agentprovider">&lt;strong>4. AgentProvider&lt;/strong>
&lt;/h3>&lt;p>Identifies the organization or company information of the provider.&lt;/p>
&lt;h3 id="5-agentskill">&lt;strong>5. AgentSkill&lt;/strong>
&lt;/h3>&lt;p>Describes an Agent&amp;rsquo;s skills, such as the tasks or functions it can perform.&lt;/p>
&lt;h3 id="6-error-definitions">&lt;strong>6. Error Definitions&lt;/strong>
&lt;/h3>&lt;p>Contains some predefined Errors — &lt;strong>PushNotificationNotSupportedError&lt;/strong>, &lt;strong>InvalidParamsError&lt;/strong>, and &lt;strong>JSONParseError&lt;/strong> indicate error types such as notifications not supported, invalid parameters, and JSON parsing, respectively.&lt;/p>
&lt;h3 id="7-filecontent--filepart">&lt;strong>7. FileContent &amp;amp; FilePart&lt;/strong>
&lt;/h3>&lt;p>Used to pass file-related data, such as upload or download operations.&lt;/p>
&lt;h2 id="case-study">Case Study
&lt;/h2>&lt;p>&lt;code>a2aprotocol.net&lt;/code> provides a case-scenario description of A2A and MCP collaboration.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/075-google%E6%8E%A8%E5%87%BAa2a%E5%8D%8F%E8%AE%AE/Pasted-20250412-1_hu_1fdf0b8e3220556e.webp"
width="1024"
height="1609"
srcset="https://chengxiaqiucao.github.io/post/075-google%E6%8E%A8%E5%87%BAa2a%E5%8D%8F%E8%AE%AE/Pasted-20250412-1_hu_a088d5dd5ca60cc.webp 480w, https://chengxiaqiucao.github.io/post/075-google%E6%8E%A8%E5%87%BAa2a%E5%8D%8F%E8%AE%AE/Pasted-20250412-1_hu_1fdf0b8e3220556e.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="63"
data-flex-basis="152px"
>
&lt;/p>
&lt;p>For applications in the testing field, as in the article 【】, some readers mentioned richer scenarios: integrating test-case parsing, Playwright execution, and issue collection and reporting. This can be accomplished by different Agents, respectively responsible for test-case generation, Playwright execution, and submissions to tools such as ZenTao and Jira. Here, besides the workflow between Agents, the transfer of items like test cases and Bugs between different Agents can be implemented using the A2A protocol.&lt;/p>
&lt;p>Relevant practices still await the enrichment of the related Agents; this account will continue to follow up going forward!&lt;/p></description></item><item><title>Microsoft Has Released Playwright MCP</title><link>https://chengxiaqiucao.github.io/en/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/</link><pubDate>Wed, 02 Apr 2025 16:38:33 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402.webp" alt="Featured image of post Microsoft Has Released Playwright MCP" />&lt;h1 id="preface">Preface
&lt;/h1>&lt;p>&lt;code>MCP protocol&lt;/code> is an open protocol for AI capabilities launched in November 2024 by the AI company Anthropic (the parent company of Claude), aimed at standardizing the interaction interface between large language models (LLMs) and external data sources and tools. Its core design goals:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Decoupling and standardization&lt;/strong> — shifting the integration of LLMs with external systems from custom development to universal connections based on a unified protocol, similar to the USB-C interface in hardware.&lt;/li>
&lt;li>&lt;strong>Decentralization&lt;/strong> — by allowing developers to build their own MCP Servers, distributing AI capabilities and avoiding a single vendor&amp;rsquo;s monopoly on knowledge and services.&lt;/li>
&lt;li>&lt;strong>Security and control&lt;/strong> — ensuring data privacy and operational safety through permission verification and localized deployment.&lt;/li>
&lt;/ul>
&lt;p>And &lt;code>MCP Server&lt;/code> is the key component of MCP, providing the following three functions:&lt;/p>
&lt;ul>
&lt;li>Resources — file-like data that can be read by clients, such as API responses or file contents.&lt;/li>
&lt;li>Tools — functions that can be called by the LLM (requiring user approval).&lt;/li>
&lt;li>Prompts — pre-written templates that help users accomplish specific tasks.&lt;/li>
&lt;/ul>
&lt;p>Through these capabilities, MCP Server can provide AI applications with richer context and the ability to operate on private data or specific applications, thereby enhancing the usefulness of LLMs.&lt;/p>
&lt;p>In the previous article 【】, we gained a basic understanding of MCP Server, provided a basic example of querying the local desktop, and used the AI editor &lt;code>Cursor&lt;/code> to invoke this MCP server.&lt;/p>
&lt;h1 id="microsoft-officially-releases-playwright-mcp">Microsoft Officially Releases Playwright-mcp
&lt;/h1>&lt;p>Among the many current applications of MCP Server, orchestrating browser operations is an extremely high-frequency scenario. Based on Playwright, this rising new browser tool, third parties have already taken the lead in releasing an MCP Server.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402_hu_6115ffe2cb7bd57.webp"
width="1024"
height="549"
srcset="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402_hu_9b19dc088504c794.webp 480w, https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402_hu_6115ffe2cb7bd57.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="186"
data-flex-basis="447px"
>
&lt;/p>
&lt;p>And now, Microsoft has finally officially released Playwright-mcp, which can be used seamlessly with VS Code Copilot.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402-1_hu_3ad7d5515eed5d41.webp"
width="1024"
height="575"
srcset="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402-1_hu_b490105d1cb5d18b.webp 480w, https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402-1_hu_3ad7d5515eed5d41.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="178"
data-flex-basis="427px"
>
&lt;/p>
&lt;h1 id="playwright-mcp-deployment">Playwright-mcp Deployment
&lt;/h1>&lt;p>Because Playwright-mcp has just been released, its integration in VS Code is currently mainly in the preview edition, VS Code Insiders. So we can first download VS Code Insiders from the official VS Code website.
&lt;img src="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402-2_hu_74ed7668c659b2fd.webp"
width="1024"
height="528"
srcset="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402-2_hu_fed69eea3aa9ff72.webp 480w, https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402-2_hu_74ed7668c659b2fd.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="193"
data-flex-basis="465px"
>
&lt;/p>
&lt;p>After installing VS Code Insiders, on the GitHub project homepage, simply click the corresponding button to install it.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402-3_hu_6f97d608f30c9908.webp"
width="1024"
height="694"
srcset="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402-3_hu_eeae79262f666e81.webp 480w, https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402-3_hu_6f97d608f30c9908.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="147"
data-flex-basis="354px"
>
&lt;/p>
&lt;p>After opening VS Code, select install server; this will automatically configure the MCP server&amp;rsquo;s configuration file. Click start to run the MCP server, and with that the deployment is actually complete.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402-4_hu_d155d43882fcee93.webp"
width="1024"
height="606"
srcset="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402-4_hu_8f82ef31fe28c5a8.webp 480w, https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402-4_hu_d155d43882fcee93.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="169"
data-flex-basis="405px"
>
&lt;/p>
&lt;p>Click the tools button shown in the Copilot dialog box to see the currently integrated tools, which mainly correspond to Playwright&amp;rsquo;s 15 main operation behaviors.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402-5_hu_58391e16e77adad.webp"
width="1024"
height="766"
srcset="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402-5_hu_d20a8dc5f22dfa88.webp 480w, https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402-5_hu_58391e16e77adad.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="133"
data-flex-basis="320px"
>
&lt;/p>
&lt;h1 id="complete-browser-operations-and-verification-with-playwright-mcp-without-writing-code">Complete Browser Operations and Verification with Playwright-mcp Without Writing Code
&lt;/h1>&lt;p>Let&amp;rsquo;s take a look at the results below.&lt;/p>
&lt;p>Open Copilot and enter the instruction:&lt;/p>
&lt;blockquote>
&lt;p>Navigate to &lt;a class="link" href="vscode-file://vscode-app/c:/Users/Administrator/AppData/Local/Programs/Microsoft%20VS%20Code%20Insiders/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html" >https://www.saucedemo.com&lt;/a>, log in with the account standard_user and the password secret_sauce, confirm the login succeeds, and verify the product page displays correctly&lt;/p>&lt;/blockquote>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402-6_hu_fd4cbb8513a9b1db.webp"
width="1024"
height="598"
srcset="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402-6_hu_e65ecd9262e5b849.webp 480w, https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402-6_hu_fd4cbb8513a9b1db.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="171"
data-flex-basis="410px"
>
&lt;/p>
&lt;p>Continue the execution and obtain the result — the test case ran successfully.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402-7_hu_f889b9b7740fec63.webp"
width="1024"
height="556"
srcset="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402-7_hu_aa4cb13af9b277bb.webp 480w, https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250402-7_hu_f889b9b7740fec63.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="184"
data-flex-basis="441px"
>
&lt;/p>
&lt;p>As you can see, here we did not write any code, yet used Playwright&amp;rsquo;s MCP to complete the execution of the login test case.&lt;/p>
&lt;p>Of course, in real work, the integration of the MCP server is more about giving us greater convenience in calling the browser to carry out task execution!&lt;/p>
&lt;p>Based on MCP Server, I believe there are still more and richer practices that can help us!&lt;/p>
&lt;hr>
&lt;p>In the previous article, we introduced the basic effect of integrating Microsoft&amp;rsquo;s official Playwright MCP through VS Code Insiders and executing tests.&lt;/p>
&lt;p>A reader asked whether it can be used in &lt;code>Cursor&lt;/code>? I also tried it here, and the answer is that it can be integrated successfully, but there are a few small pitfalls. Here I will share the configuration process with everyone, as well as the powerful capabilities after integrating MCP in Cursor. Having AI help us complete most basic functional testing is no longer far off.&lt;/p>
&lt;h2 id="enable-playwright-mcp-in-cursor">Enable Playwright-mcp in Cursor
&lt;/h2>&lt;h3 id="prerequisite-installation">Prerequisite Installation
&lt;/h3>&lt;p>First, of course, you need to install the MCP server and its corresponding dependencies; here both MCP and Playwright are based on Node.js. So install them first with the following commands.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-batch" data-lang="batch">&lt;span class="line">&lt;span class="cl">npm install -g @playwright/mcp@latest
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">npm install -g @playwright@latest
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">npx playwright install --with-deps
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;h3 id="cursor-configuration">Cursor Configuration
&lt;/h3>&lt;p>After installation is complete, go to Cursor&amp;rsquo;s settings page, and in its MCP section, add the MCP server configuration. Referring to the introduction on the official Playwright website,
add the MCP server configuration:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-json" data-lang="json">&lt;span class="line">&lt;span class="cl">&lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;mcpServers&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;playwright&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;command&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;npx&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;args&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">[&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s2">&amp;#34;@playwright/mcp@latest&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">]&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>But at this point, the MCP server in Cursor actually cannot run normally and will display &lt;code>Clint closed&lt;/code>.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/-20250404_hu_d7b32ce22abdd7db.webp"
width="1024"
height="399"
srcset="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/-20250404_hu_3ec933e8293b3541.webp 480w, https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/-20250404_hu_d7b32ce22abdd7db.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="256"
data-flex-basis="616px"
>
&lt;/p>
&lt;h3 id="on-windows-two-pitfalls-to-avoid">On Windows, Two Pitfalls to Avoid
&lt;/h3>&lt;p>&lt;strong>Pitfall 1 — the npx package loading path should be added to the search path&lt;/strong>&lt;/p>
&lt;p>That is, put the globally installed related packages into Node.js&amp;rsquo;s search path. The way to do this is to add the npm package directory to the PATH in the Windows system environment variables, and place it before Node.js.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250404_hu_efb68dc07543ffd5.webp"
width="1024"
height="1131"
srcset="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250404_hu_618db60a18911ac.webp 480w, https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250404_hu_efb68dc07543ffd5.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="90"
data-flex-basis="217px"
>
&lt;/p>
&lt;p>&lt;strong>Pitfall 2 — modify the MCP command-line invocation command&lt;/strong>&lt;/p>
&lt;p>Calling npx in Cursor is actually done through the command line, but on Windows, when npx is called directly from the command line, Cursor itself cannot obtain the invocation status, so here we need to use the &lt;code>cmd /c&lt;/code> command to invoke it and obtain the command handle.&lt;/p>
&lt;p>That is, modify the above configuration file to:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-json" data-lang="json">&lt;span class="line">&lt;span class="cl">&lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;mcpServers&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;playwright&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;command&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;cmd /c npx&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;args&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">[&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s2">&amp;#34;@playwright/mcp@latest&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">]&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>After modifying the above configuration, reload Cursor. A command-line window will then start up — this is actually Playwright-mcp; do not close it — and then you can see that the MCP in Cursor has also started up normally.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250403_hu_57d69d819e55bef6.webp"
width="1024"
height="747"
srcset="https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250403_hu_80daf4c39384c787.webp 480w, https://chengxiaqiucao.github.io/post/072-%E5%BE%AE%E8%BD%AF%E5%B7%B2%E5%8F%91%E5%B8%83playwright-mcp/Pasted-20250403_hu_57d69d819e55bef6.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="137"
data-flex-basis="329px"
>
&lt;/p>
&lt;h2 id="let-playwright-mcp-execute-tests-on-our-behalf">Let Playwright-mcp Execute Tests on Our Behalf
&lt;/h2>&lt;p>We enter a basic task instruction in Cursor:&lt;/p>
&lt;blockquote>
&lt;p>Visit the &lt;a class="link" href="https://www.saucedemo.com" target="_blank" rel="noopener"
>www.saucedemo.com&lt;/a> website, log in using problem_user, verify the site&amp;rsquo;s complete workflow, and record the issues found&lt;/p>&lt;/blockquote>
&lt;p>Below is the complete execution process.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt"> 10
&lt;/span>&lt;span class="lnt"> 11
&lt;/span>&lt;span class="lnt"> 12
&lt;/span>&lt;span class="lnt"> 13
&lt;/span>&lt;span class="lnt"> 14
&lt;/span>&lt;span class="lnt"> 15
&lt;/span>&lt;span class="lnt"> 16
&lt;/span>&lt;span class="lnt"> 17
&lt;/span>&lt;span class="lnt"> 18
&lt;/span>&lt;span class="lnt"> 19
&lt;/span>&lt;span class="lnt"> 20
&lt;/span>&lt;span class="lnt"> 21
&lt;/span>&lt;span class="lnt"> 22
&lt;/span>&lt;span class="lnt"> 23
&lt;/span>&lt;span class="lnt"> 24
&lt;/span>&lt;span class="lnt"> 25
&lt;/span>&lt;span class="lnt"> 26
&lt;/span>&lt;span class="lnt"> 27
&lt;/span>&lt;span class="lnt"> 28
&lt;/span>&lt;span class="lnt"> 29
&lt;/span>&lt;span class="lnt"> 30
&lt;/span>&lt;span class="lnt"> 31
&lt;/span>&lt;span class="lnt"> 32
&lt;/span>&lt;span class="lnt"> 33
&lt;/span>&lt;span class="lnt"> 34
&lt;/span>&lt;span class="lnt"> 35
&lt;/span>&lt;span class="lnt"> 36
&lt;/span>&lt;span class="lnt"> 37
&lt;/span>&lt;span class="lnt"> 38
&lt;/span>&lt;span class="lnt"> 39
&lt;/span>&lt;span class="lnt"> 40
&lt;/span>&lt;span class="lnt"> 41
&lt;/span>&lt;span class="lnt"> 42
&lt;/span>&lt;span class="lnt"> 43
&lt;/span>&lt;span class="lnt"> 44
&lt;/span>&lt;span class="lnt"> 45
&lt;/span>&lt;span class="lnt"> 46
&lt;/span>&lt;span class="lnt"> 47
&lt;/span>&lt;span class="lnt"> 48
&lt;/span>&lt;span class="lnt"> 49
&lt;/span>&lt;span class="lnt"> 50
&lt;/span>&lt;span class="lnt"> 51
&lt;/span>&lt;span class="lnt"> 52
&lt;/span>&lt;span class="lnt"> 53
&lt;/span>&lt;span class="lnt"> 54
&lt;/span>&lt;span class="lnt"> 55
&lt;/span>&lt;span class="lnt"> 56
&lt;/span>&lt;span class="lnt"> 57
&lt;/span>&lt;span class="lnt"> 58
&lt;/span>&lt;span class="lnt"> 59
&lt;/span>&lt;span class="lnt"> 60
&lt;/span>&lt;span class="lnt"> 61
&lt;/span>&lt;span class="lnt"> 62
&lt;/span>&lt;span class="lnt"> 63
&lt;/span>&lt;span class="lnt"> 64
&lt;/span>&lt;span class="lnt"> 65
&lt;/span>&lt;span class="lnt"> 66
&lt;/span>&lt;span class="lnt"> 67
&lt;/span>&lt;span class="lnt"> 68
&lt;/span>&lt;span class="lnt"> 69
&lt;/span>&lt;span class="lnt"> 70
&lt;/span>&lt;span class="lnt"> 71
&lt;/span>&lt;span class="lnt"> 72
&lt;/span>&lt;span class="lnt"> 73
&lt;/span>&lt;span class="lnt"> 74
&lt;/span>&lt;span class="lnt"> 75
&lt;/span>&lt;span class="lnt"> 76
&lt;/span>&lt;span class="lnt"> 77
&lt;/span>&lt;span class="lnt"> 78
&lt;/span>&lt;span class="lnt"> 79
&lt;/span>&lt;span class="lnt"> 80
&lt;/span>&lt;span class="lnt"> 81
&lt;/span>&lt;span class="lnt"> 82
&lt;/span>&lt;span class="lnt"> 83
&lt;/span>&lt;span class="lnt"> 84
&lt;/span>&lt;span class="lnt"> 85
&lt;/span>&lt;span class="lnt"> 86
&lt;/span>&lt;span class="lnt"> 87
&lt;/span>&lt;span class="lnt"> 88
&lt;/span>&lt;span class="lnt"> 89
&lt;/span>&lt;span class="lnt"> 90
&lt;/span>&lt;span class="lnt"> 91
&lt;/span>&lt;span class="lnt"> 92
&lt;/span>&lt;span class="lnt"> 93
&lt;/span>&lt;span class="lnt"> 94
&lt;/span>&lt;span class="lnt"> 95
&lt;/span>&lt;span class="lnt"> 96
&lt;/span>&lt;span class="lnt"> 97
&lt;/span>&lt;span class="lnt"> 98
&lt;/span>&lt;span class="lnt"> 99
&lt;/span>&lt;span class="lnt">100
&lt;/span>&lt;span class="lnt">101
&lt;/span>&lt;span class="lnt">102
&lt;/span>&lt;span class="lnt">103
&lt;/span>&lt;span class="lnt">104
&lt;/span>&lt;span class="lnt">105
&lt;/span>&lt;span class="lnt">106
&lt;/span>&lt;span class="lnt">107
&lt;/span>&lt;span class="lnt">108
&lt;/span>&lt;span class="lnt">109
&lt;/span>&lt;span class="lnt">110
&lt;/span>&lt;span class="lnt">111
&lt;/span>&lt;span class="lnt">112
&lt;/span>&lt;span class="lnt">113
&lt;/span>&lt;span class="lnt">114
&lt;/span>&lt;span class="lnt">115
&lt;/span>&lt;span class="lnt">116
&lt;/span>&lt;span class="lnt">117
&lt;/span>&lt;span class="lnt">118
&lt;/span>&lt;span class="lnt">119
&lt;/span>&lt;span class="lnt">120
&lt;/span>&lt;span class="lnt">121
&lt;/span>&lt;span class="lnt">122
&lt;/span>&lt;span class="lnt">123
&lt;/span>&lt;span class="lnt">124
&lt;/span>&lt;span class="lnt">125
&lt;/span>&lt;span class="lnt">126
&lt;/span>&lt;span class="lnt">127
&lt;/span>&lt;span class="lnt">128
&lt;/span>&lt;span class="lnt">129
&lt;/span>&lt;span class="lnt">130
&lt;/span>&lt;span class="lnt">131
&lt;/span>&lt;span class="lnt">132
&lt;/span>&lt;span class="lnt">133
&lt;/span>&lt;span class="lnt">134
&lt;/span>&lt;span class="lnt">135
&lt;/span>&lt;span class="lnt">136
&lt;/span>&lt;span class="lnt">137
&lt;/span>&lt;span class="lnt">138
&lt;/span>&lt;span class="lnt">139
&lt;/span>&lt;span class="lnt">140
&lt;/span>&lt;span class="lnt">141
&lt;/span>&lt;span class="lnt">142
&lt;/span>&lt;span class="lnt">143
&lt;/span>&lt;span class="lnt">144
&lt;/span>&lt;span class="lnt">145
&lt;/span>&lt;span class="lnt">146
&lt;/span>&lt;span class="lnt">147
&lt;/span>&lt;span class="lnt">148
&lt;/span>&lt;span class="lnt">149
&lt;/span>&lt;span class="lnt">150
&lt;/span>&lt;span class="lnt">151
&lt;/span>&lt;span class="lnt">152
&lt;/span>&lt;span class="lnt">153
&lt;/span>&lt;span class="lnt">154
&lt;/span>&lt;span class="lnt">155
&lt;/span>&lt;span class="lnt">156
&lt;/span>&lt;span class="lnt">157
&lt;/span>&lt;span class="lnt">158
&lt;/span>&lt;span class="lnt">159
&lt;/span>&lt;span class="lnt">160
&lt;/span>&lt;span class="lnt">161
&lt;/span>&lt;span class="lnt">162
&lt;/span>&lt;span class="lnt">163
&lt;/span>&lt;span class="lnt">164
&lt;/span>&lt;span class="lnt">165
&lt;/span>&lt;span class="lnt">166
&lt;/span>&lt;span class="lnt">167
&lt;/span>&lt;span class="lnt">168
&lt;/span>&lt;span class="lnt">169
&lt;/span>&lt;span class="lnt">170
&lt;/span>&lt;span class="lnt">171
&lt;/span>&lt;span class="lnt">172
&lt;/span>&lt;span class="lnt">173
&lt;/span>&lt;span class="lnt">174
&lt;/span>&lt;span class="lnt">175
&lt;/span>&lt;span class="lnt">176
&lt;/span>&lt;span class="lnt">177
&lt;/span>&lt;span class="lnt">178
&lt;/span>&lt;span class="lnt">179
&lt;/span>&lt;span class="lnt">180
&lt;/span>&lt;span class="lnt">181
&lt;/span>&lt;span class="lnt">182
&lt;/span>&lt;span class="lnt">183
&lt;/span>&lt;span class="lnt">184
&lt;/span>&lt;span class="lnt">185
&lt;/span>&lt;span class="lnt">186
&lt;/span>&lt;span class="lnt">187
&lt;/span>&lt;span class="lnt">188
&lt;/span>&lt;span class="lnt">189
&lt;/span>&lt;span class="lnt">190
&lt;/span>&lt;span class="lnt">191
&lt;/span>&lt;span class="lnt">192
&lt;/span>&lt;span class="lnt">193
&lt;/span>&lt;span class="lnt">194
&lt;/span>&lt;span class="lnt">195
&lt;/span>&lt;span class="lnt">196
&lt;/span>&lt;span class="lnt">197
&lt;/span>&lt;span class="lnt">198
&lt;/span>&lt;span class="lnt">199
&lt;/span>&lt;span class="lnt">200
&lt;/span>&lt;span class="lnt">201
&lt;/span>&lt;span class="lnt">202
&lt;/span>&lt;span class="lnt">203
&lt;/span>&lt;span class="lnt">204
&lt;/span>&lt;span class="lnt">205
&lt;/span>&lt;span class="lnt">206
&lt;/span>&lt;span class="lnt">207
&lt;/span>&lt;span class="lnt">208
&lt;/span>&lt;span class="lnt">209
&lt;/span>&lt;span class="lnt">210
&lt;/span>&lt;span class="lnt">211
&lt;/span>&lt;span class="lnt">212
&lt;/span>&lt;span class="lnt">213
&lt;/span>&lt;span class="lnt">214
&lt;/span>&lt;span class="lnt">215
&lt;/span>&lt;span class="lnt">216
&lt;/span>&lt;span class="lnt">217
&lt;/span>&lt;span class="lnt">218
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-text" data-lang="text">&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">I will help you visit the Sauce Demo website and use the problem_user account to carry out a complete test-flow verification. Let&amp;#39;s get started.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">First, let me visit the website:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Called MCP toolbrowser_navigate
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Let me log in with the problem_user account:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Called MCP toolbrowser_type
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Now enter the password:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Called MCP toolbrowser_type
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Click the login button:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Called MCP toolbrowser_click
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Let&amp;#39;s begin testing and recording issues. First I notice the following problem:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. Product image issue:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">All products display the same image (a picture of a dog), which is obviously a bug, because each product should display its own unique product image.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Let me try adding a product to the cart:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Called MCP toolbrowser_click
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Let me click the cart icon to view the cart:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Called MCP toolbrowser_click
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Let&amp;#39;s return to the product list and try using the sorting function:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Called MCP toolbrowser_click
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Let me try using the sorting function:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Called MCP toolbrowser_click
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Called MCP toolbrowser_select_option
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Based on the test process, I found the following problems:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. Image display issue:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- All product images display as the same dog picture, rather than their respective product images
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- This affects the user&amp;#39;s visual recognition of products
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. Cart function issue:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Clicking a product image or title does not correctly navigate to the product detail page, but instead jumps directly to a fixed product page
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- This affects the user&amp;#39;s experience of browsing and selecting products
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. Sorting function issue:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- After selecting different sorting options (such as price from low to high), the product list order does not change
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- The sorting function is completely broken
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. Navigation issue:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Clicking a product always jumps to the same product page, rather than the specific product clicked
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- This seriously affects the user&amp;#39;s shopping experience
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. Button state issue:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- The &amp;#34;Add to cart&amp;#34; and &amp;#34;Remove&amp;#34; button states for some products are displayed inconsistently
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- This may cause users to be confused about the state of products in the cart
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">These problems seriously affect the website&amp;#39;s basic functions and user experience. The problem_user account indeed demonstrates multiple issues that need fixing, covering aspects such as UI display, functional operations, and user experience.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Would you like me to continue testing other functions, such as the checkout flow?
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Please continue testing
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">OK, I will continue testing the checkout flow. First let&amp;#39;s add some products to the cart and then proceed to checkout:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Called MCP toolbrowser_click
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Now let&amp;#39;s click the cart icon to enter the cart page:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Called MCP toolbrowser_click
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">I found that clicking the cart icon revealed another problem - it took us to the product detail page instead of the cart page. Let&amp;#39;s try clicking the cart icon in the upper right corner of the page:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Called MCP toolbrowser_navigate
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Let&amp;#39;s continue the checkout flow and click the Checkout button:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Called MCP toolbrowser_click
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Let&amp;#39;s fill in the personal information:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Called MCP toolbrowser_type
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Called MCP toolbrowser_type
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Called MCP toolbrowser_type
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Click Continue to proceed:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Called MCP toolbrowser_click
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">I found a new problem: although we entered the last name, the system displays a &amp;#34;Last Name is required&amp;#34; error. This indicates there is a problem with the input field. Let&amp;#39;s try entering the last name again:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Called MCP toolbrowser_type
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Based on the test process, I found the following new problems:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. Cart navigation issue:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Clicking the cart icon on the product list page incorrectly navigates to the product detail page
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- You must manually enter the cart URL to access the cart page
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. Checkout form issue:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- The last name (Last Name) input field has a serious problem
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Even after entering the last name, the system still shows a &amp;#34;Last Name is required&amp;#34; error
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- This problem prevents the user from completing the checkout flow
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">1. Cart product display issue:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- The number of products shown in the cart does not match the number of products actually added
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Some products that were not added also appear in the cart
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Together with the previously found problems, these seriously affect the entire shopping flow:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Users cannot browse products normally (image problem)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Cannot correctly add products to the cart (cart function problem)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Cannot use the sorting function (sorting broken)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Cannot access the cart normally (navigation problem)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Cannot complete the checkout flow (form validation problem)
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">These problems make it almost impossible for the problem_user account to complete a normal shopping flow. Every major function has problems to varying degrees; this may have been deliberately set up for testing purposes.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Would you like me to continue testing other functions, such as the menu bar functions?
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Test complete — please log out and summarize the issues found
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">OK, let&amp;#39;s first click the menu button and then log out:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Called MCP toolbrowser_click
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Called MCP toolbrowser_click
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">Now I will summarize all the issues found testing with the problem_user account:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">### 1. Product display issues
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- All product images display as the same dog picture, rather than their respective product images
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- This seriously affects the user&amp;#39;s visual recognition of products and the shopping experience
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">### 2. Navigation issues
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Clicking a product image or title always jumps to a fixed product page, rather than the specific product clicked
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Clicking the cart icon incorrectly navigates to the product detail page instead of the cart page
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- You must manually enter the cart URL to correctly access the cart page
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">### 3. Product sorting function issues
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- After selecting different sorting options (such as price from low to high), the product list order does not change at all
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- The sorting function is completely broken and cannot help users browse products the way they want
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">### 4. Cart function issues
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- The products shown in the cart do not match the products actually added
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Some products that were not added also appear in the cart
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- The &amp;#34;Add to cart&amp;#34; and &amp;#34;Remove&amp;#34; button states are displayed inconsistently, causing user confusion
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">### 5. Checkout flow issues
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- The last name (Last Name) input field has a serious problem
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Even after entering the last name, the system still shows a &amp;#34;Last Name is required&amp;#34; error
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- This validation problem completely prevents the user from finishing the checkout flow
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">### 6. User experience impact
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- The combined effect of the above problems leads to:
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Users cannot correctly browse and select products
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Cannot manage cart contents
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Cannot complete the shopping flow
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- The overall shopping experience is seriously damaged
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">### 7. Functional usability assessment
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Almost all basic functions have problems
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- Users cannot complete a normal shopping flow
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">- This account may be dedicated to testing purposes, demonstrating various possible problem scenarios
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">These problems cover the core functions of an e-commerce website, including product display, navigation, cart management, and the checkout flow. Every link has problems to varying degrees, making the entire shopping experience extremely difficult and frustrating. The existence of these problems may be for testing purposes, helping developers and testers understand various possible error scenarios.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>As you can see, with Cursor + Playwright-mcp, AI can already, from the basic instructions we give it, proactively help us cover the main functional test scenarios and discover and record issues. Given time, it could largely replace fairly basic functional testing tasks, while testers can focus more on high-value, in-depth problem exploration. Of course, on the other hand, basic functional testers really do need a considerable sense of crisis — upgrading their skills and expanding their boundaries brooks no delay.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/qrcode_for_gh_e12c318badb4_258%20%281%29.jpg"
loading="lazy"
>
&lt;/p>
&lt;p>Welcome to follow Qiucao&amp;rsquo;s course on systematic, advanced improvement of testing skills; reply with &lt;code>Outline&lt;/code> in the official account to see the detailed course catalog.&lt;/p></description></item><item><title>The Next Stop for AI - MCP Server</title><link>https://chengxiaqiucao.github.io/en/post/073-ai%E4%B8%8B%E4%B8%80%E7%AB%99-mcpserver/</link><pubDate>Tue, 01 Apr 2025 00:00:00 +0000</pubDate><guid>https://chengxiaqiucao.github.io/en/post/073-ai%E4%B8%8B%E4%B8%80%E7%AB%99-mcpserver/</guid><description>&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/073-ai%E4%B8%8B%E4%B8%80%E7%AB%99-mcpserver/Pasted-20250402_hu_7489755b7817049a.webp"
width="1024"
height="573"
srcset="https://chengxiaqiucao.github.io/post/073-ai%E4%B8%8B%E4%B8%80%E7%AB%99-mcpserver/Pasted-20250402_hu_9da7da69332f4757.webp 480w, https://chengxiaqiucao.github.io/post/073-ai%E4%B8%8B%E4%B8%80%E7%AB%99-mcpserver/Pasted-20250402_hu_7489755b7817049a.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="178"
data-flex-basis="429px"
>
&lt;/p>
&lt;h2 id="introduction">Introduction
&lt;/h2>&lt;p>In 2025, as AI technology evolves at breakneck speed, the limitations of large models are becoming increasingly apparent; they possess powerful reasoning capabilities, yet struggle to directly access private data or invoke external tools. This pain point has given rise to a revolutionary technology — &lt;strong>MCP (Model Context Protocol)&lt;/strong> — and &lt;strong>MCP Server&lt;/strong>, its core component, is fast becoming the next big thing in the AI industry. This article takes a deep dive into the technical essence and industry value of MCP Server, and explores its application prospects through real-world cases.&lt;/p>
&lt;hr>
&lt;h2 id="part-one---what-is-mcp-the-past-and-present-of-mcp">Part One - What Is MCP? The Past and Present of MCP
&lt;/h2>&lt;h3 id="1-the-definition-and-design-goals-of-mcp">1. The Definition and Design Goals of MCP
&lt;/h3>&lt;p>MCP is an open protocol introduced by the AI company Anthropic (the parent company of Claude) in November 2024, designed to standardize the interaction interface between large language models (LLMs) and external data sources and tools. Its core design goals:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Decoupling and Standardization&lt;/strong>: Transforming the integration of LLMs with external systems from custom development into universal connections based on a unified protocol, similar to the USB-C interface in hardware.&lt;/li>
&lt;li>&lt;strong>Decentralization&lt;/strong>: By allowing developers to build their own MCP Servers, AI capabilities are distributed, preventing a single vendor from monopolizing knowledge and services.&lt;/li>
&lt;li>&lt;strong>Security and Control&lt;/strong>: Ensuring data privacy and operational safety through permission verification and local deployment.&lt;/li>
&lt;/ul>
&lt;h3 id="2-the-technical-evolution-from-langchain-to-mcp">2. The Technical Evolution from Langchain to MCP
&lt;/h3>&lt;p>Before MCP, developers relied on middleware frameworks such as Langchain to connect LLMs with tools, but these solutions had two major bottlenecks:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Fragmentation&lt;/strong>: API standards vary across vendors, making integration costly;&lt;/li>
&lt;li>&lt;strong>Closedness&lt;/strong>: The plugin ecosystems of vendors such as OpenAI are confined to their own platforms, making reuse across models difficult.&lt;/li>
&lt;li>&lt;/li>
&lt;/ol>
&lt;p>Through abstraction at the protocol layer, MCP encapsulates capabilities such as tool invocation and data access into standardized interfaces, so that any LLM supporting the MCP protocol can seamlessly connect to third-party services.&lt;/p>
&lt;h3 id="3-the-current-state-of-the-mcp-ecosystem">3. The Current State of the MCP Ecosystem
&lt;/h3>&lt;p>At this stage, the MCP ecosystem has begun to take shape:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Support from Leading Companies&lt;/strong>: Besides Claude from the company that initiated it, OpenAI, a leader in the AI industry, as well as domestic players such as Baidu and Tencent, have all announced support for MCP&lt;/li>
&lt;li>&lt;strong>A Large Developer Base&lt;/strong>: Thanks to a low barrier to entry, the various publicly available MCP Servers have grown explosively; within just a few weeks, thousands of public Servers have appeared, covering areas such as databases, design tools, and payment systems.&lt;/li>
&lt;li>&lt;strong>Emerging Business Value&lt;/strong>: Institutions such as a16z have drawn up MCP market maps, predicting it may give rise to a &amp;ldquo;Stripe of the Agentic AI space&amp;rdquo; caliber company.&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="part-two---what-does-mcp-server-do-why-might-it-be-the-ai-industrys-next-big-thing">Part Two - What Does MCP Server Do? Why Might It Be the AI Industry&amp;rsquo;s Next Big Thing?
&lt;/h2>&lt;h3 id="1-the-core-functions-of-mcp-server">1. The Core Functions of MCP Server
&lt;/h3>&lt;p>An MCP Server is a concrete implementation of the MCP protocol, playing the following key roles:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Tool Proxy&lt;/strong>: Converting external APIs (such as GitHub and PostgreSQL) into standardized tool descriptions that LLMs can understand, for example abstracting &amp;ldquo;create a GitHub Issue&amp;rdquo; into a function call.&lt;/li>
&lt;li>&lt;strong>Data Gateway&lt;/strong>: Securely accessing local or cloud data, for example letting an LLM read desktop files through a file-system MCP Server.&lt;/li>
&lt;li>&lt;strong>Workflow Orchestration&lt;/strong>: Supporting chained calls across multiple tools, for example querying a database first and then generating a report.&lt;/li>
&lt;/ul>
&lt;h3 id="2-three-major-drivers-behind-the-craze">2. Three Major Drivers Behind the Craze
&lt;/h3>&lt;h4 id="1-technology-trend---from-fat-models-to-thin-models--ecosystem">(1) Technology Trend - From &amp;ldquo;Fat Models&amp;rdquo; to &amp;ldquo;Thin Models + Ecosystem&amp;rdquo;
&lt;/h4>&lt;p>Traditional &amp;ldquo;fat models&amp;rdquo; try to internalize all knowledge within their parameters, resulting in high training costs and poor timeliness. Under the MCP architecture, LLMs focus on language understanding, while knowledge extension and tool invocation are handled by the MCP Server network, forming a new paradigm of &amp;ldquo;thin models + distributed capabilities&amp;rdquo;.&lt;/p>
&lt;h4 id="2-economic-model---the-ai-ification-of-the-creator-economy">(2) Economic Model - The AI-ification of the Creator Economy
&lt;/h4>&lt;p>MCP allows individual developers to earn revenue shares by building MCP Servers (such as a bird knowledge base), forming a decentralized knowledge economy network. For example, OpenMCP.Network, built on Ethereum, can automatically settle call volumes through smart contracts.&lt;/p>
&lt;h4 id="3-industry-demand---the-rigid-need-for-private-enterprise-ai-deployment">(3) Industry Demand - The Rigid Need for Private Enterprise AI Deployment
&lt;/h4>&lt;p>Enterprises can use MCP Servers to securely expose internal systems (such as CRM and ERP) to LLMs without uploading sensitive data to the cloud. Companies such as NineData have launched database MCP Server solutions that support localized data management.&lt;/p>
&lt;hr>
&lt;h2 id="part-three---as-software-testing-professionals-how-do-we-apply-mcp-server">Part Three - As Software Testing Professionals, How Do We Apply MCP Server?
&lt;/h2>&lt;h3 id="1-mcp-ifying-testing-scenarios">1. MCP-ifying Testing Scenarios
&lt;/h3>&lt;h4 id="1-simulating-external-dependencies">(1) Simulating External Dependencies
&lt;/h4>&lt;p>By building Mock MCP Servers to replace dependencies such as real payment and third-party APIs, test environment isolation is achieved. For example, simulating the Alipay interface returning an abnormal response to verify the system&amp;rsquo;s fault tolerance.&lt;/p>
&lt;h4 id="2-data-driven-testing">(2) Data-Driven Testing
&lt;/h4>&lt;p>Store test cases in a database or file, and have the MCP Server read and execute them dynamically. For example:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="nd">@mcp.tool&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">def&lt;/span> &lt;span class="nf">load_test_cases&lt;/span>&lt;span class="p">():&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s2">&amp;#34;&amp;#34;&amp;#34;Load JSON-format test cases from the specified directory&amp;#34;&amp;#34;&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">return&lt;/span> &lt;span class="n">json&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">load&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="nb">open&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;test_cases.json&amp;#34;&lt;/span>&lt;span class="p">))&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>The test framework can automatically obtain the cases and generate test reports.&lt;/p>
&lt;h4 id="3-ai-assisted-testing">(3) AI-Assisted Testing
&lt;/h4>&lt;p>Use LLMs to invoke testing tools through MCP Servers, for example:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Automatic Test Script Generation&lt;/strong>: Generating Selenium code from requirement descriptions;&lt;/li>
&lt;li>&lt;strong>Intelligent Log Analysis&lt;/strong>: Locating the root causes of defects with an ELK Stack MCP Server.&lt;/li>
&lt;/ul>
&lt;h3 id="2-skill-upgrade-suggestions-for-testing-professionals">2. Skill Upgrade Suggestions for Testing Professionals
&lt;/h3>&lt;ul>
&lt;li>&lt;strong>Master MCP Server Development&lt;/strong>: Learn the Python/TypeScript MCP SDKs to build customized testing tools.&lt;/li>
&lt;li>&lt;strong>Get Familiar with the Mainstream MCP Ecosystem&lt;/strong>: Follow the Awesome MCP Servers list on GitHub to learn about testing-related services (such as PostgreSQL and JIRA integrations).&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="part-four---a-simple-mcp-server-implementation-case---a-desktop-file-query-service">Part Four - A Simple MCP Server Implementation Case - A Desktop File Query Service
&lt;/h2>&lt;h3 id="1-environment-setup">1. Environment Setup
&lt;/h3>&lt;ul>
&lt;li>Install the Python MCP SDK: &lt;code>pip install mcp&lt;/code>&lt;/li>
&lt;li>Create a project directory: &lt;code>mkdir mcp-demo &amp;amp;&amp;amp; cd mcp-demo&lt;/code>&lt;/li>
&lt;/ul>
&lt;h3 id="2-code-implementation">2. Code Implementation
&lt;/h3>&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="kn">from&lt;/span> &lt;span class="nn">mcp.server.fastmcp&lt;/span> &lt;span class="kn">import&lt;/span> &lt;span class="n">FastMCP&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kn">import&lt;/span> &lt;span class="nn">os&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">mcp&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">FastMCP&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nd">@mcp.tool&lt;/span>&lt;span class="p">()&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">def&lt;/span> &lt;span class="nf">list_desktop_files&lt;/span>&lt;span class="p">():&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="s2">&amp;#34;&amp;#34;&amp;#34;Get the list of files on the current user&amp;#39;s desktop&amp;#34;&amp;#34;&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">return&lt;/span> &lt;span class="n">os&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">listdir&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">os&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">path&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">expanduser&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;~/Desktop&amp;#34;&lt;/span>&lt;span class="p">))&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">if&lt;/span> &lt;span class="vm">__name__&lt;/span> &lt;span class="o">==&lt;/span> &lt;span class="s2">&amp;#34;__main__&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">mcp&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">run&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">transport&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s1">&amp;#39;stdio&amp;#39;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>This code defines an MCP Server that provides the &lt;code>list_desktop_files&lt;/code> tool, allowing an LLM to query the user&amp;rsquo;s desktop files.&lt;/p>
&lt;h3 id="3-client-configuration-and-testing">3. Client Configuration and Testing
&lt;/h3>&lt;p>Add the configuration to &lt;code>mcp.json&lt;/code> in the Cursor editor:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt">1
&lt;/span>&lt;span class="lnt">2
&lt;/span>&lt;span class="lnt">3
&lt;/span>&lt;span class="lnt">4
&lt;/span>&lt;span class="lnt">5
&lt;/span>&lt;span class="lnt">6
&lt;/span>&lt;span class="lnt">7
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-json" data-lang="json">&lt;span class="line">&lt;span class="cl">&lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;mcpServers&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;desktop&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nt">&amp;#34;command&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;python server.py&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>After starting the service, we can directly ask, &amp;ldquo;What files are on my desktop?&amp;rdquo; Cursor will invoke the service through the MCP protocol, return a list of files currently on my desktop, and classify them by type.&lt;/p>
&lt;hr>
&lt;h2 id="conclusion">Conclusion
&lt;/h2>&lt;p>MCP Server is reshaping the way AI interacts with the physical world. For developers, it is a sharp tool for lowering integration costs; for enterprises, it is the key to unlocking the value of data; for testing professionals, it is a new engine for the evolution of automation. Although the ecosystem is still in its early days, its standardized, decentralized design philosophy has already pointed the way to the next stop for the AI industry. As Anthropic put it, &amp;ldquo;MCP is not the destination, but the starting point of the Agentic AI era.&amp;rdquo;&lt;/p></description></item><item><title>Software Testing in the AI Era - Assistant or Adversary?</title><link>https://chengxiaqiucao.github.io/en/post/070-ai%E6%97%B6%E4%BB%A3%E7%9A%84%E6%B5%8B%E8%AF%95/</link><pubDate>Tue, 25 Mar 2025 21:38:36 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/070-ai%E6%97%B6%E4%BB%A3%E7%9A%84%E6%B5%8B%E8%AF%95/</guid><description>&lt;p>In the present era, the AI wave is sweeping in, and &amp;ldquo;the future is already here&amp;rdquo; is no longer an empty slogan. AI-related topics and discussions have become the sure-fire &amp;ldquo;traffic magnet&amp;rdquo; of the tech world; from autonomous driving to intelligent customer service, every industry seems eager to ride this wave of AI hype.&lt;/p>
&lt;p>But as testing professionals, when we face the rapid development of AI, what we care about most is probably this: &lt;strong>What can AI actually do in software testing? Can it really help us improve output and efficiency? Or, as it evolves, will AI completely replace testing roles?&lt;/strong>&lt;/p>
&lt;p>In this article, let us explore this topic.&lt;/p>
&lt;h2 id="the-role-of-ai-in-the-different-stages-of-software-testing">The Role of AI in the Different Stages of Software Testing
&lt;/h2>&lt;p>AI testing, when it comes down to it, is about having AI take on part of, assist with, or enhance the original testing work. In other words, AI itself does not change the underlying laws of the software testing lifecycle within software development.&lt;/p>
&lt;p>Therefore, we can look at what role AI can play from the perspective of the different stages of the software testing lifecycle and the scope of testing responsibilities.&lt;/p>
&lt;h3 id="requirements-analysis-stage">Requirements Analysis Stage
&lt;/h3>&lt;p>At this stage, we can use AI&amp;rsquo;s natural language processing technology to sort out the original requirements documents and produce analysis results including business flowcharts, operation flowcharts, and data flow diagrams.&lt;/p>
&lt;p>At the same time, we can combine more relevant local data — such as historical bug data, test logs, and project data — to identify testing priorities, build risk models, and detect risks. Based on these analysis results, we can then help formulate a more reasonable test plan.&lt;/p>
&lt;h3 id="test-case-design-stage">Test Case Design Stage
&lt;/h3>&lt;p>During the software design and development phase, testers usually complete test design in parallel. At this stage, we can leverage AI to help us generate test cases based on the requirements documents and the results of the requirements analysis phase. With AI, we can produce more and fuller positive and negative cases as well as a variety of boundary conditions to expand coverage.&lt;/p>
&lt;h3 id="test-preparation-stage">Test Preparation Stage
&lt;/h3>&lt;p>At this stage, the main work is setting up and deploying the test environment. We can use AI capabilities combined with a CI platform to achieve intelligent management of test servers and database environments, as well as the dynamic allocation of resources.&lt;/p>
&lt;h3 id="test-execution-stage">Test Execution Stage
&lt;/h3>&lt;p>During the execution stage, we can dynamically adjust the test order based on factors such as various risk assessments, dependencies, and business impact, prioritizing coverage of higher-risk modules so as to expose defects as early as possible.&lt;/p>
&lt;p>In addition, AI can enhance capabilities such as log analysis and image comparison, improving our test execution efficiency and defect detection ability.&lt;/p>
&lt;h3 id="test-reporting-stage">Test Reporting Stage
&lt;/h3>&lt;p>In the closing part of testing, using AI to perform comprehensive analysis of various process data can help us produce multi-dimensional test reports, providing project decision-makers with a structured analysis of testing status.&lt;/p>
&lt;h2 id="how-ai-empowers-software-testing-at-this-stage">How AI Empowers Software Testing at This Stage
&lt;/h2>&lt;p>The current development of AI can already provide more support in many typical testing scenarios. The following outlines some typical scenarios that can be empowered by AI:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Intelligent Data Generation&lt;/strong> - Create diverse datasets covering common scenarios and edge cases&lt;/li>
&lt;li>&lt;strong>Test Automation&lt;/strong> - Automatically adapt to UI changes to keep automation scripts stable&lt;/li>
&lt;li>&lt;strong>Precise Regression Testing&lt;/strong> - Intelligently select related test cases based on code changes&lt;/li>
&lt;li>&lt;strong>Process Cloning&lt;/strong> - Learn testing workflows and then automatically execute similar processes&lt;/li>
&lt;li>&lt;strong>Dynamic Waiting Mechanism&lt;/strong> - Intelligently judge page load status before performing actions&lt;/li>
&lt;li>&lt;strong>Intelligent Log Analysis&lt;/strong> - Analyze and identify potential problem patterns in error logs&lt;/li>
&lt;li>&lt;strong>Load / Performance Testing&lt;/strong> - Simulate real user behavior and diagnose performance bottlenecks&lt;/li>
&lt;li>&lt;strong>Continuous Test Monitoring&lt;/strong> - Monitor application status in real time and alert on anomalies&lt;/li>
&lt;li>&lt;strong>Exploratory Testing Support&lt;/strong> - Provide intelligent suggestions during exploratory testing&lt;/li>
&lt;li>&lt;strong>Predictive Analysis&lt;/strong> - Predict release risks based on historical data&lt;/li>
&lt;/ul>
&lt;h2 id="the-advantages-of-introducing-ai">The Advantages of Introducing AI
&lt;/h2>&lt;p>AI can keep learning, training, and improving continuously, so after introducing AI, we can build advantages across many of the following aspects:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Cost Optimization&lt;/strong> - Reduce labor costs, optimize resource allocation, and speed up time to market&lt;/li>
&lt;li>&lt;strong>Stable and Reliable&lt;/strong> - Ensure standardized test execution and result consistency&lt;/li>
&lt;li>&lt;strong>Early Defect Screening&lt;/strong> - Expose problems early and shorten the fix cycle&lt;/li>
&lt;li>&lt;strong>Fast Feedback&lt;/strong> - Run tests in parallel across multiple environments to shorten the feedback loop&lt;/li>
&lt;li>&lt;strong>High-Quality Cases&lt;/strong> - Automatically generate diverse cases such as unit tests, regression tests, and API tests&lt;/li>
&lt;/ul>
&lt;h2 id="significant-challenges-still-remain-in-applying-ai">Significant Challenges Still Remain in Applying AI
&lt;/h2>&lt;h3 id="artificial-intelligence-or">&lt;strong>Artificial Intelligence or &amp;ldquo;Artificial Stupidity&amp;rdquo;?&lt;/strong>
&lt;/h3>&lt;p>If AI&amp;rsquo;s training data is biased, the results can be so absurd that they make you question reality. If the training outcome of AI is not ideal, then applying AI may not only fail to improve efficiency, but also waste a large amount of extra resources correcting its execution results.&lt;/p>
&lt;h3 id="data-dependency-syndrome">&lt;strong>Data Dependency Syndrome&lt;/strong>
&lt;/h3>&lt;p>AI&amp;rsquo;s high demands for quality training data and various parameter adjustments often impose significant constraints on real-world deployment in specific industries.&lt;/p>
&lt;h3 id="maintenance-costs-are-higher-than-you-think">&lt;strong>Maintenance Costs Are Higher Than You Think&lt;/strong>
&lt;/h3>&lt;p>Beyond the investment in data resources, training models on local datasets also requires a great deal of time and money, including equipment resources, which are a considerable expense. In addition, the current shortage of AI talent makes the labor cost of AI applications much higher.&lt;/p>
&lt;h3 id="experience-and-intuition-are-things-ai-can-never-learn">&lt;strong>Experience and Intuition Are Things AI Can Never Learn&lt;/strong>
&lt;/h3>&lt;p>Veteran testers with rich experience can sniff out hidden defects in a product from all kinds of subtle clues; this &amp;ldquo;mystical,&amp;rdquo; sixth-sense-like ability is bound to be difficult for AI to replicate.&lt;/p>
&lt;h2 id="assistant-or-adversary">Assistant or Adversary?
&lt;/h2>&lt;p>&amp;ldquo;With AI developing like this, are test engineers going to lose their jobs?&amp;rdquo; &lt;strong>There is really no need to panic!&lt;/strong>&lt;/p>
&lt;p>AI is still essentially a tool. Just as test automation replaced some manual checks, it only changes parts of the way we work rather than eliminating the role altogether. Future testers will be more like an &amp;ldquo;AI Trainer + Strategy Commander&amp;rdquo; — what we actually need to do boils down to the following:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>Teach AI to understand business logic&lt;/strong> (for example, what a &amp;ldquo;correct order status transition&amp;rdquo; is);&lt;/li>
&lt;li>&lt;strong>Design smarter testing strategies&lt;/strong> (for example, how to balance automation and exploratory testing);&lt;/li>
&lt;li>&lt;strong>Interpret AI&amp;rsquo;s results and make decisions&lt;/strong> (for example, whether a given anomaly is a bug or a false positive).&lt;/li>
&lt;/ul>
&lt;p>AI is like a robotic vacuum: it can help you clean the floor, but when it comes to stubborn stains (complex business scenarios) or changes in furniture layout (requirement changes), you still have to step in yourself.&lt;/p>
&lt;h2 id="conclusion---ai-is-not-the-end-but-a-new-starting-point">Conclusion - AI Is Not the End, but a New Starting Point
&lt;/h2>&lt;p>The application of AI in software testing is still in its infancy. We can see its enormous potential, but it is not yet time to place full trust in it and abandon the original models. As testers, rather than worrying about &amp;ldquo;whether we will be replaced,&amp;rdquo; it is better to actively embrace change: learn some basic machine learning, get to know mainstream AI testing tools, and even take part in training your own models.&lt;/p>
&lt;p>After all, &lt;strong>in the future world of software testing, the most sought-after people will certainly not be &amp;ldquo;those who are best at clicking a mouse,&amp;rdquo; but &amp;ldquo;those who are best at working with AI&amp;rdquo;&lt;/strong>. What do you think?&lt;/p>
&lt;hr>
&lt;p>Some earlier articles also discussed the development of AI. For further reading:&lt;/p>
&lt;p>&lt;a class="link" href="https://mp.weixin.qq.com/s/JkBcOzZpVEVJBtvZjE4vEQ?token=645759914&amp;amp;lang=zh_CN" target="_blank" rel="noopener"
>In the AI Era, Do Programmers Still Have a Future?&lt;/a>&lt;/p>
&lt;p>&lt;a class="link" href="https://mp.weixin.qq.com/s/k9Dj9eRBhehPtbMiIHnn9g" target="_blank" rel="noopener"
>The Testing Profession and Its Future Prospects&lt;/a>&lt;/p></description></item><item><title>DeepSeek Prompt Frameworks Help Teams Improve the Status Quo and Boost Efficiency</title><link>https://chengxiaqiucao.github.io/en/post/069-%E4%BC%98%E5%8C%96ai%E6%8F%90%E7%A4%BA%E6%A1%86%E6%9E%B6%E5%AE%9E%E7%8E%B0%E5%9B%A2%E9%98%9F%E6%8F%90%E5%8D%87/</link><pubDate>Wed, 19 Mar 2025 22:44:42 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/069-%E4%BC%98%E5%8C%96ai%E6%8F%90%E7%A4%BA%E6%A1%86%E6%9E%B6%E5%AE%9E%E7%8E%B0%E5%9B%A2%E9%98%9F%E6%8F%90%E5%8D%87/</guid><description>&lt;img src="https://chengxiaqiucao.github.io/post/069-%E4%BC%98%E5%8C%96ai%E6%8F%90%E7%A4%BA%E6%A1%86%E6%9E%B6%E5%AE%9E%E7%8E%B0%E5%9B%A2%E9%98%9F%E6%8F%90%E5%8D%87/%E6%8F%90%E7%A4%BA%E8%AF%8D%E6%A1%86%E6%9E%B6.webp" alt="Featured image of post DeepSeek Prompt Frameworks Help Teams Improve the Status Quo and Boost Efficiency" />&lt;p>With the rapid development of AI technology, from ChatGPT to the explosion of DeepSeek, AI can now genuinely play a role in assisting our daily work.&lt;/p>
&lt;p>Beyond specific areas such as assisted programming and copywriting, we can also make full use of AI&amp;rsquo;s powerful logical capabilities and vast foundational data to help us propose practical and feasible improvement plans for some of the difficulties we encounter at work.&lt;/p>
&lt;p>But for AI to give us actionable solutions, the design of the prompt framework and the contextual information provided to AI are extremely critical. A well-designed prompt framework can help us quickly obtain highly valuable references.&lt;/p>
&lt;h2 id="a-case-of-the-predicament-we-face">A Case of the Predicament We Face
&lt;/h2>&lt;p>Here we use a fairly common case of an agile team&amp;rsquo;s quality predicament to illustrate:&lt;/p>
&lt;blockquote>
&lt;p>As a test engineer responsible for quality assurance in an agile team running the Scrum framework, the team also includes an SM, a PO, two Android developers (among whom Xiao Li is responsible for the overall system design of the App), one back-end developer, and one part-time visual designer. The team&amp;rsquo;s product is a companion Android App for an IoT smart bracelet product. However, due to issues such as coordination with the hardware team, frequently changing requirements, untimely visual design, delayed test submissions, and a backlog of bugs, product quality is not optimistic. The App has now gone through multiple iterations, and the planned launch date is drawing ever closer. How can we propose an improvement plan for the current quality predicament?&lt;/p>&lt;/blockquote>
&lt;h3 id="designing-the-prompt-framework">Designing the Prompt Framework
&lt;/h3>&lt;p>For AI to help us produce a feasible improvement plan, we first need to design the prompt framework reasonably, so that the final plan better fits the team&amp;rsquo;s current situation and is actionable.&lt;/p>
&lt;p>The key points of the prompt framework design are then:&lt;/p>
&lt;ul>
&lt;li>A given role, so that AI determines from what perspective to propose the improvement plan&lt;/li>
&lt;li>The current status quo, that is, sufficient background information and context&lt;/li>
&lt;li>What AI should analyze in detail, or what its task should be&lt;/li>
&lt;li>The specific output expected from AI, including format requirements and the elements to be included&lt;/li>
&lt;li>Some relevant constraints, which have an important impact on whether the plan is feasible&lt;/li>
&lt;/ul>
&lt;p>Now, for the predicament above, I want AI to help me provide an overall quality improvement plan for the team that can be discussed at the retrospective meeting. Based on the above thinking, by inputting the prompt framework into DeepSeek, we get the following output:&lt;/p>
&lt;h3 id="quality-improvement-plan-for-the-iteration-retrospective">Quality Improvement Plan (For the Iteration Retrospective)
&lt;/h3>&lt;hr>
&lt;h4 id="1-overall-quality-goals">&lt;strong>1. Overall Quality Goals&lt;/strong>
&lt;/h4>&lt;p>&lt;strong>&amp;ldquo;Within 2 iterations, raise automated test coverage to 40%, shorten defect-fix response time by 50%, compress regression testing time by 30%, and establish a quality defense line linking requirement changes with testing&amp;rdquo;&lt;/strong>&lt;/p>
&lt;hr>
&lt;h4 id="2-specific-improvement-initiatives">&lt;strong>2. Specific Improvement Initiatives&lt;/strong>
&lt;/h4>&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Initiative&lt;/th>
&lt;th>Owner&lt;/th>
&lt;th>Execution Plan&lt;/th>
&lt;th>Evaluation Method&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;strong>Requirement Freeze Mechanism&lt;/strong>&lt;br>- Lock core functional requirements 3 days before each iteration&lt;br>- Hardware integration requirements are jointly reviewed by the PO and the hardware team to form interface documents&lt;/td>
&lt;td>PO, hardware team lead&lt;/td>
&lt;td>Sign the requirements baseline document at the iteration planning meeting&lt;br>Share hardware interface documents via Confluence&lt;/td>
&lt;td>Reduce requirement changes by 50%&lt;br>Interface document version change records are traceable&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Automated Test Case Tiering Strategy&lt;/strong>&lt;br>- L0 (core business flows): mandatory full automation&lt;br>- L1 (high-frequency usage scenarios): prioritized for automation&lt;br>- L2 (edge scenarios): manual verification&lt;/td>
&lt;td>Test Engineer&lt;br>(Lead)&lt;br>Android Developer&lt;br>(Support)&lt;/td>
&lt;td>Use Allure to label case tiers&lt;br>Daily builds prioritize running L0 cases&lt;/td>
&lt;td>100% pass rate of L0 cases as the test-submission exit criterion&lt;br>Reduce automation execution time by 40%&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Developer Self-Testing Responsibility&lt;/strong>&lt;br>- Code submitted by developers must include unit tests (coverage ≥60%)&lt;br>- API tests are maintained by back-end engineers in Swagger&lt;/td>
&lt;td>Android Developer&lt;br>Back-end Engineer&lt;/td>
&lt;td>Include unit tests as a code review checklist item&lt;br>Link Postman API cases with the code repository&lt;/td>
&lt;td>Raise the smoke-test pass rate of submitted builds to 80%&lt;br>Reduce the API defect rate by 30%&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Hardware Compatibility Mock Service&lt;/strong>&lt;br>- Develop a simulator based on the hardware protocol&lt;br>- Decouple automated testing from real devices&lt;/td>
&lt;td>Test Engineer&lt;br>(Lead)&lt;br>Hardware team provides protocol documents&lt;/td>
&lt;td>Develop a Bluetooth protocol simulator using Python&lt;br>Automatically start the Mock service during Jenkins builds&lt;/td>
&lt;td>Reduce test blockages caused by hardware dependencies to zero&lt;br>Raise automation stability to 95%&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;strong>Defect Severity Management&lt;/strong>&lt;br>- P0 defects: respond within 2 hours&lt;br>- P1 defects: must be fixed in the current iteration&lt;br>- Residual defects require the PO to sign off on the risk&lt;/td>
&lt;td>Test Engineer&lt;br>(Classification)&lt;br>Developer&lt;br>(Fix)&lt;/td>
&lt;td>Configure automated defect workflow rules in Jira&lt;br>Sync the progress of the top 3 defects at the daily stand-up&lt;/td>
&lt;td>Shorten the average defect-fix cycle to 8 hours&lt;br>Reduce the number of backlogged defects by 60%&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;hr>
&lt;h4 id="3-risks-and-responses">&lt;strong>3. Risks and Responses&lt;/strong>
&lt;/h4>&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Risk&lt;/th>
&lt;th>Response&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Developers resist unit testing&lt;/td>
&lt;td>- Xiao Li (the system designer) demonstrates writing unit tests&lt;br>- Incorporate test coverage into the DoD completion criteria&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>The hardware protocol changes frequently&lt;/td>
&lt;td>- Require the hardware team to notify of protocol changes 3 days in advance&lt;br>- Design a version compatibility mechanism for the Mock service&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>UE design delays affect UI testing&lt;/td>
&lt;td>- Agree with the UE designer: deliver UI element ID specifications together with the visual drafts&lt;br>- Use a screenshot comparison tool with a 10% pixel-difference tolerance&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;hr>
&lt;h4 id="4-external-support-requirements">&lt;strong>4. External Support Requirements&lt;/strong>
&lt;/h4>&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Type&lt;/th>
&lt;th>Specific Requirements&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Tools&lt;/td>
&lt;td>- Apply for a BrowserStack mobile cloud testing platform license&lt;br>- Purchase an Xray test case management plugin license&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>People&lt;/td>
&lt;td>- The hardware team designates a protocol liaison&lt;br>- A DevOps engineer optimizes the CI/CD pipeline&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Training&lt;/td>
&lt;td>- Invite a unit testing expert to run a TDD workshop&lt;br>- Internal training on advanced Appium usage&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;hr>
&lt;h4 id="5-effect-evaluation-milestones">&lt;strong>5. Effect Evaluation Milestones&lt;/strong>
&lt;/h4>&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Milestone&lt;/th>
&lt;th>Verification Criteria&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Mid-iteration 5&lt;/td>
&lt;td>- L0 automated cases cover all core business flows&lt;br>- Unit test coverage ≥40%&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>End of iteration 5&lt;/td>
&lt;td>- Automation coverage ≥25%&lt;br>- Regression testing time ≤8 hours per run&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>End of iteration 6&lt;/td>
&lt;td>- Automation coverage ≥40%&lt;br>- Zero fatal defects in the production environment&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;hr>
&lt;p>&lt;strong>Notes on Key Execution Points:&lt;/strong>&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Daily Quality Dashboard&lt;/strong>: Hang the automation execution rate / defect trend chart in the team war room&lt;/li>
&lt;li>&lt;strong>Quality Gate Mechanism&lt;/strong>: Code merge requests must pass L0 cases plus SonarQube checks&lt;/li>
&lt;li>&lt;strong>Shift-Left Testing Practice&lt;/strong>: Test engineers produce a test-point matrix as soon as they participate in requirement reviews&lt;/li>
&lt;/ol>
&lt;p>This plan requires the whole team to sign a quality commitment letter. It is recommended that, at the iteration retrospective, the team use the &amp;ldquo;5 Whys analysis&amp;rdquo; to reach a consensus on improvement regarding the current quality issues.&lt;/p>
&lt;p>As we can see, we have obtained an improvement plan that is highly targeted and quite feasible. Based on the team&amp;rsquo;s current situation, we can actually put it into implementation after some fine-tuning.&lt;/p>
&lt;p>So making good use of AI prompt frameworks can not only help us get assistance on specific tasks, but also provide tremendous support for overall improvement initiatives of this kind.&lt;/p>
&lt;p>Reply with &amp;ldquo;prompt framework&amp;rdquo; to get the complete prompt example shown above. Regarding more practical applications of AI at work, everyone is also welcome to leave comments or join the group to discuss!&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/qrcode_for_gh_e12c318badb4_258%20%281%29.jpg"
loading="lazy"
>
&lt;/p></description></item><item><title>Integrating the DeepSeek API into Code to Run Tests</title><link>https://chengxiaqiucao.github.io/en/post/068-%E4%BB%A3%E7%A0%81%E4%B8%AD%E9%9B%86%E6%88%90deepseekapi%E6%89%A7%E8%A1%8C%E6%B5%8B%E8%AF%95/</link><pubDate>Wed, 19 Mar 2025 14:05:03 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/068-%E4%BB%A3%E7%A0%81%E4%B8%AD%E9%9B%86%E6%88%90deepseekapi%E6%89%A7%E8%A1%8C%E6%B5%8B%E8%AF%95/</guid><description>&lt;p>In a previous article&lt;/p>
&lt;p>&lt;a class="link" href="https://chengxiaqiucao.github.io/post/52-%E7%94%A8deepseek&amp;#43;vscode%E8%87%AA%E5%8A%A8%E5%AE%8C%E6%88%90%E6%B5%8B%E8%AF%95%E8%84%9A%E6%9C%AC/" target="_blank" rel="noopener"
>Automatically Generating Test Scripts with DeepSeek + VS Code&lt;/a>&lt;/p>
&lt;p>we introduced an AI plugin for VS Code that helps us automatically generate test cases.&lt;/p>
&lt;p>Now the official DeepSeek API has reopened as well, offering more possibilities for deeply leveraging large models such as DeepSeek to build applications that fit real-world work.&lt;/p>
&lt;p>Below, taking the integration of DeepSeek&amp;rsquo;s official API as an example, we will walk through a practice of calling a large model from code to automatically generate test cases and execute them.&lt;/p>
&lt;p>First, head to the API open platform from the official DeepSeek website&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/068-%E4%BB%A3%E7%A0%81%E4%B8%AD%E9%9B%86%E6%88%90deepseekapi%E6%89%A7%E8%A1%8C%E6%B5%8B%E8%AF%95/Pasted-20250319_hu_a02cc43452797fe9.webp"
width="1024"
height="531"
srcset="https://chengxiaqiucao.github.io/post/068-%E4%BB%A3%E7%A0%81%E4%B8%AD%E9%9B%86%E6%88%90deepseekapi%E6%89%A7%E8%A1%8C%E6%B5%8B%E8%AF%95/Pasted-20250319_hu_abf187e9b5055a0c.webp 480w, https://chengxiaqiucao.github.io/post/068-%E4%BB%A3%E7%A0%81%E4%B8%AD%E9%9B%86%E6%88%90deepseekapi%E6%89%A7%E8%A1%8C%E6%B5%8B%E8%AF%95/Pasted-20250319_hu_a02cc43452797fe9.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="192"
data-flex-basis="463px"
>
&lt;/p>
&lt;p>Once there, apply for an API key. DeepSeek&amp;rsquo;s pricing is still fairly low at the moment, and there are sizable discounts during certain hours.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/068-%E4%BB%A3%E7%A0%81%E4%B8%AD%E9%9B%86%E6%88%90deepseekapi%E6%89%A7%E8%A1%8C%E6%B5%8B%E8%AF%95/Pasted-20250319-1_hu_b77711537548fa64.webp"
width="1024"
height="723"
srcset="https://chengxiaqiucao.github.io/post/068-%E4%BB%A3%E7%A0%81%E4%B8%AD%E9%9B%86%E6%88%90deepseekapi%E6%89%A7%E8%A1%8C%E6%B5%8B%E8%AF%95/Pasted-20250319-1_hu_580e4efa1b933510.webp 480w, https://chengxiaqiucao.github.io/post/068-%E4%BB%A3%E7%A0%81%E4%B8%AD%E9%9B%86%E6%88%90deepseekapi%E6%89%A7%E8%A1%8C%E6%B5%8B%E8%AF%95/Pasted-20250319-1_hu_b77711537548fa64.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="141"
data-flex-basis="340px"
>
&lt;/p>
&lt;p>With this API key, we can start calling it from our code.&lt;/p>
&lt;p>The DeepSeek API is currently compatible with the OpenAI API interface.&lt;/p>
&lt;p>With the code below, combined with Python&amp;rsquo;s standard library inspect, we can have DeepSeek generate test cases directly against our code under test.&lt;/p>
&lt;p>Of course, we can also feed the corresponding requirements text to DeepSeek; the principle is similar.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;span class="lnt">29
&lt;/span>&lt;span class="lnt">30
&lt;/span>&lt;span class="lnt">31
&lt;/span>&lt;span class="lnt">32
&lt;/span>&lt;span class="lnt">33
&lt;/span>&lt;span class="lnt">34
&lt;/span>&lt;span class="lnt">35
&lt;/span>&lt;span class="lnt">36
&lt;/span>&lt;span class="lnt">37
&lt;/span>&lt;span class="lnt">38
&lt;/span>&lt;span class="lnt">39
&lt;/span>&lt;span class="lnt">40
&lt;/span>&lt;span class="lnt">41
&lt;/span>&lt;span class="lnt">42
&lt;/span>&lt;span class="lnt">43
&lt;/span>&lt;span class="lnt">44
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="kn">import&lt;/span> &lt;span class="nn">inspect&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="kn">from&lt;/span> &lt;span class="nn">openai&lt;/span> &lt;span class="kn">import&lt;/span> &lt;span class="n">OpenAI&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Import the DeepSeek API&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">client&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">OpenAI&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">api_key&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s2">&amp;#34;&amp;lt;your_deepseek_api_key&amp;gt;&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">base_url&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s2">&amp;#34;https://api.deepseek.com&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Function under test, calculates BMI&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">def&lt;/span> &lt;span class="nf">calculate_bmi&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">weight&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">height&lt;/span>&lt;span class="p">):&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="n">height&lt;/span> &lt;span class="o">&amp;lt;=&lt;/span> &lt;span class="mi">0&lt;/span> &lt;span class="ow">or&lt;/span> &lt;span class="n">weight&lt;/span> &lt;span class="o">&amp;lt;=&lt;/span> &lt;span class="mi">0&lt;/span>&lt;span class="p">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">raise&lt;/span> &lt;span class="ne">ValueError&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;身高、体重必须大于0&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">bmi&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">weight&lt;/span> &lt;span class="o">/&lt;/span> &lt;span class="p">(&lt;/span>&lt;span class="n">height&lt;/span> &lt;span class="o">**&lt;/span> &lt;span class="mi">2&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">if&lt;/span> &lt;span class="n">bmi&lt;/span> &lt;span class="o">&amp;lt;&lt;/span> &lt;span class="mf">18.5&lt;/span>&lt;span class="p">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">return&lt;/span> &lt;span class="s2">&amp;#34;竹竿！&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">elif&lt;/span> &lt;span class="mf">18.5&lt;/span> &lt;span class="o">&amp;lt;=&lt;/span> &lt;span class="n">bmi&lt;/span> &lt;span class="o">&amp;lt;&lt;/span> &lt;span class="mf">24.9&lt;/span>&lt;span class="p">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">return&lt;/span> &lt;span class="s2">&amp;#34;正常人&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">elif&lt;/span> &lt;span class="mi">25&lt;/span> &lt;span class="o">&amp;lt;=&lt;/span> &lt;span class="n">bmi&lt;/span> &lt;span class="o">&amp;lt;&lt;/span> &lt;span class="mf">29.9&lt;/span>&lt;span class="p">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">return&lt;/span> &lt;span class="s2">&amp;#34;壮士！&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">else&lt;/span>&lt;span class="p">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">return&lt;/span> &lt;span class="s2">&amp;#34;肥宅！&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Get the function&amp;#39;s source code via inspect&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">function_code&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">inspect&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">getsource&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">calculate_bmi&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Define the prompt based on the retrieved code&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">the_prompt&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="sa">f&lt;/span>&lt;span class="s2">&amp;#34;&amp;#34;&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s2">请针对以下代码生成基于pytest框架的测试用例：&lt;/span>&lt;span class="si">{&lt;/span>&lt;span class="n">function_code&lt;/span>&lt;span class="si">}&lt;/span>&lt;span class="s2">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s2">尽可能使用参数化测试，包含各种异常场景
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s2">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s2">&amp;#34;&amp;#34;&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># Call the DeepSeek API using the V3 model and get the response&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">response&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">client&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">chat&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">completions&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">create&lt;/span>&lt;span class="p">(&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">model&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s2">&amp;#34;deepseek-chat&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">messages&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="p">[&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span>&lt;span class="s2">&amp;#34;role&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;system&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s2">&amp;#34;content&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;You are a python testing assistant&amp;#34;&lt;/span>&lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">{&lt;/span>&lt;span class="s2">&amp;#34;role&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;user&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s2">&amp;#34;content&amp;#34;&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="n">the_prompt&lt;/span>&lt;span class="p">},&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="p">],&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">max_tokens&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mi">1024&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">temperature&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="mf">0.7&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">stream&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="kc">False&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">response&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">choices&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">message&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">content&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>With the code above, we can obtain the result returned by DeepSeek V3:&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;span class="lnt">28
&lt;/span>&lt;span class="lnt">29
&lt;/span>&lt;span class="lnt">30
&lt;/span>&lt;span class="lnt">31
&lt;/span>&lt;span class="lnt">32
&lt;/span>&lt;span class="lnt">33
&lt;/span>&lt;span class="lnt">34
&lt;/span>&lt;span class="lnt">35
&lt;/span>&lt;span class="lnt">36
&lt;/span>&lt;span class="lnt">37
&lt;/span>&lt;span class="lnt">38
&lt;/span>&lt;span class="lnt">39
&lt;/span>&lt;span class="lnt">40
&lt;/span>&lt;span class="lnt">41
&lt;/span>&lt;span class="lnt">42
&lt;/span>&lt;span class="lnt">43
&lt;/span>&lt;span class="lnt">44
&lt;/span>&lt;span class="lnt">45
&lt;/span>&lt;span class="lnt">46
&lt;/span>&lt;span class="lnt">47
&lt;/span>&lt;span class="lnt">48
&lt;/span>&lt;span class="lnt">49
&lt;/span>&lt;span class="lnt">50
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-markdown" data-lang="markdown">&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">To test the &lt;span class="sb">`calculate_bmi`&lt;/span> function, we can use the &lt;span class="sb">`pytest`&lt;/span> framework together with &lt;span class="sb">`pytest.mark.parametrize`&lt;/span> to implement parameterized testing. Below is a complete test case covering both normal and exceptional scenarios.
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> ``&lt;span class="sb">`python
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">import pytest
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"># Import the function under test
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">from your_module import calculate_bmi
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"># Test cases for normal scenarios
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">@pytest.mark.parametrize(&amp;#34;weight, height, expected&amp;#34;, [
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> (60, 1.75, &amp;#34;正常人&amp;#34;), # Normal BMI
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> (50, 1.75, &amp;#34;竹竿！&amp;#34;), # Low BMI
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> (80, 1.75, &amp;#34;壮士！&amp;#34;), # High BMI
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> (100, 1.75, &amp;#34;肥宅！&amp;#34;), # Very high BMI
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">])
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">def test_calculate_bmi_normal(weight, height, expected):
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> assert calculate_bmi(weight, height) == expected
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"># Test cases for exceptional scenarios
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">@pytest.mark.parametrize(&amp;#34;weight, height, expected_exception&amp;#34;, [
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> (0, 1.75, ValueError), # Weight is 0
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> (60, 0, ValueError), # Height is 0
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> (-10, 1.75, ValueError), # Weight is negative
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> (60, -1.75, ValueError), # Height is negative
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">])
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">def test_calculate_bmi_exceptions(weight, height, expected_exception):
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> with pytest.raises(expected_exception):
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> calculate_bmi(weight, height)
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">`&lt;/span> `&lt;span class="sb">`
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">### Explanation:
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">1. **Normal scenario tests**:
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - Use `&lt;/span>pytest.mark.parametrize&lt;span class="sb">` to test different combinations of weight and height, verifying that the BMI category returned by the function is correct.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - The test cases cover normal BMI, low BMI, high BMI, and very high BMI.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">2. **Exceptional scenario tests**:
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - Verify that the function raises a `&lt;/span>ValueError&lt;span class="sb">` when given invalid inputs (such as weight or height being 0 or negative).
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb"> - Use `&lt;/span>pytest.raises&lt;span class="sb">` to catch the expected exception.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">### Running the tests:
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">Make sure you have `&lt;/span>pytest&lt;span class="sb">` installed, then run the following command in the terminal to execute the tests:
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">`&lt;/span>`&lt;span class="sb">`bash
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">pytest test_bmi.py
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">`&lt;/span> `&lt;span class="sb">`
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">### Notes:
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">- `&lt;/span>your_module&lt;span class="sb">` is the name of the module containing the `&lt;/span>calculate_bmi&lt;span class="sb">` function; replace it with the actual one.
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="sb">- Test files are usually named `&lt;/span>test_*.py&lt;span class="sb">` or `&lt;/span>*_test.py&lt;span class="sb">` so that `&lt;/span>pytest` can discover and run them automatically.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>To make more direct use of the generated result, we can extract the code from the markdown-formatted output here, write it into a test file, and then simply invoke and execute it.&lt;/p>
&lt;p>The specific code is below; it uses a regular expression (for a detailed introduction to regular expressions, see the earlier article &lt;a class="link" href="https://chengxiaqiucao.github.io/post/58-%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E7%94%A8%E6%B3%95%E8%AF%A6%E8%A7%A3/" target="_blank" rel="noopener"
>Mastering Regular Expressions - Leaving the Newbie Village Behind!&lt;/a>) to extract the code portion.&lt;/p>
&lt;div class="highlight">&lt;div class="chroma">
&lt;table class="lntable">&lt;tr>&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code>&lt;span class="lnt"> 1
&lt;/span>&lt;span class="lnt"> 2
&lt;/span>&lt;span class="lnt"> 3
&lt;/span>&lt;span class="lnt"> 4
&lt;/span>&lt;span class="lnt"> 5
&lt;/span>&lt;span class="lnt"> 6
&lt;/span>&lt;span class="lnt"> 7
&lt;/span>&lt;span class="lnt"> 8
&lt;/span>&lt;span class="lnt"> 9
&lt;/span>&lt;span class="lnt">10
&lt;/span>&lt;span class="lnt">11
&lt;/span>&lt;span class="lnt">12
&lt;/span>&lt;span class="lnt">13
&lt;/span>&lt;span class="lnt">14
&lt;/span>&lt;span class="lnt">15
&lt;/span>&lt;span class="lnt">16
&lt;/span>&lt;span class="lnt">17
&lt;/span>&lt;span class="lnt">18
&lt;/span>&lt;span class="lnt">19
&lt;/span>&lt;span class="lnt">20
&lt;/span>&lt;span class="lnt">21
&lt;/span>&lt;span class="lnt">22
&lt;/span>&lt;span class="lnt">23
&lt;/span>&lt;span class="lnt">24
&lt;/span>&lt;span class="lnt">25
&lt;/span>&lt;span class="lnt">26
&lt;/span>&lt;span class="lnt">27
&lt;/span>&lt;/code>&lt;/pre>&lt;/td>
&lt;td class="lntd">
&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># User configuration &lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">run_tests&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="kc">True&lt;/span> &lt;span class="c1"># Whether to run the tests &lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1"># If tests should be run, write the test cases to a file and execute them &lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="k">if&lt;/span> &lt;span class="n">run_tests&lt;/span>&lt;span class="p">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># Create the test file &lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">test_file_name&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="s2">&amp;#34;test_calculate_bmi.py&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="k">with&lt;/span> &lt;span class="nb">open&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">test_file_name&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="s2">&amp;#34;w&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="n">encoding&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="s2">&amp;#34;utf-8&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span> &lt;span class="k">as&lt;/span> &lt;span class="n">test_file&lt;/span>&lt;span class="p">:&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">test_file&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">write&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="sa">f&lt;/span>&lt;span class="s2">&amp;#34;import pytest&lt;/span>&lt;span class="se">\n\n&lt;/span>&lt;span class="s2">&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">test_file&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">write&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="sa">f&lt;/span>&lt;span class="s2">&amp;#34;from ai_test import calculate_bmi&lt;/span>&lt;span class="se">\n\n&lt;/span>&lt;span class="s2">&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">pattern&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="sa">r&lt;/span>&lt;span class="s1">&amp;#39;```python([\s\S]*?)```\n&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">test_code&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">re&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">findall&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">pattern&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">test_cases&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">re&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">DOTALL&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">test_file&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">write&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">test_code&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">])&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># Run the tests with pytest &lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">result&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="n">subprocess&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">run&lt;/span>&lt;span class="p">([&lt;/span>&lt;span class="s2">&amp;#34;pytest&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">test_file_name&lt;/span>&lt;span class="p">],&lt;/span> &lt;span class="n">capture_output&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="kc">True&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="n">text&lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="kc">True&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># Print the test results &lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;测试结果:&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">result&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">stdout&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;错误信息:&amp;#34;&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="nb">print&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">result&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">stderr&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># Optional - delete the test file &lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="c1"># os.remove(test_file_name)&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/td>&lt;/tr>&lt;/table>
&lt;/div>
&lt;/div>&lt;p>In this way, we have completed an experiment in which DeepSeek automatically generates test cases, executes them immediately, and outputs the results.&lt;/p>
&lt;p>Of course, this example is fairly simple and only a preliminary experiment in fully automated unit testing with AI; practical applications still require deeper exploration!&lt;/p></description></item><item><title>Why Did DeepSeek Choose Open Source?</title><link>https://chengxiaqiucao.github.io/en/post/036-deepseek%E4%B8%BA%E4%BB%80%E4%B9%88%E5%BC%80%E6%BA%90/</link><pubDate>Tue, 25 Feb 2025 00:00:00 +0000</pubDate><guid>https://chengxiaqiucao.github.io/en/post/036-deepseek%E4%B8%BA%E4%BB%80%E4%B9%88%E5%BC%80%E6%BA%90/</guid><description>&lt;hr>
&lt;blockquote>
&lt;p>Someone asked: the major large models abroad are basically all closed source, so why did DeepSeek, being so capable, choose to open source?&lt;/p>&lt;/blockquote>
&lt;p>To answer this question, you actually only need to understand who Liang Wenfeng is, how he made his start, and a few of his interviews available online, and it becomes clear!&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/036-deepseek%E4%B8%BA%E4%BB%80%E4%B9%88%E5%BC%80%E6%BA%90/Pasted-20250224-2_hu_4bd2a35132176428.webp"
width="1024"
height="694"
srcset="https://chengxiaqiucao.github.io/post/036-deepseek%E4%B8%BA%E4%BB%80%E4%B9%88%E5%BC%80%E6%BA%90/Pasted-20250224-2_hu_a91fb8967d884d20.webp 480w, https://chengxiaqiucao.github.io/post/036-deepseek%E4%B8%BA%E4%BB%80%E4%B9%88%E5%BC%80%E6%BA%90/Pasted-20250224-2_hu_4bd2a35132176428.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="147"
data-flex-basis="354px"
>
&lt;/p>
&lt;h2 id="deepseek-is-a-product-of-interest">DeepSeek Is a Product of Interest
&lt;/h2>&lt;p>As one of China&amp;rsquo;s leading quantitative private funds, High-Flying has dominated the field by relying on AI technologies such as machine learning, and it has already been enormously successful. In other words, High-Flying already earns more than enough money on its own; building the DeepSeek large model on top of its existing technical accumulation is more a product of the founders&amp;rsquo; personal interest than a core product. At most, the original intent was to empower its core business—but it was absolutely never its main track.&lt;/p>
&lt;p>Of course, now that DeepSeek has reached this position, it is not out of the question that High-Flying&amp;rsquo;s direction could become large models in the future.&lt;/p>
&lt;p>It is just like Nokia originally making pulp, or Lamborghini originally making tractors&amp;hellip;. An unintentional result that took root.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/036-deepseek%E4%B8%BA%E4%BB%80%E4%B9%88%E5%BC%80%E6%BA%90/Pasted-20250224-1_hu_a19df2b6d7133dea.webp"
width="1024"
height="703"
srcset="https://chengxiaqiucao.github.io/post/036-deepseek%E4%B8%BA%E4%BB%80%E4%B9%88%E5%BC%80%E6%BA%90/Pasted-20250224-1_hu_f6602a1ff8572285.webp 480w, https://chengxiaqiucao.github.io/post/036-deepseek%E4%B8%BA%E4%BB%80%E4%B9%88%E5%BC%80%E6%BA%90/Pasted-20250224-1_hu_a19df2b6d7133dea.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="145"
data-flex-basis="349px"
>
&lt;/p>
&lt;p>So the first consideration in building DeepSeek was not the business model, not how to make money! Whether to open source or stay closed source was not much of a dilemma in terms of business model!&lt;/p>
&lt;h2 id="the-core-of-technology-is-not-the-technology-itself-but-the-talent-that-produces-it">The Core of Technology Is Not the Technology Itself, but the Talent That Produces It
&lt;/h2>&lt;p>And from Liang Wenfeng&amp;rsquo;s interviews, we can also learn his view on open source: people are the key to innovation! In the face of a disruptive innovation like AI, the moat gained through closed source is extremely short-lived; it is passionate, curious, daring top talent that is the source of such technology!&lt;/p>
&lt;p>He also gave the example of NVIDIA: there is nothing particularly secret about NVIDIA&amp;rsquo;s technology itself, but assembling a team, building an ecosystem, and catching up all take time—and that time is the real moat!&lt;/p>
&lt;h2 id="">
&lt;/h2>&lt;p>The confidence in one&amp;rsquo;s bones and the sense of mission to take the world upon oneself&lt;/p>
&lt;p>In his interviews, Liang Wenfeng repeatedly spoke about how China&amp;rsquo;s earlier technological development was mostly that of a follower, with incremental, fine-tuning innovations but a lack of disruptive innovation. There is a need to move from the imitation stage toward original creation, and to reflect Chinese contributions within the progress of human technology. I believe this is also the result of his giving the all-domestic talent on his team, on the foundation of his financial strength, ample freedom and room to innovate, accumulating strength over time and then breaking through!&lt;/p>
&lt;p>Liang Wenfeng has truly lived up to the ideal: when you succeed, help the whole world succeed&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/036-deepseek%E4%B8%BA%E4%BB%80%E4%B9%88%E5%BC%80%E6%BA%90/Pasted-20250224_hu_867ea5cdee01f2.webp"
width="1024"
height="325"
srcset="https://chengxiaqiucao.github.io/post/036-deepseek%E4%B8%BA%E4%BB%80%E4%B9%88%E5%BC%80%E6%BA%90/Pasted-20250224_hu_a09c12ac6ff35265.webp 480w, https://chengxiaqiucao.github.io/post/036-deepseek%E4%B8%BA%E4%BB%80%E4%B9%88%E5%BC%80%E6%BA%90/Pasted-20250224_hu_867ea5cdee01f2.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="314"
data-flex-basis="755px"
>
&lt;/p>
&lt;hr></description></item><item><title>Musk's Audit Storm, an AI Shock More Direct Than DeepSeek</title><link>https://chengxiaqiucao.github.io/en/post/053-%E9%A9%AC%E6%96%AF%E5%85%8Bai%E6%B2%BB%E5%9B%BD/</link><pubDate>Mon, 10 Feb 2025 11:20:27 +0800</pubDate><guid>https://chengxiaqiucao.github.io/en/post/053-%E9%A9%AC%E6%96%AF%E5%85%8Bai%E6%B2%BB%E5%9B%BD/</guid><description>&lt;p>During the Spring Festival holiday, everyone here was celebrating in high spirits. The box office of Ne Zha kept climbing; DeepSeek also broke into the mainstream, dominating everyone&amp;rsquo;s feeds, with its servers busy for long stretches.&lt;/p>
&lt;p>At the same time, across the ocean, as Trump moved into the White House on January 20, Musk also took charge of DOGE and got to work at lightning speed that very day, launching a large-scale audit of federal government spending.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/053-%E9%A9%AC%E6%96%AF%E5%85%8Bai%E6%B2%BB%E5%9B%BD/Pasted-20250210-1_hu_cb6ffff9124e69bc.webp"
width="1024"
height="768"
srcset="https://chengxiaqiucao.github.io/post/053-%E9%A9%AC%E6%96%AF%E5%85%8Bai%E6%B2%BB%E5%9B%BD/Pasted-20250210-1_hu_8150ece301eb9c84.webp 480w, https://chengxiaqiucao.github.io/post/053-%E9%A9%AC%E6%96%AF%E5%85%8Bai%E6%B2%BB%E5%9B%BD/Pasted-20250210-1_hu_cb6ffff9124e69bc.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="133"
data-flex-basis="320px"
>
&lt;/p>
&lt;p>This DOGE is not the cryptocurrency DOGE; it is short for the U.S. &lt;strong>Department of Government Efficiency&lt;/strong>.&lt;/p>
&lt;h2 id="musk-and-the-doge-audit-storm">Musk and the DOGE Audit Storm
&lt;/h2>&lt;p>Unlike the traditional large-scale audits we might imagine — first setting up an audit department, then hundreds or even thousands of auditors spending months on preparation, on-site work, and reconciliation — DOGE has, in less than 20 days, already turned American politics upside down.&lt;/p>
&lt;p>&amp;mdash; &lt;strong>January 20: shut down the Chief Diversity Officers Executive Council (CDOEC);&lt;/strong>&lt;/p>
&lt;p>&amp;mdash; January 25: canceled about $420 million in existing / soon-to-be-signed contracts;&lt;/p>
&lt;p>&amp;mdash; January 27: the Departments of Labor, Transportation, Agriculture, Commerce, Health and Human Services, and the Treasury canceled 16 DEIA contracts, saving $145 million;&lt;/p>
&lt;p>&amp;mdash; January 28: the General Services Administration (GSA) terminated three leases on nearly empty office space and shut down 17 DEIA websites, saving $1.6 million;&lt;/p>
&lt;p>&amp;mdash; January 29: canceled a $45 million DEI scholarship for Myanmar;&lt;/p>
&lt;p>(As of January 29, 2025, 26 departments including the Department of Education and the GSA had terminated 85 DEIA-related contracts totaling about $1 billion;)&lt;/p>
&lt;p>&amp;mdash; February 3: the number of terminated leases on underutilized buildings rose to 22, and the savings grew from $1.6 million to $44.6 million;&lt;/p>
&lt;p>&amp;mdash; &lt;strong>February 3: shut down the United States Agency for International Development (USAID);&lt;/strong>&lt;/p>
&lt;p>&amp;mdash; February 4: six agencies terminated 36 contracts, saving about $165 million in total, including the Department of Homeland Security&amp;rsquo;s &amp;ldquo;Humanities Research and Climate Support Services&amp;rdquo; contract;&lt;/p>
&lt;p>&amp;mdash; February 5: terminated 12 consulting contracts (at the GSA and the Department of Education), saving about $30 million in total;&lt;/p>
&lt;p>&amp;mdash; February 6: the Social Security Administration terminated its &amp;ldquo;Gender X Initiative Marker&amp;rdquo; contract, saving over $1 million; NASA canceled its Politico subscription, saving $500,000; 78 contracts in the DEI, distressed assets, media, and consulting categories were terminated, for total savings of about $110 million;&lt;/p>
&lt;p>&amp;mdash; February 8: announced that within the past 48 hours, the Department of Health and Human Services had canceled 62 contracts worth $182 million; the Department of Education terminated three DEI training grants totaling $15 million.&lt;/p>
&lt;p>Yet behind such fast and efficient audit results and actions there is no massive team — it relies on nothing more than a few geniuses barely in their twenties, backed by their AI algorithms.&lt;/p>
&lt;h2 id="doges-six-young-prodigies">DOGE&amp;rsquo;s Six Young Prodigies
&lt;/h2>&lt;p>Hard to imagine, but every move on the list above was carried out by the six young men below.&lt;/p>
&lt;p>&lt;img src="https://chengxiaqiucao.github.io/post/053-%E9%A9%AC%E6%96%AF%E5%85%8Bai%E6%B2%BB%E5%9B%BD/Pasted-20250210_hu_d3ec35e1fe2e372a.webp"
width="1024"
height="607"
srcset="https://chengxiaqiucao.github.io/post/053-%E9%A9%AC%E6%96%AF%E5%85%8Bai%E6%B2%BB%E5%9B%BD/Pasted-20250210_hu_d26187522a937430.webp 480w, https://chengxiaqiucao.github.io/post/053-%E9%A9%AC%E6%96%AF%E5%85%8Bai%E6%B2%BB%E5%9B%BD/Pasted-20250210_hu_d3ec35e1fe2e372a.webp 1024w"
loading="lazy"
class="gallery-image"
data-flex-grow="168"
data-flex-basis="404px"
>
&lt;/p>
&lt;ul>
&lt;li>
&lt;p>&lt;strong>Gavin Kliger (25)&lt;/strong>: A graduate of UC Berkeley in electrical engineering and computer science, Kliger was formerly a senior software engineer at the U.S. AI data analytics company Databricks and is an expert in artificial intelligence and big data analysis. His job is to &lt;strong>draft executive orders&lt;/strong> and ensure they take effect quickly within the government — the email telling all USAID staff they need not return to headquarters on Monday came from his hand. He also directly drafted the funding review order targeting the U.S. Treasury, took part in OPM&amp;rsquo;s mass layoff plan, and was responsible for setting the &amp;ldquo;rehire standards&amp;rdquo; for civil servants, requiring that future government employees be approved by DOGE before being hired.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Luke Farritor (23)&lt;/strong>: Farritor dropped out of the University of Nebraska–Lincoln and later worked for Nat Friedman, the Silicon Valley entrepreneur behind GitHub. He once interned at SpaceX, writing software for the pumps, valves, and other components that help fuel rockets. Farritor is currently listed as an &amp;ldquo;executive engineer&amp;rdquo; in the office of the Secretary of Health and Human Services (HHS), and personally oversaw the &lt;strong>digital lockdown&lt;/strong> operation at USAID; his next target is already the systems of the Centers for Medicare &amp;amp; Medicaid Services, which handles contracts.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Edward Coristine (19)&lt;/strong>: The youngest of the group, Coristine had just graduated from high school and was studying mechanical engineering and physics at Northeastern University in Boston. He spent three months last summer working at Musk&amp;rsquo;s brain-computer interface company Neuralink, and his specific duties have not yet been made clear. Coristine once joined a call with U.S. General Services Administration employees using a non-government Google Gmail account, asking them to review code he had written and justify their own work — a move that sparked dissatisfaction among federal employees.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Akash Bobba (21)&lt;/strong>: Bobba comes from UC Berkeley and was an investment engineering intern at Bridgewater Associates; he had also interned at Meta and at Palantir, the U.S. software services company founded by MAGA backer Peter Thiel. He specializes in artificial intelligence, data analysis, and financial modeling. He is responsible for &lt;strong>designing algorithms to monitor the flow of government funds&lt;/strong>, leading a &amp;ldquo;real-time fiscal spending monitoring system&amp;rdquo; that allows federal &amp;ldquo;inefficient spending&amp;rdquo; to be frozen in real time without congressional review.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Ethan Shaotran (22)&lt;/strong>: A senior computer science major at Harvard, Shaotran is the only one on the team with AI startup experience. The AI company he founded, Energize AI, received $100,000 in funding from OpenAI, and he once took second place in a hackathon held by Musk&amp;rsquo;s AI company xAI. Shaotran leads DOGE&amp;rsquo;s AI government initiative, whose goal is to &lt;strong>replace the government&amp;rsquo;s traditional human decision-making with algorithms&lt;/strong>, automating most administrative approvals, budget evaluations, and even congressional reports.&lt;/p>
&lt;/li>
&lt;li>
&lt;p>&lt;strong>Gautier Cole Killian (24)&lt;/strong>: Breached the Treasury&amp;rsquo;s security systems and obtained access to the payment network. A graduate of McGill University, Killian is exceptionally strong in financial data processing and once worked as an engineer at Jump Trading, a firm specializing in high-frequency financial trading and algorithms. His main task is to help the DOGE team &lt;strong>break through the Treasury&amp;rsquo;s security defenses&lt;/strong>, giving them access to the government payment network and letting them bypass security checks to read millions of transaction records directly. Killian is also one of the few young people granted senior White House access, and Musk places extremely high trust in him.&lt;/p>
&lt;/li>
&lt;/ul>
&lt;p>So these few engineers, barely out of college, after obtaining data access and in only about two weeks, used AI to bring to the surface all sorts of problems that had lain hidden beneath the iceberg for decades. You could say it truly was a case of speed being everything — the bureaucrats over in the U.S. probably hadn&amp;rsquo;t even come to their senses before finding their house had been raided.&lt;/p>
&lt;h2 id="reflections">Reflections
&lt;/h2>&lt;p>No matter where this reform storm ultimately takes Musk and his six young lieutenants, &lt;strong>AI&lt;/strong> has already, in a jaw-dropping way, begun to sway the political situation across the ocean, and it is bound to deeply affect every aspect of our lives.&lt;/p></description></item></channel></rss>