fix(cli): system-reminder prefixes reach bash in shell mode
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 28k
- Forks
- 3.1k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 702
Description
What happens
handleFinalSubmit in packages/cli/src/ui/AppContainer.tsx can prepend up to three <system-reminder> blocks to a submission:
- the recovered-agents notice (
config.consumePendingRecoveredAgentsNotice()), - the worktree restore notice after
--resume(pendingWorktreeNoticeRef), - the
workflowkeyword reminder.
Only the keyword reminder checks shell mode (added in #11520). In shell mode the other two are still prepended, so the text handed to bash starts with <system-reminder>, which is a syntax error. The user's command never runs, the reminder text is recorded as the command they ran, and the one-shot notice is consumed by the failed submission, so the next model turn never sees it.
A second gap affects all three. Shell mode is read when the prompt is submitted, but packages/cli/src/ui/hooks/use-llm-stream.ts routes it with the live flag when the queue drains (if (shellModeActive && handleShellCommand(trimmedQuery, abortSignal))). A prompt queued while the model is responding, drained after the user presses !, goes to bash with its prefix.
Steps to reproduce
qwen --resumea session whose sidecar names a live worktree, or one with restored background agents pending a notice.- Press
!and submitgh workflow list. - Bash reports a syntax error, and history shows the reminder text as the command.
Expected
- A shell-mode submission carries no reminder, and the one-shot notices stay armed for the next model turn.
- Shell intent travels with the queued entry, so the drain-time routing and the submit-time decision cannot disagree.
Found while reviewing #11520, which narrowed its own claim to the keyword reminder at submit time.
中文说明
AppContainer.tsx 的 handleFinalSubmit 最多会给提交内容前置三段 <system-reminder>:恢复 agent 通知、--resume 后的 worktree 通知、workflow 关键词提醒。只有关键词提醒检查了 shell 模式(#11520)。另外两段在 shell 模式下仍会前置,bash 收到以 <system-reminder> 开头的文本直接报语法错误:用户命令没执行,提醒文本被记成用户执行的命令,一次性通知也被这次失败的提交消耗掉。
第二处缺口三段都有:shell 模式在提交时读取,而 use-llm-stream.ts 在出队时按实时标志分流。模型回复期间排队、按 ! 之后才出队的提示,会带着前缀进 bash。
期望:shell 模式提交不带任何提醒,一次性通知保留到下一个模型轮次;shell 意图随排队条目一起携带。
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/cli/src/ui/AppContainer.tsx at handleFinalSubmit, then read packages/cli/src/ui/hooks/use-llm-stream.ts to trace how queued prompts are routed. Reproduce the --resume or recovered-agent case in shell mode and verify that shell submissions reach bash without reminder prefixes, one-shot notices remain for the next model turn, and queued shell intent is preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100