Agent turns truncate mid-sentence; per-turn context bloated by full branch-to-main diff on diverged branches

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Environment: Cursor Desktop, macOS 25.2.0. Large monorepo. Coordinator branch diverged from origin/main (17 ahead / 13 behind).

Summary: Agent responses frequently cut off mid-stream — sometimes mid-sentence — before the turn completes. Frequency correlates with large working-tree/branch state.

What I expected: Turns stream to completion, or fail with a clear error and resumability. Per-turn context injection should be bounded.

What happens:

Agent begins responding normally.
Output stops abruptly, often mid-sentence, with no error surfaced.
Recurs across many turns in the same long-lived session.
Likely contributing factor: The <git_diff_from_branch_to_main> context block is computed against origin/main. On a diverged branch this is huge (in my repo: 185 files / ~13.7k lines) and is re-injected every turn regardless of relevance to the prompt. This appears to inflate per-turn payload and may interact badly with streaming.

Requests:

Robust streaming (retry/resume on truncation; surface an error instead of silent cut-off).
Cap or make-configurable the branch-diff injection; consider diffing against the local merge-base rather than remote origin/main, and truncating past a size threshold with a notice.
Repro reliability: Intermittent but frequent; scales with branch divergence / working-tree size.

Steps to Reproduce

Open Cursor Desktop on macOS with a large monorepo workspace (not sure if this is just a ‘me’ problem, ~thousands of files).
Use the coordinator checkout on main that has diverged from origin/main (in my case: 17 commits ahead, 13 behind).
Start a long-lived Agent chat (hub or spoke) and send normal multi-turn prompts (orchestration, code edits, /spoke, etc.).
Observe that each turn includes a large injected context block: <git_diff_from_branch_to_main> — in my repo this is ~185 files / ~13.7k changed lines, recomputed every turn.
Continue the session across many turns (10+).

Optional tighter repro (for a minimal case):
Same diverged main vs origin/main
Clean working tree (no uncommitted changes)
Single prompt: “Summarize what we should do next and list 5 concrete steps with rationale for each.”
Repeat 5–10 times; truncation is intermittent but frequent enough to block work.

Expected Behavior

Streaming completes — the agent finishes the full response, or fails with a clear, visible error (timeout, context limit, connection drop), not a silent mid-sentence stop.
Resumability — if a turn is interrupted, Cursor should offer retry / continue generation instead of leaving a half-written answer as “done.”
Bounded git context — <git_diff_from_branch_to_main> should be capped, summarized, or configurable, especially when the branch has diverged from remote. Prefer diff against local merge-base (or only uncommitted + recent changes), not the full ahead/behind delta on every turn.
User-visible signal — when context injection is huge, show something like “large branch diff attached (185 files)” so users can tell why turns are slow or failing.
No silent failure — mid-sentence cutoff should never look like a successful turn completion.

Operating System

MacOS

Version Information

Version: 3.10.20
VS Code Extension API: 1.125.0
Commit: 23b9fb205fe595ea2be29da7214e19762d037fc0
Date: 2026-07-07T07:03:33.071Z (1 day ago)
Layout: Agent Window
Build Type: Stable
Release Track: Default
Electron: 40.10.3
Chromium: 144.0.7559.236
Node.js: 24.15.0
V8: 14.4.258.32-electron.0
xterm.js: 6.1.0-beta.256
OS: Darwin arm64 25.2.0

For AI issues: which model did you use?

Auto (though I am not sure what any subagents were using) - tried to parallelize

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

Hi Caitlin!

Two separate things are going on here.

The branch diff is very unlikely to be the cause. The @Branch (Diff with Main) context already does the three things you asked for:

  1. It’s diffed against your local merge-base, not the full ahead/behind delta - so the commits your branch is behind on aren’t included. The ~185 files / 13.7k lines you’re seeing is genuinely your own “17 ahead” divergence, not the sum.
  2. It’s size-capped. When the diff is large it’s truncated before it’s sent, with a visible note that the diff was truncated, so the per-turn payload from this block is bounded no matter how big the repo is.
  3. It’s opt-in. It only rides along if you’ve attached @Branch (Diff with Main). If you don’t want it re-sent each turn, remove that context pill and it stops. (@ mentions and context)

The mid-sentence cutoff is the real issue, and it’s a separate streaming-reliability problem we’re actively working on - most common on long-lived sessions with heavier thinking models (Auto often routes to those). It isn’t tied to the branch diff; large diverged repos just tend to produce heavier turns, which is probably why you spotted the correlation.

Two things that tend to help in the meantime:

  1. Start a fresh chat for each new task rather than one very long-lived session — the cutoffs cluster in long sessions.
  2. If you can, grab a Request ID from a specific truncated turn with Privacy Mode disabled (chat menu → Copy Request ID) and paste it here. That lets us pin the exact failed turn on our side and confirm what’s cutting it. (Finding your request ID)

Your other asks - retry/resume on truncation, a visible signal when a turn is interrupted, and never rendering a cut-off as a completed turn - are exactly the right direction and are part of the reliability work.