Skip to content

fix: model discovery, fallback IDs, and conversation context persistence#19

Merged
ephraimduncan merged 1 commit intomainfrom
fix/use-other-models-in-cursor
Mar 22, 2026
Merged

fix: model discovery, fallback IDs, and conversation context persistence#19
ephraimduncan merged 1 commit intomainfrom
fix/use-other-models-in-cursor

Conversation

@ephraimduncan
Copy link
Copy Markdown
Owner

@ephraimduncan ephraimduncan commented Mar 22, 2026

Three compounding bugs prevented non-composer models from working and caused context loss when switching models or restarting the proxy.

Model discovery (h2-bridge.mjs)

callCursorUnaryRpc used streaming mode (application/connect+proto with Connect framing) for the GetUsableModels unary RPC. Cursor expects application/proto with a raw protobuf body for unary calls. Discovery silently failed, falling back to hardcoded models.

Fix: Add unary config flag to the H2 bridge that switches content-type and writes a single body instead of streaming.

Fallback model IDs (models.ts)

Nearly every non-composer fallback ID was wrong: claude-4.6-opus (real: claude-4.6-opus-high), gpt-5.4 (real: gpt-5.4-medium), grok-4.20 (doesn't exist). Only composer-2/composer-2-fast happened to be valid.

Fix: Corrected all IDs against Oh My Pi's maintained model registry.

Conversation context (proxy.ts)

Two issues:

  1. Context lost on model switch: A single bridgeKey (model-specific) was used for both active tool-call bridges and conversation state. Switching models changed the key, creating a new conversationId with no history.

  2. Context lost on proxy restart: conversationId was crypto.randomUUID() — ephemeral. After restart, the in-memory map was empty and a new random ID was generated. Cursor's server couldn't match it to the existing conversation.

Fix:

  • Split into bridgeKey (model-specific, for activeBridges) and convKey (model-independent, for conversationStates)
  • Derive conversationId deterministically from convKey hash so Cursor's server-side conversation persists across restarts

Fixes #17

Three compounding bugs prevented non-composer models from working and
caused context loss when switching models or restarting the proxy.

Model discovery (h2-bridge.mjs):
- callCursorUnaryRpc used streaming mode (application/connect+proto with
  Connect framing) for the GetUsableModels unary RPC. Cursor expects
  application/proto with a raw protobuf body. Add unary config flag that
  switches content-type and writes a single body instead of streaming.

Fallback model IDs (models.ts):
- Nearly every non-composer ID was wrong: claude-4.6-opus (real:
  claude-4.6-opus-high), gpt-5.4 (real: gpt-5.4-medium), grok-4.20
  (doesn't exist). Corrected against Oh My Pi's maintained registry.

Conversation context (proxy.ts):
- Split single bridgeKey into two: bridgeKey (model-specific, for active
  tool-call bridges) and convKey (model-independent, for conversation
  state). Context now survives model switches within a session.
- Make conversationId deterministic from convKey hash instead of
  crypto.randomUUID(). Same first user message produces the same UUID,
  so Cursor's server-side conversation persists across proxy restarts.
@ephraimduncan ephraimduncan merged commit ef868d3 into main Mar 22, 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.

Error: Connect error not_found: Error

1 participant