refactor(prompts): decouple allow_shell from static system-prompt prefix#2949
Conversation
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
cc409b9 to
638b50c
Compare
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
There was a problem hiding this comment.
Code Review
This pull request decouples the allow_shell configuration from the static system prompt prefix, moving it instead to the per-turn <runtime_prompt> tag. This change prevents mutating the static system prompt when shell access is toggled, thereby preserving the DeepSeek prefix cache. As a result, the complex logic for dynamically removing shell tool guidance from the static prompt has been removed, and the static prompt now always includes full shell tool guidance. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
638b50c to
6d44dad
Compare
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
6d44dad to
ed84ef1
Compare
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Move allow_shell from message[0] (static system prompt) to the per-turn <runtime_prompt> tag alongside mode and approval. This preserves the DeepSeek prefix cache across shell-access toggles and mode switches, which previously forced YOLO entry/exit to rebuild the entire prompt. Changes: - Delete remove_shell_tool_guidance and 3 other dead functions (~60 lines) - Remove allow_shell field from PromptSessionContext and StaticPromptCtx - Remove shell_tools_available dead parameter from compose functions - Add Shell Policy section to Runtime Policy Reference (static text) - Extend <runtime_prompt> tag with allow_shell="true|false" attribute - Update tests: omits→always_keeps, 83/83 prompts tests pass - Drop dead compose_mode_prompt_with_approval_and_model Net: message[0] bytes are now stable regardless of shell-access state. Mode/approval/shell flags all use the same per-turn tag pattern.
ed84ef1 to
9206eb9
Compare
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
|
Merged — thank you @LeoAlex0. Reviewed in full: the inversion from prompt-redaction to runtime-gates + per-turn tag is the right architecture for prefix-cache stability, and deleting |
Summary · 概述
Move
allow_shellfrom message[0] (static system prompt prefix) to the per-turn<runtime_prompt>tag alongsidemodeandapproval.将
allow_shell从 message[0](静态 system prompt 前缀)移至每轮<runtime_prompt>标签,与mode、approval并列。Motivation · 动机
The DeepSeek prefix cache keys on the byte-stable prefix of each request. When
allow_shellwas embedded in message[0], toggling shell access or switching modes forced a full prompt rebuild — losing cache and increasing latency.By moving all three runtime flags (
mode,approval,allow_shell) into the per-turn<runtime_prompt>tag, message[0] bytes remain stable regardless of shell-access state or mode switches. The model still sees the same Shell Policy reference (static text in the Runtime Policy Reference section), but the binary on/off flag is delivered per-turn.DeepSeek 的 prefix cache 基于每次请求中字节稳定的前缀。当
allow_shell嵌入 message[0] 时,切换 shell 访问或切换模式会迫使整个 prompt 重建,导致缓存丢失、延迟增加。将三个运行时标志(
mode、approval、allow_shell)全部放入每轮<runtime_prompt>标签后,message[0] 字节不再受 shell-access 状态或模式切换影响,保持稳定。模型仍能看到相同的 Shell Policy 参考(Runtime Policy Reference 中的静态文本),但二值开关按轮次传递。Changes · 变更
remove_shell_tool_guidanceand 3 other dead functions (~60 lines)allow_shellfield fromPromptSessionContextandStaticPromptCtxshell_tools_availableparameter from compose functions<runtime_prompt>tag withallow_shell="true|false"attributecompose_mode_prompt_with_approval_and_modelremove_shell_tool_guidance等 4 个死函数(约 60 行)PromptSessionContext和StaticPromptCtx中移除allow_shell字段shell_tools_available<runtime_prompt>标签,增加allow_shell="true|false"属性compose_mode_prompt_with_approval_and_modelNet · 效果
message[0] bytes are now stable regardless of shell-access state. Mode/approval/shell flags all use the same per-turn tag pattern.
message[0] 字节现在不随 shell-access 状态变化,保持稳定。mode/approval/shell 三个标志统一使用每轮 tag 模式。
Files · 涉及文件
crates/tui/src/core/engine.rs— runtime_prompt_text signature, caller updatescrates/tui/src/prompts.rs— remove dead functions, add Shell Policy, update testscrates/tui/src/tui/ui.rs— drop allow_shell from StaticPromptCtx call site