Kiro icon indicating copy to clipboard operation
Kiro copied to clipboard

Agent/AI terminal returns no command output when zsh RPROMPT is set (regression in Kiro 1.0.0)

Open AshwinJGitHub opened this issue 5 months ago • 7 comments

Before opening, please confirm:

Operating System

macOS 26.5.1 (build 25F80)

Kiro Version

1.0.0 (TERM_PROGRAM_VERSION=1.0.0)

Bug Description

After updating to Kiro 1.0.0, the agent's terminal tool (execute_bash) returns empty output with exit code 1 for every command, while the user's own interactive integrated terminal runs the identical commands correctly. Bisecting the user's ~/.zshrc shows the trigger is a non-empty RPROMPT. With RPROMPT set, the agent terminal spawns the shell and runs the command (verified via side effects), but the IDE never captures the command's output or completion. Removing RPROMPT fully restores agent terminal output capture.

Steps to Reproduce

  1. On macOS with zsh, set a minimal ~/.zshrc:
zsh

PROMPT='test%1~ %% '
RPROMPT='xyz'

  1. Reload the window (or start a new session) so a fresh shell sources the config.
  2. Have the agent run a trivial command, e.g. echo hello.

Expected Behavior

Agent terminal returns hello with exit code 0 (matching the user's interactive terminal).

Conversation ID

No response

Additional Context

Actual Agent terminal returns empty output, exit code 1. The command actually executes (confirmed by writing to a file from ~/.zshrc and observing the side effect), but no stdout / exit status is captured. The user's own integrated terminal shows correct output for the same command.

Isolation / what was ruled out Controlled bisect, holding ~/.zshrc constant and running each command multiple times:

compinit (no -i): one-time hang on the insecure-directories [y/n] prompt in the non-interactive agent shell (separate, minor issue; worked around with compinit -i). Custom PROMPT alone (with or without PROMPT_SUBST, with or without $(...) command substitution): works. A standalone CLI shell-integration block in the user's rc file: innocent (works fine as long as RPROMPT is empty). Adding RPROMPT (any non-empty value, including RPROMPT='xyz'): consistently breaks output capture across repeated runs. No ~/.zshrc / default prompt: works.

Suspected root cause In shellIntegration-rc.zsh, __vsc_update_prompt wraps the right prompt when RPROMPT is non-empty:

if [ -n "$RPROMPT" ]; then
    __vsc_prior_rprompt="$RPROMPT"
    RPROMPT="%{$(__vsc_right_prompt_start)%}$RPROMPT%{$(__vsc_right_prompt_end)%}"
fi

This emits the OSC 633;H / OSC 633;I right-prompt markers. In 1.0.0, this path appears to corrupt or misframe the OSC 633;C / OSC 633;D command start/end + exit-code markers that the agent's command-output parser depends on, so the agent sees no output and no completion.

Workaround Unset RPROMPT (or leave it empty) in ~/.zshrc. Right-prompt content can be moved into the left PROMPT (e.g. a clock via %D{%H:%M:%S}) with no loss of information.

Additional note (possible second bug) During diagnosis, edits to ~/.zshrc appeared to take effect on the agent terminal with a one-command lag (the first command after an edit reflected the previous file contents). This may be a separate caching / shell-reuse issue worth investigating.

AshwinJGitHub avatar Jun 18 '26 17:06 AshwinJGitHub

🤖 Potential Duplicate Detected

This issue appears to be similar to:

What happens next?

  • ⏰ This issue will be automatically closed in 3 days
  • 🏷️ If this is not a duplicate, you can prevent automatic closure by adding a comment or reacting with 👎 to this message.
  • 💬 Comment on the original issue if you have additional information

Why is this marked as duplicate? Both report bash/terminal returning empty output in Kiro 1.0.0 on macOS, which is the same core problem with identical symptoms

github-actions[bot] avatar Jun 18 '26 17:06 github-actions[bot]

This issue has been automatically closed as it appears to be a duplicate of #9535.

If you believe this is incorrect, please comment on this issue and a maintainer will review it.

github-actions[bot] avatar Jun 22 '26 00:06 github-actions[bot]

Thanks for the detailed bisection — your hypothesis is correct. The __vsc_update_prompt block you quoted matches the shipped shellIntegration-rc.zsh verbatim, and the H/I right-prompt OSC 633 markers it emits are confusing VS Code core's command-detection parser. Downstream we see onDidEndTerminalShellExecution never fire, so the agent falls through to a bounded timeout and returns empty output with a default exit code — matching exactly what you observed.

Distinct from the other 1.0.0 terminal reports (#9628 is an xterm renderer race; #9663 is venv activation overriding commandLine) — three separate root causes with the same surface symptom. Your workaround (move right-prompt content into PROMPT) is the right one for now.

Marking as a bug for the team to investigate further.

AnilMaktala avatar Jun 22 '26 20:06 AnilMaktala

Thank you for your feedback! 🙏

The duplicate label has been removed and this issue has been sent back for maintainer review.

A maintainer will review this issue shortly.

github-actions[bot] avatar Jun 22 '26 20:06 github-actions[bot]

Hi! Several updates have shipped since this was filed — the latest is Kiro IDE 1.0.52, which includes terminal handling improvements. Could you update and let us know if this is still happening?

To update: download from kiro.dev.

If the issue persists after updating, please share:

  • Your current version (Help → About)
  • Whether the workaround mentioned in your report still applies
  • A Conversation ID if possible

AnilMaktala avatar Jun 26 '26 19:06 AnilMaktala

This issue has been automatically closed due to inactivity. It has been 7 days since we requested additional information.

If you still need help with this issue, please feel free to reopen it or create a new issue with the requested details.

github-actions[bot] avatar Jul 04 '26 00:07 github-actions[bot]

Same failure on Windows with PowerShell, plus two details I have not seen in this thread or in the related reports (#8279, #9483, #8658, #9514, #3149).

Environment: Kiro IDE 1.3.0, Windows 11 Enterprise build 26100, shell is Windows PowerShell 5.1 running in ConstrainedLanguage mode, TERM_PROGRAM=kiro, TERM_PROGRAM_VERSION=1.3.0, VSCODE_INJECTION=1. No PowerShell profile exists on this machine, so profile level customisation is not the cause here.

Measured over 11 consecutive agent terminal calls in one session, mixing the foreground command tool and the background process tool:

Observation Result
Calls that returned usable output 2 of 11
All other calls empty output, tool reported Exit Code: -1, no error message
Background process output tool empty 6 of 6 times, even for a process that demonstrably ran
Tool level exit code always -1, including for calls that succeeded
$LASTEXITCODE echoed into stdout correct when output arrives. cmd /c exit 3 produced RC=3

Detail 1, delayed completion. This is the part that makes the bug worse than lost output. Some commands do run, but they finish minutes after the tool has already returned empty. I had a Python script write a timestamp into an output file. The tool returned empty output, the file did not exist when I checked immediately afterwards, and the file appeared about four minutes later carrying a timestamp that matched the real completion time, not the call time. A separate command in the same session never ran at all, its output file never appeared. So from the agent side, empty output is ambiguous between three different states: did not run, is still queued, and ran but output was dropped. There is no way to tell them apart without writing a run id into a file and polling it.

Detail 2, the timeout parameter has no effect. I retried one trivial command with an explicit timeout of 600000 ms. It still returned empty immediately. So this is not the tool giving up at a short default timeout, or at least the timeout value is not what governs the wait.

Possible lead, and the reason I think #9663 is relevant. On this machine the Documents folder is redirected to a network share, and PowerShell therefore performs module auto discovery across that share on shell startup. The string Searching UNC share \\<redacted>\...\WindowsPowerShell\Modules appears in the output of the calls that did succeed. That blocks shell startup for a noticeable time. My hypothesis is that output capture is abandoned when shell startup exceeds some internal budget, the command is then run in a shell that nobody is listening to any more, and nothing is surfaced as an error. #9663 found the same symptom from a different cause that also delays or decorates shell startup, which fits.

What makes this hard to work around rather than just annoying: because the command may still land later, retrying is not safe. Any command with a side effect, a file write, a git operation, an API call, can be executed twice if the agent retries after an empty response. The only safe pattern I have found is to run once, never retry, write a unique run id into an output file, and read that file later in the turn.

Two things that would each make this bearable even before a fix:

  1. Surface a distinct error when output capture is abandoned, instead of returning empty output with Exit Code: -1. Empty plus -1 is indistinguishable from a command that legitimately printed nothing.
  2. Report the real exit code. $LASTEXITCODE is available and correct, as the RC=3 measurement above shows, so the value exists and is simply not being propagated.

Logs, for reference. kiro.log shows the lifecycle but no error:

terminal.background.started {"terminalId":"N","interactive":false}
acp-peer.terminal.wait_for_exit.ok {"system":"acp-peer","durationMs":1015}
terminal.background.exited {"terminalId":"N","killed":false,"exitCode":null,"signal":null}

exitCode: null with killed: false on a process that did run looks like the place where the real code is lost.

kkkemit avatar Oct 20 '26 08:10 kkkemit