Terminal execute_pwsh shows character-by-character echo and false Exit Code 1 on Windows
Before opening, please confirm:
- [x] I have searched for duplicate or closed issues
Operating System
Windows 11
Kiro Version
Latest (agosto 2026)
Bug Description
When the Kiro agent executes shell commands via the execute_pwsh tool, the output shows a character-by-character echo of the command being typed (as if simulating keyboard input one character at a time). Additionally, every command reports Exit Code: 1 even when it succeeds.
Example output for git checkout master:
ggit checkogit checkougit checkoutgit checkout git checkout mgit checkout magit checkout masgit checkout mastgit checkout mastegit checkout master Already on 'master' Your branch is up to date with 'origin/master'. :\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe\PS C:\sites\am-live
Exit Code: 1
The real output is correct ("Already on 'master'") but buried in echo noise, and exit code is always 1 regardless of actual success.
Steps to Reproduce
- Open any workspace on Windows
- Ask the Kiro agent to run any shell command (e.g., "run git status" or "run git checkout master")
- Observe the character-by-character echo in the tool output
- Note that Exit Code is always 1 even for successful commands
Expected Behavior
Clean command output without character echo, and correct exit code (0 for success, non-zero for actual failures). For example:
Already on 'master' Your branch is up to date with 'origin/master'.
Exit Code: 0
Conversation ID
No response
Additional Context
- Shell used internally: C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe
- Tried changing
terminal.integrated.defaultProfile.windowsto: null, PowerShell, Command Prompt — issue persists with all options - Reinstalled Kiro completely — issue persists
- Commands DO execute correctly, only the output parsing/display is affected
- The shell path in output is always PowerShell regardless of terminal profile setting
- This affects all commands (git, npm, etc.), not just specific ones
🤖 Potential Duplicate Detected
This issue appears to be similar to:
- #10685: executePwsh always reports Exit Code 1 for WSL2 UNC-path workspaces (opened without Open Remote - WSL) (88% similar)
- #7431: [Bug] Shell tool fails on Windows native kiro-cli 2.0 (88% similar)
- #10376: kiro-cli --v3:
execute_pwshescapes double quotes to\"on Windows, breaking every quoted command (82% similar) - #10006: execute_pwsh tool collapses consecutive spaces in command strings (82% similar)
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 issues report 'executePwsh' always returning Exit Code 1 even for successful commands on Windows, with correct actual command execution. The new issue adds the character-by-character echo symptom, but the core Exit Code 1 bug is the same.
This is related but not exactly a duplicate. The Exit Code 1 issue is shared, but this report adds a new symptom: character-by-character echo of the command in the output (the command is "typed" letter by letter instead of executed cleanly). This echo behavior is not mentioned in #10685 or #7431.
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.
Confirmed regression:
- Kiro 0.12.224 (2026-05-20): ✅ Works correctly, no echo, correct exit codes
- Kiro 1.0.293 (2026-08-07): ❌ Character-by-character echo + Exit Code always 1
Same OS on both machines: Windows_NT x64 10.0.26200 Same Electron/Chromium/Node versions.
Root cause found, with a fix. I hit this on Windows 11 / Kiro 1.0.437 with
symptoms identical to this report — including the same
:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe\ fragment. In my case
the false exit code was -1 rather than 1, but the cause is the same.
The cause is the PowerShell execution policy, not Kiro's terminal profile.
Kiro launches the shell with:
powershell.exe -noexit -command "try { . "<...>\shellIntegration.ps1" } catch {}"
Dot-sourcing a .ps1 requires execution policy permission. On my machine the
policy was Undefined at all five scopes, so the effective policy was
Restricted. The dot-source throws PSSecurityException / UnauthorizedAccess,
and the empty catch {} discards it silently — no warning in the UI, nothing in
the terminal.
Shell integration therefore never installs:
Test-Path variable:global:__VSCodeState
# False
That single failure explains two of the three symptoms in this thread:
- No
OSC 633;Dmarkers are emitted, so Kiro has no exit code to parse and falls back to a constant fabricated value (1for you,-1for me) - No rich command detection, so Kiro scrapes the raw terminal buffer instead — and that buffer contains PSReadLine's per-keystroke line redraws, which is the character-by-character echo
- The leaked
:\WINDOWS\...powershell.exe\fragments are a separate issue and are not fixed by this. With integration confirmed loaded (Test-Path variable:global:__VSCodeState→True) and both the echo and exit code correct, they still appear, one per native.exeinvocation. Cosmetic only — a prefix on one output line, content is never corrupted.
It also explains why the usual remedies in this thread cannot work. Reinstalling
Kiro, switching terminal.integrated.defaultProfile.windows, and restarting all
leave the execution policy untouched, so integration still fails to load. The
integration script itself is Microsoft's, unmodified and intact — this is not
#3838 (file corruption).
Check whether this is your cause:
Get-ExecutionPolicy -List # all Undefined?
Get-ExecutionPolicy # Restricted?
Test-Path variable:global:__VSCodeState # False means integration never loaded
Confirm it directly by reproducing the swallowed exception:
try {
. "$env:LOCALAPPDATA\Programs\Kiro\resources\app\out\vs\workbench\contrib\terminal\common\scripts\shellIntegration.ps1"
"SUCCESS"
} catch {
$_.Exception.GetType().Name
$_.FullyQualifiedErrorId
}
# PSSecurityException
# UnauthorizedAccess
Workaround:
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned
Then restart the terminal. Before and after, same command:
# Before
WWrite-OWrite-OuWrite-OutWrite-OutpWrite-OutpuWrite-OutputWrite-Output AWrite-Output ABWrite-Output ABC
ABC
Exit Code: -1
# After
POSTFIX_OK
Exit Code: 0
Exit codes become accurate as a pass/fail signal (cmd /c exit 3 → Exit Code: 1,
success → Exit Code: 0), the character echo disappears entirely, and newly
spawned terminals report __VSCodeState as True. The setting persists in the
registry under
HKCU:\Software\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell, needs no
admin rights, and is reversible with -Scope CurrentUser Undefined.
Suggested fix, which needs no user action at all: pass
-ExecutionPolicy Bypass in the shell integration launch command, as proposed
upstream in microsoft/vscode#199122. The flag applies only to that process and
does not modify the user's or machine's policy:
powershell.exe -noexit -ExecutionPolicy Bypass -command "try { . "<...>\shellIntegration.ps1" } catch {}"
Two secondary requests:
- Don't swallow the error. The empty
catch {}is what makes this undiagnosable. A single warning would have saved everyone in this thread a lot of time. - Don't fabricate an exit code. A constant
1or-1looks like a real result. When noOSC 633;Dmarker arrives, surfacing "exit code unavailable" would tell the agent not to trust it — right now an agent cannot distinguish a passing test run from a failing one and may proceed on a broken build.
Worth flagging that the -ExecutionPolicy Bypass fix matters beyond convenience:
on managed machines where policy is enforced by Group Policy (MachinePolicy /
UserPolicy scope), users cannot apply the workaround at all, so Kiro's
terminal integration can never work for them.
Related: #9938 and #9499 look like the same root cause. #9499 is closed but this is clearly still present in 1.0.437.
Environment: Kiro 1.0.437, Windows 11 Pro build 26200, Windows PowerShell
5.1.26100.9444 (Desktop), PSReadLine 2.0.0, no PowerShell profile
(Test-Path $PROFILE → False), language mode FullLanguage. No custom prompt,
no oh-my-posh, no starship — so the usual "simplify your prompt" guidance does
not apply here, there is nothing to simplify.
@SlipstreamZA
Thanks for identifying the execution-policy issue. It appears to identify one PowerShell-specific failure mode, but it does not explain the behaviour in my environment.
With Kiro's help I've determined the following:
The same fabricated exit code and terminal-capture problems occur with:
- Windows PowerShell 5.1
- PowerShell 7
- CMD
- Git Bash
Environment details:
- Kiro v1.0.116 (not able to upgrade due to corporate software distribution mechanism))
- Windows 11
- Kiro installed under
C:\DEV\KIRO - Default terminal profile: Git Bash
- PowerShell 5.1 effective execution policy:
RemoteSigned shellIntegration.ps1loads successfullyTest-Path variable:global:__VSCodeStatereturnsTruewhen tested under PowerShell
The shell itself reports the correct status. For example, direct Git Bash execution gives:
true rc=0
false rc=1
However, Kiro reports Exit Code: 1 for a successful invocation as well. Switching shells does not resolve the exit-code problem.
This suggests the primary issue is in a shared Kiro terminal/PTY result-capture or command-result correlation layer rather than in a particular shell. Each shell has different integration mechanisms, but they all ultimately pass through Kiro’s common terminal process handling.
One important distinction may be getting lost:
- The persistent shell process has its own process exit code.
- The command executed inside that shell has a separate exit code.
- Shell integration may report a command result through OSC 633 markers.
- If shell integration is unavailable, Kiro appears to fall back to scraping terminal output and/or fabricate an exit code.
Could the terminal implementation expose diagnostic information showing which source produced the reported result?
- Native PTY process exit
- OSC 633 command-finished marker
- Shell-specific fallback
- Raw terminal-buffer parsing
- Unavailable or unknown
In particular, a persistent shell’s process exit code should not be used as the exit code of the last command executed inside that shell.
Kiro's suggested fixes:
- Test command-result handling across CMD, PowerShell 5.1, PowerShell 7, Git Bash, and other supported shells using:
- A successful command
- A failing command
- A non-zero command such as
exit 7
- Preserve the actual command exit code independently of the shell process lifetime.
- If no trustworthy command marker or result is available, report
exit code unavailablerather than returning a fabricated1or-1. - Add debug logging showing the shell, terminal PID, command ID, marker received, native process status, and final result source.
- Do not fall back to raw terminal-buffer scraping when shell integration fails, since this causes command text and line redraws to be mistaken for output.
- Continue considering
-ExecutionPolicy Bypassfor PowerShell startup, but treat that as a separate fix for shell-integration initialization—not as the explanation for the cross-shell issue.
The distinction between “the command failed” and “Kiro could not determine the command exit code” is especially important for agent-driven terminal use.
Additional research by Kiro on the above suggestions it found that this is part of a broader agent-shell execution issue rather than a Git Bash or PowerShell-specific problem.
Related reports:
- Kiro #4833: terminal output is corrupted when OSC escape sequences are emitted, with incorrect exit codes reported for successful commands.
- Kiro #9514: manual integrated-terminal commands work, while commands executed through the AI shell tool return incorrect exit codes or incomplete output.
- Kiro #11165: execute_bash tool returns empty stdout on all commands mid-session
- VS Code #317789: Agent Host parses OSC 633 command-lifecycle sequences server-side but exposes a reduced lifecycle model to the client.
These reports point to the agent terminal execution/result-mapping layer as the common component.
Could the team add a regression matrix covering CMD, Windows PowerShell 5.1, PowerShell 7, Git Bash, and WSL with:
- a successful command;
- a failing command;
- a command returning a non-zero value such as
exit 7; - commands that emit OSC 633 sequences;
- commands with shell integration disabled or unavailable.
The diagnostic output should distinguish between:
- the persistent shell process exit code;
- the command’s exit code;
- an OSC 633 command-finished marker;
- raw terminal-buffer parsing;
- an unavailable or unknown result.
If no trustworthy command result is available, Kiro should return exit code unavailable rather than fabricating 1 or -1. It should also strip all OSC control sequences before exposing terminal output to the user or agent.
A debug mode showing the terminal PID, command ID, received OSC marker, native process status, and final result source would make this straightforward to diagnose.
The PowerShell -ExecutionPolicy Bypass change remains useful for machines where PowerShell shell integration cannot load, but it should be treated as a separate initialization fix, not the explanation for the cross-shell symptoms.
Thanks for raising this. The character-by-character echo (ggit checkogit checkout...) is a Windows PTY echo artifact: execute_pwsh creates an interactive terminal session rather than a non-interactive subprocess, and the terminal's line discipline echoes each input character as it streams into the shell's stdin. The false Exit Code 1 on successful commands is a separate issue in how the exit code is collected from the PTY session. Both are symptoms of the Windows terminal execution path. Marking this as a bug to investigate further.
Confirming the ...powershell.exe\ fragment still reproduces on 1.1.14 stable (commit f694ef1b025756b1ae27ae7c3d9ed4215b0160fe), and adding a data point that isolates it cleanly from the execution-policy root cause described earlier in this thread.
Key point: on my machine shell integration is fully loaded, echo and exit codes are correct, and the fragment still persists. So this is not gated by the execution-policy issue. It is a distinct defect in the output-capture layer.
Environment
- Kiro 1.1.14 (stable), Windows 11 (10.0.26200)
- Default agent shell: Windows PowerShell 5.1.26100.9444 (no
terminal.integrated.defaultProfile.windowsoverride, no$PROFILE) Get-ExecutionPolicy(effective) = RemoteSignedTest-Path variable:global:__VSCodeState= True (integration loaded)- No character-by-character echo; exit codes are a correct pass/fail signal (
cmd /c exit 7givesExit Code: 1)
Deterministic trigger: native process vs. pure cmdlet
Pure cmdlets / expressions, 0/N fragments:
Write-Output "C1"; Get-Date -Format "yyyy"; [math]::Sqrt(16); "C2"
-> C1 / 2026 / 4 / C2 (clean)
Native/external processes, N/N fragments, one per invocation, always a single line appended after the real output:
git --version -> git version 2.55.0.windows.5
:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe\
node --version -> v26.8.2
:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe\
whoami -> <user>
:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe\
It also appears when the native process produces no output at all:
& cmd /c exit 0; Write-Output "AFTER-NATIVE"
-> :\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe\AFTER-NATIVE
Isolation proof: the fragment is injected by the capture layer, not the shell or the program
Capturing the identical native output inside PowerShell is byte-perfect:
$out = & cmd /c "echo BYTEPROBE" 2>&1 | Out-String
"LEN=" + $out.Length
# LEN=11, bytes 66,89,84,69,80,82,79,66,69,13,10 = "BYTEPROBE\r\n", no fragment
The fragment exists only in the agent-returned channel. It is the tail of the shell executable path (C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe, missing the leading C), i.e. a shell-integration/prompt marker leaking into command output at the native-process to prompt transition.
Same signature cross-platform
#11496 reports the structurally identical defect on macOS/fish: external commands get the command text plus prompt_pwd fragment leaked into captured output, builtins are clean, the manual terminal is fine, and erasing the fish integration functions does not fix it ("the problem is in the output capture layer"). Windows/pwsh and macOS/fish sharing this signature points at the shared capture/OSC-stripping layer rather than any one shell.
Suggested handling
The two secondary requests already raised in this thread cover it well: (1) don't fabricate exit codes when no OSC 633;D marker arrives, and (2) strip all shell-integration/OSC markers before exposing output to the agent, since the leaked path fragment is one such marker surviving the strip. This is low-severity per invocation (one prefixed line, content not corrupted), but for an agent parsing output programmatically (git porcelain, JSON, test output), an unexpected line in the stream is a real correctness hazard.
Happy to provide full logs or test a pre-release.
Follow-up with a trace-level root cause, captured on 1.1.14 stable with trace logging on.
The leaked line is the payload of the OSC 0 window-title escape that PowerShell emits whenever a native process runs. This is the single pty data event for one finished native command (git --version; Write-Output "TRACE-NATIVE-CHARLIE"), decoded from the trace:
ESC ] 0 ; C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe ESC \ <- OSC 0 window title, ST-terminated
TRACE-NATIVE-CHARLIE CR LF <- real program output
ESC ] 633 ; D ; 0 BEL ESC ] 633 ; A BEL ESC ] 633 ; P ; Cwd=... BEL <- OSC 633 markers, BEL-terminated
PS C:\...> ESC ] 633 ; B BEL
What is observable in the trace:
- The OSC 633 shell-integration markers (
;Dfinished,;Aprompt start,;Pcwd,;Bprompt end) end in BEL (0x07) and do not appear in the captured output. Command detection and exit codes work. - The OSC 0 window-title sequence here ends in a String Terminator (
ESC \), and its payload (the shell path) does appear in the captured output.
I dumped the rendered buffer line byte by byte: it starts ESC ] 0 ; C : \ W I N D O W S ..., so the full OSC 0 introducer and payload are present in the captured text. The on-screen :\WINDOWS... with an apparently missing leading C is just a cursor/rendering artifact; the C is in the buffer.
This matches the trigger exactly: it fires once per native process invocation (each makes PowerShell rewrite the title) and never for pure cmdlets (no title rewrite, no OSC 0).
Hypothesis, since I have not seen the capture source: the output capture strips BEL-terminated OSC sequences but not the ESC \-terminated OSC 0. If that holds, also stripping OSC sequences closed by the ESC-backslash String Terminator before exposing output to the agent would fix it. Offered as a suggestion, not a confirmed diagnosis.
For maintainers: I have also raised this via AWS Support, case 179019172800861, which has the full trace logs attached and can handle any PII-sensitive details (user paths, session ids) not suitable to post here. Happy to test a pre-release.
Here are my results while I retested the three symptoms from this thread using Kiro 1.3.0, Windows 11, default Windows PowerShell 5.x, Get-ExecutionPolicy = RemoteSigned, Test-Path variable:global:__VSCodeState = True. All tests ran with shell integration fully loaded. The results may differ on machines where it fails to load (e.g. Restricted policy without the -ExecutionPolicy Bypass fix).
Character-by-character echo: ✅ not reproducible
Clean output across all tested invocations, including multiple consecutive native processes. No PSReadLine keystroke redraws in the captured output. Note: since the echo was originally caused by shell integration not loading, this result only confirms the symptom is absent when integration is working. It does not confirm whether the Restricted-policy path is also fixed in 1.3.0.
:\WINDOWS\...\powershell.exe\ fragment: ❓I didn't see it anymore.
Tested the exact triggers from my earlier comment: cmd /c exit 0; Write-Output "AFTER", git --version, whoami, and multiple native processes followed by a cmdlet. No fragment in any run. The root cause (OSC 0 window-title sequence not being stripped) was a hypothesis; whether 1.3.0 addresses that or something else changed is unconfirmed without a changelog entry or trace comparison.
Exit-code accuracy: ⚠️ partial
The exact non-zero value is still collapsed to 1. This matches the behaviour I wrote before. Hence, no regression, but no progress either:
| Command | Expected | Reported |
|---|---|---|
Write-Output "ok" |
0 | 0 ✅ |
nonexistentcommand |
1 | 1 ✅ |
cmd /c exit 7 |
7 | 1 ❌ |
cmd /c exit 3 |
3 | 1 ❌ |
For most agent use cases the binary signal is enough. It becomes a correctness issue when a script or tool encodes distinct failure modes in specific exit codes (e.g. test runners, rsync, custom scripts). Also observed once (not independently reproduced): when a no-output command returns non-zero, the PS prompt leaked into the captured text (PS C:\...\> cmd /c exit 7). Noisy for programmatic output parsing if consistent.
What are the results using Kiro IDE 1.3.x on your side?
This is still an issue with 1.3.0 on my system:
Run a shell command and verify that you can read the output.
The command ran and I can read its output. Here's what came back:
Hello from PowerShell 2026-10-19 10:24:25The actual output is readable. Two things worth noting:
- The terminal echoed the command text back in a garbled, character-by-character way before the real output. That's a display artifact from the shell integration, not part of the command result.
- The reported exit code was
-1, which is unexpected for a command that clearly succeeded (bothechoandGet-Dateproduced correct output). This also looks like a shell-integration quirk rather than a genuine failure.So: output reading works fine. If you want, I can run another command to confirm the exit-code reporting behaves normally on a simpler call.
Run the same command again. Report any unexpected behaviour for a bug report.
Ran it again. The real output is correct:
Hello from PowerShell 2026-10-19 10:25:28Here are the unexpected behaviours, reproduced consistently across both runs, for your bug report:
Bug report notes
Command text echoed repeatedly in a garbled, partial-string pattern before the real output.
- On run 1 the echo grew one character at a time (
echo "Hello..., then...dd,...dd H,...dd HH, etc.) — it looked like each keystroke/chunk of the command was being re-emitted.- On run 2 the full command line was echoed back 11 times in a row before the actual output.
- This appears to be a shell-integration / command-echo artifact, not something the command itself produces.
Exit code reported as
-1despite the command succeeding.
- Both
echoandGet-Dateproduced correct, complete output, so the command clearly ran successfully (a real success would be exit code0).-1is not a value PowerShell would normally return here, suggesting the exit-code capture in the shell integration is misreporting status.Reproduction
- Command:
echo "Hello from PowerShell"; Get-Date -Format "yyyy-MM-dd HH:mm:ss"- Shell: pwsh on Windows (win32)
- Working dir:
<redacted>- Frequency: 2/2 runs
Environment detail that may be relevant
- The prompt line shows
[(.invalid) +2 ~1 -0 !]— the(.invalid)branch indicator in the git prompt may point to an unusual repo/git state that could be interacting with the shell-integration prompt parsing.
Conversation ID: sess_f32cbcdd-4533-48f3-8035-048c7fb3a470
@AnilMaktala This issue basically renders Kiro IDE useless on Windows. It's broken for month now, with multiple user confirmations but no reaction from the maintainers so far other than closing duplicates. What's the plan here?
A controlled repro of the execution-policy cause described above, on Kiro IDE 1.4.86, plus one thing it means for the signing fix discussed in #11424.
We hit this on a customer's Windows 11 PC (Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned made it go away; the policy before the fix was not captured) and reproduced it on EC2 Windows Server 2025, Kiro IDE 1.4.86, Windows PowerShell 5.1 as the default terminal, shell integration at its default setting. Only the execution policy was changed between runs, with Kiro restarted each time:
| Policy | Test-Path function:__VSCode-Escape-Value in a new Kiro terminal |
Agent shell tool (execute_pwsh) |
|---|---|---|
CurrentUser Restricted |
False | every tested command: exit code -1, the command echoed back, the prompt line; output of commands running past ~1 s missing |
CurrentUser AllSigned |
False | same as Restricted |
CurrentUser RemoteSigned |
True | exit code 0, no echo, 2 s commands waited for and returned |
MachinePolicy AllSigned (the registry values a GPO writes) + CurrentUser RemoteSigned |
False | same as Restricted — a user cannot fix this one |
- Without shell integration the result was collected about 1.0–1.05 s after the command started (the first one or two took ~11 s while the terminal opened): output after
Start-Sleep -Milliseconds 500came back, after 1000 ms, 1500 ms and 2 s it was missing. So it is not only the exit code: the output of slower commands is lost as well. Settingterminal.integrated.shellIntegration.enabled: falsegives the same result. - Repro: with LocalMachine
RemoteSignedand MachinePolicy/UserPolicyUndefined, set CurrentUser toRestricted, restart Kiro, and ask the agent to runStart-Sleep 2; Write-Output slow-ok. - On signing (#11424): it would cover
AllSignedand WDAC, butRestrictedblocks every script, signed or not, andRestrictedis the documented default on Windows client editions (we have not measured a client OS ourselves). Loading the integration code in a way that is not a script file, and telling the agent when shell integration is not available instead of reporting -1, would cover the default case too.
Still reproducing on Kiro IDE 1.4.215 (Windows 11, Windows PowerShell 5.1, user install), with one more cause that the execution-policy fix above does not cover: AppLocker in Enforce mode, which puts PowerShell into ConstrainedLanguage mode.
Log evidence (%APPDATA%\Kiro\logs\...\kiro.kiroAgent\Kiro Logs.log, 30.10 to 18.11.2026, versions 1.4.26 to 1.4.215; the latest lines are from 1.4.215 on 18.11):
Proceeding without shell integrationappears 204 times, once for every agent terminal, always with"errorType":"ShellIntegrationInitializationError","producedByteBeforeTimeout":true.- Every
Command execution completedline (510) has"exitCode":"(undefined)","exitCodeSource":"none", which the tool then reports asExit Code: -1. - Verified with
cmd /c exit 3: the tool row says-1, while"RC=$LASTEXITCODE"in stdout printsRC=3.
Why the execution-policy fix does not help here. $ExecutionContext.SessionState.LanguageMode is ConstrainedLanguage on this machine. AppLocker script rules allow only %PROGRAMFILES%, %WINDIR% and a few admin-defined folders. The user install's shellIntegration.ps1 (%LOCALAPPDATA%\Programs\Kiro\resources\app\out\vs\workbench\contrib\terminal\common\scripts\) is not in an allowed path, so it runs in ConstrainedLanguage. Users without local admin cannot change AppLocker rules or the language mode. My guess (not verified line by line) is that the script uses .NET method calls that ConstrainedLanguage blocks, so initialization fails. The 1.4.154 fix for App Control Audit mode with PowerShell 7.4+ does not change this, because this is Enforce mode with PowerShell 5.1.
Second symptom with a cost. Without shell integration the command is echoed character by character (ggit checkogit checkou...). The echo is roughly 10 times the command length, and it goes into the model context on every call, so it costs tokens and credits on top of being noise.
What still works: the background-process path (control_pwsh_process + get_process_output) returned complete output, including non-ASCII text, in my tests on 1.4.178 and 1.4.215. This matches the macOS report in #12053.
Suggestions:
- Detect ConstrainedLanguage (or a failed
ShellIntegrationInitializationError) and say so in the tool result instead of returning-1. - Make
shellIntegration.ps1work under ConstrainedLanguage, or do not depend on it for the exit code (for example, append an exit-code marker to the command and parse it). - Do not echo the typed command into the tool result when shell integration is off.
Enterprise Windows machines with AppLocker or WDAC are common, and on them the agent terminal is unusable for verifying builds and tests without these workarounds.