Skip to content

[Bug]: submit-after-ready pastes and submits the prompt into the shell when the agent CLI already exited #25628

Open

Description

@siddh7007

What happens

With promptDelivery: 'submit-after-ready', planLaunchAgentStartupPrompt (src/renderer/src/lib/launch-agent-startup-prompt-plan.ts) launches the agent with an empty prompt and later pastes the prompt and presses Enter once the pane looks ready:

if (hasPrompt && promptDelivery === 'submit-after-ready') {
  // Why: multi-line generated prompts are too large for a shell argv, so launch clean then paste+submit in the TUI.
  return pasteAfterReady(true)
}

If the agent CLI exits immediately (rejected flag, missing auth, a wrapper binary on PATH with the agent's name), the shell is the foreground process when the paste happens. Each line of the prompt is then run by the shell as a command.

Observed

Launching an agent tab through launchAgentInNewTab({ promptDelivery: 'submit-after-ready', prompt: <multi-line generated text> }) where the agent binary on PATH was a wrapper that exited with ERROR: no prompt (no stdin and no positional args). The terminal then showed bash running every line of the prompt (command not found, syntax error near unexpected token, …). In this case nothing harmful ran, but generated text containing $(…), backticks or a valid command line would be executed.

Expected

A prompt meant for an agent is never submitted to a shell. For example: before pasting, confirm the expected agent process is still the PTY's foreground process (the stdin-after-start follow-up path already avoids sending into a shell when the agent never starts), and never press Enter when it is not.

Notes

Activity

  1. leilei3167 commented on Oct 6, 2026

    @leilei3167
    Contributor

    I'll look into this. Once the launched CLI has already exited, the delayed paste should not be submitted into the shell.

  2. leilei3167 commented on Oct 6, 2026

    @leilei3167
    Contributor

    Stepping back from this. Open changes already touch the same paste files (#18996, #24115), so I won't add another one on top.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions