Bug: Surface-owned background shell wakeup drops subagent modelId and falls back to grok-4.7-high-fast (host-owned path preserves lastTurnModel)

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Summary

When a background subagent is spawned via Task with an explicit model override (e.g. model: "grok-4.7-medium", run_in_background: true), its primary turn and any explicit Task(resume) turns correctly run on grok-4.7-medium.

However, if a background Shell (block_until_ms: 0) inside that subagent finishes or exits, the resulting BACKGROUND_TASK_COMPLETION follow-up turn ("Briefly inform the user about the task result...") drops the subagent’s modelId (grok-4.7-medium) and executes on grok-4.7-high-fast instead.

Steps to Reproduce

  1. From a parent agent session, invoke Task with subagent_type: "generalPurpose", model: "grok-4.7-medium", run_in_background: true.
  2. Inside the subagent, run a background Shell command (block_until_ms: 0) that finishes after the turn ends (or is terminated).
  3. Observe GetFilteredUsageEvents / billing events for the subagent’s conversationId:
    • Initial subagent turn: grok-4.7-medium
    • Automatic BACKGROUND_TASK_COMPLETION turn ("Briefly inform the user about the task result..."): billed as grok-4.7-high-fast.

Expected Behavior

A background wakeup turn on a session/subagent should always inherit that session’s lastTurnModel / hostedTaskSettings.modelId (preserveRequestedModel: true), matching buildHostOwnedWakeupRequest.

  • Either include lastTurnModel (modelId, modelDetails, requestedModel) in the $enqueueBackgroundWakeup payload, or have resolveRequestedModel (daemon.cjs:23830) fall back to session.lastTurnModel / hostedTaskSettings.modelId on BACKGROUND_TASK_COMPLETION turns.

Operating System

MacOS

Version Information

  • Cursor Version: 3.27.22 (Commit b1aa50cb6db84fd3e8c808259cb172ea73425c10)
  • Component: cursor-agent-host / cursor-agent-exec (Background Wakeup & Subagent Model Routing)

Additional Information

Root Cause (AI generated)

  1. Host-owned wakeup path explicitly preserves lastTurnModel:
    In extensions/cursor-agent-host/dist/agent-host-daemon/dist/bin/daemon.cjs (L23585:110 buildHostOwnedWakeupRequest & L23663:748 startHostOwnedBackgroundWakeupTurn), the host copies modelId, modelDetails, and requestedModel from session.lastTurnModel and calls sendAction(..., { preserveRequestedModel: true }).
  2. Default IDE Surface-owned wakeup path short-circuits this and drops model fields:
    • extensions/cursor-agent-host/dist/main.js (L8:10825288) hardcodes surfaceOwnsBackgroundWakeups: true, causing queueHostOwnedBackgroundWakeup (daemon.cjs:23661:957) to return early.
    • notifyBackgroundTaskCompletion (extensions/cursor-agent-exec/dist/main.js L8:9396788) calls enqueueBackgroundWakeup({ conversationId: e.composerId, id: e.taskId, source: "shell", payload: e }) via $enqueueBackgroundWakeup (extensionHostProcess.js L182:3030156).
    • Neither the RPC envelope nor payload carries lastTurnModel (modelId / modelDetails / requestedModel), and hostedTaskSettings.modelId (daemon.cjs:23805:295) is never consulted during wakeup construction. As a result, the surface dispatches the subagent’s follow-up turn using grok-4.7-high-fast rather than the subagent’s locked grok-4.7-medium.

Does this stop you from using Cursor

No - Cursor works, but with this issue

Hi @wanquan, you’re right: when a background shell finishes inside a subagent, the automatic follow-up turn keeps the model (Grok 4.7) but falls back to its default variant, which is why it shows as Grok 4.7 High Fast instead of Medium. Nothing in your setup causes it, and it’s a known issue the team is aware of.

Until it’s fixed, two things help:

  1. Have the subagent run its shell commands in the foreground instead of with block_until_ms: 0. No automatic follow-up turn is created then, at the cost of the subagent waiting on the command.
  2. Select Grok 4.7 Medium once in the main chat model picker. The follow-up turn falls back to your saved setting for Grok 4.7, so this should keep it on Medium.