Skip to content

fix(executors): decode Composer Cursor </think>-marked visible output - #4554

Merged
diegosouzapw merged 4 commits into
release/v3.8.33from
fix/port-pr-1310-cursor-composer-thinking
Jun 21, 2026
Merged

diegosouzapw merged 4 commits into
release/v3.8.33from
fix/port-pr-1310-cursor-composer-thinking

Conversation

@diegosouzapw

Copy link
Copy Markdown
Collaborator

Summary

Port of decolua/9router#1310 by @noestelar, adapted JS→TS to OmniRoute's StreamCtx-based cursor pipeline.

The Cursor composer-* family encodes its visible reply inside the thinking protobuf field, separated from the (private) chain-of-thought by a final </think> sentinel. OmniRoute was forwarding the whole thinking payload as reasoning_content only, so OpenAI-compatible clients saw an empty message.content and never displayed the reply.

Changes

  • New pure helpers in open-sse/executors/cursor.ts:
    • isComposerModel(model) — case-insensitive ^composer(?:-|$)/i after stripping any vendor prefix (cu/composer-2.5 ✓).
    • visibleComposerContentFromThinking(text) — slice after last </think>, trimStart.
    • composerReasoningRemainder(text) — slice before last </think> (the still-private chain-of-thought).
  • StreamCtx gets a composerVisibleEmittedLength cursor so streaming only emits the incremental tail per thinking frame.
  • processFrame thinking branch: for Composer models, emit the post-</think> suffix as content deltas (mirrored into ctx.totalText so the non-streaming aggregator picks it up); for non-Composer models, the existing reasoning_content contract is preserved.
  • buildResponseFromCtx: strips the visible suffix from reasoning_content for Composer, so the visible reply is not duplicated between content and reasoning_content.

Test plan

  • New tests/unit/cursor-composer-thinking.test.ts (6 tests, all green):
    • pure-helper contracts (composer detection, suffix/remainder slicing);
    • streaming Composer: incremental visible suffix lands as content deltas, hidden reasoning never leaks as content nor as reasoning_content;
    • non-streaming Composer: ctx.totalText populated from </think>-marked thinking;
    • non-Composer regression: thinking still emits as reasoning_content, totalText stays empty.
  • Existing tests/unit/cursor-streaming.test.ts — 20/20 green (no regression).
  • npx eslint open-sse/executors/cursor.ts tests/unit/cursor-composer-thinking.test.ts — clean.
  • npx tsc -p tsconfig.json --noEmit — no new errors in changed files (5 pre-existing drift errors in unrelated tests).

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@diegosouzapw
diegosouzapw changed the base branch from release/v3.8.32 to release/v3.8.33 June 21, 2026 21:20
The composer-* family on Cursor encodes its visible reply inside the
`thinking` protobuf field, separated from the (private) chain-of-thought
by a final `</think>` marker. OmniRoute was forwarding the whole thinking
payload as `reasoning_content` only, so OpenAI-compatible clients saw an
empty `message.content` and never displayed the reply.

The cursor executor now:
- detects Composer models (case-insensitive, tolerates vendor prefix);
- splits the thinking payload at the last `</think>` marker;
- streams the suffix as `content` deltas (mirrored into `totalText` so
  the non-streaming aggregator surfaces it as `message.content`);
- keeps only the pre-marker hidden reasoning in `reasoning_content`,
  with the visible portion stripped to avoid duplication.

Non-Composer models keep their existing reasoning_content contract.

Inspired-by: decolua/9router#1310
Co-authored-by: Noé Rivera <95829890+noestelar@users.noreply.github.com>
@diegosouzapw
diegosouzapw force-pushed the fix/port-pr-1310-cursor-composer-thinking branch from b8b1091 to e8448b7 Compare June 21, 2026 21:23
Diego Rodrigues de Sa e Souza added 3 commits June 21, 2026 19:05
Composer </think>-marked visible-output decoding adds +62 lines. Baseline bumped to
match (wc+1); fast-gate PR->release does not run check:file-size (Hard Rule #9).
@diegosouzapw
diegosouzapw merged commit 3ffd6ff into release/v3.8.33 Jun 21, 2026
4 checks passed
@diegosouzapw
diegosouzapw deleted the fix/port-pr-1310-cursor-composer-thinking branch June 22, 2026 02:48
tkgo11 pushed a commit to tkgo11/OmniRoute that referenced this pull request Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant