Commit 6a2c290
fix: progressive widget MCP — only register when conversation needs widgets
The codepilot-widget MCP server (added in 0.38) registers an in-process
tool for loading detailed design specs. SDK tool discovery during init
adds overhead to every request, even plain text conversations.
Change to progressive loading: detect widget intent via keywords in the
user prompt, conversation history (show-widget fences), or system prompt.
Only register the MCP server when the conversation likely involves widget
generation.
- Plain text conversations: no MCP server, no overhead (same as v0.37)
- Widget conversations: MCP server registered, full design specs available
- Keywords: 可视化/图表/流程图/visualize/diagram/chart/flowchart etc.
- Conversation history check: existing show-widget output triggers it
Also reverts the WIDGET_SYSTEM_PROMPT_HINT experiment — keeps the full
WIDGET_SYSTEM_PROMPT in system prompt (same as v0.37) since prompt token
count is not the bottleneck.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 303facb commit 6a2c290
File tree
4 files changed
+36
-45
lines changed- src
- __tests__/unit
- app/api/chat
- lib
4 files changed
+36
-45
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
| 300 | + | |
317 | 301 | | |
318 | 302 | | |
319 | 303 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
333 | | - | |
334 | | - | |
335 | | - | |
| 333 | + | |
336 | 334 | | |
337 | 335 | | |
338 | 336 | | |
339 | 337 | | |
340 | | - | |
341 | | - | |
| 338 | + | |
| 339 | + | |
342 | 340 | | |
343 | 341 | | |
344 | 342 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
| 448 | + | |
448 | 449 | | |
449 | 450 | | |
450 | 451 | | |
| |||
509 | 510 | | |
510 | 511 | | |
511 | 512 | | |
512 | | - | |
513 | | - | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
514 | 519 | | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
519 | | - | |
520 | | - | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
521 | 539 | | |
522 | 540 | | |
523 | 541 | | |
| |||
806 | 824 | | |
807 | 825 | | |
808 | 826 | | |
809 | | - | |
810 | 827 | | |
811 | 828 | | |
812 | 829 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
12 | 10 | | |
13 | 11 | | |
14 | 12 | | |
15 | 13 | | |
16 | 14 | | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 15 | + | |
24 | 16 | | |
25 | 17 | | |
26 | 18 | | |
| |||
263 | 255 | | |
264 | 256 | | |
265 | 257 | | |
266 | | - | |
| 258 | + | |
267 | 259 | | |
268 | 260 | | |
269 | 261 | | |
| |||
0 commit comments