# Cursor Agent gets stuck in “Connection failed” loop after PowerShell output-truncation pipeline; local protobuf serialization fails (invalid int 32: 4294967295)

**URL:** <https://forum.cursor.com/t/cursor-agent-gets-stuck-in-connection-failed-loop-after-powershell-output-truncation-pipeline-local-protobuf-serialization-fails-invalid-int-32-4294967295/146588>\
**Category:** Bug Reports\
**Created:** [December 17, 2025, 7:43am UTC](https://forum.cursor.com/t/cursor-agent-gets-stuck-in-connection-failed-loop-after-powershell-output-truncation-pipeline-local-protobuf-serialization-fails-invalid-int-32-4294967295/146588 "2025-12-17T07:43:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PriitSMIT](https://avatars.discourse-cdn.com/v4/letter/p/e495f1/32.png) [@PriitSMIT](https://forum.cursor.com/u/PriitSMIT)\
**Post date:** [December 17, 2025, 7:43am UTC](https://forum.cursor.com/t/cursor-agent-gets-stuck-in-connection-failed-loop-after-powershell-output-truncation-pipeline-local-protobuf-serialization-fails-invalid-int-32-4294967295/146588/1 "2025-12-17T07:43:38Z")

</div>

### Where does the bug appear (feature/product)?

Cursor IDE

### Describe the Bug

## Bug report: Cursor Agent gets stuck in “Connection failed” loop after PowerShell output-truncation pipeline; local protobuf serialization fails (`invalid int 32: 4294967295`)

### Summary

On Windows, Cursor Agent sometimes runs a verification command that truncates output via a PowerShell pipeline (e.g. `... | Select-Object -First 30`). This can cause PowerShell to abort the upstream process/pipe and set `$LASTEXITCODE = -1`. Cursor then attempts to serialize the tool result into an aiserver protobuf request and fails locally with:

- `[transport] Message serialization error in stream Error: invalid int 32: 4294967295`
- `ERR [internal] Serialization error in aiserver.v1.StreamUnifiedChatRequestWithTools`

After that, the UI shows **“Connection failed. If the problem persists, please check your internet connection or VPN”** and “Try again” loops forever. DevTools shows no outgoing network request because serialization fails before the request can be sent.

### Environment

- Cursor: **2.2.23** (stable) (from DevTools log)
- OS: **Windows (win32 x64)** (inferred from log paths / extension win32-x64)
- Shell: PowerShell (Windows PowerShell / pwsh; exact version not required to repro)
- Project: Node/npm + SvelteKit (`svelte-kit sync && svelte-check ...`)

### Steps to reproduce

1. In Cursor Agent (or any tool execution path that records command exit codes), run a verification command that truncates output via early-terminating pipeline, e.g.:

2. Immediately check exit code (manual reproduction outside agent is sufficient):

3. Observe `$LASTEXITCODE` is **-1** (reproduced reliably in my environment with the truncating pipeline).

4. After the agent runs the command, the agent chat UI becomes stuck showing “Connection failed…”, and clicking “Try again” does not create any network activity.

### Actual result

- Cursor fails locally while preparing the chat/tool request:

- UI shows “Connection failed … check your internet connection or VPN”.

- Retrying does not help; no network requests are triggered (failure happens pre-send).

### Expected result

- Cursor should not treat this as a network failure.

- Tool results should be serializable even if the executed command returns an unusual/negative exit code.

- “Try again” should either:

### Evidence (DevTools excerpt)

From DevTools console (pasted log):

- `Message serialization error in stream Error: invalid int 32: 4294967295`
- `Serialization error in aiserver.v1.StreamUnifiedChatRequestWithTools`
- `Caused by: Error: invalid int 32: 4294967295`

Also observed in the same sequence:

- `[composer] Error in getPopulatedContext: EntryNotFound ... .cursor\projects\...\terminals\3.txt`  
(May be secondary, but appears around the failure.)

### Key finding / suspected root cause

- PowerShell output-truncation pipelines like:

- Cursor appears to serialize a tool result field that expects a **signed int32** exit code, but the value is ending up as **0xFFFFFFFF** interpreted as an _unsigned_ 32-bit integer:

### Impact

- Agent workflows frequently end with a “verify” command; if the agent chooses an output-truncating pipeline, the entire run can become unrecoverable without reloading/restarting Cursor.
- Misleading “internet/VPN” error message obscures the real failure mode.
- Affects long tasks disproportionately (because verification steps run at the end).

### Workarounds (user-side)

Avoid early-terminating pipelines for external commands. Instead:

- Run command to completion, redirect output to a file, then print first N lines:

I implemented this via a wrapper script + `npm run check:cursor` and instructed the agent (via project rules) not to use `| Select-Object -First …`.

### Suggested fixes (developer-side)

1. **Exit code type/validation**

2. **Error handling / UX**

3. **Agent command generation**

### Minimal repro (copy/paste)

```powershell
cd C:\git\project\frontend
npm run check 2>&1 | Select-Object -First 30
$LASTEXITCODE # observed: -1

```

If needed, I can provide the full DevTools log and a wrapper script that avoids the issue.

### Steps to Reproduce

### Minimal repro (copy/paste)

```powershell
cd C:\git\project\frontend
npm run check 2>&1 | Select-Object -First 30
$LASTEXITCODE # observed: -1

```

### Operating System

Windows 10/11

### Current Cursor Version (Menu → About Cursor → Copy)

Version: 2.2.20 (user setup)  
VSCode Version: 1.105.1  
Commit: b3573281c4775bfc6bba466bf6563d3d498d1070  
Date: 2025-12-12T06:29:26.017Z  
Electron: 37.7.0  
Chromium: 138.0.7204.251  
Node.js: 22.20.0  
V8: 13.8.258.32-electron.0  
OS: Windows\_NT x64 10.0.22631

### For AI issues: which model did you use?

Opus 4.5

### Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

---

<div class="post-metadata">

**Author:** ![sanjeed5](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/sanjeed5/32/9610_2.png) [@sanjeed5](https://forum.cursor.com/u/sanjeed5)\
**Post date:** [December 17, 2025, 8:32am UTC](https://forum.cursor.com/t/cursor-agent-gets-stuck-in-connection-failed-loop-after-powershell-output-truncation-pipeline-local-protobuf-serialization-fails-invalid-int-32-4294967295/146588/3 "2025-12-17T08:32:31Z")

</div>

Thanks for the report, I’ve raised it with the team.

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/cursor1/user_avatar/forum.cursor.com/system/32/99069_2.png) [@system](https://forum.cursor.com/u/system)\
**Post date:** [January 8, 2026, 8:33am UTC](https://forum.cursor.com/t/cursor-agent-gets-stuck-in-connection-failed-loop-after-powershell-output-truncation-pipeline-local-protobuf-serialization-fails-invalid-int-32-4294967295/146588/4 "2026-01-08T08:33:20Z")

</div>

This topic was automatically closed 22 days after the last reply. New replies are no longer allowed.
